View Issue Details

IDProjectCategoryView StatusLast Update
0035136FPCRTLpublic2019-12-28 11:36
Reporterhelbig1Assigned ToFlorian 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64OSOS XOS Version10.11.6
Product Version3.0.4Product Build 
Target VersionFixed in Version3.3.1 
Summary0035136: The function EOF does not comply to ISO Pascal
DescriptionEOF returns true even before the file pointer passes the end of file.
Steps To ReproduceTurn on the ISO mode, compile and run the following program:
program p;
var f: text;
begin
    rewrite(f);
    f^ := 'a';
    put(f);
    reset(f);
    if eof(f) then writeln('premature eof');
    writeln(f^);
    if eof(f) then writeln('premature eof');
    writeln(f^);
    if eof(f) then writeln('premature eof');
    get(f);
    if eof(f) then writeln('eof correctly set') else writeln('eof should be set, but isn''t');
end.
Additional InformationWith this error is a show stopper, if you want to use ISO-Pascal.
TagsNo tags attached.
Fixed in Revision43801
FPCOldBugId
FPCTarget-
Attached Files

Activities

Thaddy de Koning

2019-02-22 18:02

reporter   ~0114348

Last edited: 2019-02-22 18:11

View 3 revisions

This is fixed in 3.2.0.
[edit]
I do not think your code is ISO compliant and contains errors. I miss input and output parameters for one...

helbig1

2019-02-23 20:56

reporter   ~0114375

Nice to know, that this bug is fixed in 3.2.0.

Thaddy de Koning, you are right, the example program is not ISO compliant. It should list the output parameter, because later I used it when calling the writeln procedure. The program header should read:

program p(output);

With this fix the program is ISO compliant, isn't it?

Marco van de Voort

2019-02-24 15:30

manager   ~0114384

In normal FPC "text" files are writeonly. (only typed and untyped files are read/write)

https://www.freepascal.org/docs-html/rtl/system/rewrite.html

What does ISO say about that R/W status of "text" files?

helbig1

2019-02-25 13:56

reporter   ~0114404

Last edited: 2019-03-01 15:06

View 2 revisions

Textfiles are both readable and writeable, like any other file. All external files have to be listed as parameters in the program header and declared as variables, with the two exceptions "input" and "output". If they occur in the parameter list, they are implicitly declared as textfiles. When the input file is used for the first time, it is automatically opened for reading and when output is used for the first time, it is opened for writing. By the way, this works fine with FPC.

Marco van de Voort

2019-02-25 14:28

manager   ~0114409

I think I misread your example, doing put and get after a rewrite. I read over the reset() inbetween.

helbig

2019-02-25 15:02

reporter   ~0114410

The procedures get and put and the function eof refer to the internal text file f and writeln refers to the external file output.

Florian

2019-12-28 11:36

administrator   ~0120099

I am not sure, if the approach I have chosen is correct. If it does not work as expected, please provide more tests.

Issue History

Date Modified Username Field Change
2019-02-22 14:48 helbig1 New Issue
2019-02-22 18:02 Thaddy de Koning Note Added: 0114348
2019-02-22 18:10 Thaddy de Koning Note Edited: 0114348 View Revisions
2019-02-22 18:11 Thaddy de Koning Note Edited: 0114348 View Revisions
2019-02-23 20:56 helbig1 Note Added: 0114375
2019-02-24 15:30 Marco van de Voort Note Added: 0114384
2019-02-25 13:56 helbig1 Note Added: 0114404
2019-02-25 14:28 Marco van de Voort Note Added: 0114409
2019-02-25 15:02 helbig Note Added: 0114410
2019-03-01 15:06 helbig1 Note Edited: 0114404 View Revisions
2019-12-28 11:36 Florian Assigned To => Florian
2019-12-28 11:36 Florian Status new => resolved
2019-12-28 11:36 Florian Resolution open => fixed
2019-12-28 11:36 Florian Fixed in Version => 3.3.1
2019-12-28 11:36 Florian Fixed in Revision => 43801
2019-12-28 11:36 Florian FPCTarget => -
2019-12-28 11:36 Florian Note Added: 0120099