diff --git a/.gitattributes b/.gitattributes index c4a02ea22d..b77879bb4e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15932,6 +15932,7 @@ tests/webtbs/tw3281.pp svneol=native#text/plain tests/webtbs/tw32821.pp svneol=native#text/pascal tests/webtbs/tw3286.pp svneol=native#text/plain tests/webtbs/tw3292.pp svneol=native#text/plain +tests/webtbs/tw32938.pp svneol=native#text/pascal tests/webtbs/tw3294a.pp svneol=native#text/plain tests/webtbs/tw3298.pp svneol=native#text/plain tests/webtbs/tw3301.pp svneol=native#text/plain diff --git a/rtl/inc/iso7185.pp b/rtl/inc/iso7185.pp index 35c4ba787d..31569f84a5 100644 --- a/rtl/inc/iso7185.pp +++ b/rtl/inc/iso7185.pp @@ -204,10 +204,8 @@ unit iso7185; Function Eof(var f:TypedFile): Boolean;[IOCheck]; - Type - UnTypedFile = File; Begin - Eof:=System.Eof(UnTypedFile(f)); + Eof:=FileRec(f)._private[1]=1; End; begin diff --git a/rtl/inc/typefile.inc b/rtl/inc/typefile.inc index e3f2be71bd..28279b7699 100644 --- a/rtl/inc/typefile.inc +++ b/rtl/inc/typefile.inc @@ -102,6 +102,9 @@ Begin if FileRec(f).mode=0 then DoAssign(f); + { use _private[1] to track eof } + FileRec(f)._private[1]:=0; + Reset(UnTypedFile(f),Size); BlockRead(UntypedFile(f),(pbyte(@f)+sizeof(FileRec))^,1); End; @@ -129,6 +132,9 @@ Begin if FileRec(f).mode=0 then Assign(f,FileName); + { use _private[1] to track eof } + FileRec(f)._private[1]:=0; + Reset(UnTypedFile(f),Size); BlockRead(UntypedFile(f),(pbyte(@f)+sizeof(FileRec))^,1); End; @@ -183,6 +189,8 @@ Begin move((pbyte(@f)+sizeof(TypedFile))^,Buf,TypeSize); if not(eof(f)) then BlockRead(f,(pbyte(@f)+sizeof(FileRec))^,1) + else + FileRec(f)._private[1]:=1; End; diff --git a/tests/webtbs/tw32938.pp b/tests/webtbs/tw32938.pp new file mode 100644 index 0000000000..495b343dc3 --- /dev/null +++ b/tests/webtbs/tw32938.pp @@ -0,0 +1,35 @@ +{$mode iso} +program test(output); + +label 99; + +type byte = 0..255; + +var f: file of byte; + b: byte; + i: integer; + +begin + + rewrite(f); + for b := 1 to 10 do write(f, b); + reset(f); + for i := 1 to 10 do begin + + if eof(f) then begin + + writeln('End of file'); + goto 99 + + end; + read(f, b); + write(b:1, ' ') + + end; + 99: + if b<>10 then + halt(1); + write; + writeln('ok'); +end. +