293
{ try to save the current position in the file, seekeof() should not move }
294
{ the current file position (JM) }
295
oldbufpos := TextRec(t).BufPos;
296
oldbufend := TextRec(t).BufEnd;
299
isdevice := Do_IsDevice(TextRec(t).handle);
288
301
If TextRec(t).BufPos>=TextRec(t).BufEnd Then
303
{ signal that the we will have to do a seek }
308
oldfilepos := Do_FilePos(TextRec(t).handle) - TextRec(t).BufEnd;
290
311
FileFunc(TextRec(t).InOutFunc)(TextRec(t));
291
312
If TextRec(t).BufPos>=TextRec(t).BufEnd Then
314
{ if we only did a read in which we didn't read anything, the }
315
{ old buffer is still valid and we can simply restore the }
294
322
case TextRec(t).Bufptr^[TextRec(t).BufPos] of
301
inc(TextRec(t).BufPos);
338
inc(TextRec(t).BufPos);
340
{ restore file position if not working with a device }
342
{ if we didn't modify the buffer, simply restore the BufPos and BufEnd }
343
{ (the latter becuase it's now probably set to zero because nothing was }
344
{ was read anymore) }
347
TextRec(t).BufPos:=oldbufpos;
348
TextRec(t).BufEnd:=oldbufend;
350
{ otherwise return to the old filepos and reset the buffer }
353
do_seek(TextRec(t).handle,oldfilepos);
355
FileFunc(TextRec(t).InOutFunc)(TextRec(t));
356
TextRec(t).BufPos:=oldbufpos;
401
left:=f.BufSize-f.BufPos;
456
left:=TextRec(f).BufSize-TextRec(f).BufPos;
402
457
while len>left do
404
move(p[idx],f.Bufptr^[f.BufPos],left);
459
move(p[idx],TextRec(f).Bufptr^[TextRec(f).BufPos],left);
408
FileFunc(f.InOutFunc)(f);
409
left:=f.BufSize-f.BufPos;
462
inc(TextRec(f).BufPos,left);
463
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
464
left:=TextRec(f).BufSize-TextRec(f).BufPos;
411
move(p[idx],f.Bufptr^[f.BufPos],len);
466
move(p[idx],TextRec(f).Bufptr^[TextRec(f).BufPos],len);
467
inc(TextRec(f).BufPos,len);
416
Procedure WriteBlanks(var f:TextRec;len:longint);
471
Procedure WriteBlanks(var f:Text;len:longint);
420
left:=f.BufSize-f.BufPos;
475
left:=TextRec(f).BufSize-TextRec(f).BufPos;
421
476
while len>left do
423
FillChar(f.Bufptr^[f.BufPos],left,' ');
478
FillChar(TextRec(f).Bufptr^[TextRec(f).BufPos],left,' ');
426
FileFunc(f.InOutFunc)(f);
427
left:=f.BufSize-f.BufPos;
480
inc(TextRec(f).BufPos,left);
481
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
482
left:=TextRec(f).BufSize-TextRec(f).BufPos;
429
FillChar(f.Bufptr^[f.BufPos],len,' ');
484
FillChar(TextRec(f).Bufptr^[TextRec(f).BufPos],len,' ');
485
inc(TextRec(f).BufPos,len);
434
Procedure Write_End(var f:TextRec);[Public,Alias:'FPC_WRITE_END'];
489
Procedure fpc_Write_End(var f:Text);[Public,Alias:'FPC_WRITE_END']; iocheck; {$ifdef hascompilerproc} compilerproc; {$endif}
436
if f.FlushFunc<>nil then
437
FileFunc(f.FlushFunc)(f);
491
if TextRec(f).FlushFunc<>nil then
492
FileFunc(TextRec(f).FlushFunc)(TextRec(f));
441
Procedure Writeln_End(var f:TextRec);[Public,Alias:'FPC_WRITELN_END'];
443
{$IFDEF SHORT_LINEBREAK}
445
eol : array[0..0] of char=(#10);
446
{$ELSE SHORT_LINEBREAK}
448
eol : array[0..1] of char=(#13,#10);
449
{$ENDIF SHORT_LINEBREAK}
496
Procedure fpc_Writeln_End(var f:Text);[Public,Alias:'FPC_WRITELN_END']; iocheck; {$ifdef hascompilerproc} compilerproc; {$endif}
498
eol : array[0..3] of char;
451
500
If InOutRes <> 0 then exit;
501
case TextRec(f).mode of
453
502
fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
456
WriteBuffer(f,eol,eollen);
506
WriteBuffer(f,eol,length(sLineBreak));
458
if f.FlushFunc<>nil then
459
FileFunc(f.FlushFunc)(f);
508
if TextRec(f).FlushFunc<>nil then
509
FileFunc(TextRec(f).FlushFunc)(TextRec(f));
461
511
fmInput: InOutRes:=105
462
512
else InOutRes:=103;
484
Procedure Write_Array(Len : Longint;var f : TextRec;const s : array of char);[Public,Alias:'FPC_WRITE_TEXT_PCHAR_AS_ARRAY'];
533
{ provide local access to write_str }
534
procedure Write_Str(Len : Longint;var f : Text;const s : String); iocheck; [external name 'FPC_WRITE_TEXT_SHORTSTR'];
537
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}
486
539
ArrayLen : longint;
489
542
If (InOutRes<>0) then
544
case TextRec(f).mode of
492
545
fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
496
if ArrayLen>sizeof(s) then
548
{ can't use StrLen, since that one could try to read past the end }
550
ArrayLen:=IndexByte(p^,high(s)+1,0);
551
{ IndexByte returns -1 if not found (JM) }
552
if ArrayLen = -1 then
553
ArrayLen := high(s)+1;
498
554
If Len>ArrayLen Then
499
555
WriteBlanks(f,Len-ArrayLen);
500
556
WriteBuffer(f,p^,ArrayLen);
528
Procedure Write_Text_AnsiString (Len : Longint; Var f : TextRec; S : AnsiString);[Public,alias:'FPC_WRITE_TEXT_ANSISTR'];
584
Procedure fpc_Write_Text_AnsiStr (Len : Longint; Var f : Text; S : AnsiString); iocheck; [Public,alias:'FPC_WRITE_TEXT_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
530
586
Writes a AnsiString to the Text file T
591
If (InOutRes<>0) then
593
case TextRec(f).mode of
594
fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
598
WriteBlanks(f,Len-SLen);
600
WriteBuffer(f,PChar(S)^,SLen);
602
fmInput: InOutRes:=105
608
{$ifdef HASWIDESTRING}
609
Procedure fpc_Write_Text_WideStr (Len : Longint; Var f : Text; S : WideString); iocheck; [Public,alias:'FPC_WRITE_TEXT_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
611
Writes a WideString to the Text file T
535
616
If (pointer(S)=nil) or (InOutRes<>0) then
618
case TextRec(f).mode of
538
619
fmOutput { fmAppend gets changed to fmOutPut in do_open (JM) }:
542
623
WriteBlanks(f,Len-SLen);
543
WriteBuffer(f,PChar(S)^,SLen);
624
WriteBuffer(f,PChar(AnsiString(S))^,SLen);
545
626
fmInput: InOutRes:=105
546
627
else InOutRes:=103;
551
Procedure Write_SInt(Len : Longint;var t : TextRec;l : ValSInt);[Public,Alias:'FPC_WRITE_TEXT_SINT'];
630
{$endif HASWIDESTRING}
632
Procedure fpc_Write_Text_SInt(Len : Longint;var t : Text;l : ValSInt); iocheck; [Public,Alias:'FPC_WRITE_TEXT_SINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
574
procedure write_qword(len : longint;var t : textrec;q : qword);[public,alias:'FPC_WRITE_TEXT_QWORD'];
578
if (InOutRes<>0) then
584
procedure write_int64(len : longint;var t : textrec;i : int64);[public,alias:'FPC_WRITE_TEXT_INT64'];
588
if (InOutRes<>0) then
596
Procedure Write_Float(rt,fixkomma,Len : Longint;var t : TextRec;r : ValReal);[Public,Alias:'FPC_WRITE_TEXT_FLOAT'];
656
procedure fpc_write_text_qword(len : longint;var t : text;q : qword); iocheck; [public,alias:'FPC_WRITE_TEXT_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
660
if (InOutRes<>0) then
666
procedure fpc_write_text_int64(len : longint;var t : text;i : int64); iocheck; [public,alias:'FPC_WRITE_TEXT_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
670
if (InOutRes<>0) then
678
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}
619
Procedure Write_Char(Len : Longint;var t : TextRec;c : Char);[Public,Alias:'FPC_WRITE_TEXT_CHAR'];
621
If (InOutRes<>0) then
623
if (TextRec(t).mode<>fmOutput) Then
625
if TextRec(t).mode=fmClosed then
632
WriteBlanks(t,Len-1);
633
If t.BufPos+1>=t.BufSize Then
634
FileFunc(t.InOutFunc)(t);
635
t.Bufptr^[t.BufPos]:=c;
701
Procedure fpc_Write_Text_Char(Len : Longint;var t : Text;c : Char); iocheck; [Public,Alias:'FPC_WRITE_TEXT_CHAR']; {$ifdef hascompilerproc} compilerproc; {$endif}
703
If (InOutRes<>0) then
705
if (TextRec(t).mode<>fmOutput) Then
707
if TextRec(t).mode=fmClosed then
714
WriteBlanks(t,Len-1);
715
If TextRec(t).BufPos+1>=TextRec(t).BufSize Then
716
FileFunc(TextRec(t).InOutFunc)(TextRec(t));
717
TextRec(t).Bufptr^[TextRec(t).BufPos]:=c;
718
Inc(TextRec(t).BufPos);
723
Procedure fpc_Write_Text_WideChar(Len : Longint;var t : Text;c : WideChar); iocheck; [Public,Alias:'FPC_WRITE_TEXT_WIDECHAR']; {$ifdef hascompilerproc} compilerproc; {$endif}
727
If (InOutRes<>0) then
729
if (TextRec(t).mode<>fmOutput) Then
731
if TextRec(t).mode=fmClosed then
738
WriteBlanks(t,Len-1);
739
If TextRec(t).BufPos+1>=TextRec(t).BufSize Then
740
FileFunc(TextRec(t).InOutFunc)(TextRec(t));
742
TextRec(t).Bufptr^[TextRec(t).BufPos]:=ch;
743
Inc(TextRec(t).BufPos);
640
748
{*****************************************************************************
642
750
*****************************************************************************}
644
Function NextChar(var f:TextRec;var s:string):Boolean;
752
Function NextChar(var f:Text;var s:string):Boolean;
646
if f.BufPos<f.BufEnd then
754
if TextRec(f).BufPos<TextRec(f).BufEnd then
648
756
if length(s)<high(s) then
651
s[length(s)]:=f.BufPtr^[f.BufPos];
759
s[length(s)]:=TextRec(f).BufPtr^[TextRec(f).BufPos];
654
If f.BufPos>=f.BufEnd Then
655
FileFunc(f.InOutFunc)(f);
761
Inc(TextRec(f).BufPos);
762
If TextRec(f).BufPos>=TextRec(f).BufEnd Then
763
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
672
780
IgnoreSpaces:=false;
673
while f.Bufptr^[f.BufPos] in [#9,#10,#13,' '] do
674
if not NextChar(f,s) then
781
{ Return false when already at EOF }
782
if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
784
while (TextRec(f).Bufptr^[TextRec(f).BufPos] in [#9,#10,#13,' ']) do
786
if not NextChar(f,s) then
789
if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
676
792
IgnoreSpaces:=true;
680
procedure ReadNumeric(var f:TextRec;var s:string);
796
procedure ReadNumeric(var f:Text;var s:string);
682
798
Read numeric input, if buffer is empty then return True
686
802
if not NextChar(f,s) then
688
until (length(s)=high(s)) or (f.BufPtr^[f.BufPos] in [#9,#10,#13,' ']);
804
until (length(s)=high(s)) or (TextRec(f).BufPtr^[TextRec(f).BufPos] in [#9,#10,#13,' ']);
692
Procedure Read_End(var f:TextRec);[Public,Alias:'FPC_READ_END'];
808
Procedure fpc_Read_End(var f:Text);[Public,Alias:'FPC_READ_END']; iocheck; {$ifdef hascompilerproc} compilerproc; {$endif}
694
if f.FlushFunc<>nil then
695
FileFunc(f.FlushFunc)(f);
810
if TextRec(f).FlushFunc<>nil then
811
FileFunc(TextRec(f).FlushFunc)(TextRec(f));
699
Procedure ReadLn_End(var f : TextRec);[Public,Alias:'FPC_READLN_END'];
815
Procedure fpc_ReadLn_End(var f : Text);[Public,Alias:'FPC_READLN_END']; iocheck; {$ifdef hascompilerproc} compilerproc; {$endif}
702
818
{ Check error and if file is open and load buf if empty }
703
819
If (InOutRes<>0) then
705
if (f.mode<>fmInput) Then
821
if (TextRec(f).mode<>fmInput) Then
707
823
case TextRec(f).mode of
708
824
fmOutPut,fmAppend:
715
if f.BufPos>=f.BufEnd Then
831
if TextRec(f).BufPos>=TextRec(f).BufEnd Then
717
FileFunc(f.InOutFunc)(f);
718
if (f.BufPos>=f.BufEnd) then
833
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
834
if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
721
if (f.FlushFunc<>nil) then
722
FileFunc(f.FlushFunc)(f);
837
if (TextRec(f).FlushFunc<>nil) then
838
FileFunc(TextRec(f).FlushFunc)(TextRec(f));
727
prev := f.BufPtr^[f.BufPos];
843
prev := TextRec(f).BufPtr^[TextRec(f).BufPos];
844
inc(TextRec(f).BufPos);
729
845
{ no system uses #10#13 as line seperator (#10 = *nix, #13 = Mac, }
730
846
{ #13#10 = Dos), so if we've got #10, we can safely exit }
731
847
if prev = #10 then
733
if f.BufPos>=f.BufEnd Then
849
if TextRec(f).BufPos>=TextRec(f).BufEnd Then
735
FileFunc(f.InOutFunc)(f);
736
if (f.BufPos>=f.BufEnd) then
851
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
852
if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
739
if (f.FlushFunc<>nil) then
740
FileFunc(f.FlushFunc)(f);
855
if (TextRec(f).FlushFunc<>nil) then
856
FileFunc(TextRec(f).FlushFunc)(TextRec(f));
744
860
if (prev=#13) then
745
861
{ is there also a #10 after it? }
747
if (f.BufPtr^[f.BufPos]=#10) then
863
if (TextRec(f).BufPtr^[TextRec(f).BufPos]=#10) then
748
864
{ yes, skip that one as well }
865
inc(TextRec(f).BufPos);
756
Function ReadPCharLen(var f:TextRec;s:pchar;maxlen:longint):longint;
872
Function ReadPCharLen(var f:Text;s:pchar;maxlen:longint):longint;
758
874
sPos,len : Longint;
759
875
p,startp,maxp : pchar;
775
891
{ Read maximal until Maxlen is reached }
778
If f.BufPos>=f.BufEnd Then
894
If TextRec(f).BufPos>=TextRec(f).BufEnd Then
780
FileFunc(f.InOutFunc)(f);
781
If f.BufPos>=f.BufEnd Then
896
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
897
If TextRec(f).BufPos>=TextRec(f).BufEnd Then
784
p:=@f.Bufptr^[f.BufPos];
785
if SPos+f.BufEnd-f.BufPos>MaxLen then
786
maxp:=@f.BufPtr^[f.BufPos+MaxLen-SPos]
900
p:=@TextRec(f).Bufptr^[TextRec(f).BufPos];
901
if SPos+TextRec(f).BufEnd-TextRec(f).BufPos>MaxLen then
902
maxp:=@TextRec(f).BufPtr^[TextRec(f).BufPos+MaxLen-SPos]
788
maxp:=@f.Bufptr^[f.BufEnd];
904
maxp:=@TextRec(f).Bufptr^[TextRec(f).BufEnd];
790
906
{ search linefeed }
791
907
while (p<maxp) and not(P^ in [#10,#13]) do
793
909
{ calculate read bytes }
911
inc(TextRec(f).BufPos,Len);
796
912
Move(startp^,s[sPos],Len);
798
914
{ was it a LF or CR? then leave }
807
Procedure Read_String(var f : TextRec;var s : String);[Public,Alias:'FPC_READ_TEXT_SHORTSTR'];
923
Procedure fpc_Read_Text_ShortStr(var f : Text;var s : String); iocheck; [Public,Alias:'FPC_READ_TEXT_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
809
925
s[0]:=chr(ReadPCharLen(f,pchar(@s[1]),high(s)));
813
Procedure Read_PChar(var f : TextRec;var s : PChar);[Public,Alias:'FPC_READ_TEXT_PCHAR_AS_POINTER'];
929
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}
815
931
pchar(s+ReadPCharLen(f,s,$7fffffff))^:=#0;
819
Procedure Read_Array(var f : TextRec;var s : array of char);[Public,Alias:'FPC_READ_TEXT_PCHAR_AS_ARRAY'];
935
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
pchar(pchar(@s)+ReadPCharLen(f,pchar(@s),high(s)))^:=#0;
939
len := ReadPCharLen(f,pchar(@s),high(s)+1);
940
if len <= high(s) then
825
Procedure Read_AnsiString(var f : TextRec;var s : AnsiString);[Public,Alias:'FPC_READ_TEXT_ANSISTR'];
945
Procedure fpc_Read_Text_AnsiStr(var f : Text;var s : AnsiString); iocheck; [Public,Alias:'FPC_READ_TEXT_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
827
947
slen,len : longint;
857
984
{ Read next char or EOF }
858
If f.BufPos>=f.BufEnd Then
985
If TextRec(f).BufPos>=TextRec(f).BufEnd Then
860
FileFunc(f.InOutFunc)(f);
861
If f.BufPos>=f.BufEnd Then
987
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
988
If TextRec(f).BufPos>=TextRec(f).BufEnd Then
989
{$ifdef hascompilerproc}
994
{$else hascompilerproc}
996
{$endif hascompilerproc}
864
Read_Char:=f.Bufptr^[f.BufPos];
998
{$ifdef hascompilerproc}
999
c:=TextRec(f).Bufptr^[TextRec(f).BufPos];
1000
{$else hascompilerproc}
1001
fpc_Read_Text_Char:=TextRec(f).Bufptr^[TextRec(f).BufPos];
1002
{$endif hascompilerproc}
1003
inc(TextRec(f).BufPos);
869
Function Read_SInt(var f : TextRec):ValSInt;[Public,Alias:'FPC_READ_TEXT_SINT'];
875
{ Leave if error or not open file, else check for empty buf }
876
If (InOutRes<>0) then
878
if (f.mode<>fmInput) Then
880
case TextRec(f).mode of
888
If f.BufPos>=f.BufEnd Then
889
FileFunc(f.InOutFunc)(f);
891
if IgnoreSpaces(f) then
893
Val(hs,Read_SInt,code);
899
Function Read_UInt(var f : TextRec):ValUInt;[Public,Alias:'FPC_READ_TEXT_UINT'];
905
{ Leave if error or not open file, else check for empty buf }
906
If (InOutRes<>0) then
908
if (f.mode<>fmInput) Then
910
case TextRec(f).mode of
918
If f.BufPos>=f.BufEnd Then
919
FileFunc(f.InOutFunc)(f);
921
if IgnoreSpaces(f) then
923
val(hs,Read_UInt,code);
929
Function Read_Float(var f : TextRec):ValReal;[Public,Alias:'FPC_READ_TEXT_FLOAT'];
1007
{$ifdef hascompilerproc}
1008
Procedure fpc_Read_Text_SInt(var f : Text; var l : ValSInt); iocheck; [Public,Alias:'FPC_READ_TEXT_SINT']; compilerproc;
1009
{$else hascompilerproc}
1010
Function fpc_Read_Text_SInt(var f : Text):ValSInt;[Public,Alias:'FPC_READ_TEXT_SINT'];
1011
{$endif hascompilerproc}
1016
{$ifdef hascompilerproc}
1018
{$else hascompilerproc}
1019
fpc_Read_Text_SInt:=0;
1020
{$endif hascompilerproc}
1021
{ Leave if error or not open file, else check for empty buf }
1022
If (InOutRes<>0) then
1024
if (TextRec(f).mode<>fmInput) Then
1026
case TextRec(f).mode of
1034
If TextRec(f).BufPos>=TextRec(f).BufEnd Then
1035
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
1037
if IgnoreSpaces(f) then
1039
{ When spaces were found and we are now at EOF,
1041
if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
1045
{$ifdef hascompilerproc}
1047
{$else hascompilerproc}
1048
Val(hs,fpc_Read_Text_SInt,code);
1049
{$endif hascompilerproc}
1055
{$ifdef hascompilerproc}
1056
Procedure fpc_Read_Text_UInt(var f : Text; var u : ValUInt); iocheck; [Public,Alias:'FPC_READ_TEXT_UINT']; compilerproc;
1057
{$else hascompilerproc}
1058
Function fpc_Read_Text_UInt(var f : Text):ValUInt;[Public,Alias:'FPC_READ_TEXT_UINT'];
1059
{$endif hascompilerproc}
1064
{$ifdef hascompilerproc}
1066
{$else hascompilerproc}
1067
fpc_Read_Text_UInt:=0;
1068
{$endif hascompilerproc}
1069
{ Leave if error or not open file, else check for empty buf }
1070
If (InOutRes<>0) then
1072
if (TextRec(f).mode<>fmInput) Then
1074
case TextRec(f).mode of
1082
If TextRec(f).BufPos>=TextRec(f).BufEnd Then
1083
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
1085
if IgnoreSpaces(f) then
1087
{ When spaces were found and we are now at EOF,
1089
if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
1093
{$ifdef hascompilerproc}
1095
{$else hascompilerproc}
1096
val(hs,fpc_Read_Text_UInt,code);
1097
{$endif hascompilerproc}
1103
{$ifdef hascompilerproc}
1104
procedure fpc_Read_Text_Float(var f : Text; var v : ValReal); iocheck; [Public,Alias:'FPC_READ_TEXT_FLOAT']; compilerproc;
1105
{$else hascompilerproc}
1106
Function fpc_Read_Text_Float(var f : Text):ValReal;[Public,Alias:'FPC_READ_TEXT_FLOAT'];
1107
{$endif hascompilerproc}
1112
{$ifdef hascompilerproc}
1114
{$else hascompilerproc}
1115
fpc_Read_Text_Float:=0.0;
1116
{$endif hascompilerproc}
935
1117
{ Leave if error or not open file, else check for empty buf }
936
1118
If (InOutRes<>0) then
938
if (f.mode<>fmInput) Then
1120
if (TextRec(f).mode<>fmInput) Then
940
1122
case TextRec(f).mode of
941
1123
fmOutPut,fmAppend:
948
If f.BufPos>=f.BufEnd Then
949
FileFunc(f.InOutFunc)(f);
1130
If TextRec(f).BufPos>=TextRec(f).BufEnd Then
1131
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
951
1133
if IgnoreSpaces(f) then
953
val(hs,Read_Float,code);
1135
{ When spaces were found and we are now at EOF,
1137
if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
1141
{$ifdef hascompilerproc}
1143
{$else hascompilerproc}
1144
val(hs,fpc_Read_Text_Float,code);
1145
{$endif hascompilerproc}
960
function Read_QWord(var f : textrec) : qword;[public,alias:'FPC_READ_TEXT_QWORD'];
1153
{$ifdef hascompilerproc}
1154
procedure fpc_Read_Text_QWord(var f : text; var q : qword); iocheck; [public,alias:'FPC_READ_TEXT_QWORD']; compilerproc;
1155
{$else hascompilerproc}
1156
function fpc_Read_Text_QWord(var f : text) : qword;[public,alias:'FPC_READ_TEXT_QWORD'];
1157
{$endif hascompilerproc}
1162
{$ifdef hascompilerproc}
1164
{$else hascompilerproc}
1165
fpc_Read_Text_QWord:=0;
1166
{$endif hascompilerproc}
966
1167
{ Leave if error or not open file, else check for empty buf }
967
1168
If (InOutRes<>0) then
969
if (f.mode<>fmInput) Then
1170
if (TextRec(f).mode<>fmInput) Then
971
1172
case TextRec(f).mode of
972
1173
fmOutPut,fmAppend:
979
If f.BufPos>=f.BufEnd Then
980
FileFunc(f.InOutFunc)(f);
1180
If TextRec(f).BufPos>=TextRec(f).BufEnd Then
1181
FileFunc(TextRec(f).InOutFunc)(TextRec(f));
982
1183
if IgnoreSpaces(f) then
984
val(hs,Read_QWord,code);
1185
{ When spaces were found and we are now at EOF,
1187
if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
1191
{$ifdef hascompilerproc}
1193
{$else hascompilerproc}
1194
val(hs,fpc_Read_Text_QWord,code);
1195
{$endif hascompilerproc}
989
function Read_Int64(var f : textrec) : int64;[public,alias:'FPC_READ_TEXT_INT64'];
1200
{$ifdef hascompilerproc}
1201
procedure fpc_Read_Text_Int64(var f : text; var i : int64); iocheck; [public,alias:'FPC_READ_TEXT_INT64']; compilerproc;
1202
{$else hascompilerproc}
1203
function fpc_Read_Text_Int64(var f : text) : int64;[public,alias:'FPC_READ_TEXT_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
1204
{$endif hascompilerproc}
1209
{$ifdef hascompilerproc}
1211
{$else hascompilerproc}
1212
fpc_Read_Text_Int64:=0;
1213
{$endif hascompilerproc}
995
1214
{ Leave if error or not open file, else check for empty buf }
996
1215
If (InOutRes<>0) then
998
if (f.mode<>fmInput) Then
1217
if (TextRec(f).mode<>fmInput) Then
1000
1219
case TextRec(f).mode of
1001
1220
fmOutPut,fmAppend:
1045
1275
$Log: text.inc,v $
1046
Revision 1.1.2.1 2000/11/23 13:12:30 jonas
1047
* fix for web bug 1210 from Peter
1049
Revision 1.1 2000/07/13 06:30:49 michael
1052
Revision 1.72 2000/03/24 10:26:18 jonas
1053
* changed a lot of "if fm.mode = fmClosed then" to case statements,
1054
because if f is not yet initialized, the mode is invalid and can
1055
contain another value even though the file is closed
1056
+ check if a file is open in writeln_end (caused crash if used on
1059
Revision 1.71 2000/03/19 08:36:41 peter
1060
* length check for readnumeric
1062
Revision 1.70 2000/03/17 21:27:56 jonas
1063
* fixed declaration of val_int64 (removed destsize parameter)
1064
* fixed val_int64 and val_qword so they reject invalid input
1066
* when reading a number, invalid input is removed from the input
1067
buffer (+ it should be faster as well)
1069
Revision 1.69 2000/02/09 16:59:31 peter
1072
Revision 1.68 2000/01/31 12:11:53 jonas
1073
* committed the rest of my fix :)
1075
Revision 1.67 2000/01/31 10:15:43 pierre
1076
* Jonas' fix for bug811
1078
Revision 1.66 2000/01/23 12:22:37 florian
1079
* reading of 64 bit type implemented
1081
Revision 1.65 2000/01/20 20:19:37 florian
1082
* writing of int64/qword fixed
1084
Revision 1.64 2000/01/08 17:08:36 jonas
1085
+ Mac linebreak (#13) support for readln
1087
Revision 1.63 2000/01/07 16:41:36 daniel
1090
Revision 1.62 2000/01/07 16:32:25 daniel
1091
* copyright 2000 added
1093
Revision 1.61 1999/12/02 17:40:06 peter
1094
* read_int64 dummy added
1096
Revision 1.60 1999/11/06 14:35:39 peter
1099
Revision 1.59 1999/10/26 12:25:19 peter
1100
* inoutres 103 for closed files, just like delphi
1102
Revision 1.58 1999/10/04 20:42:45 peter
1103
* read ansistring speedup (no length(s) calls anymore)
1105
Revision 1.57 1999/09/10 17:14:43 peter
1106
* remove CR when reading one char less then size
1108
Revision 1.56 1999/09/10 15:40:33 peter
1109
* fixed do_open flags to be > $100, becuase filemode can be upto 255
1111
Revision 1.55 1999/09/08 16:12:24 peter
1112
* fixed inoutres for diskfull
1114
Revision 1.54 1999/09/07 07:44:58 peter
1115
* fixed array of char writing which didn't write the last char
1117
Revision 1.53 1999/08/19 11:16:14 peter
1118
* settextbuf size is now longint
1120
Revision 1.52 1999/08/03 21:58:45 peter
1121
* small speed improvements
1123
Revision 1.51 1999/07/26 09:43:24 florian
1124
+ write helper routine for in64 implemented
1276
Revision 1.23 2004/05/01 20:52:50 peter
1277
* ValSInt fixed for 64 bit
1279
Revision 1.22 2004/04/29 18:59:43 peter
1280
* str() helpers now also use valint/valuint
1281
* int64/qword helpers disabled for cpu64
1283
Revision 1.21 2004/04/22 21:10:56 peter
1284
* do_read/do_write addr argument changed to pointer
1286
Revision 1.20 2002/11/29 16:26:52 peter
1287
* fixed ignorespaces which was broken by the previous commit
1288
when a line started with spaces
1290
Revision 1.19 2002/11/29 15:50:27 peter
1293
Revision 1.18 2002/09/07 15:07:46 peter
1294
* old logs removed and tabs fixed
1296
Revision 1.17 2002/07/01 16:29:05 peter
1297
* sLineBreak changed to normal constant like Kylix