[patch, fortran] PR38291 Rejects I/O with POS= if FMT=*
jvdelisle@verizon.net
jvdelisle@verizon.net
Fri Dec 5 12:04:00 GMT 2008
Here is a revised patch. I found a problem with positioning on a read
in that I was not checking end-of-file and setting
dtp->u.p.current_unit->endfile = NO_ENDFILE. This has to be done for the
case of an empty read in data_transfer_init. Otherwise, we get an EOF
error for every read in list_read.c (finish_list_read ).
This brings up a subtle point. With list directed input and an empty
input list, the F2003 standard says that the current record is skipped.
If I create a small file with no end-of-record marker (LF) and attempt a
list directed read with no input list (empty read), gfortran dutifully
trys to read through, looking for the end-of-record marker and hits the
end-of-file, giving an error. At least one other compiler I have does
not give an error and seems to interpret the EOF as the EOR in the case
of "skipping the record.
Regardless the final patch is regression tested.
Since the change I made since Tobias approval is very minor, I will
commit. (See small portion of change below.
Regards,
Jerry
+ if (dtp->u.p.mode == READING)
+ {
+ /* Required for compatibility between 4.3 and 4.4 runtime.
Check
+ to see if we might be reading what we wrote before */
+ if (dtp->u.p.current_unit->mode == WRITING)
+ flush(dtp->u.p.current_unit->s);
+
+ if (dtp->pos < file_length (dtp->u.p.current_unit->s))
<---This added
+ dtp->u.p.current_unit->endfile = NO_ENDFILE;
+ }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streamio_16.f90
Type: application/octet-stream
Size: 452 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20081205/90c832ad/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr38291-3.diff
Type: application/octet-stream
Size: 5136 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20081205/90c832ad/attachment-0001.obj>
More information about the Fortran
mailing list