[Patch, libgfortran] Fix PR26499 End of File incorrectly positioned after binary I/O.

Jerry DeLisle jvdelisle@verizon.net
Thu Mar 2 06:34:00 GMT 2006


:ADDPATCH fortran:

Hi,

The attached patch fixes this problem.  In st_read_done there is logic to handle 
end-of-file conditions for unformatted sequential writes.  This bug was caused 
by a conditional that never went true so the file never was truncated when it 
was supposed to.  Evidently over th evolutions current_record was suppose to 
hold a record number.  Now it is just a flag telling whether or not to 
pre_position the file.  It has a value of either 0 or 1 so it was always less 
than the last_record count.

We may want to change this to a bit in dtp and free up current_record to be used 
to actually hold a record number.

After getting truncate to actually be called I then noticed during testing that 
gfortran.dg/write_to_null.f90 was failing.  The reason for this is that before 
truncate was never getting called, now that it is it should not fail on 
/dev/null.  According to notes and my search of the past PRs, behavior of 
truncate for /dev/null is not defined so we might as well pass a SUCCESS rather 
than a FAILURE in that case.

Regression tested, NIST tested, many IO tested.

OK for trunk and 4.1.1 ?

Regards,

Jerry

2006-03-02  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/26499
	* io/unix.c (fd_truncate): Return SUCCESS rather than FAILURE for
	special files like /dev/null.
	* io/transfer.c (st_write_done): Remove broken logic that prevented
	calling fd_truncate.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr26499.diff
Type: text/x-patch
Size: 2803 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060302/54ada3bf/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: write_back.f
Type: text/x-fortran
Size: 622 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060302/54ada3bf/attachment-0001.bin>


More information about the Fortran mailing list