text.inc 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  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 (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. if slen > 0 then
  532. WriteBuffer(f,PChar(S)^,SLen);
  533. end;
  534. fmInput: InOutRes:=105
  535. else InOutRes:=103;
  536. end;
  537. end;
  538. {$ifdef HASWIDESTRING}
  539. Procedure fpc_Write_Text_WideStr (Len : Longint; Var f : Text; S : WideString); iocheck; [Public,alias:'FPC_WRITE_TEXT_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  540. {
  541. Writes a WideString to the Text file T
  542. }
  543. var
  544. SLen : longint;
  545. begin
  546. If (pointer(S)=nil) or (InOutRes<>0) then
  547. exit;
  548. case TextRec(f).mode of
  549. fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
  550. begin
  551. SLen:=Length(s);
  552. If Len>SLen Then
  553. WriteBlanks(f,Len-SLen);
  554. WriteBuffer(f,PChar(AnsiString(S))^,SLen);
  555. end;
  556. fmInput: InOutRes:=105
  557. else InOutRes:=103;
  558. end;
  559. end;
  560. {$endif HASWIDESTRING}
  561. Procedure fpc_Write_Text_SInt(Len : Longint;var t : Text;l : ValSInt); iocheck; [Public,Alias:'FPC_WRITE_TEXT_SINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  562. var
  563. s : String;
  564. Begin
  565. If (InOutRes<>0) then
  566. exit;
  567. Str(l,s);
  568. Write_Str(Len,t,s);
  569. End;
  570. Procedure fpc_Write_Text_UInt(Len : Longint;var t : Text;l : ValUInt); iocheck; [Public,Alias:'FPC_WRITE_TEXT_UINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  571. var
  572. s : String;
  573. Begin
  574. If (InOutRes<>0) then
  575. exit;
  576. Str(L,s);
  577. Write_Str(Len,t,s);
  578. End;
  579. procedure fpc_write_text_qword(len : longint;var t : text;q : qword); iocheck; [public,alias:'FPC_WRITE_TEXT_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  580. var
  581. s : string;
  582. begin
  583. if (InOutRes<>0) then
  584. exit;
  585. qword_str(q,s);
  586. write_str(len,t,s);
  587. end;
  588. procedure fpc_write_text_int64(len : longint;var t : text;i : int64); iocheck; [public,alias:'FPC_WRITE_TEXT_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
  589. var
  590. s : string;
  591. begin
  592. if (InOutRes<>0) then
  593. exit;
  594. int64_str(i,s);
  595. write_str(len,t,s);
  596. end;
  597. 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}
  598. var
  599. s : String;
  600. Begin
  601. If (InOutRes<>0) then
  602. exit;
  603. Str_real(Len,fixkomma,r,treal_type(rt),s);
  604. Write_Str(Len,t,s);
  605. End;
  606. Procedure fpc_Write_Text_Boolean(Len : Longint;var t : Text;b : Boolean); iocheck; [Public,Alias:'FPC_WRITE_TEXT_BOOLEAN']; {$ifdef hascompilerproc} compilerproc; {$endif}
  607. Begin
  608. If (InOutRes<>0) then
  609. exit;
  610. { Can't use array[boolean] because b can be >0 ! }
  611. if b then
  612. Write_Str(Len,t,'TRUE')
  613. else
  614. Write_Str(Len,t,'FALSE');
  615. End;
  616. Procedure fpc_Write_Text_Char(Len : Longint;var t : Text;c : Char); iocheck; [Public,Alias:'FPC_WRITE_TEXT_CHAR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  617. Begin
  618. If (InOutRes<>0) then
  619. exit;
  620. if (TextRec(t).mode<>fmOutput) Then
  621. begin
  622. if TextRec(t).mode=fmClosed then
  623. InOutRes:=103
  624. else
  625. InOutRes:=105;
  626. exit;
  627. end;
  628. If Len>1 Then
  629. WriteBlanks(t,Len-1);
  630. If TextRec(t).BufPos+1>=TextRec(t).BufSize Then
  631. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  632. TextRec(t).Bufptr^[TextRec(t).BufPos]:=c;
  633. Inc(TextRec(t).BufPos);
  634. End;
  635. {$ifdef HASWIDECHAR}
  636. Procedure fpc_Write_Text_WideChar(Len : Longint;var t : Text;c : WideChar); iocheck; [Public,Alias:'FPC_WRITE_TEXT_WIDECHAR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  637. var
  638. ch : char;
  639. Begin
  640. If (InOutRes<>0) then
  641. exit;
  642. if (TextRec(t).mode<>fmOutput) Then
  643. begin
  644. if TextRec(t).mode=fmClosed then
  645. InOutRes:=103
  646. else
  647. InOutRes:=105;
  648. exit;
  649. end;
  650. If Len>1 Then
  651. WriteBlanks(t,Len-1);
  652. If TextRec(t).BufPos+1>=TextRec(t).BufSize Then
  653. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  654. ch:=c;
  655. TextRec(t).Bufptr^[TextRec(t).BufPos]:=ch;
  656. Inc(TextRec(t).BufPos);
  657. End;
  658. {$endif HASWIDECHAR}
  659. {*****************************************************************************
  660. Read(Ln)
  661. *****************************************************************************}
  662. Function NextChar(var f:Text;var s:string):Boolean;
  663. begin
  664. if TextRec(f).BufPos<TextRec(f).BufEnd then
  665. begin
  666. if length(s)<high(s) then
  667. begin
  668. inc(s[0]);
  669. s[length(s)]:=TextRec(f).BufPtr^[TextRec(f).BufPos];
  670. end;
  671. Inc(TextRec(f).BufPos);
  672. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  673. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  674. NextChar:=true;
  675. end
  676. else
  677. NextChar:=false;
  678. end;
  679. Function IgnoreSpaces(var f:Text):Boolean;
  680. {
  681. Removes all leading spaces,tab,eols from the input buffer, returns true if
  682. the buffer is empty
  683. }
  684. var
  685. s : string;
  686. begin
  687. s:='';
  688. IgnoreSpaces:=false;
  689. while TextRec(f).Bufptr^[TextRec(f).BufPos] in [#9,#10,#13,' '] do
  690. if not NextChar(f,s) then
  691. exit;
  692. IgnoreSpaces:=true;
  693. end;
  694. procedure ReadNumeric(var f:Text;var s:string);
  695. {
  696. Read numeric input, if buffer is empty then return True
  697. }
  698. begin
  699. repeat
  700. if not NextChar(f,s) then
  701. exit;
  702. until (length(s)=high(s)) or (TextRec(f).BufPtr^[TextRec(f).BufPos] in [#9,#10,#13,' ']);
  703. end;
  704. Procedure fpc_Read_End(var f:Text);[Public,Alias:'FPC_READ_END']; iocheck; {$ifdef hascompilerproc} compilerproc; {$endif}
  705. begin
  706. if TextRec(f).FlushFunc<>nil then
  707. FileFunc(TextRec(f).FlushFunc)(TextRec(f));
  708. end;
  709. Procedure fpc_ReadLn_End(var f : Text);[Public,Alias:'FPC_READLN_END']; iocheck; {$ifdef hascompilerproc} compilerproc; {$endif}
  710. var prev: char;
  711. Begin
  712. { Check error and if file is open and load buf if empty }
  713. If (InOutRes<>0) then
  714. exit;
  715. if (TextRec(f).mode<>fmInput) Then
  716. begin
  717. case TextRec(f).mode of
  718. fmOutPut,fmAppend:
  719. InOutRes:=104
  720. else
  721. InOutRes:=103;
  722. end;
  723. exit;
  724. end;
  725. if TextRec(f).BufPos>=TextRec(f).BufEnd Then
  726. begin
  727. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  728. if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
  729. { Flush if set }
  730. begin
  731. if (TextRec(f).FlushFunc<>nil) then
  732. FileFunc(TextRec(f).FlushFunc)(TextRec(f));
  733. exit;
  734. end;
  735. end;
  736. repeat
  737. prev := TextRec(f).BufPtr^[TextRec(f).BufPos];
  738. inc(TextRec(f).BufPos);
  739. { no system uses #10#13 as line seperator (#10 = *nix, #13 = Mac, }
  740. { #13#10 = Dos), so if we've got #10, we can safely exit }
  741. if prev = #10 then
  742. exit;
  743. if TextRec(f).BufPos>=TextRec(f).BufEnd Then
  744. begin
  745. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  746. if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
  747. { Flush if set }
  748. begin
  749. if (TextRec(f).FlushFunc<>nil) then
  750. FileFunc(TextRec(f).FlushFunc)(TextRec(f));
  751. exit;
  752. end;
  753. end;
  754. if (prev=#13) then
  755. { is there also a #10 after it? }
  756. begin
  757. if (TextRec(f).BufPtr^[TextRec(f).BufPos]=#10) then
  758. { yes, skip that one as well }
  759. inc(TextRec(f).BufPos);
  760. exit;
  761. end;
  762. until false;
  763. End;
  764. Function ReadPCharLen(var f:Text;s:pchar;maxlen:longint):longint;
  765. var
  766. sPos,len : Longint;
  767. p,startp,maxp : pchar;
  768. Begin
  769. ReadPCharLen:=0;
  770. { Check error and if file is open }
  771. If (InOutRes<>0) then
  772. exit;
  773. if (TextRec(f).mode<>fmInput) Then
  774. begin
  775. case TextRec(f).mode of
  776. fmOutPut,fmAppend:
  777. InOutRes:=104
  778. else
  779. InOutRes:=103;
  780. end;
  781. exit;
  782. end;
  783. { Read maximal until Maxlen is reached }
  784. sPos:=0;
  785. repeat
  786. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  787. begin
  788. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  789. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  790. break;
  791. end;
  792. p:=@TextRec(f).Bufptr^[TextRec(f).BufPos];
  793. if SPos+TextRec(f).BufEnd-TextRec(f).BufPos>MaxLen then
  794. maxp:=@TextRec(f).BufPtr^[TextRec(f).BufPos+MaxLen-SPos]
  795. else
  796. maxp:=@TextRec(f).Bufptr^[TextRec(f).BufEnd];
  797. startp:=p;
  798. { search linefeed }
  799. while (p<maxp) and not(P^ in [#10,#13]) do
  800. inc(p);
  801. { calculate read bytes }
  802. len:=p-startp;
  803. inc(TextRec(f).BufPos,Len);
  804. Move(startp^,s[sPos],Len);
  805. inc(sPos,Len);
  806. { was it a LF or CR? then leave }
  807. if (spos=MaxLen) or
  808. ((p<maxp) and (p^ in [#10,#13])) then
  809. break;
  810. until false;
  811. ReadPCharLen:=spos;
  812. End;
  813. Procedure fpc_Read_Text_ShortStr(var f : Text;var s : String); iocheck; [Public,Alias:'FPC_READ_TEXT_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  814. Begin
  815. s[0]:=chr(ReadPCharLen(f,pchar(@s[1]),high(s)));
  816. End;
  817. 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}
  818. Begin
  819. pchar(s+ReadPCharLen(f,s,$7fffffff))^:=#0;
  820. End;
  821. 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}
  822. var
  823. len: longint;
  824. Begin
  825. len := ReadPCharLen(f,pchar(@s),high(s)+1);
  826. if len <= high(s) then
  827. s[len] := #0;
  828. End;
  829. Procedure fpc_Read_Text_AnsiStr(var f : Text;var s : AnsiString); iocheck; [Public,Alias:'FPC_READ_TEXT_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  830. var
  831. slen,len : longint;
  832. Begin
  833. slen:=0;
  834. Repeat
  835. // SetLength will reallocate the length.
  836. SetLength(S,slen+255);
  837. len:=ReadPCharLen(f,pchar(Pointer(S)+slen),255);
  838. inc(slen,len);
  839. Until len<255;
  840. // Set actual length
  841. SetLength(S,Slen);
  842. End;
  843. {$ifdef hascompilerproc}
  844. procedure fpc_Read_Text_Char(var f : Text; var c: char); iocheck; [Public,Alias:'FPC_READ_TEXT_CHAR'];compilerproc;
  845. {$else hascompilerproc}
  846. Function fpc_Read_Text_Char(var f : Text):char;[Public,Alias:'FPC_READ_TEXT_CHAR'];
  847. {$endif hascompilerproc}
  848. Begin
  849. {$ifdef hascompilerproc}
  850. c:=#0;
  851. {$else hascompilerproc}
  852. fpc_Read_Text_Char:=#0;
  853. {$endif hascompilerproc}
  854. { Check error and if file is open }
  855. If (InOutRes<>0) then
  856. exit;
  857. if (TextRec(f).mode<>fmInput) Then
  858. begin
  859. case TextRec(f).mode of
  860. fmOutPut,fmAppend:
  861. InOutRes:=104
  862. else
  863. InOutRes:=103;
  864. end;
  865. exit;
  866. end;
  867. { Read next char or EOF }
  868. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  869. begin
  870. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  871. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  872. {$ifdef hascompilerproc}
  873. begin
  874. c := #26;
  875. exit;
  876. end;
  877. {$else hascompilerproc}
  878. exit(#26);
  879. {$endif hascompilerproc}
  880. end;
  881. {$ifdef hascompilerproc}
  882. c:=TextRec(f).Bufptr^[TextRec(f).BufPos];
  883. {$else hascompilerproc}
  884. fpc_Read_Text_Char:=TextRec(f).Bufptr^[TextRec(f).BufPos];
  885. {$endif hascompilerproc}
  886. inc(TextRec(f).BufPos);
  887. end;
  888. {$ifdef hascompilerproc}
  889. Procedure fpc_Read_Text_SInt(var f : Text; var l : ValSInt); iocheck; [Public,Alias:'FPC_READ_TEXT_SINT']; compilerproc;
  890. {$else hascompilerproc}
  891. Function fpc_Read_Text_SInt(var f : Text):ValSInt;[Public,Alias:'FPC_READ_TEXT_SINT'];
  892. {$endif hascompilerproc}
  893. var
  894. hs : String;
  895. code : Longint;
  896. Begin
  897. {$ifdef hascompilerproc}
  898. l:=0;
  899. {$else hascompilerproc}
  900. fpc_Read_Text_SInt:=0;
  901. {$endif hascompilerproc}
  902. { Leave if error or not open file, else check for empty buf }
  903. If (InOutRes<>0) then
  904. exit;
  905. if (TextRec(f).mode<>fmInput) Then
  906. begin
  907. case TextRec(f).mode of
  908. fmOutPut,fmAppend:
  909. InOutRes:=104
  910. else
  911. InOutRes:=103;
  912. end;
  913. exit;
  914. end;
  915. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  916. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  917. hs:='';
  918. if IgnoreSpaces(f) then
  919. ReadNumeric(f,hs);
  920. {$ifdef hascompilerproc}
  921. Val(hs,l,code);
  922. {$else hascompilerproc}
  923. Val(hs,fpc_Read_Text_SInt,code);
  924. {$endif hascompilerproc}
  925. If code<>0 Then
  926. InOutRes:=106;
  927. End;
  928. {$ifdef hascompilerproc}
  929. Procedure fpc_Read_Text_UInt(var f : Text; var u : ValUInt); iocheck; [Public,Alias:'FPC_READ_TEXT_UINT']; compilerproc;
  930. {$else hascompilerproc}
  931. Function fpc_Read_Text_UInt(var f : Text):ValUInt;[Public,Alias:'FPC_READ_TEXT_UINT'];
  932. {$endif hascompilerproc}
  933. var
  934. hs : String;
  935. code : longint;
  936. Begin
  937. {$ifdef hascompilerproc}
  938. u:=0;
  939. {$else hascompilerproc}
  940. fpc_Read_Text_UInt:=0;
  941. {$endif hascompilerproc}
  942. { Leave if error or not open file, else check for empty buf }
  943. If (InOutRes<>0) then
  944. exit;
  945. if (TextRec(f).mode<>fmInput) Then
  946. begin
  947. case TextRec(f).mode of
  948. fmOutPut,fmAppend:
  949. InOutRes:=104
  950. else
  951. InOutRes:=103;
  952. end;
  953. exit;
  954. end;
  955. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  956. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  957. hs:='';
  958. if IgnoreSpaces(f) then
  959. ReadNumeric(f,hs);
  960. {$ifdef hascompilerproc}
  961. val(hs,u,code);
  962. {$else hascompilerproc}
  963. val(hs,fpc_Read_Text_UInt,code);
  964. {$endif hascompilerproc}
  965. If code<>0 Then
  966. InOutRes:=106;
  967. End;
  968. {$ifdef hascompilerproc}
  969. procedure fpc_Read_Text_Float(var f : Text; var v : ValReal); iocheck; [Public,Alias:'FPC_READ_TEXT_FLOAT']; compilerproc;
  970. {$else hascompilerproc}
  971. Function fpc_Read_Text_Float(var f : Text):ValReal;[Public,Alias:'FPC_READ_TEXT_FLOAT'];
  972. {$endif hascompilerproc}
  973. var
  974. hs : string;
  975. code : Word;
  976. begin
  977. {$ifdef hascompilerproc}
  978. v:=0.0;
  979. {$else hascompilerproc}
  980. fpc_Read_Text_Float:=0.0;
  981. {$endif hascompilerproc}
  982. { Leave if error or not open file, else check for empty buf }
  983. If (InOutRes<>0) then
  984. exit;
  985. if (TextRec(f).mode<>fmInput) Then
  986. begin
  987. case TextRec(f).mode of
  988. fmOutPut,fmAppend:
  989. InOutRes:=104
  990. else
  991. InOutRes:=103;
  992. end;
  993. exit;
  994. end;
  995. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  996. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  997. hs:='';
  998. if IgnoreSpaces(f) then
  999. ReadNumeric(f,hs);
  1000. {$ifdef hascompilerproc}
  1001. val(hs,v,code);
  1002. {$else hascompilerproc}
  1003. val(hs,fpc_Read_Text_Float,code);
  1004. {$endif hascompilerproc}
  1005. If code<>0 Then
  1006. InOutRes:=106;
  1007. end;
  1008. {$ifdef hascompilerproc}
  1009. procedure fpc_Read_Text_QWord(var f : text; var q : qword); iocheck; [public,alias:'FPC_READ_TEXT_QWORD']; compilerproc;
  1010. {$else hascompilerproc}
  1011. function fpc_Read_Text_QWord(var f : text) : qword;[public,alias:'FPC_READ_TEXT_QWORD'];
  1012. {$endif hascompilerproc}
  1013. var
  1014. hs : String;
  1015. code : longint;
  1016. Begin
  1017. {$ifdef hascompilerproc}
  1018. q:=0;
  1019. {$else hascompilerproc}
  1020. fpc_Read_Text_QWord:=0;
  1021. {$endif hascompilerproc}
  1022. { Leave if error or not open file, else check for empty buf }
  1023. If (InOutRes<>0) then
  1024. exit;
  1025. if (TextRec(f).mode<>fmInput) Then
  1026. begin
  1027. case TextRec(f).mode of
  1028. fmOutPut,fmAppend:
  1029. InOutRes:=104
  1030. else
  1031. InOutRes:=103;
  1032. end;
  1033. exit;
  1034. end;
  1035. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  1036. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  1037. hs:='';
  1038. if IgnoreSpaces(f) then
  1039. ReadNumeric(f,hs);
  1040. {$ifdef hascompilerproc}
  1041. val(hs,q,code);
  1042. {$else hascompilerproc}
  1043. val(hs,fpc_Read_Text_QWord,code);
  1044. {$endif hascompilerproc}
  1045. If code<>0 Then
  1046. InOutRes:=106;
  1047. End;
  1048. {$ifdef hascompilerproc}
  1049. procedure fpc_Read_Text_Int64(var f : text; var i : int64); iocheck; [public,alias:'FPC_READ_TEXT_INT64']; compilerproc;
  1050. {$else hascompilerproc}
  1051. function fpc_Read_Text_Int64(var f : text) : int64;[public,alias:'FPC_READ_TEXT_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
  1052. {$endif hascompilerproc}
  1053. var
  1054. hs : String;
  1055. code : Longint;
  1056. Begin
  1057. {$ifdef hascompilerproc}
  1058. i:=0;
  1059. {$else hascompilerproc}
  1060. fpc_Read_Text_Int64:=0;
  1061. {$endif hascompilerproc}
  1062. { Leave if error or not open file, else check for empty buf }
  1063. If (InOutRes<>0) then
  1064. exit;
  1065. if (TextRec(f).mode<>fmInput) Then
  1066. begin
  1067. case TextRec(f).mode of
  1068. fmOutPut,fmAppend:
  1069. InOutRes:=104
  1070. else
  1071. InOutRes:=103;
  1072. end;
  1073. exit;
  1074. end;
  1075. If TextRec(f).BufPos>=TextRec(f).BufEnd Then
  1076. FileFunc(TextRec(f).InOutFunc)(TextRec(f));
  1077. hs:='';
  1078. if IgnoreSpaces(f) then
  1079. ReadNumeric(f,hs);
  1080. {$ifdef hascompilerproc}
  1081. Val(hs,i,code);
  1082. {$else hascompilerproc}
  1083. Val(hs,fpc_Read_Text_Int64,code);
  1084. {$endif hascompilerproc}
  1085. If code<>0 Then
  1086. InOutRes:=106;
  1087. End;
  1088. {*****************************************************************************
  1089. Initializing
  1090. *****************************************************************************}
  1091. procedure OpenStdIO(var f:text;mode,hdl:longint);
  1092. begin
  1093. Assign(f,'');
  1094. TextRec(f).Handle:=hdl;
  1095. TextRec(f).Mode:=mode;
  1096. TextRec(f).Closefunc:=@FileCloseFunc;
  1097. case mode of
  1098. fmInput :
  1099. TextRec(f).InOutFunc:=@FileReadFunc;
  1100. fmOutput :
  1101. begin
  1102. TextRec(f).InOutFunc:=@FileWriteFunc;
  1103. TextRec(f).FlushFunc:=@FileWriteFunc;
  1104. end;
  1105. else
  1106. HandleError(102);
  1107. end;
  1108. end;
  1109. {
  1110. $Log$
  1111. Revision 1.16 2001-11-21 14:51:33 jonas
  1112. * fixed writing of empty ansistring with specified width (merged)
  1113. Revision 1.15 2001/09/25 16:34:59 jonas
  1114. * fixed seekeof() so that it doesn't move the current possition in the
  1115. file anymore (merged)
  1116. * seekeof() now only regards #26 as EOF marker if EOF_CTRLZ is defined
  1117. (just like eof()) (merged)
  1118. * very tiny optimization to read_array_as_pchar
  1119. Revision 1.14 2001/08/23 14:28:36 jonas
  1120. + tempcreate/ref/delete nodes (allows the use of temps in the
  1121. resulttype and first pass)
  1122. * made handling of read(ln)/write(ln) processor independent
  1123. * moved processor independent handling for str and reset/rewrite-typed
  1124. from firstpass to resulttype pass
  1125. * changed names of helpers in text.inc to be generic for use as
  1126. compilerprocs + added "iocheck" directive for most of them
  1127. * reading of ordinals is done by procedures instead of functions
  1128. because otherwise FPC_IOCHECK overwrote the result before it could
  1129. be stored elsewhere (range checking still works)
  1130. * compilerprocs can now be used in the system unit before they are
  1131. implemented
  1132. * added note to errore.msg that booleans can't be read using read/readln
  1133. Revision 1.13 2001/08/22 20:49:18 peter
  1134. * regenerated
  1135. Revision 1.12 2001/08/19 11:23:10 peter
  1136. * read_array fix merged
  1137. Revision 1.11 2001/07/21 15:53:28 jonas
  1138. * really fixed write_array this time :/ (merged)
  1139. Revision 1.10 2001/07/16 13:53:21 jonas
  1140. * correctly fixed potential buffer overrun in write_array
  1141. Revision 1.9 2001/07/08 21:00:18 peter
  1142. * various widestring updates, it works now mostly without charset
  1143. mapping supported
  1144. Revision 1.8 2001/06/27 21:37:38 peter
  1145. * v10 merges
  1146. Revision 1.7 2001/06/04 11:43:51 peter
  1147. * Formal const to var fixes
  1148. * Hexstr(int64) added
  1149. Revision 1.6 2001/04/08 13:21:30 jonas
  1150. * fixed potential buffer overflow in FPC_WRITE_TEXT_PCHAR_AS_ARRAY (merged)
  1151. Revision 1.5 2001/03/21 23:29:40 florian
  1152. + sLineBreak and misc. stuff for Kylix compatiblity
  1153. Revision 1.4 2000/11/23 13:14:02 jonas
  1154. * fix for web bug 1210 from Peter (merged)
  1155. Revision 1.3 2000/07/14 10:33:10 michael
  1156. + Conditionals fixed
  1157. Revision 1.2 2000/07/13 11:33:46 michael
  1158. + removed logs
  1159. }