mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-11 10:29:21 +02:00
* use the first element of the filrec._private array to track eof for typed files in iso mode (this will not hurt as iso mode does not specify the _private field), resolves #32938
git-svn-id: trunk@37915 -
This commit is contained in:
parent
f1ace2b74d
commit
273045c295
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
35
tests/webtbs/tw32938.pp
Normal file
35
tests/webtbs/tw32938.pp
Normal file
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user