text.inc 32 KB

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