[patch, libfortran] PR31532 INQUIRE(...,POSITION=...) not standard conforming

Jerry DeLisle jvdelisle@verizon.net
Sun Apr 22 17:23:00 GMT 2007


:ADDPATCH fortran:

Hi all,

It turns out the implementation of this feature of Fortran was not complete. 
The attached patch adds a new function to update the flags.position which is 
used by INQUIRE.  The patch also adds a few individual updates where efficient 
to do so.

Also, for units that are not opened for DIRECT access, I return a value of zero 
for NEXTREC since a record number is meaningless in any other context.  This is 
at least consistent with ifort.

In the test suite, inquire_5.f90 had to be adjusted.  After a record is written 
to the file, its position status is APPEND.  Writing two records and the 
backspacing one record, puts the file into an ASIS condition.

The position status is updated when ever a file position action happens such as 
READ, WRITE, BACKSPACE, REWIND.

Feel free to comment on my interpretations:

If the file position is zero -> REWIND
If the file position == file length -> APPEND
If the file position is neither of the above -> ASIS

Regression tested on x86-64-Gnu/Linux.  I will work up another test case as well.

OK for trunk?

Best regards,

Jerry

2007-04-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/31532
	* io/file_pos.c (st_backspace): Set flags.position for end of file
	condition and use new function update_position.
	(st_endfile): Use new function update_position.
	* io/io.h: Add prototype for new function.
	* io/inquire.c (inquire_via_unit): If not direct access, set NEXTREC
	to zero.
	* io/unit.c (update_position): New function to update position info
	used by inquire.
	* io/transfer.c (next_record): Fix typo and use new function.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr31532.diff
Type: text/x-patch
Size: 4136 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070422/e4a41ca1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: inquire_5.diff
Type: text/x-patch
Size: 523 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070422/e4a41ca1/attachment-0001.bin>


More information about the Gcc-patches mailing list