text.inc 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408
  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. {$ifdef INT64}
  445. procedure write_qword(len : longint;var t : textrec;q : qword);[public,alias:'FPC_WRITE_TEXT_QWORD'];
  446. var
  447. s : string;
  448. begin
  449. if (InOutRes<>0) then
  450. exit;
  451. int_str(q,s);
  452. write_str(len,t,s);
  453. end;
  454. {$endif INT64}
  455. {$ifdef INTERNDOUBLE}
  456. Procedure Write_Float(rt,fixkomma,Len : Longint;var t : TextRec;r : ValReal);[Public,Alias:'FPC_WRITE_TEXT_FLOAT'];
  457. var
  458. s : String;
  459. Begin
  460. If (InOutRes<>0) then
  461. exit;
  462. Str_real(Len,fixkomma,r,treal_type(rt),s);
  463. Write_Str(Len,t,s);
  464. End;
  465. {$else INTERNDOUBLE}
  466. {$ifdef SUPPORT_SINGLE}
  467. Procedure Write_S32Real(fixkomma,Len : Longint;var t : TextRec;r : single);[Public,Alias:'FPC_WRITE_TEXT_'+{$ifdef INTERNDOUBLE}'S32REAL'{$else}'SINGLE'{$endif}];
  468. var
  469. s : String;
  470. Begin
  471. If (InOutRes<>0) then
  472. exit;
  473. Str_real(Len,fixkomma,r,rt_s32real,s);
  474. Write_Str(Len,t,s);
  475. End;
  476. {$endif SUPPORT_S32REAL}
  477. {$ifdef SUPPORT_DOUBLE}
  478. Procedure Write_s64Real(fixkomma,Len : Longint;var t : TextRec;r : double);[Public,Alias:'FPC_WRITE_TEXT_'+{$ifdef INTERNDOUBLE}'S64'{$endif}+'REAL'];
  479. var
  480. s : String;
  481. Begin
  482. If (InOutRes<>0) then
  483. exit;
  484. Str_real(Len,fixkomma,r,rt_s64real,s);
  485. Write_Str(Len,t,s);
  486. End;
  487. {$endif SUPPORT_S64REAL}
  488. {$ifdef SUPPORT_EXTENDED}
  489. Procedure Write_S80Real(fixkomma,Len : Longint;var t : TextRec;r : extended);[Public,Alias:'FPC_WRITE_TEXT_'+{$ifdef INTERNDOUBLE}'S80REAL'{$else}'EXTENDED'{$endif}];
  490. var
  491. s : String;
  492. Begin
  493. If (InOutRes<>0) then
  494. exit;
  495. Str_real(Len,fixkomma,r,rt_s80real,s);
  496. Write_Str(Len,t,s);
  497. End;
  498. {$endif SUPPORT_S80REAL}
  499. {$ifdef SUPPORT_COMP}
  500. Procedure Write_C64Bit(fixkomma,Len : Longint;var t : TextRec;r : comp);[Public,Alias:'FPC_WRITE_TEXT_'+{$ifdef INTERNDOUBLE}'C64BIT'{$else}'COMP'{$endif}];
  501. var
  502. s : String;
  503. Begin
  504. If (InOutRes<>0) then
  505. exit;
  506. Str_real(Len,fixkomma,r,rt_c64bit,s);
  507. Write_Str(Len,t,s);
  508. End;
  509. {$endif SUPPORT_C64BIT}
  510. {$ifdef SUPPORT_FIXED}
  511. Procedure Write_Fixed(fixkomma,Len : Longint;var t : TextRec;r : fixed16);[Public,Alias:'FPC_WRITE_TEXT_'+{$ifdef INTERNDOUBLE}'F16BIT'{$else}'FIXED'{$endif}];
  512. var
  513. s : String;
  514. Begin
  515. If (InOutRes<>0) then
  516. exit;
  517. Str_real(Len,fixkomma,r,rt_f32bit,s);
  518. Write_Str(Len,t,s);
  519. End;
  520. {$endif SUPPORT_F16BIT}
  521. {$endif INTERNDOUBLE}
  522. Procedure Write_Boolean(Len : Longint;var t : TextRec;b : Boolean);[Public,Alias:'FPC_WRITE_TEXT_BOOLEAN'];
  523. Begin
  524. If (InOutRes<>0) then
  525. exit;
  526. { Can't use array[boolean] because b can be >0 ! }
  527. if b then
  528. Write_Str(Len,t,'TRUE')
  529. else
  530. Write_Str(Len,t,'FALSE');
  531. End;
  532. Procedure Write_Char(Len : Longint;var t : TextRec;c : Char);[Public,Alias:'FPC_WRITE_TEXT_CHAR'];
  533. Begin
  534. If (InOutRes<>0) then
  535. exit;
  536. if (TextRec(t).mode<>fmOutput) Then
  537. begin
  538. InOutRes:=105;
  539. exit;
  540. end;
  541. If Len>1 Then
  542. WriteBlanks(t,Len-1);
  543. If t.BufPos+1>=t.BufSize Then
  544. FileFunc(t.InOutFunc)(t);
  545. t.Bufptr^[t.BufPos]:=c;
  546. Inc(t.BufPos);
  547. End;
  548. {*****************************************************************************
  549. Read(Ln)
  550. *****************************************************************************}
  551. Function NextChar(var f:TextRec;var s:string):Boolean;
  552. begin
  553. if f.BufPos<f.BufEnd then
  554. begin
  555. s:=s+f.BufPtr^[f.BufPos];
  556. Inc(f.BufPos);
  557. If f.BufPos>=f.BufEnd Then
  558. FileFunc(f.InOutFunc)(f);
  559. NextChar:=true;
  560. end
  561. else
  562. NextChar:=false;
  563. end;
  564. Function IgnoreSpaces(var f:TextRec):Boolean;
  565. {
  566. Removes all leading spaces,tab,eols from the input buffer, returns true if
  567. the buffer is empty
  568. }
  569. var
  570. s : string;
  571. begin
  572. s:='';
  573. IgnoreSpaces:=false;
  574. while f.Bufptr^[f.BufPos] in [#9,#10,#13,' '] do
  575. if not NextChar(f,s) then
  576. exit;
  577. IgnoreSpaces:=true;
  578. end;
  579. Function ReadSign(var f:TextRec;var s:string):Boolean;
  580. {
  581. Read + and - sign, return true if buffer is empty
  582. }
  583. begin
  584. ReadSign:=(not (f.Bufptr^[f.BufPos] in ['-','+'])) or NextChar(f,s);
  585. end;
  586. Function ReadBase(var f:TextRec;var s:string;var Base:longint):boolean;
  587. {
  588. Read the base $ For 16 and % For 2, if buffer is empty return true
  589. }
  590. begin
  591. case f.BufPtr^[f.BufPos] of
  592. '$' : Base:=16;
  593. '%' : Base:=2;
  594. else
  595. Base:=10;
  596. end;
  597. ReadBase:=(Base=10) or NextChar(f,s);
  598. end;
  599. Function ReadNumeric(var f:TextRec;var s:string;base:longint):Boolean;
  600. {
  601. Read numeric input, if buffer is empty then return True
  602. }
  603. var
  604. c : char;
  605. begin
  606. ReadNumeric:=false;
  607. c:=f.BufPtr^[f.BufPos];
  608. while ((base>=10) and (c in ['0'..'9'])) or
  609. ((base=16) and (c in ['A'..'F','a'..'f'])) or
  610. ((base=2) and (c in ['0'..'1'])) do
  611. begin
  612. if not NextChar(f,s) then
  613. exit;
  614. c:=f.BufPtr^[f.BufPos];
  615. end;
  616. ReadNumeric:=true;
  617. end;
  618. Procedure Read_End(var f:TextRec);[Public,Alias:'FPC_READ_END'];
  619. begin
  620. if f.FlushFunc<>nil then
  621. FileFunc(f.FlushFunc)(f);
  622. end;
  623. Procedure ReadLn_End(var f : TextRec);[Public,Alias:'FPC_READLN_END'];
  624. Begin
  625. { Check error and if file is open and load buf if empty }
  626. If (InOutRes<>0) then
  627. exit;
  628. if (f.mode<>fmInput) Then
  629. begin
  630. InOutRes:=104;
  631. exit;
  632. end;
  633. repeat
  634. If f.BufPos>=f.BufEnd Then
  635. begin
  636. FileFunc(f.InOutFunc)(f);
  637. if f.BufPos>=f.BufEnd then
  638. break;
  639. end;
  640. inc(f.BufPos);
  641. if (f.BufPtr^[f.BufPos-1]=#10) then
  642. exit;
  643. until false;
  644. { Flush if set }
  645. if f.FlushFunc<>nil then
  646. FileFunc(f.FlushFunc)(f);
  647. End;
  648. Function ReadPCharLen(var f:TextRec;s:pchar;maxlen:longint):longint;
  649. var
  650. sPos,len : Longint;
  651. p,startp,maxp : pchar;
  652. Begin
  653. ReadPCharLen:=0;
  654. { Check error and if file is open }
  655. If (InOutRes<>0) then
  656. exit;
  657. if (f.mode<>fmInput) Then
  658. begin
  659. InOutRes:=104;
  660. exit;
  661. end;
  662. { Read maximal until Maxlen is reached }
  663. sPos:=0;
  664. repeat
  665. If f.BufPos>=f.BufEnd Then
  666. begin
  667. FileFunc(f.InOutFunc)(f);
  668. If f.BufPos>=f.BufEnd Then
  669. break;
  670. end;
  671. p:[email protected]^[f.BufPos];
  672. if SPos+f.BufEnd-f.BufPos>MaxLen then
  673. maxp:[email protected]^[f.BufPos+MaxLen-SPos]
  674. else
  675. maxp:[email protected]^[f.BufEnd];
  676. startp:=p;
  677. { search linefeed }
  678. while (p<maxp) and (P^<>#10) do
  679. inc(p);
  680. { calculate read bytes }
  681. len:=p-startp;
  682. inc(f.BufPos,Len);
  683. Move(startp^,s[sPos],Len);
  684. inc(sPos,Len);
  685. { was it a LF? then leave }
  686. if (p<maxp) and (p^=#10) then
  687. begin
  688. if (spos>0) and (s[spos-1]=#13) then
  689. dec(sPos);
  690. break;
  691. end;
  692. { Maxlen reached ? }
  693. if spos=MaxLen then
  694. break;
  695. until false;
  696. ReadPCharLen:=spos;
  697. End;
  698. Procedure Read_String(var f : TextRec;var s : String);[Public,Alias:'FPC_READ_TEXT_'+{$ifdef NEWREADINT}'SHORTSTR'{$else}'STRING'{$endif}];
  699. Begin
  700. s[0]:=chr(ReadPCharLen(f,pchar(@s[1]),high(s)));
  701. End;
  702. Procedure Read_PChar(var f : TextRec;var s : PChar);[Public,Alias:'FPC_READ_TEXT_PCHAR_AS_POINTER'];
  703. Begin
  704. pchar(s+ReadPCharLen(f,s,$7fffffff))^:=#0;
  705. End;
  706. Procedure Read_Array(var f : TextRec;var s : {$ifdef NEWWRITEARRAY}array of char{$else}array00{$endif});[Public,Alias:'FPC_READ_TEXT_PCHAR_AS_ARRAY'];
  707. Begin
  708. pchar(pchar(@s)+ReadPCharLen(f,pchar(@s),{$ifdef NEWWRITEARRAY}high(s){$else}$7fffffff{$endif}))^:=#0;
  709. End;
  710. Procedure Read_AnsiString(var f : TextRec;var s : AnsiString);[Public,Alias:'FPC_READ_TEXT_'+{$ifdef NEWREADINT}'ANSISTR'{$else}'ANSISTRING'{$endif}];
  711. var
  712. len : longint;
  713. Begin
  714. { Delete the string }
  715. AnsiStr_Decr_ref (Pointer(S));
  716. { We assign room for 1024 characters totally at random.... }
  717. Pointer(s):=Pointer(NewAnsiString(1024));
  718. len:=ReadPCharLen(f,pchar(s),1024);
  719. pchar(pchar(s)+len)^:=#0;
  720. PAnsiRec(Pointer(S)-FirstOff)^.Len:=len;
  721. End;
  722. {$ifdef NEWREADINT}
  723. Function Read_Char(var f : TextRec):char;[Public,Alias:'FPC_READ_TEXT_CHAR'];
  724. Begin
  725. Read_Char:=#0;
  726. { Check error and if file is open }
  727. If (InOutRes<>0) then
  728. exit;
  729. if (f.mode<>fmInput) Then
  730. begin
  731. InOutRes:=104;
  732. exit;
  733. end;
  734. { Read next char or EOF }
  735. If f.BufPos>=f.BufEnd Then
  736. begin
  737. FileFunc(f.InOutFunc)(f);
  738. If f.BufPos>=f.BufEnd Then
  739. exit(#26);
  740. end;
  741. Read_Char:=f.Bufptr^[f.BufPos];
  742. inc(f.BufPos);
  743. end;
  744. Function Read_SInt(var f : TextRec):ValSInt;[Public,Alias:'FPC_READ_TEXT_SINT'];
  745. var
  746. hs : String;
  747. code : Longint;
  748. base : longint;
  749. Begin
  750. Read_SInt:=0;
  751. { Leave if error or not open file, else check for empty buf }
  752. If (InOutRes<>0) then
  753. exit;
  754. if (f.mode<>fmInput) Then
  755. begin
  756. InOutRes:=104;
  757. exit;
  758. end;
  759. If f.BufPos>=f.BufEnd Then
  760. FileFunc(f.InOutFunc)(f);
  761. hs:='';
  762. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadBase(f,hs,Base) then
  763. ReadNumeric(f,hs,Base);
  764. Val(hs,Read_SInt,code);
  765. If code<>0 Then
  766. InOutRes:=106;
  767. End;
  768. Function Read_UInt(var f : TextRec):ValUInt;[Public,Alias:'FPC_READ_TEXT_UINT'];
  769. var
  770. hs : String;
  771. code : longint;
  772. base : longint;
  773. Begin
  774. Read_UInt:=0;
  775. { Leave if error or not open file, else check for empty buf }
  776. If (InOutRes<>0) then
  777. exit;
  778. if (f.mode<>fmInput) Then
  779. begin
  780. InOutRes:=104;
  781. exit;
  782. end;
  783. If f.BufPos>=f.BufEnd Then
  784. FileFunc(f.InOutFunc)(f);
  785. hs:='';
  786. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadBase(f,hs,Base) then
  787. ReadNumeric(f,hs,Base);
  788. val(hs,Read_UInt,code);
  789. If code<>0 Then
  790. InOutRes:=106;
  791. End;
  792. Function Read_Float(var f : TextRec):ValReal;[Public,Alias:'FPC_READ_TEXT_FLOAT'];
  793. var
  794. hs : string;
  795. code : Word;
  796. begin
  797. Read_Float:=0.0;
  798. { Leave if error or not open file, else check for empty buf }
  799. If (InOutRes<>0) then
  800. exit;
  801. if (f.mode<>fmInput) Then
  802. begin
  803. InOutRes:=104;
  804. exit;
  805. end;
  806. If f.BufPos>=f.BufEnd Then
  807. FileFunc(f.InOutFunc)(f);
  808. hs:='';
  809. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadNumeric(f,hs,10) then
  810. begin
  811. { First check for a . }
  812. if (f.Bufptr^[f.BufPos]='.') and (f.BufPos<f.BufEnd) Then
  813. begin
  814. hs:=hs+'.';
  815. Inc(f.BufPos);
  816. If f.BufPos>=f.BufEnd Then
  817. FileFunc(f.InOutFunc)(f);
  818. ReadNumeric(f,hs,10);
  819. end;
  820. { Also when a point is found check for a E }
  821. if (f.Bufptr^[f.BufPos] in ['e','E']) and (f.BufPos<f.BufEnd) Then
  822. begin
  823. hs:=hs+'E';
  824. Inc(f.BufPos);
  825. If f.BufPos>=f.BufEnd Then
  826. FileFunc(f.InOutFunc)(f);
  827. if ReadSign(f,hs) then
  828. ReadNumeric(f,hs,10);
  829. end;
  830. end;
  831. val(hs,Read_Float,code);
  832. If code<>0 Then
  833. InOutRes:=106;
  834. end;
  835. {$ifdef INT64}
  836. procedure read_qword(len : longint;var t : textrec;q : qword);[public,alias:'FPC_READ_TEXT_QWORD'];
  837. begin
  838. {!!!!!!!!!!!!!}
  839. end;
  840. {$endif INT64}
  841. {$else}
  842. Procedure Read_Char(var f : TextRec;var c : Char);[Public,Alias:'FPC_READ_TEXT_CHAR'];
  843. Begin
  844. c:=#0;
  845. { Check error and if file is open }
  846. If (InOutRes<>0) then
  847. exit;
  848. if (f.mode<>fmInput) Then
  849. begin
  850. InOutRes:=104;
  851. exit;
  852. end;
  853. { Read next char or EOF }
  854. If f.BufPos>=f.BufEnd Then
  855. begin
  856. FileFunc(f.InOutFunc)(f);
  857. If f.BufPos>=f.BufEnd Then
  858. begin
  859. c:=#26;
  860. exit;
  861. end;
  862. end;
  863. c:=f.Bufptr^[f.BufPos];
  864. inc(f.BufPos);
  865. end;
  866. Procedure Read_Longint(var f : TextRec;var l : Longint);[Public,Alias:'FPC_READ_TEXT_LONGINT'];
  867. var
  868. hs : String;
  869. code : Longint;
  870. base : longint;
  871. Begin
  872. l:=0;
  873. { Leave if error or not open file, else check for empty buf }
  874. If (InOutRes<>0) then
  875. exit;
  876. if (f.mode<>fmInput) Then
  877. begin
  878. InOutRes:=104;
  879. exit;
  880. end;
  881. If f.BufPos>=f.BufEnd Then
  882. FileFunc(f.InOutFunc)(f);
  883. hs:='';
  884. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadBase(f,hs,Base) then
  885. ReadNumeric(f,hs,Base);
  886. Val(hs,l,code);
  887. If code<>0 Then
  888. InOutRes:=106;
  889. End;
  890. Procedure Read_Integer(var f : TextRec;var l : Integer);[Public,Alias:'FPC_READ_TEXT_INTEGER'];
  891. var
  892. ll : Longint;
  893. Begin
  894. l:=0;
  895. If InOutRes <> 0 then
  896. exit;
  897. Read_Longint(f,ll);
  898. If (ll<-32768) or (ll>32767) Then
  899. InOutRes:=201
  900. else
  901. l:=ll;
  902. End;
  903. Procedure Read_Word(var f : TextRec;var l : Word);[Public,Alias:'FPC_READ_TEXT_WORD'];
  904. var
  905. ll : Longint;
  906. Begin
  907. l:=0;
  908. If InOutRes <> 0 then
  909. exit;
  910. Read_Longint(f,ll);
  911. If (ll<0) or (ll>$ffff) Then
  912. InOutRes:=201
  913. else
  914. l:=ll;
  915. End;
  916. Procedure Read_Byte(var f : TextRec;var l : byte);[Public,Alias:'FPC_READ_TEXT_BYTE'];
  917. var
  918. ll : Longint;
  919. Begin
  920. l:=0;
  921. If InOutRes <> 0 then
  922. exit;
  923. Read_Longint(f,ll);
  924. If (ll<0) or (ll>255) Then
  925. InOutRes:=201
  926. else
  927. l:=ll;
  928. End;
  929. Procedure Read_Shortint(var f : TextRec;var l : shortint);[Public,Alias:'FPC_READ_TEXT_SHORTINT'];
  930. var
  931. ll : Longint;
  932. Begin
  933. l:=0;
  934. If InOutRes <> 0 then
  935. exit;
  936. Read_Longint(f,ll);
  937. If (ll<-128) or (ll>127) Then
  938. InOutRes:=201
  939. else
  940. l:=ll;
  941. End;
  942. Procedure Read_Cardinal(var f : TextRec;var l : cardinal);[Public,Alias:'FPC_READ_TEXT_CARDINAL'];
  943. var
  944. hs : String;
  945. code : longint;
  946. base : longint;
  947. Begin
  948. l:=0;
  949. { Leave if error or not open file, else check for empty buf }
  950. If (InOutRes<>0) then
  951. exit;
  952. if (f.mode<>fmInput) Then
  953. begin
  954. InOutRes:=104;
  955. exit;
  956. end;
  957. If f.BufPos>=f.BufEnd Then
  958. FileFunc(f.InOutFunc)(f);
  959. hs:='';
  960. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadBase(f,hs,Base) then
  961. ReadNumeric(f,hs,Base);
  962. val(hs,l,code);
  963. If code<>0 Then
  964. InOutRes:=106;
  965. End;
  966. {$ifdef INT64}
  967. procedure read_qword(len : longint;var t : textrec;q : qword);[public,alias:'FPC_READ_TEXT_QWORD'];
  968. begin
  969. {!!!!!!!!!!!!!}
  970. end;
  971. {$endif INT64}
  972. function ReadRealStr(var f:TextRec):string;
  973. var
  974. hs : string;
  975. begin
  976. ReadRealStr:='';
  977. { Leave if error or not open file, else check for empty buf }
  978. If (InOutRes<>0) then
  979. exit;
  980. if (f.mode<>fmInput) Then
  981. begin
  982. InOutRes:=104;
  983. exit;
  984. end;
  985. If f.BufPos>=f.BufEnd Then
  986. FileFunc(f.InOutFunc)(f);
  987. hs:='';
  988. if IgnoreSpaces(f) and ReadSign(f,hs) and ReadNumeric(f,hs,10) then
  989. begin
  990. { First check for a . }
  991. if (f.Bufptr^[f.BufPos]='.') and (f.BufPos<f.BufEnd) Then
  992. begin
  993. hs:=hs+'.';
  994. Inc(f.BufPos);
  995. If f.BufPos>=f.BufEnd Then
  996. FileFunc(f.InOutFunc)(f);
  997. ReadNumeric(f,hs,10);
  998. end;
  999. { Also when a point is found check for a E }
  1000. if (f.Bufptr^[f.BufPos] in ['e','E']) and (f.BufPos<f.BufEnd) Then
  1001. begin
  1002. hs:=hs+'E';
  1003. Inc(f.BufPos);
  1004. If f.BufPos>=f.BufEnd Then
  1005. FileFunc(f.InOutFunc)(f);
  1006. if ReadSign(f,hs) then
  1007. ReadNumeric(f,hs,10);
  1008. end;
  1009. end;
  1010. ReadRealStr:=hs;
  1011. end;
  1012. Procedure Read_Real(var f : TextRec;var d : Real);[Public,Alias:'FPC_READ_TEXT_REAL'];
  1013. var
  1014. code : Word;
  1015. Begin
  1016. val(ReadRealStr(f),d,code);
  1017. If code<>0 Then
  1018. InOutRes:=106;
  1019. End;
  1020. {$ifdef SUPPORT_SINGLE}
  1021. Procedure Read_Single(var f : TextRec;var d : single);[Public,Alias:'FPC_READ_TEXT_SINGLE'];
  1022. var
  1023. code : Word;
  1024. Begin
  1025. val(ReadRealStr(f),d,code);
  1026. If code<>0 Then
  1027. InOutRes:=106;
  1028. End;
  1029. {$endif SUPPORT_SINGLE}
  1030. {$ifdef SUPPORT_EXTENDED}
  1031. Procedure Read_Extended(var f : TextRec;var d : extended);[Public,Alias:'FPC_READ_TEXT_EXTENDED'];
  1032. var
  1033. code : Word;
  1034. Begin
  1035. val(ReadRealStr(f),d,code);
  1036. If code<>0 Then
  1037. InOutRes:=106;
  1038. End;
  1039. {$endif SUPPORT_EXTENDED}
  1040. {$ifdef SUPPORT_COMP}
  1041. Procedure Read_Comp(var f : TextRec;var d : comp);[Public,Alias:'FPC_READ_TEXT_COMP'];
  1042. var
  1043. code : Word;
  1044. Begin
  1045. val(ReadRealStr(f),d,code);
  1046. If code<>0 Then
  1047. InOutRes:=106;
  1048. End;
  1049. {$endif SUPPORT_COMP}
  1050. {$ifdef SUPPORT_FIXED}
  1051. Procedure Read_Fixed(var f : TextRec;var d : fixed);[Public,Alias:'FPC_READ_TEXT_FIXED'];
  1052. var
  1053. code : Word;
  1054. Begin
  1055. val(ReadRealStr(f),d,code);
  1056. If code<>0 Then
  1057. InOutRes:=106;
  1058. End;
  1059. {$endif SUPPORT_FIXED}
  1060. {$endif}
  1061. {*****************************************************************************
  1062. Initializing
  1063. *****************************************************************************}
  1064. procedure OpenStdIO(var f:text;mode,hdl:longint);
  1065. begin
  1066. Assign(f,'');
  1067. TextRec(f).Handle:=hdl;
  1068. TextRec(f).Mode:=mode;
  1069. TextRec(f).Closefunc:=@FileCloseFunc;
  1070. case mode of
  1071. fmInput : TextRec(f).InOutFunc:=@FileReadFunc;
  1072. fmOutput : begin
  1073. TextRec(f).InOutFunc:=@FileWriteFunc;
  1074. TextRec(f).FlushFunc:=@FileWriteFunc;
  1075. end;
  1076. else
  1077. HandleError(102);
  1078. end;
  1079. end;
  1080. {
  1081. $Log$
  1082. Revision 1.48 1999-07-01 15:39:52 florian
  1083. + qword/int64 type released
  1084. Revision 1.47 1999/06/30 22:17:24 florian
  1085. + fpuint64 to system unit interface added: if it is true, the rtl
  1086. uses the fpu to do int64 operations, if possible
  1087. Revision 1.46 1999/05/06 09:05:16 peter
  1088. * generic write_float str_float
  1089. Revision 1.45 1999/04/26 18:27:26 peter
  1090. * fixed write array
  1091. * read array with maxlen
  1092. Revision 1.44 1999/04/08 15:57:57 peter
  1093. + subrange checking for readln()
  1094. Revision 1.43 1999/04/07 22:05:18 peter
  1095. * fixed bug with readln where it sometime didn't read until eol
  1096. Revision 1.42 1999/03/16 17:49:39 jonas
  1097. * changes for internal Val code (do a "make cycle OPT=-dvalintern" to test)
  1098. * in text.inc: changed RTE 106 when read integer values are out of bounds to RTE 201
  1099. * in systemh.inc: disabled "support_fixed" for the i386 because it gave internal errors,
  1100. Revision 1.41 1999/03/02 18:23:37 peter
  1101. * changed so handlerror() -> inoutres:= to have $I- support
  1102. Revision 1.40 1999/03/01 15:41:04 peter
  1103. * use external names
  1104. * removed all direct assembler modes
  1105. Revision 1.39 1999/02/17 10:13:29 peter
  1106. * when error when opening a file, then reset the mode to fmclosed
  1107. Revision 1.38 1999/01/28 19:38:19 peter
  1108. * fixed readln(ansistring)
  1109. Revision 1.37 1998/12/15 22:43:06 peter
  1110. * removed temp symbols
  1111. Revision 1.36 1998/12/11 18:07:39 peter
  1112. * fixed read(char) with empty buffer
  1113. Revision 1.35 1998/11/27 14:50:58 peter
  1114. + open strings, $P switch support
  1115. Revision 1.34 1998/11/16 12:21:48 peter
  1116. * fixes for 0.99.8
  1117. Revision 1.33 1998/10/23 00:03:29 peter
  1118. * write(pchar) has check for nil
  1119. Revision 1.32 1998/10/20 14:37:45 peter
  1120. * fixed maxlen which was not correct after my read_string update
  1121. Revision 1.31 1998/10/10 15:28:48 peter
  1122. + read single,fixed
  1123. + val with code:longint
  1124. + val for fixed
  1125. Revision 1.30 1998/09/29 08:39:07 michael
  1126. + Ansistring write now gets pointer.
  1127. Revision 1.29 1998/09/28 14:27:08 michael
  1128. + AnsiStrings update
  1129. Revision 1.28 1998/09/24 23:32:24 peter
  1130. * fixed small bug with a #13#10 on a line
  1131. Revision 1.27 1998/09/18 12:23:22 peter
  1132. * fixed a bug introduced by my previous update
  1133. Revision 1.26 1998/09/17 16:34:18 peter
  1134. * new eof,eoln,seekeoln,seekeof
  1135. * speed upgrade for read_string
  1136. * inoutres 104/105 updates for read_* and write_*
  1137. Revision 1.25 1998/09/14 10:48:23 peter
  1138. * FPC_ names
  1139. * Heap manager is now system independent
  1140. Revision 1.24 1998/09/08 10:14:06 peter
  1141. + textrecbufsize
  1142. Revision 1.23 1998/08/26 15:33:28 peter
  1143. * reset bufpos,bufend in opentext like tp7
  1144. Revision 1.22 1998/08/26 11:23:25 pierre
  1145. * close did not reset the bufpos and bufend fields
  1146. led to problems when using the same file several times
  1147. Revision 1.21 1998/08/17 22:42:17 michael
  1148. + Flush on close only for output files cd ../inc
  1149. Revision 1.20 1998/08/11 00:05:28 peter
  1150. * $ifdef ver0_99_5 updates
  1151. Revision 1.19 1998/07/30 13:26:16 michael
  1152. + Added support for ErrorProc variable. All internal functions are required
  1153. to call HandleError instead of runerror from now on.
  1154. This is necessary for exception support.
  1155. Revision 1.18 1998/07/29 21:44:35 michael
  1156. + Implemented reading/writing of ansistrings
  1157. Revision 1.17 1998/07/19 19:55:33 michael
  1158. + fixed rename. Changed p to p^
  1159. Revision 1.16 1998/07/10 11:02:40 peter
  1160. * support_fixed, becuase fixed is not 100% yet for the m68k
  1161. Revision 1.15 1998/07/06 15:56:43 michael
  1162. Added length checking for string reading
  1163. Revision 1.14 1998/07/02 12:14:56 carl
  1164. + Each IOCheck routine now check InOutRes before, just like TP
  1165. Revision 1.13 1998/07/01 15:30:00 peter
  1166. * better readln/writeln
  1167. Revision 1.12 1998/07/01 14:48:10 carl
  1168. * bugfix of WRITE_TEXT_BOOLEAN , was not TP compatible
  1169. + added explicit typecast in OpenText
  1170. Revision 1.11 1998/06/25 09:44:22 daniel
  1171. + RTLLITE directive to compile minimal RTL.
  1172. Revision 1.10 1998/06/04 23:46:03 peter
  1173. * comp,extended are only i386 added support_comp,support_extended
  1174. Revision 1.9 1998/06/02 16:47:56 pierre
  1175. * bug for boolean values greater than one fixed
  1176. Revision 1.8 1998/05/31 14:14:54 peter
  1177. * removed warnings using comp()
  1178. Revision 1.7 1998/05/27 00:19:21 peter
  1179. * fixed crt input
  1180. Revision 1.6 1998/05/21 19:31:01 peter
  1181. * objects compiles for linux
  1182. + assign(pchar), assign(char), rename(pchar), rename(char)
  1183. * fixed read_text_as_array
  1184. + read_text_as_pchar which was not yet in the rtl
  1185. Revision 1.5 1998/05/12 10:42:45 peter
  1186. * moved getopts to inc/, all supported OS's need argc,argv exported
  1187. + strpas, strlen are now exported in the systemunit
  1188. * removed logs
  1189. * removed $ifdef ver_above
  1190. Revision 1.4 1998/04/07 22:40:46 florian
  1191. * final fix of comp writing
  1192. }