text.inc 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Run time library.
  4. Copyright (c) 1993,97 by the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {
  12. Possible Defines:
  13. EOF_CTRLZ Is Ctrl-Z (#26) a EOF mark for textfiles
  14. SHORT_LINEBREAK Use short Linebreaks #10 instead of #10#13
  15. SHORT_LINEBREAK is defined in the Linux system unit (syslinux.pp)
  16. }
  17. {****************************************************************************
  18. subroutines For TextFile handling
  19. ****************************************************************************}
  20. Procedure FileCloseFunc(Var t:TextRec);
  21. Begin
  22. Do_Close(t.Handle);
  23. t.Handle:=UnusedHandle;
  24. End;
  25. Procedure FileReadFunc(var t:TextRec);
  26. Begin
  27. t.BufEnd:=Do_Read(t.Handle,Longint(t.Bufptr),t.BufSize);
  28. t.BufPos:=0;
  29. End;
  30. Procedure FileWriteFunc(var t:TextRec);
  31. Begin
  32. Do_Write(t.Handle,Longint(t.Bufptr),t.BufPos);
  33. t.BufPos:=0;
  34. End;
  35. Procedure FileOpenFunc(var t:TextRec);
  36. var
  37. Flags : Longint;
  38. Begin
  39. Case t.mode Of
  40. fmInput : Flags:=$1000;
  41. fmOutput : Flags:=$1101;
  42. fmAppend : Flags:=$1011;
  43. else
  44. begin
  45. InOutRes:=102;
  46. exit;
  47. end;
  48. End;
  49. Do_Open(t,PChar(@t.Name),Flags);
  50. t.CloseFunc:=@FileCloseFunc;
  51. t.FlushFunc:=nil;
  52. if t.Mode=fmInput then
  53. t.InOutFunc:=@FileReadFunc
  54. else
  55. begin
  56. t.InOutFunc:=@FileWriteFunc;
  57. { Only install flushing if its a NOT a file }
  58. if Do_Isdevice(t.Handle) then
  59. t.FlushFunc:=@FileWriteFunc;
  60. end;
  61. End;
  62. Procedure assign(var t:Text;const s:String);
  63. Begin
  64. FillChar(t,SizEof(TextRec),0);
  65. { only set things that are not zero }
  66. TextRec(t).Handle:=UnusedHandle;
  67. TextRec(t).mode:=fmClosed;
  68. TextRec(t).BufSize:=TextRecBufSize;
  69. TextRec(t).Bufptr:=@TextRec(t).Buffer;
  70. TextRec(t).OpenFunc:=@FileOpenFunc;
  71. Move(s[1],TextRec(t).Name,Length(s));
  72. End;
  73. Procedure assign(var t:Text;p:pchar);
  74. begin
  75. Assign(t,StrPas(p));
  76. end;
  77. Procedure assign(var t:Text;c:char);
  78. begin
  79. Assign(t,string(c));
  80. end;
  81. Procedure Close(var t : Text);[IOCheck];
  82. Begin
  83. if InOutRes<>0 then
  84. Exit;
  85. If (TextRec(t).mode<>fmClosed) Then
  86. Begin
  87. { Write pending buffer }
  88. If Textrec(t).Mode=fmoutput then
  89. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  90. TextRec(t).mode:=fmClosed;
  91. { Only close functions not connected to stdout.}
  92. If ((TextRec(t).Handle<>StdInputHandle) and
  93. (TextRec(t).Handle<>StdOutputHandle) and
  94. (TextRec(t).Handle<>StdErrorHandle)) Then
  95. FileFunc(TextRec(t).CloseFunc)(TextRec(t));
  96. { Reset buffer for safety }
  97. TextRec(t).BufPos:=0;
  98. TextRec(t).BufEnd:=0;
  99. End;
  100. End;
  101. Procedure OpenText(var t : Text;mode,defHdl:Longint);
  102. Begin
  103. Case TextRec(t).mode Of {This gives the fastest code}
  104. fmInput,fmOutput,fmInOut : Close(t);
  105. fmClosed : ;
  106. else
  107. Begin
  108. InOutRes:=102;
  109. exit;
  110. End;
  111. End;
  112. TextRec(t).mode:=mode;
  113. TextRec(t).bufpos:=0;
  114. TextRec(t).bufend:=0;
  115. FileFunc(TextRec(t).OpenFunc)(TextRec(t));
  116. { reset the mode to closed when an error has occured }
  117. if InOutRes<>0 then
  118. TextRec(t).mode:=fmClosed;
  119. End;
  120. Procedure Rewrite(var t : Text);[IOCheck];
  121. Begin
  122. If InOutRes<>0 then
  123. exit;
  124. OpenText(t,fmOutput,1);
  125. End;
  126. Procedure Reset(var t : Text);[IOCheck];
  127. Begin
  128. If InOutRes<>0 then
  129. exit;
  130. OpenText(t,fmInput,0);
  131. End;
  132. Procedure Append(var t : Text);[IOCheck];
  133. Begin
  134. If InOutRes<>0 then
  135. exit;
  136. OpenText(t,fmAppend,1);
  137. End;
  138. Procedure Flush(var t : Text);[IOCheck];
  139. Begin
  140. If InOutRes<>0 then
  141. exit;
  142. If TextRec(t).mode<>fmOutput Then
  143. begin
  144. InOutres:=105;
  145. exit;
  146. end;
  147. { Not the flushfunc but the inoutfunc should be used, becuase that
  148. writes the data, flushfunc doesn't need to be assigned }
  149. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  150. End;
  151. Procedure Erase(var t:Text);[IOCheck];
  152. Begin
  153. If InOutRes <> 0 then
  154. exit;
  155. If TextRec(t).mode=fmClosed Then
  156. Do_Erase(PChar(@TextRec(t).Name));
  157. End;
  158. Procedure Rename(var t : text;p:pchar);[IOCheck];
  159. Begin
  160. If InOutRes <> 0 then
  161. exit;
  162. If TextRec(t).mode=fmClosed Then
  163. Begin
  164. Do_Rename(PChar(@TextRec(t).Name),p);
  165. Move(p^,TextRec(t).Name,StrLen(p)+1);
  166. End;
  167. End;
  168. Procedure Rename(var t : Text;const s : string);[IOCheck];
  169. var
  170. p : array[0..255] Of Char;
  171. Begin
  172. If InOutRes <> 0 then
  173. exit;
  174. Move(s[1],p,Length(s));
  175. p[Length(s)]:=#0;
  176. Rename(t,Pchar(@p));
  177. End;
  178. Procedure Rename(var t : Text;c : char);[IOCheck];
  179. var
  180. p : array[0..1] Of Char;
  181. Begin
  182. If InOutRes <> 0 then
  183. exit;
  184. p[0]:=c;
  185. p[1]:=#0;
  186. Rename(t,Pchar(@p));
  187. End;
  188. Function Eof(Var t: Text): Boolean;[IOCheck];
  189. Begin
  190. If (InOutRes<>0) then
  191. exit(true);
  192. if (TextRec(t).mode<>fmInput) Then
  193. begin
  194. InOutRes:=104;
  195. exit(true);
  196. end;
  197. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  198. begin
  199. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  200. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  201. exit(true);
  202. end;
  203. {$ifdef EOF_CTRLZ}
  204. Eof:=(TextRec(t).Bufptr^[TextRec(t).BufPos]=#26);
  205. {$else}
  206. Eof:=false;
  207. {$endif EOL_CTRLZ}
  208. end;
  209. Function Eof:Boolean;
  210. Begin
  211. Eof:=Eof(Input);
  212. End;
  213. Function SeekEof (Var t : Text) : Boolean;
  214. Begin
  215. If (InOutRes<>0) then
  216. exit(true);
  217. if (TextRec(t).mode<>fmInput) Then
  218. begin
  219. InOutRes:=104;
  220. exit(true);
  221. end;
  222. repeat
  223. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  224. begin
  225. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  226. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  227. exit(true);
  228. end;
  229. case TextRec(t).Bufptr^[TextRec(t).BufPos] of
  230. #26 : exit(true);
  231. #10,#13,
  232. #9,' ' : ;
  233. else
  234. exit(false);
  235. end;
  236. inc(TextRec(t).BufPos);
  237. until false;
  238. End;
  239. Function SeekEof : Boolean;
  240. Begin
  241. SeekEof:=SeekEof(Input);
  242. End;
  243. Function Eoln(var t:Text) : Boolean;
  244. Begin
  245. If (InOutRes<>0) then
  246. exit(true);
  247. if (TextRec(t).mode<>fmInput) Then
  248. begin
  249. InOutRes:=104;
  250. exit(true);
  251. end;
  252. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  253. begin
  254. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  255. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  256. exit(true);
  257. end;
  258. Eoln:=(TextRec(t).Bufptr^[TextRec(t).BufPos] in [#10,#13]);
  259. End;
  260. Function Eoln : Boolean;
  261. Begin
  262. Eoln:=Eoln(Input);
  263. End;
  264. Function SeekEoln (Var t : Text) : Boolean;
  265. Begin
  266. If (InOutRes<>0) then
  267. exit(true);
  268. if (TextRec(t).mode<>fmInput) Then
  269. begin
  270. InOutRes:=104;
  271. exit(true);
  272. end;
  273. repeat
  274. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  275. begin
  276. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  277. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  278. exit(true);
  279. end;
  280. case TextRec(t).Bufptr^[TextRec(t).BufPos] of
  281. #26,
  282. #10,#13 : exit(true);
  283. #9,' ' : ;
  284. else
  285. exit(false);
  286. end;
  287. inc(TextRec(t).BufPos);
  288. until false;
  289. End;
  290. Function SeekEoln : Boolean;
  291. Begin
  292. SeekEoln:=SeekEoln(Input);
  293. End;
  294. Procedure SetTextBuf(Var F : Text; Var Buf);[INTERNPROC: In_settextbuf_file_x];
  295. Procedure SetTextBuf(Var F : Text; Var Buf; Size : Word);
  296. Begin
  297. TextRec(f).BufPtr:=@Buf;
  298. TextRec(f).BufSize:=Size;
  299. TextRec(f).BufPos:=0;
  300. TextRec(f).BufEnd:=0;
  301. End;
  302. {*****************************************************************************
  303. Write(Ln)
  304. *****************************************************************************}
  305. Procedure WriteBuffer(var f:TextRec;var b;len:longint);
  306. var
  307. p : pchar;
  308. left,
  309. idx : longint;
  310. begin
  311. p:=pchar(@b);
  312. idx:=0;
  313. left:=f.BufSize-f.BufPos;
  314. while len>left do
  315. begin
  316. move(p[idx],f.Bufptr^[f.BufPos],left);
  317. dec(len,left);
  318. inc(idx,left);
  319. inc(f.BufPos,left);
  320. FileFunc(f.InOutFunc)(f);
  321. left:=f.BufSize-f.BufPos;
  322. end;
  323. move(p[idx],f.Bufptr^[f.BufPos],len);
  324. inc(f.BufPos,len);
  325. end;
  326. Procedure WriteBlanks(var f:TextRec;len:longint);
  327. var
  328. left : longint;
  329. begin
  330. left:=f.BufSize-f.BufPos;
  331. while len>left do
  332. begin
  333. FillChar(f.Bufptr^[f.BufPos],left,' ');
  334. dec(len,left);
  335. inc(f.BufPos,left);
  336. FileFunc(f.InOutFunc)(f);
  337. left:=f.BufSize-f.BufPos;
  338. end;
  339. FillChar(f.Bufptr^[f.BufPos],len,' ');
  340. inc(f.BufPos,len);
  341. end;
  342. Procedure Write_End(var f:TextRec);[Public,Alias:'FPC_WRITE_END'];
  343. begin
  344. if f.FlushFunc<>nil then
  345. FileFunc(f.FlushFunc)(f);
  346. end;
  347. Procedure Writeln_End(var f:TextRec);[Public,Alias:'FPC_WRITELN_END'];
  348. const
  349. {$IFDEF SHORT_LINEBREAK}
  350. eollen=1;
  351. eol : array[0..0] of char=(#10);
  352. {$ELSE SHORT_LINEBREAK}
  353. eollen=2;
  354. eol : array[0..1] of char=(#13,#10);
  355. {$ENDIF SHORT_LINEBREAK}
  356. begin
  357. If InOutRes <> 0 then exit;
  358. { Write EOL }
  359. WriteBuffer(f,eol,eollen);
  360. { Flush }
  361. if f.FlushFunc<>nil then
  362. FileFunc(f.FlushFunc)(f);
  363. end;
  364. Procedure Write_Str(Len : Longint;var f : TextRec;const s : String);[Public,Alias:'FPC_WRITE_TEXT_'+{$ifdef NEWREADINT}'SHORTSTR'{$else}'STRING'{$endif}];
  365. Begin
  366. If (InOutRes<>0) then
  367. exit;
  368. if (f.mode<>fmOutput) Then
  369. begin
  370. InOutRes:=105;
  371. exit;
  372. end;
  373. If Len>Length(s) Then
  374. WriteBlanks(f,Len-Length(s));
  375. WriteBuffer(f,s[1],Length(s));
  376. End;
  377. {$ifndef NEWWRITEARRAY}
  378. type
  379. array00=array[0..0] of char;
  380. {$endif}
  381. Procedure Write_Array(Len : Longint;var f : TextRec;const s : {$ifdef NEWWRITEARRAY} array of char{$else}array00{$endif});[Public,Alias:'FPC_WRITE_TEXT_PCHAR_AS_ARRAY'];
  382. var
  383. ArrayLen : longint;
  384. p : pchar;
  385. Begin
  386. If (InOutRes<>0) then
  387. exit;
  388. if (f.mode<>fmOutput) Then
  389. begin
  390. InOutRes:=105;
  391. exit;
  392. end;
  393. p:=pchar(@s);
  394. ArrayLen:=StrLen(p);
  395. if ArrayLen>high(s) then
  396. ArrayLen:=high(s);
  397. If Len>ArrayLen Then
  398. WriteBlanks(f,Len-ArrayLen);
  399. WriteBuffer(f,p^,ArrayLen);
  400. End;
  401. Procedure Write_PChar(Len : Longint;var f : TextRec;p : PChar);[Public,Alias:'FPC_WRITE_TEXT_PCHAR_AS_POINTER'];
  402. var
  403. PCharLen : longint;
  404. Begin
  405. If (p=nil) or (InOutRes<>0) then
  406. exit;
  407. if (f.mode<>fmOutput) Then
  408. begin
  409. InOutRes:=105;
  410. exit;
  411. end;
  412. PCharLen:=StrLen(p);
  413. If Len>PCharLen Then
  414. WriteBlanks(f,Len-PCharLen);
  415. WriteBuffer(f,p^,PCharLen);
  416. End;
  417. Procedure Write_Text_AnsiString (Len : Longint; Var T : TextRec; S : Pointer);[Public,alias:'FPC_WRITE_TEXT_'+{$ifdef NEWREADINT}'ANSISTR'{$else}'ANSISTRING'{$endif}];
  418. {
  419. Writes a AnsiString to the Text file T
  420. }
  421. begin
  422. If S=Nil then
  423. exit;
  424. Write_pchar (Len,t,PChar(S));
  425. end;
  426. Procedure Write_SInt(Len : Longint;var t : TextRec;l : ValSInt);[Public,Alias:'FPC_WRITE_TEXT_'+{$ifdef NEWREADINT}'SINT'{$else}'LONGINT'{$endif}];
  427. var
  428. s : String;
  429. Begin
  430. If (InOutRes<>0) then
  431. exit;
  432. Str(l,s);
  433. Write_Str(Len,t,s);
  434. End;
  435. Procedure Write_UInt(Len : Longint;var t : TextRec;l : ValUInt);[Public,Alias:'FPC_WRITE_TEXT_'+{$ifdef NEWREADINT}'UINT'{$else}'CARDINAL'{$endif}];
  436. var
  437. s : String;
  438. Begin
  439. If (InOutRes<>0) then
  440. exit;
  441. Str(L,s);
  442. Write_Str(Len,t,s);
  443. End;
  444. Procedure Write_Real(fixkomma,Len : Longint;var t : TextRec;r : real);[Public,Alias:'FPC_WRITE_TEXT_REAL'];
  445. var
  446. s : String;
  447. Begin
  448. If (InOutRes<>0) then
  449. exit;
  450. {$ifdef i386}
  451. Str_real(Len,fixkomma,r,rt_s64real,s);
  452. {$else}
  453. Str_real(Len,fixkomma,r,rt_s32real,s);
  454. {$endif}
  455. Write_Str(Len,t,s);
  456. End;
  457. {$ifdef SUPPORT_SINGLE}
  458. Procedure Write_Single(fixkomma,Len : Longint;var t : TextRec;r : single);[Public,Alias:'FPC_WRITE_TEXT_SINGLE'];
  459. var
  460. s : String;
  461. Begin
  462. If (InOutRes<>0) then
  463. exit;
  464. Str_real(Len,fixkomma,r,rt_s32real,s);
  465. Write_Str(Len,t,s);
  466. End;
  467. {$endif SUPPORT_SINGLE}
  468. {$ifdef SUPPORT_EXTENDED}
  469. Procedure Write_Extended(fixkomma,Len : Longint;var t : TextRec;r : extended);[Public,Alias:'FPC_WRITE_TEXT_EXTENDED'];
  470. var
  471. s : String;
  472. Begin
  473. If (InOutRes<>0) then
  474. exit;
  475. Str_real(Len,fixkomma,r,rt_s80real,s);
  476. Write_Str(Len,t,s);
  477. End;
  478. {$endif SUPPORT_EXTENDED}
  479. {$ifdef SUPPORT_COMP}
  480. Procedure Write_Comp(fixkomma,Len : Longint;var t : TextRec;r : comp);[Public,Alias:'FPC_WRITE_TEXT_COMP'];
  481. var
  482. s : String;
  483. Begin
  484. If (InOutRes<>0) then
  485. exit;
  486. Str_real(Len,fixkomma,r,rt_s64bit,s);
  487. Write_Str(Len,t,s);
  488. End;
  489. {$endif SUPPORT_COMP}
  490. {$ifdef SUPPORT_FIXED}
  491. Procedure Write_Fixed(fixkomma,Len : Longint;var t : TextRec;r : fixed);[Public,Alias:'FPC_WRITE_TEXT_FIXED'];
  492. var
  493. s : String;
  494. Begin
  495. If (InOutRes<>0) then
  496. exit;
  497. Str_real(Len,fixkomma,r,rt_f32bit,s);
  498. Write_Str(Len,t,s);
  499. End;
  500. {$endif SUPPORT_FIXED}
  501. Procedure Write_Boolean(Len : Longint;var t : TextRec;b : Boolean);[Public,Alias:'FPC_WRITE_TEXT_BOOLEAN'];
  502. Begin
  503. If (InOutRes<>0) then
  504. exit;
  505. { Can't use array[boolean] because b can be >0 ! }
  506. if b then
  507. Write_Str(Len,t,'TRUE')
  508. else
  509. Write_Str(Len,t,'FALSE');
  510. End;
  511. Procedure Write_Char(Len : Longint;var t : TextRec;c : Char);[Public,Alias:'FPC_WRITE_TEXT_CHAR'];
  512. Begin
  513. If (InOutRes<>0) then
  514. exit;
  515. if (TextRec(t).mode<>fmOutput) Then
  516. begin
  517. InOutRes:=105;
  518. exit;
  519. end;
  520. If Len>1 Then
  521. WriteBlanks(t,Len-1);
  522. If t.BufPos+1>=t.BufSize Then
  523. FileFunc(t.InOutFunc)(t);
  524. t.Bufptr^[t.BufPos]:=c;
  525. Inc(t.BufPos);
  526. End;
  527. {*****************************************************************************
  528. Read(Ln)
  529. *****************************************************************************}
  530. Function NextChar(var f:TextRec;var s:string):Boolean;
  531. begin
  532. if f.BufPos<f.BufEnd then
  533. begin
  534. s:=s+f.BufPtr^[f.BufPos];
  535. Inc(f.BufPos);
  536. If f.BufPos>=f.BufEnd Then
  537. FileFunc(f.InOutFunc)(f);
  538. NextChar:=true;
  539. end
  540. else
  541. NextChar:=false;
  542. end;
  543. Function IgnoreSpaces(var f:TextRec):Boolean;
  544. {
  545. Removes all leading spaces,tab,eols from the input buffer, returns true if
  546. the buffer is empty
  547. }
  548. var
  549. s : string;
  550. begin
  551. s:='';
  552. IgnoreSpaces:=false;
  553. while f.Bufptr^[f.BufPos] in [#9,#10,#13,' '] do
  554. if not NextChar(f,s) then
  555. exit;
  556. IgnoreSpaces:=true;
  557. end;
  558. Function ReadSign(var f:TextRec;var s:string):Boolean;
  559. {
  560. Read + and - sign, return true if buffer is empty
  561. }
  562. begin
  563. ReadSign:=(not (f.Bufptr^[f.BufPos] in ['-','+'])) or NextChar(f,s);
  564. end;
  565. Function ReadBase(var f:TextRec;var s:string;var Base:longint):boolean;
  566. {
  567. Read the base $ For 16 and % For 2, if buffer is empty return true
  568. }
  569. begin
  570. case f.BufPtr^[f.BufPos] of
  571. '$' : Base:=16;
  572. '%' : Base:=2;
  573. else
  574. Base:=10;
  575. end;
  576. ReadBase:=(Base=10) or NextChar(f,s);
  577. end;
  578. Function ReadNumeric(var f:TextRec;var s:string;base:longint):Boolean;
  579. {
  580. Read numeric input, if buffer is empty then return True
  581. }
  582. var
  583. c : char;
  584. begin
  585. ReadNumeric:=false;
  586. c:=f.BufPtr^[f.BufPos];
  587. while ((base>=10) and (c in ['0'..'9'])) or
  588. ((base=16) and (c in ['A'..'F','a'..'f'])) or
  589. ((base=2) and (c in ['0'..'1'])) do
  590. begin
  591. if not NextChar(f,s) then
  592. exit;
  593. c:=f.BufPtr^[f.BufPos];
  594. end;
  595. ReadNumeric:=true;
  596. end;
  597. Procedure Read_End(var f:TextRec);[Public,Alias:'FPC_READ_END'];
  598. begin
  599. if f.FlushFunc<>nil then
  600. FileFunc(f.FlushFunc)(f);
  601. end;
  602. Procedure ReadLn_End(var f : TextRec);[Public,Alias:'FPC_READLN_END'];
  603. Begin
  604. { Check error and if file is open and load buf if empty }
  605. If (InOutRes<>0) then
  606. exit;
  607. if (f.mode<>fmInput) Then
  608. begin
  609. InOutRes:=104;
  610. exit;
  611. end;
  612. repeat
  613. If f.BufPos>=f.BufEnd Then
  614. begin
  615. FileFunc(f.InOutFunc)(f);
  616. if f.BufPos>=f.BufEnd then
  617. break;
  618. end;
  619. inc(f.BufPos);
  620. if (f.BufPtr^[f.BufPos-1]=#10) then
  621. exit;
  622. until false;
  623. { Flush if set }
  624. if f.FlushFunc<>nil then
  625. FileFunc(f.FlushFunc)(f);
  626. End;
  627. Function ReadPCharLen(var f:TextRec;s:pchar;maxlen:longint):longint;
  628. var
  629. sPos,len : Longint;
  630. p,startp,maxp : pchar;
  631. Begin
  632. ReadPCharLen:=0;
  633. { Check error and if file is open }
  634. If (InOutRes<>0) then
  635. exit;
  636. if (f.mode<>fmInput) Then
  637. begin
  638. InOutRes:=104;
  639. exit;
  640. end;
  641. { Read maximal until Maxlen is reached }
  642. sPos:=0;
  643. repeat
  644. If f.BufPos>=f.BufEnd Then
  645. begin
  646. FileFunc(f.InOutFunc)(f);
  647. If f.BufPos>=f.BufEnd Then
  648. break;
  649. end;
  650. p:[email protected]^[f.BufPos];
  651. if SPos+f.BufEnd-f.BufPos>MaxLen then
  652. maxp:[email protected]^[f.BufPos+MaxLen-SPos]
  653. else
  654. maxp:[email protected]^[f.BufEnd];
  655. startp:=p;
  656. { search linefeed }
  657. while (p<maxp) and (P^<>#10) do
  658. inc(p);
  659. { calculate read bytes }
  660. len:=p-startp;
  661. inc(f.BufPos,Len);
  662. Move(startp^,s[sPos],Len);
  663. inc(sPos,Len);
  664. { was it a LF? then leave }
  665. if (p<maxp) and (p^=#10) then
  666. begin
  667. if (spos>0) and (s[spos-1]=#13) then
  668. dec(sPos);
  669. break;
  670. end;
  671. { Maxlen reached ? }
  672. if spos=MaxLen then
  673. break;
  674. until false;
  675. ReadPCharLen:=spos;
  676. End;
  677. Procedure Read_String(var f : TextRec;var s : String);[Public,Alias:'FPC_READ_TEXT_'+{$ifdef NEWREADINT}'SHORTSTR'{$else}'STRING'{$endif}];
  678. Begin
  679. s[0]:=chr(ReadPCharLen(f,pchar(@s[1]),high(s)));
  680. End;
  681. Procedure Read_PChar(var f : TextRec;var s : PChar);[Public,Alias:'FPC_READ_TEXT_PCHAR_AS_POINTER'];
  682. Begin
  683. pchar(s+ReadPCharLen(f,s,$7fffffff))^:=#0;
  684. End;
  685. Procedure Read_Array(var f : TextRec;var s : {$ifdef NEWWRITEARRAY}array of char{$else}array00{$endif});[Public,Alias:'FPC_READ_TEXT_PCHAR_AS_ARRAY'];
  686. Begin
  687. pchar(pchar(@s)+ReadPCharLen(f,pchar(@s),{$ifdef NEWWRITEARRAY}high(s){$else}$7fffffff{$endif}))^:=#0;
  688. End;
  689. Procedure Read_AnsiString(var f : TextRec;var s : AnsiString);[Public,Alias:'FPC_READ_TEXT_'+{$ifdef NEWREADINT}'ANSISTR'{$else}'ANSISTRING'{$endif}];
  690. var
  691. len : longint;
  692. Begin
  693. { Delete the string }
  694. AnsiStr_Decr_ref (Pointer(S));
  695. { We assign room for 1024 characters totally at random.... }
  696. Pointer(s):=Pointer(NewAnsiString(1024));
  697. len:=ReadPCharLen(f,pchar(s),1024);
  698. pchar(pchar(s)+len)^:=#0;
  699. PAnsiRec(Pointer(S)-FirstOff)^.Len:=len;
  700. End;
  701. {$ifdef NEWREADINT}
  702. Function Read_Char(var f : TextRec):char;[Public,Alias:'FPC_READ_TEXT_CHAR'];
  703. Begin
  704. Read_Char:=#0;
  705. { Check error and if file is open }
  706. If (InOutRes<>0) then
  707. exit;
  708. if (f.mode<>fmInput) Then
  709. begin
  710. InOutRes:=104;
  711. exit;
  712. end;
  713. { Read next char or EOF }
  714. If f.BufPos>=f.BufEnd Then
  715. begin
  716. FileFunc(f.InOutFunc)(f);
  717. If f.BufPos>=f.BufEnd Then
  718. exit(#26);
  719. end;
  720. Read_Char:=f.Bufptr^[f.BufPos];
  721. inc(f.BufPos);
  722. end;
  723. Function Read_SInt(var f : TextRec):ValSInt;[Public,Alias:'FPC_READ_TEXT_SINT'];
  724. var
  725. hs : String;
  726. code : Longint;
  727. base : longint;
  728. Begin
  729. Read_SInt:=0;
  730. { Leave if error or not open file, else check for empty buf }
  731. If (InOutRes<>0) then
  732. exit;
  733. if (f.mode<>fmInput) Then
  734. begin
  735. InOutRes:=104;
  736. exit;
  737. end;
  738. If f.BufPos>=f.BufEnd Then
  739. FileFunc(f.InOutFunc)(f);
  740. hs:='';
  741. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadBase(f,hs,Base) then
  742. ReadNumeric(f,hs,Base);
  743. Val(hs,Read_SInt,code);
  744. If code<>0 Then
  745. InOutRes:=106;
  746. End;
  747. Function Read_UInt(var f : TextRec):ValUInt;[Public,Alias:'FPC_READ_TEXT_UINT'];
  748. var
  749. hs : String;
  750. code : longint;
  751. base : longint;
  752. Begin
  753. Read_UInt:=0;
  754. { Leave if error or not open file, else check for empty buf }
  755. If (InOutRes<>0) then
  756. exit;
  757. if (f.mode<>fmInput) Then
  758. begin
  759. InOutRes:=104;
  760. exit;
  761. end;
  762. If f.BufPos>=f.BufEnd Then
  763. FileFunc(f.InOutFunc)(f);
  764. hs:='';
  765. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadBase(f,hs,Base) then
  766. ReadNumeric(f,hs,Base);
  767. val(hs,Read_UInt,code);
  768. If code<>0 Then
  769. InOutRes:=106;
  770. End;
  771. Function Read_Float(var f : TextRec):ValReal;[Public,Alias:'FPC_READ_TEXT_FLOAT'];
  772. var
  773. hs : string;
  774. code : Word;
  775. begin
  776. Read_Float:=0.0;
  777. { Leave if error or not open file, else check for empty buf }
  778. If (InOutRes<>0) then
  779. exit;
  780. if (f.mode<>fmInput) Then
  781. begin
  782. InOutRes:=104;
  783. exit;
  784. end;
  785. If f.BufPos>=f.BufEnd Then
  786. FileFunc(f.InOutFunc)(f);
  787. hs:='';
  788. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadNumeric(f,hs,10) then
  789. begin
  790. { First check for a . }
  791. if (f.Bufptr^[f.BufPos]='.') and (f.BufPos<f.BufEnd) Then
  792. begin
  793. hs:=hs+'.';
  794. Inc(f.BufPos);
  795. If f.BufPos>=f.BufEnd Then
  796. FileFunc(f.InOutFunc)(f);
  797. ReadNumeric(f,hs,10);
  798. end;
  799. { Also when a point is found check for a E }
  800. if (f.Bufptr^[f.BufPos] in ['e','E']) and (f.BufPos<f.BufEnd) Then
  801. begin
  802. hs:=hs+'E';
  803. Inc(f.BufPos);
  804. If f.BufPos>=f.BufEnd Then
  805. FileFunc(f.InOutFunc)(f);
  806. if ReadSign(f,hs) then
  807. ReadNumeric(f,hs,10);
  808. end;
  809. end;
  810. val(hs,Read_Float,code);
  811. If code<>0 Then
  812. InOutRes:=106;
  813. end;
  814. {$else}
  815. Procedure Read_Char(var f : TextRec;var c : Char);[Public,Alias:'FPC_READ_TEXT_CHAR'];
  816. Begin
  817. c:=#0;
  818. { Check error and if file is open }
  819. If (InOutRes<>0) then
  820. exit;
  821. if (f.mode<>fmInput) Then
  822. begin
  823. InOutRes:=104;
  824. exit;
  825. end;
  826. { Read next char or EOF }
  827. If f.BufPos>=f.BufEnd Then
  828. begin
  829. FileFunc(f.InOutFunc)(f);
  830. If f.BufPos>=f.BufEnd Then
  831. begin
  832. c:=#26;
  833. exit;
  834. end;
  835. end;
  836. c:=f.Bufptr^[f.BufPos];
  837. inc(f.BufPos);
  838. end;
  839. Procedure Read_Longint(var f : TextRec;var l : Longint);[Public,Alias:'FPC_READ_TEXT_LONGINT'];
  840. var
  841. hs : String;
  842. code : Longint;
  843. base : longint;
  844. Begin
  845. l:=0;
  846. { Leave if error or not open file, else check for empty buf }
  847. If (InOutRes<>0) then
  848. exit;
  849. if (f.mode<>fmInput) Then
  850. begin
  851. InOutRes:=104;
  852. exit;
  853. end;
  854. If f.BufPos>=f.BufEnd Then
  855. FileFunc(f.InOutFunc)(f);
  856. hs:='';
  857. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadBase(f,hs,Base) then
  858. ReadNumeric(f,hs,Base);
  859. Val(hs,l,code);
  860. If code<>0 Then
  861. InOutRes:=106;
  862. End;
  863. Procedure Read_Integer(var f : TextRec;var l : Integer);[Public,Alias:'FPC_READ_TEXT_INTEGER'];
  864. var
  865. ll : Longint;
  866. Begin
  867. l:=0;
  868. If InOutRes <> 0 then
  869. exit;
  870. Read_Longint(f,ll);
  871. If (ll<-32768) or (ll>32767) Then
  872. InOutRes:=201
  873. else
  874. l:=ll;
  875. End;
  876. Procedure Read_Word(var f : TextRec;var l : Word);[Public,Alias:'FPC_READ_TEXT_WORD'];
  877. var
  878. ll : Longint;
  879. Begin
  880. l:=0;
  881. If InOutRes <> 0 then
  882. exit;
  883. Read_Longint(f,ll);
  884. If (ll<0) or (ll>$ffff) Then
  885. InOutRes:=201
  886. else
  887. l:=ll;
  888. End;
  889. Procedure Read_Byte(var f : TextRec;var l : byte);[Public,Alias:'FPC_READ_TEXT_BYTE'];
  890. var
  891. ll : Longint;
  892. Begin
  893. l:=0;
  894. If InOutRes <> 0 then
  895. exit;
  896. Read_Longint(f,ll);
  897. If (ll<0) or (ll>255) Then
  898. InOutRes:=201
  899. else
  900. l:=ll;
  901. End;
  902. Procedure Read_Shortint(var f : TextRec;var l : shortint);[Public,Alias:'FPC_READ_TEXT_SHORTINT'];
  903. var
  904. ll : Longint;
  905. Begin
  906. l:=0;
  907. If InOutRes <> 0 then
  908. exit;
  909. Read_Longint(f,ll);
  910. If (ll<-128) or (ll>127) Then
  911. InOutRes:=201
  912. else
  913. l:=ll;
  914. End;
  915. Procedure Read_Cardinal(var f : TextRec;var l : cardinal);[Public,Alias:'FPC_READ_TEXT_CARDINAL'];
  916. var
  917. hs : String;
  918. code : longint;
  919. base : longint;
  920. Begin
  921. l:=0;
  922. { Leave if error or not open file, else check for empty buf }
  923. If (InOutRes<>0) then
  924. exit;
  925. if (f.mode<>fmInput) Then
  926. begin
  927. InOutRes:=104;
  928. exit;
  929. end;
  930. If f.BufPos>=f.BufEnd Then
  931. FileFunc(f.InOutFunc)(f);
  932. hs:='';
  933. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadBase(f,hs,Base) then
  934. ReadNumeric(f,hs,Base);
  935. val(hs,l,code);
  936. If code<>0 Then
  937. InOutRes:=106;
  938. End;
  939. function ReadRealStr(var f:TextRec):string;
  940. var
  941. hs : string;
  942. begin
  943. ReadRealStr:='';
  944. { Leave if error or not open file, else check for empty buf }
  945. If (InOutRes<>0) then
  946. exit;
  947. if (f.mode<>fmInput) Then
  948. begin
  949. InOutRes:=104;
  950. exit;
  951. end;
  952. If f.BufPos>=f.BufEnd Then
  953. FileFunc(f.InOutFunc)(f);
  954. hs:='';
  955. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadNumeric(f,hs,10) then
  956. begin
  957. { First check for a . }
  958. if (f.Bufptr^[f.BufPos]='.') and (f.BufPos<f.BufEnd) Then
  959. begin
  960. hs:=hs+'.';
  961. Inc(f.BufPos);
  962. If f.BufPos>=f.BufEnd Then
  963. FileFunc(f.InOutFunc)(f);
  964. ReadNumeric(f,hs,10);
  965. end;
  966. { Also when a point is found check for a E }
  967. if (f.Bufptr^[f.BufPos] in ['e','E']) and (f.BufPos<f.BufEnd) Then
  968. begin
  969. hs:=hs+'E';
  970. Inc(f.BufPos);
  971. If f.BufPos>=f.BufEnd Then
  972. FileFunc(f.InOutFunc)(f);
  973. if ReadSign(f,hs) then
  974. ReadNumeric(f,hs,10);
  975. end;
  976. end;
  977. ReadRealStr:=hs;
  978. end;
  979. Procedure Read_Real(var f : TextRec;var d : Real);[Public,Alias:'FPC_READ_TEXT_REAL'];
  980. var
  981. code : Word;
  982. Begin
  983. val(ReadRealStr(f),d,code);
  984. If code<>0 Then
  985. InOutRes:=106;
  986. End;
  987. {$ifdef SUPPORT_SINGLE}
  988. Procedure Read_Single(var f : TextRec;var d : single);[Public,Alias:'FPC_READ_TEXT_SINGLE'];
  989. var
  990. code : Word;
  991. Begin
  992. val(ReadRealStr(f),d,code);
  993. If code<>0 Then
  994. InOutRes:=106;
  995. End;
  996. {$endif SUPPORT_SINGLE}
  997. {$ifdef SUPPORT_EXTENDED}
  998. Procedure Read_Extended(var f : TextRec;var d : extended);[Public,Alias:'FPC_READ_TEXT_EXTENDED'];
  999. var
  1000. code : Word;
  1001. Begin
  1002. val(ReadRealStr(f),d,code);
  1003. If code<>0 Then
  1004. InOutRes:=106;
  1005. End;
  1006. {$endif SUPPORT_EXTENDED}
  1007. {$ifdef SUPPORT_COMP}
  1008. Procedure Read_Comp(var f : TextRec;var d : comp);[Public,Alias:'FPC_READ_TEXT_COMP'];
  1009. var
  1010. code : Word;
  1011. Begin
  1012. val(ReadRealStr(f),d,code);
  1013. If code<>0 Then
  1014. InOutRes:=106;
  1015. End;
  1016. {$endif SUPPORT_COMP}
  1017. {$ifdef SUPPORT_FIXED}
  1018. Procedure Read_Fixed(var f : TextRec;var d : fixed);[Public,Alias:'FPC_READ_TEXT_FIXED'];
  1019. var
  1020. code : Word;
  1021. Begin
  1022. val(ReadRealStr(f),d,code);
  1023. If code<>0 Then
  1024. InOutRes:=106;
  1025. End;
  1026. {$endif SUPPORT_FIXED}
  1027. {$endif}
  1028. {*****************************************************************************
  1029. Initializing
  1030. *****************************************************************************}
  1031. procedure OpenStdIO(var f:text;mode,hdl:longint);
  1032. begin
  1033. Assign(f,'');
  1034. TextRec(f).Handle:=hdl;
  1035. TextRec(f).Mode:=mode;
  1036. TextRec(f).Closefunc:=@FileCloseFunc;
  1037. case mode of
  1038. fmInput : TextRec(f).InOutFunc:=@FileReadFunc;
  1039. fmOutput : begin
  1040. TextRec(f).InOutFunc:=@FileWriteFunc;
  1041. TextRec(f).FlushFunc:=@FileWriteFunc;
  1042. end;
  1043. else
  1044. HandleError(102);
  1045. end;
  1046. end;
  1047. {
  1048. $Log$
  1049. Revision 1.45 1999-04-26 18:27:26 peter
  1050. * fixed write array
  1051. * read array with maxlen
  1052. Revision 1.44 1999/04/08 15:57:57 peter
  1053. + subrange checking for readln()
  1054. Revision 1.43 1999/04/07 22:05:18 peter
  1055. * fixed bug with readln where it sometime didn't read until eol
  1056. Revision 1.42 1999/03/16 17:49:39 jonas
  1057. * changes for internal Val code (do a "make cycle OPT=-dvalintern" to test)
  1058. * in text.inc: changed RTE 106 when read integer values are out of bounds to RTE 201
  1059. * in systemh.inc: disabled "support_fixed" for the i386 because it gave internal errors,
  1060. Revision 1.41 1999/03/02 18:23:37 peter
  1061. * changed so handlerror() -> inoutres:= to have $I- support
  1062. Revision 1.40 1999/03/01 15:41:04 peter
  1063. * use external names
  1064. * removed all direct assembler modes
  1065. Revision 1.39 1999/02/17 10:13:29 peter
  1066. * when error when opening a file, then reset the mode to fmclosed
  1067. Revision 1.38 1999/01/28 19:38:19 peter
  1068. * fixed readln(ansistring)
  1069. Revision 1.37 1998/12/15 22:43:06 peter
  1070. * removed temp symbols
  1071. Revision 1.36 1998/12/11 18:07:39 peter
  1072. * fixed read(char) with empty buffer
  1073. Revision 1.35 1998/11/27 14:50:58 peter
  1074. + open strings, $P switch support
  1075. Revision 1.34 1998/11/16 12:21:48 peter
  1076. * fixes for 0.99.8
  1077. Revision 1.33 1998/10/23 00:03:29 peter
  1078. * write(pchar) has check for nil
  1079. Revision 1.32 1998/10/20 14:37:45 peter
  1080. * fixed maxlen which was not correct after my read_string update
  1081. Revision 1.31 1998/10/10 15:28:48 peter
  1082. + read single,fixed
  1083. + val with code:longint
  1084. + val for fixed
  1085. Revision 1.30 1998/09/29 08:39:07 michael
  1086. + Ansistring write now gets pointer.
  1087. Revision 1.29 1998/09/28 14:27:08 michael
  1088. + AnsiStrings update
  1089. Revision 1.28 1998/09/24 23:32:24 peter
  1090. * fixed small bug with a #13#10 on a line
  1091. Revision 1.27 1998/09/18 12:23:22 peter
  1092. * fixed a bug introduced by my previous update
  1093. Revision 1.26 1998/09/17 16:34:18 peter
  1094. * new eof,eoln,seekeoln,seekeof
  1095. * speed upgrade for read_string
  1096. * inoutres 104/105 updates for read_* and write_*
  1097. Revision 1.25 1998/09/14 10:48:23 peter
  1098. * FPC_ names
  1099. * Heap manager is now system independent
  1100. Revision 1.24 1998/09/08 10:14:06 peter
  1101. + textrecbufsize
  1102. Revision 1.23 1998/08/26 15:33:28 peter
  1103. * reset bufpos,bufend in opentext like tp7
  1104. Revision 1.22 1998/08/26 11:23:25 pierre
  1105. * close did not reset the bufpos and bufend fields
  1106. led to problems when using the same file several times
  1107. Revision 1.21 1998/08/17 22:42:17 michael
  1108. + Flush on close only for output files cd ../inc
  1109. Revision 1.20 1998/08/11 00:05:28 peter
  1110. * $ifdef ver0_99_5 updates
  1111. Revision 1.19 1998/07/30 13:26:16 michael
  1112. + Added support for ErrorProc variable. All internal functions are required
  1113. to call HandleError instead of runerror from now on.
  1114. This is necessary for exception support.
  1115. Revision 1.18 1998/07/29 21:44:35 michael
  1116. + Implemented reading/writing of ansistrings
  1117. Revision 1.17 1998/07/19 19:55:33 michael
  1118. + fixed rename. Changed p to p^
  1119. Revision 1.16 1998/07/10 11:02:40 peter
  1120. * support_fixed, becuase fixed is not 100% yet for the m68k
  1121. Revision 1.15 1998/07/06 15:56:43 michael
  1122. Added length checking for string reading
  1123. Revision 1.14 1998/07/02 12:14:56 carl
  1124. + Each IOCheck routine now check InOutRes before, just like TP
  1125. Revision 1.13 1998/07/01 15:30:00 peter
  1126. * better readln/writeln
  1127. Revision 1.12 1998/07/01 14:48:10 carl
  1128. * bugfix of WRITE_TEXT_BOOLEAN , was not TP compatible
  1129. + added explicit typecast in OpenText
  1130. Revision 1.11 1998/06/25 09:44:22 daniel
  1131. + RTLLITE directive to compile minimal RTL.
  1132. Revision 1.10 1998/06/04 23:46:03 peter
  1133. * comp,extended are only i386 added support_comp,support_extended
  1134. Revision 1.9 1998/06/02 16:47:56 pierre
  1135. * bug for boolean values greater than one fixed
  1136. Revision 1.8 1998/05/31 14:14:54 peter
  1137. * removed warnings using comp()
  1138. Revision 1.7 1998/05/27 00:19:21 peter
  1139. * fixed crt input
  1140. Revision 1.6 1998/05/21 19:31:01 peter
  1141. * objects compiles for linux
  1142. + assign(pchar), assign(char), rename(pchar), rename(char)
  1143. * fixed read_text_as_array
  1144. + read_text_as_pchar which was not yet in the rtl
  1145. Revision 1.5 1998/05/12 10:42:45 peter
  1146. * moved getopts to inc/, all supported OS's need argc,argv exported
  1147. + strpas, strlen are now exported in the systemunit
  1148. * removed logs
  1149. * removed $ifdef ver_above
  1150. Revision 1.4 1998/04/07 22:40:46 florian
  1151. * final fix of comp writing
  1152. }