text.inc 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Run time library.
  4. Copyright (c) 1999-2000 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. MAC_LINEBREAK Use Mac Linebreaks: #13 instead of #10 or #10#13
  16. SHORT_LINEBREAK is defined in the Linux system unit (syslinux.pp)
  17. }
  18. {****************************************************************************
  19. subroutines For TextFile handling
  20. ****************************************************************************}
  21. Procedure FileCloseFunc(Var t:TextRec);
  22. Begin
  23. Do_Close(t.Handle);
  24. t.Handle:=UnusedHandle;
  25. End;
  26. Procedure FileReadFunc(var t:TextRec);
  27. Begin
  28. t.BufEnd:=Do_Read(t.Handle,Longint(t.Bufptr),t.BufSize);
  29. t.BufPos:=0;
  30. End;
  31. Procedure FileWriteFunc(var t:TextRec);
  32. var
  33. i : longint;
  34. Begin
  35. i:=Do_Write(t.Handle,Longint(t.Bufptr),t.BufPos);
  36. if i<>t.BufPos then
  37. InOutRes:=101;
  38. t.BufPos:=0;
  39. End;
  40. Procedure FileOpenFunc(var t:TextRec);
  41. var
  42. Flags : Longint;
  43. Begin
  44. Case t.mode Of
  45. fmInput : Flags:=$10000;
  46. fmOutput : Flags:=$11001;
  47. fmAppend : Flags:=$10101;
  48. else
  49. begin
  50. InOutRes:=102;
  51. exit;
  52. end;
  53. End;
  54. Do_Open(t,PChar(@t.Name),Flags);
  55. t.CloseFunc:=@FileCloseFunc;
  56. t.FlushFunc:=nil;
  57. if t.Mode=fmInput then
  58. t.InOutFunc:=@FileReadFunc
  59. else
  60. begin
  61. t.InOutFunc:=@FileWriteFunc;
  62. { Only install flushing if its a NOT a file, and only check if there
  63. was no error opening the file, becuase else we always get a bad
  64. file handle error 6 (PFV) }
  65. if (InOutRes=0) and
  66. Do_Isdevice(t.Handle) then
  67. t.FlushFunc:=@FileWriteFunc;
  68. end;
  69. End;
  70. Procedure assign(var t:Text;const s:String);
  71. Begin
  72. FillChar(t,SizEof(TextRec),0);
  73. { only set things that are not zero }
  74. TextRec(t).Handle:=UnusedHandle;
  75. TextRec(t).mode:=fmClosed;
  76. TextRec(t).BufSize:=TextRecBufSize;
  77. TextRec(t).Bufptr:=@TextRec(t).Buffer;
  78. TextRec(t).OpenFunc:=@FileOpenFunc;
  79. Move(s[1],TextRec(t).Name,Length(s));
  80. End;
  81. Procedure assign(var t:Text;p:pchar);
  82. begin
  83. Assign(t,StrPas(p));
  84. end;
  85. Procedure assign(var t:Text;c:char);
  86. begin
  87. Assign(t,string(c));
  88. end;
  89. Procedure Close(var t : Text);[IOCheck];
  90. Begin
  91. if InOutRes<>0 then
  92. Exit;
  93. case TextRec(t).mode of
  94. fmInput,fmOutPut,fmAppend:
  95. Begin
  96. { Write pending buffer }
  97. If Textrec(t).Mode=fmoutput then
  98. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  99. { Only close functions not connected to stdout.}
  100. If ((TextRec(t).Handle<>StdInputHandle) and
  101. (TextRec(t).Handle<>StdOutputHandle) and
  102. (TextRec(t).Handle<>StdErrorHandle)) Then
  103. FileFunc(TextRec(t).CloseFunc)(TextRec(t));
  104. TextRec(t).mode := fmClosed;
  105. { Reset buffer for safety }
  106. TextRec(t).BufPos:=0;
  107. TextRec(t).BufEnd:=0;
  108. End
  109. else inOutRes := 103;
  110. End;
  111. End;
  112. Procedure OpenText(var t : Text;mode,defHdl:Longint);
  113. Begin
  114. Case TextRec(t).mode Of {This gives the fastest code}
  115. fmInput,fmOutput,fmInOut : Close(t);
  116. fmClosed : ;
  117. else
  118. Begin
  119. InOutRes:=102;
  120. exit;
  121. End;
  122. End;
  123. TextRec(t).mode:=mode;
  124. TextRec(t).bufpos:=0;
  125. TextRec(t).bufend:=0;
  126. FileFunc(TextRec(t).OpenFunc)(TextRec(t));
  127. { reset the mode to closed when an error has occured }
  128. if InOutRes<>0 then
  129. TextRec(t).mode:=fmClosed;
  130. End;
  131. Procedure Rewrite(var t : Text);[IOCheck];
  132. Begin
  133. If InOutRes<>0 then
  134. exit;
  135. OpenText(t,fmOutput,1);
  136. End;
  137. Procedure Reset(var t : Text);[IOCheck];
  138. Begin
  139. If InOutRes<>0 then
  140. exit;
  141. OpenText(t,fmInput,0);
  142. End;
  143. Procedure Append(var t : Text);[IOCheck];
  144. Begin
  145. If InOutRes<>0 then
  146. exit;
  147. OpenText(t,fmAppend,1);
  148. End;
  149. Procedure Flush(var t : Text);[IOCheck];
  150. Begin
  151. If InOutRes<>0 then
  152. exit;
  153. if TextRec(t).mode<>fmOutput then
  154. begin
  155. if TextRec(t).mode=fmInput then
  156. InOutRes:=105
  157. else
  158. InOutRes:=103;
  159. exit;
  160. end;
  161. { Not the flushfunc but the inoutfunc should be used, becuase that
  162. writes the data, flushfunc doesn't need to be assigned }
  163. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  164. End;
  165. Procedure Erase(var t:Text);[IOCheck];
  166. Begin
  167. If InOutRes <> 0 then
  168. exit;
  169. If TextRec(t).mode=fmClosed Then
  170. Do_Erase(PChar(@TextRec(t).Name));
  171. End;
  172. Procedure Rename(var t : text;p:pchar);[IOCheck];
  173. Begin
  174. If InOutRes <> 0 then
  175. exit;
  176. If TextRec(t).mode=fmClosed Then
  177. Begin
  178. Do_Rename(PChar(@TextRec(t).Name),p);
  179. { check error code of do_rename }
  180. If InOutRes = 0 then
  181. Move(p^,TextRec(t).Name,StrLen(p)+1);
  182. End;
  183. End;
  184. Procedure Rename(var t : Text;const s : string);[IOCheck];
  185. var
  186. p : array[0..255] Of Char;
  187. Begin
  188. If InOutRes <> 0 then
  189. exit;
  190. Move(s[1],p,Length(s));
  191. p[Length(s)]:=#0;
  192. Rename(t,Pchar(@p));
  193. End;
  194. Procedure Rename(var t : Text;c : char);[IOCheck];
  195. var
  196. p : array[0..1] Of Char;
  197. Begin
  198. If InOutRes <> 0 then
  199. exit;
  200. p[0]:=c;
  201. p[1]:=#0;
  202. Rename(t,Pchar(@p));
  203. End;
  204. Function Eof(Var t: Text): Boolean;[IOCheck];
  205. Begin
  206. If (InOutRes<>0) then
  207. exit(true);
  208. if (TextRec(t).mode<>fmInput) Then
  209. begin
  210. if TextRec(t).mode=fmOutput then
  211. InOutRes:=104
  212. else
  213. InOutRes:=103;
  214. exit(true);
  215. end;
  216. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  217. begin
  218. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  219. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  220. exit(true);
  221. end;
  222. {$ifdef EOF_CTRLZ}
  223. Eof:=(TextRec(t).Bufptr^[TextRec(t).BufPos]=#26);
  224. {$else}
  225. Eof:=false;
  226. {$endif EOL_CTRLZ}
  227. end;
  228. Function Eof:Boolean;
  229. Begin
  230. Eof:=Eof(Input);
  231. End;
  232. Function SeekEof (Var t : Text) : Boolean;
  233. var
  234. oldfilepos, oldbufpos, oldbufend, reads: longint;
  235. isdevice: boolean;
  236. Begin
  237. If (InOutRes<>0) then
  238. exit(true);
  239. if (TextRec(t).mode<>fmInput) Then
  240. begin
  241. if TextRec(t).mode=fmOutPut then
  242. InOutRes:=104
  243. else
  244. InOutRes:=103;
  245. exit(true);
  246. end;
  247. { try to save the current position in the file, seekeof() should not move }
  248. { the current file position (JM) }
  249. oldbufpos := TextRec(t).BufPos;
  250. oldbufend := TextRec(t).BufEnd;
  251. reads := 0;
  252. oldfilepos := -1;
  253. isdevice := Do_IsDevice(TextRec(t).handle);
  254. repeat
  255. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  256. begin
  257. { signal that the we will have to do a seek }
  258. inc(reads);
  259. if not isdevice and
  260. (reads = 1) then
  261. begin
  262. oldfilepos := Do_FilePos(TextRec(t).handle) - TextRec(t).BufEnd;
  263. InOutRes:=0;
  264. end;
  265. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  266. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  267. begin
  268. { if we only did a read in which we didn't read anything, the }
  269. { old buffer is still valid and we can simply restore the }
  270. { pointers (JM) }
  271. dec(reads);
  272. SeekEof := true;
  273. break;
  274. end;
  275. end;
  276. case TextRec(t).Bufptr^[TextRec(t).BufPos] of
  277. {$ifdef EOF_CTRLZ}
  278. #26 :
  279. begin
  280. SeekEof := true;
  281. break;
  282. end;
  283. {$endif EOF_CTRLZ}
  284. #10,#13,
  285. #9,' ' : ;
  286. else
  287. begin
  288. SeekEof := false;
  289. break;
  290. end;
  291. end;
  292. inc(TextRec(t).BufPos);
  293. until false;
  294. { restore file position if not working with a device }
  295. if not isdevice then
  296. { if we didn't modify the buffer, simply restore the BufPos and BufEnd }
  297. { (the latter becuase it's now probably set to zero because nothing was }
  298. { was read anymore) }
  299. if (reads = 0) then
  300. begin
  301. TextRec(t).BufPos:=oldbufpos;
  302. TextRec(t).BufEnd:=oldbufend;
  303. end
  304. { otherwise return to the old filepos and reset the buffer }
  305. else
  306. begin
  307. do_seek(TextRec(t).handle,oldfilepos);
  308. InOutRes:=0;
  309. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  310. TextRec(t).BufPos:=oldbufpos;
  311. end;
  312. End;
  313. Function SeekEof : Boolean;
  314. Begin
  315. SeekEof:=SeekEof(Input);
  316. End;
  317. Function Eoln(var t:Text) : Boolean;
  318. Begin
  319. If (InOutRes<>0) then
  320. exit(true);
  321. if (TextRec(t).mode<>fmInput) Then
  322. begin
  323. if TextRec(t).mode=fmOutPut then
  324. InOutRes:=104
  325. else
  326. InOutRes:=103;
  327. exit(true);
  328. end;
  329. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  330. begin
  331. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  332. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  333. exit(true);
  334. end;
  335. Eoln:=(TextRec(t).Bufptr^[TextRec(t).BufPos] in [#10,#13]);
  336. End;
  337. Function Eoln : Boolean;
  338. Begin
  339. Eoln:=Eoln(Input);
  340. End;
  341. Function SeekEoln (Var t : Text) : Boolean;
  342. Begin
  343. If (InOutRes<>0) then
  344. exit(true);
  345. if (TextRec(t).mode<>fmInput) Then
  346. begin
  347. if TextRec(t).mode=fmOutput then
  348. InOutRes:=104
  349. else
  350. InOutRes:=103;
  351. exit(true);
  352. end;
  353. repeat
  354. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  355. begin
  356. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  357. If TextRec(t).BufPos>=TextRec(t).BufEnd Then
  358. exit(true);
  359. end;
  360. case TextRec(t).Bufptr^[TextRec(t).BufPos] of
  361. #26,
  362. #10,#13 : exit(true);
  363. #9,' ' : ;
  364. else
  365. exit(false);
  366. end;
  367. inc(TextRec(t).BufPos);
  368. until false;
  369. End;
  370. Function SeekEoln : Boolean;
  371. Begin
  372. SeekEoln:=SeekEoln(Input);
  373. End;
  374. Procedure SetTextBuf(Var F : Text; Var Buf);[INTERNPROC: In_settextbuf_file_x];
  375. Procedure SetTextBuf(Var F : Text; Var Buf; Size : Longint);
  376. Begin
  377. TextRec(f).BufPtr:=@Buf;
  378. TextRec(f).BufSize:=Size;
  379. TextRec(f).BufPos:=0;
  380. TextRec(f).BufEnd:=0;
  381. End;
  382. {*****************************************************************************
  383. Write(Ln)
  384. *****************************************************************************}
  385. Procedure WriteBuffer(var f:Text;const b;len:longint);
  386. var
  387. p : pchar;
  388. left,
  389. idx : longint;
  390. begin
  391. p:=pchar(@b);
  392. idx:=0;
  393. left:=TextRec(f).BufSize-TextRec(f).BufPos;
  394. while len>left do
  395. begin
  396. move(p[idx],TextRec(f).Bufptr^[TextRec(f).BufPos],left);
  397. dec(len,left);
  398. inc(idx,left);
  399. inc(TextRec(f).BufPos,left);
  400. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  401. left:=TextRec(f).BufSize-TextRec(f).BufPos;
  402. end;
  403. move(p[idx],TextRec(f).Bufptr^[TextRec(f).BufPos],len);
  404. inc(TextRec(f).BufPos,len);
  405. end;
  406. Procedure WriteBlanks(var f:Text;len:longint);
  407. var
  408. left : longint;
  409. begin
  410. left:=TextRec(f).BufSize-TextRec(f).BufPos;
  411. while len>left do
  412. begin
  413. FillChar(TextRec(f).Bufptr^[TextRec(f).BufPos],left,' ');
  414. dec(len,left);
  415. inc(TextRec(f).BufPos,left);
  416. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  417. left:=TextRec(f).BufSize-TextRec(f).BufPos;
  418. end;
  419. FillChar(TextRec(f).Bufptr^[TextRec(f).BufPos],len,' ');
  420. inc(TextRec(f).BufPos,len);
  421. end;
  422. Procedure fpc_Write_End(var f:Text);[Public,Alias:'FPC_WRITE_END']; iocheck; {$ifdef hascompilerproc} compilerproc; {$endif}
  423. begin
  424. if TextRec(f).FlushFunc<>nil then
  425. FileFunc(TextRec(f).FlushFunc)(TextRec(f));
  426. end;
  427. Procedure fpc_Writeln_End(var f:Text);[Public,Alias:'FPC_WRITELN_END']; iocheck; {$ifdef hascompilerproc} compilerproc; {$endif}
  428. const
  429. {$IFDEF SHORT_LINEBREAK}
  430. eollen=1;
  431. eol : array[0..0] of char=(#10);
  432. {$ELSE SHORT_LINEBREAK}
  433. {$ifdef MAC_LINEBREAK}
  434. eollen=1;
  435. eol : array[0..0] of char=(#13);
  436. {$else MAC_LINEBREAK}
  437. eollen=2;
  438. eol : array[0..1] of char=(#13,#10);
  439. {$endif MAC_LINEBREAK}
  440. {$ENDIF SHORT_LINEBREAK}
  441. begin
  442. If InOutRes <> 0 then exit;
  443. case TextRec(f).mode of
  444. fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
  445. begin
  446. { Write EOL }
  447. WriteBuffer(f,(@sLineBreak+1)^,length(sLineBreak));
  448. { Flush }
  449. if TextRec(f).FlushFunc<>nil then
  450. FileFunc(TextRec(f).FlushFunc)(TextRec(f));
  451. end;
  452. fmInput: InOutRes:=105
  453. else InOutRes:=103;
  454. end;
  455. end;
  456. Procedure fpc_Write_Text_ShortStr(Len : Longint;var f : Text;const s : String); iocheck; [Public,Alias:'FPC_WRITE_TEXT_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  457. Begin
  458. If (InOutRes<>0) then
  459. exit;
  460. case TextRec(f).mode of
  461. fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
  462. begin
  463. If Len>Length(s) Then
  464. WriteBlanks(f,Len-Length(s));
  465. WriteBuffer(f,s[1],Length(s));
  466. end;
  467. fmInput: InOutRes:=105
  468. else InOutRes:=103;
  469. end;
  470. End;
  471. { provide local access to write_str }
  472. procedure Write_Str(Len : Longint;var f : Text;const s : String); iocheck; [external name 'FPC_WRITE_TEXT_SHORTSTR'];
  473. Procedure fpc_Write_Text_Pchar_as_Array(Len : Longint;var f : Text;const s : array of char); iocheck; [Public,Alias:'FPC_WRITE_TEXT_PCHAR_AS_ARRAY']; {$ifdef hascompilerproc} compilerproc; {$endif}
  474. var
  475. ArrayLen : longint;
  476. p : pchar;
  477. Begin
  478. If (InOutRes<>0) then
  479. exit;
  480. case TextRec(f).mode of
  481. fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
  482. begin
  483. p:=pchar(@s);
  484. { can't use StrLen, since that one could try to read past the end }
  485. { of the heap (JM) }
  486. ArrayLen:=IndexByte(p^,high(s)+1,0);
  487. { IndexByte returns -1 if not found (JM) }
  488. if ArrayLen = -1 then
  489. ArrayLen := high(s)+1;
  490. If Len>ArrayLen Then
  491. WriteBlanks(f,Len-ArrayLen);
  492. WriteBuffer(f,p^,ArrayLen);
  493. end;
  494. fmInput: InOutRes:=105
  495. else InOutRes:=103;
  496. end;
  497. End;
  498. Procedure fpc_Write_Text_PChar_As_Pointer(Len : Longint;var f : Text;p : PChar); iocheck; [Public,Alias:'FPC_WRITE_TEXT_PCHAR_AS_POINTER']; {$ifdef hascompilerproc} compilerproc; {$endif}
  499. var
  500. PCharLen : longint;
  501. Begin
  502. If (p=nil) or (InOutRes<>0) then
  503. exit;
  504. case TextRec(f).mode of
  505. fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
  506. begin
  507. PCharLen:=StrLen(p);
  508. If Len>PCharLen Then
  509. WriteBlanks(f,Len-PCharLen);
  510. WriteBuffer(f,p^,PCharLen);
  511. end;
  512. fmInput: InOutRes:=105
  513. else InOutRes:=103;
  514. end;
  515. End;
  516. Procedure fpc_Write_Text_AnsiStr (Len : Longint; Var f : Text; S : AnsiString); iocheck; [Public,alias:'FPC_WRITE_TEXT_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  517. {
  518. Writes a AnsiString to the Text file T
  519. }
  520. var
  521. SLen : longint;
  522. begin
  523. If (pointer(S)=nil) or (InOutRes<>0) then
  524. exit;
  525. case TextRec(f).mode of
  526. fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
  527. begin
  528. SLen:=Length(s);
  529. If Len>SLen Then
  530. WriteBlanks(f,Len-SLen);
  531. WriteBuffer(f,PChar(S)^,SLen);
  532. end;
  533. fmInput: InOutRes:=105
  534. else InOutRes:=103;
  535. end;
  536. end;
  537. {$ifdef HASWIDESTRING}
  538. Procedure fpc_Write_Text_WideStr (Len : Longint; Var f : Text; S : WideString); iocheck; [Public,alias:'FPC_WRITE_TEXT_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  539. {
  540. Writes a WideString to the Text file T
  541. }
  542. var
  543. SLen : longint;
  544. begin
  545. If (pointer(S)=nil) or (InOutRes<>0) then
  546. exit;
  547. case TextRec(f).mode of
  548. fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
  549. begin
  550. SLen:=Length(s);
  551. If Len>SLen Then
  552. WriteBlanks(f,Len-SLen);
  553. WriteBuffer(f,PChar(AnsiString(S))^,SLen);
  554. end;
  555. fmInput: InOutRes:=105
  556. else InOutRes:=103;
  557. end;
  558. end;
  559. {$endif HASWIDESTRING}
  560. Procedure fpc_Write_Text_SInt(Len : Longint;var t : Text;l : ValSInt); iocheck; [Public,Alias:'FPC_WRITE_TEXT_SINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  561. var
  562. s : String;
  563. Begin
  564. If (InOutRes<>0) then
  565. exit;
  566. Str(l,s);
  567. Write_Str(Len,t,s);
  568. End;
  569. Procedure fpc_Write_Text_UInt(Len : Longint;var t : Text;l : ValUInt); iocheck; [Public,Alias:'FPC_WRITE_TEXT_UINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  570. var
  571. s : String;
  572. Begin
  573. If (InOutRes<>0) then
  574. exit;
  575. Str(L,s);
  576. Write_Str(Len,t,s);
  577. End;
  578. procedure fpc_write_text_qword(len : longint;var t : text;q : qword); iocheck; [public,alias:'FPC_WRITE_TEXT_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  579. var
  580. s : string;
  581. begin
  582. if (InOutRes<>0) then
  583. exit;
  584. qword_str(q,s);
  585. write_str(len,t,s);
  586. end;
  587. procedure fpc_write_text_int64(len : longint;var t : text;i : int64); iocheck; [public,alias:'FPC_WRITE_TEXT_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
  588. var
  589. s : string;
  590. begin
  591. if (InOutRes<>0) then
  592. exit;
  593. int64_str(i,s);
  594. write_str(len,t,s);
  595. end;
  596. Procedure fpc_Write_Text_Float(rt,fixkomma,Len : Longint;var t : Text;r : ValReal); iocheck; [Public,Alias:'FPC_WRITE_TEXT_FLOAT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  597. var
  598. s : String;
  599. Begin
  600. If (InOutRes<>0) then
  601. exit;
  602. Str_real(Len,fixkomma,r,treal_type(rt),s);
  603. Write_Str(Len,t,s);
  604. End;
  605. Procedure fpc_Write_Text_Boolean(Len : Longint;var t : Text;b : Boolean); iocheck; [Public,Alias:'FPC_WRITE_TEXT_BOOLEAN']; {$ifdef hascompilerproc} compilerproc; {$endif}
  606. Begin
  607. If (InOutRes<>0) then
  608. exit;
  609. { Can't use array[boolean] because b can be >0 ! }
  610. if b then
  611. Write_Str(Len,t,'TRUE')
  612. else
  613. Write_Str(Len,t,'FALSE');
  614. End;
  615. Procedure fpc_Write_Text_Char(Len : Longint;var t : Text;c : Char); iocheck; [Public,Alias:'FPC_WRITE_TEXT_CHAR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  616. Begin
  617. If (InOutRes<>0) then
  618. exit;
  619. if (TextRec(t).mode<>fmOutput) Then
  620. begin
  621. if TextRec(t).mode=fmClosed then
  622. InOutRes:=103
  623. else
  624. InOutRes:=105;
  625. exit;
  626. end;
  627. If Len>1 Then
  628. WriteBlanks(t,Len-1);
  629. If TextRec(t).BufPos+1>=TextRec(t).BufSize Then
  630. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  631. TextRec(t).Bufptr^[TextRec(t).BufPos]:=c;
  632. Inc(TextRec(t).BufPos);
  633. End;
  634. {$ifdef HASWIDECHAR}
  635. Procedure fpc_Write_Text_WideChar(Len : Longint;var t : Text;c : WideChar); iocheck; [Public,Alias:'FPC_WRITE_TEXT_WIDECHAR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  636. var
  637. ch : char;
  638. Begin
  639. If (InOutRes<>0) then
  640. exit;
  641. if (TextRec(t).mode<>fmOutput) Then
  642. begin
  643. if TextRec(t).mode=fmClosed then
  644. InOutRes:=103
  645. else
  646. InOutRes:=105;
  647. exit;
  648. end;
  649. If Len>1 Then
  650. WriteBlanks(t,Len-1);
  651. If TextRec(t).BufPos+1>=TextRec(t).BufSize Then
  652. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  653. ch:=c;
  654. TextRec(t).Bufptr^[TextRec(t).BufPos]:=ch;
  655. Inc(TextRec(t).BufPos);
  656. End;
  657. {$endif HASWIDECHAR}
  658. {*****************************************************************************
  659. Read(Ln)
  660. *****************************************************************************}
  661. Function NextChar(var f:Text;var s:string):Boolean;
  662. begin
  663. if TextRec(f).BufPos<TextRec(f).BufEnd then
  664. begin
  665. if length(s)<high(s) then
  666. begin
  667. inc(s[0]);
  668. s[length(s)]:=TextRec(f).BufPtr^[TextRec(f).BufPos];
  669. end;
  670. Inc(TextRec(f).BufPos);
  671. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  672. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  673. NextChar:=true;
  674. end
  675. else
  676. NextChar:=false;
  677. end;
  678. Function IgnoreSpaces(var f:Text):Boolean;
  679. {
  680. Removes all leading spaces,tab,eols from the input buffer, returns true if
  681. the buffer is empty
  682. }
  683. var
  684. s : string;
  685. begin
  686. s:='';
  687. IgnoreSpaces:=false;
  688. while TextRec(f).Bufptr^[TextRec(f).BufPos] in [#9,#10,#13,' '] do
  689. if not NextChar(f,s) then
  690. exit;
  691. IgnoreSpaces:=true;
  692. end;
  693. procedure ReadNumeric(var f:Text;var s:string);
  694. {
  695. Read numeric input, if buffer is empty then return True
  696. }
  697. begin
  698. repeat
  699. if not NextChar(f,s) then
  700. exit;
  701. until (length(s)=high(s)) or (TextRec(f).BufPtr^[TextRec(f).BufPos] in [#9,#10,#13,' ']);
  702. end;
  703. Procedure fpc_Read_End(var f:Text);[Public,Alias:'FPC_READ_END']; iocheck; {$ifdef hascompilerproc} compilerproc; {$endif}
  704. begin
  705. if TextRec(f).FlushFunc<>nil then
  706. FileFunc(TextRec(f).FlushFunc)(TextRec(f));
  707. end;
  708. Procedure fpc_ReadLn_End(var f : Text);[Public,Alias:'FPC_READLN_END']; iocheck; {$ifdef hascompilerproc} compilerproc; {$endif}
  709. var prev: char;
  710. Begin
  711. { Check error and if file is open and load buf if empty }
  712. If (InOutRes<>0) then
  713. exit;
  714. if (TextRec(f).mode<>fmInput) Then
  715. begin
  716. case TextRec(f).mode of
  717. fmOutPut,fmAppend:
  718. InOutRes:=104
  719. else
  720. InOutRes:=103;
  721. end;
  722. exit;
  723. end;
  724. if TextRec(f).BufPos>=TextRec(f).BufEnd Then
  725. begin
  726. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  727. if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
  728. { Flush if set }
  729. begin
  730. if (TextRec(f).FlushFunc<>nil) then
  731. FileFunc(TextRec(f).FlushFunc)(TextRec(f));
  732. exit;
  733. end;
  734. end;
  735. repeat
  736. prev := TextRec(f).BufPtr^[TextRec(f).BufPos];
  737. inc(TextRec(f).BufPos);
  738. { no system uses #10#13 as line seperator (#10 = *nix, #13 = Mac, }
  739. { #13#10 = Dos), so if we've got #10, we can safely exit }
  740. if prev = #10 then
  741. exit;
  742. if TextRec(f).BufPos>=TextRec(f).BufEnd Then
  743. begin
  744. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  745. if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
  746. { Flush if set }
  747. begin
  748. if (TextRec(f).FlushFunc<>nil) then
  749. FileFunc(TextRec(f).FlushFunc)(TextRec(f));
  750. exit;
  751. end;
  752. end;
  753. if (prev=#13) then
  754. { is there also a #10 after it? }
  755. begin
  756. if (TextRec(f).BufPtr^[TextRec(f).BufPos]=#10) then
  757. { yes, skip that one as well }
  758. inc(TextRec(f).BufPos);
  759. exit;
  760. end;
  761. until false;
  762. End;
  763. Function ReadPCharLen(var f:Text;s:pchar;maxlen:longint):longint;
  764. var
  765. sPos,len : Longint;
  766. p,startp,maxp : pchar;
  767. Begin
  768. ReadPCharLen:=0;
  769. { Check error and if file is open }
  770. If (InOutRes<>0) then
  771. exit;
  772. if (TextRec(f).mode<>fmInput) Then
  773. begin
  774. case TextRec(f).mode of
  775. fmOutPut,fmAppend:
  776. InOutRes:=104
  777. else
  778. InOutRes:=103;
  779. end;
  780. exit;
  781. end;
  782. { Read maximal until Maxlen is reached }
  783. sPos:=0;
  784. repeat
  785. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  786. begin
  787. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  788. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  789. break;
  790. end;
  791. p:=@TextRec(f).Bufptr^[TextRec(f).BufPos];
  792. if SPos+TextRec(f).BufEnd-TextRec(f).BufPos>MaxLen then
  793. maxp:=@TextRec(f).BufPtr^[TextRec(f).BufPos+MaxLen-SPos]
  794. else
  795. maxp:=@TextRec(f).Bufptr^[TextRec(f).BufEnd];
  796. startp:=p;
  797. { search linefeed }
  798. while (p<maxp) and not(P^ in [#10,#13]) do
  799. inc(p);
  800. { calculate read bytes }
  801. len:=p-startp;
  802. inc(TextRec(f).BufPos,Len);
  803. Move(startp^,s[sPos],Len);
  804. inc(sPos,Len);
  805. { was it a LF or CR? then leave }
  806. if (spos=MaxLen) or
  807. ((p<maxp) and (p^ in [#10,#13])) then
  808. break;
  809. until false;
  810. ReadPCharLen:=spos;
  811. End;
  812. Procedure fpc_Read_Text_ShortStr(var f : Text;var s : String); iocheck; [Public,Alias:'FPC_READ_TEXT_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  813. Begin
  814. s[0]:=chr(ReadPCharLen(f,pchar(@s[1]),high(s)));
  815. End;
  816. Procedure fpc_Read_Text_PChar_As_Pointer(var f : Text;var s : PChar); iocheck; [Public,Alias:'FPC_READ_TEXT_PCHAR_AS_POINTER']; {$ifdef hascompilerproc} compilerproc; {$endif}
  817. Begin
  818. pchar(s+ReadPCharLen(f,s,$7fffffff))^:=#0;
  819. End;
  820. Procedure fpc_Read_Text_PChar_As_Array(var f : Text;var s : array of char); iocheck; [Public,Alias:'FPC_READ_TEXT_PCHAR_AS_ARRAY']; {$ifdef hascompilerproc} compilerproc; {$endif}
  821. var
  822. len: longint;
  823. Begin
  824. len := ReadPCharLen(f,pchar(@s),high(s)+1);
  825. if len <= high(s) then
  826. s[len] := #0;
  827. End;
  828. Procedure fpc_Read_Text_AnsiStr(var f : Text;var s : AnsiString); iocheck; [Public,Alias:'FPC_READ_TEXT_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  829. var
  830. slen,len : longint;
  831. Begin
  832. slen:=0;
  833. Repeat
  834. // SetLength will reallocate the length.
  835. SetLength(S,slen+255);
  836. len:=ReadPCharLen(f,pchar(Pointer(S)+slen),255);
  837. inc(slen,len);
  838. Until len<255;
  839. // Set actual length
  840. SetLength(S,Slen);
  841. End;
  842. {$ifdef hascompilerproc}
  843. procedure fpc_Read_Text_Char(var f : Text; var c: char); iocheck; [Public,Alias:'FPC_READ_TEXT_CHAR'];compilerproc;
  844. {$else hascompilerproc}
  845. Function fpc_Read_Text_Char(var f : Text):char;[Public,Alias:'FPC_READ_TEXT_CHAR'];
  846. {$endif hascompilerproc}
  847. Begin
  848. {$ifdef hascompilerproc}
  849. c:=#0;
  850. {$else hascompilerproc}
  851. fpc_Read_Text_Char:=#0;
  852. {$endif hascompilerproc}
  853. { Check error and if file is open }
  854. If (InOutRes<>0) then
  855. exit;
  856. if (TextRec(f).mode<>fmInput) Then
  857. begin
  858. case TextRec(f).mode of
  859. fmOutPut,fmAppend:
  860. InOutRes:=104
  861. else
  862. InOutRes:=103;
  863. end;
  864. exit;
  865. end;
  866. { Read next char or EOF }
  867. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  868. begin
  869. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  870. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  871. {$ifdef hascompilerproc}
  872. begin
  873. c := #26;
  874. exit;
  875. end;
  876. {$else hascompilerproc}
  877. exit(#26);
  878. {$endif hascompilerproc}
  879. end;
  880. {$ifdef hascompilerproc}
  881. c:=TextRec(f).Bufptr^[TextRec(f).BufPos];
  882. {$else hascompilerproc}
  883. fpc_Read_Text_Char:=TextRec(f).Bufptr^[TextRec(f).BufPos];
  884. {$endif hascompilerproc}
  885. inc(TextRec(f).BufPos);
  886. end;
  887. {$ifdef hascompilerproc}
  888. Procedure fpc_Read_Text_SInt(var f : Text; var l : ValSInt); iocheck; [Public,Alias:'FPC_READ_TEXT_SINT']; compilerproc;
  889. {$else hascompilerproc}
  890. Function fpc_Read_Text_SInt(var f : Text):ValSInt;[Public,Alias:'FPC_READ_TEXT_SINT'];
  891. {$endif hascompilerproc}
  892. var
  893. hs : String;
  894. code : Longint;
  895. Begin
  896. {$ifdef hascompilerproc}
  897. l:=0;
  898. {$else hascompilerproc}
  899. fpc_Read_Text_SInt:=0;
  900. {$endif hascompilerproc}
  901. { Leave if error or not open file, else check for empty buf }
  902. If (InOutRes<>0) then
  903. exit;
  904. if (TextRec(f).mode<>fmInput) Then
  905. begin
  906. case TextRec(f).mode of
  907. fmOutPut,fmAppend:
  908. InOutRes:=104
  909. else
  910. InOutRes:=103;
  911. end;
  912. exit;
  913. end;
  914. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  915. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  916. hs:='';
  917. if IgnoreSpaces(f) then
  918. ReadNumeric(f,hs);
  919. {$ifdef hascompilerproc}
  920. Val(hs,l,code);
  921. {$else hascompilerproc}
  922. Val(hs,fpc_Read_Text_SInt,code);
  923. {$endif hascompilerproc}
  924. If code<>0 Then
  925. InOutRes:=106;
  926. End;
  927. {$ifdef hascompilerproc}
  928. Procedure fpc_Read_Text_UInt(var f : Text; var u : ValUInt); iocheck; [Public,Alias:'FPC_READ_TEXT_UINT']; compilerproc;
  929. {$else hascompilerproc}
  930. Function fpc_Read_Text_UInt(var f : Text):ValUInt;[Public,Alias:'FPC_READ_TEXT_UINT'];
  931. {$endif hascompilerproc}
  932. var
  933. hs : String;
  934. code : longint;
  935. Begin
  936. {$ifdef hascompilerproc}
  937. u:=0;
  938. {$else hascompilerproc}
  939. fpc_Read_Text_UInt:=0;
  940. {$endif hascompilerproc}
  941. { Leave if error or not open file, else check for empty buf }
  942. If (InOutRes<>0) then
  943. exit;
  944. if (TextRec(f).mode<>fmInput) Then
  945. begin
  946. case TextRec(f).mode of
  947. fmOutPut,fmAppend:
  948. InOutRes:=104
  949. else
  950. InOutRes:=103;
  951. end;
  952. exit;
  953. end;
  954. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  955. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  956. hs:='';
  957. if IgnoreSpaces(f) then
  958. ReadNumeric(f,hs);
  959. {$ifdef hascompilerproc}
  960. val(hs,u,code);
  961. {$else hascompilerproc}
  962. val(hs,fpc_Read_Text_UInt,code);
  963. {$endif hascompilerproc}
  964. If code<>0 Then
  965. InOutRes:=106;
  966. End;
  967. {$ifdef hascompilerproc}
  968. procedure fpc_Read_Text_Float(var f : Text; var v : ValReal); iocheck; [Public,Alias:'FPC_READ_TEXT_FLOAT']; compilerproc;
  969. {$else hascompilerproc}
  970. Function fpc_Read_Text_Float(var f : Text):ValReal;[Public,Alias:'FPC_READ_TEXT_FLOAT'];
  971. {$endif hascompilerproc}
  972. var
  973. hs : string;
  974. code : Word;
  975. begin
  976. {$ifdef hascompilerproc}
  977. v:=0.0;
  978. {$else hascompilerproc}
  979. fpc_Read_Text_Float:=0.0;
  980. {$endif hascompilerproc}
  981. { Leave if error or not open file, else check for empty buf }
  982. If (InOutRes<>0) then
  983. exit;
  984. if (TextRec(f).mode<>fmInput) Then
  985. begin
  986. case TextRec(f).mode of
  987. fmOutPut,fmAppend:
  988. InOutRes:=104
  989. else
  990. InOutRes:=103;
  991. end;
  992. exit;
  993. end;
  994. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  995. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  996. hs:='';
  997. if IgnoreSpaces(f) then
  998. ReadNumeric(f,hs);
  999. {$ifdef hascompilerproc}
  1000. val(hs,v,code);
  1001. {$else hascompilerproc}
  1002. val(hs,fpc_Read_Text_Float,code);
  1003. {$endif hascompilerproc}
  1004. If code<>0 Then
  1005. InOutRes:=106;
  1006. end;
  1007. {$ifdef hascompilerproc}
  1008. procedure fpc_Read_Text_QWord(var f : text; var q : qword); iocheck; [public,alias:'FPC_READ_TEXT_QWORD']; compilerproc;
  1009. {$else hascompilerproc}
  1010. function fpc_Read_Text_QWord(var f : text) : qword;[public,alias:'FPC_READ_TEXT_QWORD'];
  1011. {$endif hascompilerproc}
  1012. var
  1013. hs : String;
  1014. code : longint;
  1015. Begin
  1016. {$ifdef hascompilerproc}
  1017. q:=0;
  1018. {$else hascompilerproc}
  1019. fpc_Read_Text_QWord:=0;
  1020. {$endif hascompilerproc}
  1021. { Leave if error or not open file, else check for empty buf }
  1022. If (InOutRes<>0) then
  1023. exit;
  1024. if (TextRec(f).mode<>fmInput) Then
  1025. begin
  1026. case TextRec(f).mode of
  1027. fmOutPut,fmAppend:
  1028. InOutRes:=104
  1029. else
  1030. InOutRes:=103;
  1031. end;
  1032. exit;
  1033. end;
  1034. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  1035. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  1036. hs:='';
  1037. if IgnoreSpaces(f) then
  1038. ReadNumeric(f,hs);
  1039. {$ifdef hascompilerproc}
  1040. val(hs,q,code);
  1041. {$else hascompilerproc}
  1042. val(hs,fpc_Read_Text_QWord,code);
  1043. {$endif hascompilerproc}
  1044. If code<>0 Then
  1045. InOutRes:=106;
  1046. End;
  1047. {$ifdef hascompilerproc}
  1048. procedure fpc_Read_Text_Int64(var f : text; var i : int64); iocheck; [public,alias:'FPC_READ_TEXT_INT64']; compilerproc;
  1049. {$else hascompilerproc}
  1050. function fpc_Read_Text_Int64(var f : text) : int64;[public,alias:'FPC_READ_TEXT_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
  1051. {$endif hascompilerproc}
  1052. var
  1053. hs : String;
  1054. code : Longint;
  1055. Begin
  1056. {$ifdef hascompilerproc}
  1057. i:=0;
  1058. {$else hascompilerproc}
  1059. fpc_Read_Text_Int64:=0;
  1060. {$endif hascompilerproc}
  1061. { Leave if error or not open file, else check for empty buf }
  1062. If (InOutRes<>0) then
  1063. exit;
  1064. if (TextRec(f).mode<>fmInput) Then
  1065. begin
  1066. case TextRec(f).mode of
  1067. fmOutPut,fmAppend:
  1068. InOutRes:=104
  1069. else
  1070. InOutRes:=103;
  1071. end;
  1072. exit;
  1073. end;
  1074. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  1075. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  1076. hs:='';
  1077. if IgnoreSpaces(f) then
  1078. ReadNumeric(f,hs);
  1079. {$ifdef hascompilerproc}
  1080. Val(hs,i,code);
  1081. {$else hascompilerproc}
  1082. Val(hs,fpc_Read_Text_Int64,code);
  1083. {$endif hascompilerproc}
  1084. If code<>0 Then
  1085. InOutRes:=106;
  1086. End;
  1087. {*****************************************************************************
  1088. Initializing
  1089. *****************************************************************************}
  1090. procedure OpenStdIO(var f:text;mode,hdl:longint);
  1091. begin
  1092. Assign(f,'');
  1093. TextRec(f).Handle:=hdl;
  1094. TextRec(f).Mode:=mode;
  1095. TextRec(f).Closefunc:=@FileCloseFunc;
  1096. case mode of
  1097. fmInput :
  1098. TextRec(f).InOutFunc:=@FileReadFunc;
  1099. fmOutput :
  1100. begin
  1101. TextRec(f).InOutFunc:=@FileWriteFunc;
  1102. TextRec(f).FlushFunc:=@FileWriteFunc;
  1103. end;
  1104. else
  1105. HandleError(102);
  1106. end;
  1107. end;
  1108. {
  1109. $Log$
  1110. Revision 1.15 2001-09-25 16:34:59 jonas
  1111. * fixed seekeof() so that it doesn't move the current possition in the
  1112. file anymore (merged)
  1113. * seekeof() now only regards #26 as EOF marker if EOF_CTRLZ is defined
  1114. (just like eof()) (merged)
  1115. * very tiny optimization to read_array_as_pchar
  1116. Revision 1.14 2001/08/23 14:28:36 jonas
  1117. + tempcreate/ref/delete nodes (allows the use of temps in the
  1118. resulttype and first pass)
  1119. * made handling of read(ln)/write(ln) processor independent
  1120. * moved processor independent handling for str and reset/rewrite-typed
  1121. from firstpass to resulttype pass
  1122. * changed names of helpers in text.inc to be generic for use as
  1123. compilerprocs + added "iocheck" directive for most of them
  1124. * reading of ordinals is done by procedures instead of functions
  1125. because otherwise FPC_IOCHECK overwrote the result before it could
  1126. be stored elsewhere (range checking still works)
  1127. * compilerprocs can now be used in the system unit before they are
  1128. implemented
  1129. * added note to errore.msg that booleans can't be read using read/readln
  1130. Revision 1.13 2001/08/22 20:49:18 peter
  1131. * regenerated
  1132. Revision 1.12 2001/08/19 11:23:10 peter
  1133. * read_array fix merged
  1134. Revision 1.11 2001/07/21 15:53:28 jonas
  1135. * really fixed write_array this time :/ (merged)
  1136. Revision 1.10 2001/07/16 13:53:21 jonas
  1137. * correctly fixed potential buffer overrun in write_array
  1138. Revision 1.9 2001/07/08 21:00:18 peter
  1139. * various widestring updates, it works now mostly without charset
  1140. mapping supported
  1141. Revision 1.8 2001/06/27 21:37:38 peter
  1142. * v10 merges
  1143. Revision 1.7 2001/06/04 11:43:51 peter
  1144. * Formal const to var fixes
  1145. * Hexstr(int64) added
  1146. Revision 1.6 2001/04/08 13:21:30 jonas
  1147. * fixed potential buffer overflow in FPC_WRITE_TEXT_PCHAR_AS_ARRAY (merged)
  1148. Revision 1.5 2001/03/21 23:29:40 florian
  1149. + sLineBreak and misc. stuff for Kylix compatiblity
  1150. Revision 1.4 2000/11/23 13:14:02 jonas
  1151. * fix for web bug 1210 from Peter (merged)
  1152. Revision 1.3 2000/07/14 10:33:10 michael
  1153. + Conditionals fixed
  1154. Revision 1.2 2000/07/13 11:33:46 michael
  1155. + removed logs
  1156. }