[patch,libgfortran) PR31199 write with "t1" + nonadvancing transfer format gives wrong output

Jerry DeLisle jvdelisle@verizon.net
Fri Mar 23 16:54:00 GMT 2007


:ADDPATCH fortran:

This was a bit tricky to fix.  There are two problems solved.

First, the maximum position reached was not being saved from a WRITE that used 
ADVANCE="no".  Without this the following WRITE can not know where to continue 
writing in the file.

This is fixed using a new variable in gfc_unit called saved_pos.

The second problem was that in finalize_transfer the maximum position was not 
being calculated correctly because the number of bytes written was not being 
factored into the positioning.  The result was that even though the strings in 
the test case were being written correctly, there were trailing NULL bytes 
inserted before the ends of records in the file.

This is fixed by calculating bytes_written and then using that to figure max_pos.

Regression tested on x86-64-Gnu/Linux.

OK for trunk?


Regards,

Jerry

  2007-03-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31199
	*io/io.h: Add saved_pos to gfc_unit structure.
	*io/open.c (new_unit): Initialize saved_pos.
	*io/transfer.c (data_transfer_init): Set max_pos to value in saved_pos.
	(next_record_w): Fix whitespace.
	(finalze_transfer): Calculate max_pos for ADVANCE="no" and save it for
	later use.  If not ADVANCE="no" set saved_pos to zero.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr31199.diff
Type: text/x-patch
Size: 2462 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070323/8dd90117/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr31199.f
Type: text/x-fortran
Size: 452 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070323/8dd90117/attachment-0001.bin>


More information about the Gcc-patches mailing list