[patch, fortran] PR22539 implement FSEEK intrinsic

Daniel Franke franke.daniel@gmail.com
Thu May 3 17:52:00 GMT 2007


I updated the patch according to comments of Brooks Moses and Jerry DeLisle.

Due to Brooks concers, I was also able to identify a possible problem in the 
function fd_seek (libgfortran/io/unix.c), where the physical and logical 
offsets of the internal representation of the file were changed, regardless 
of the status of lseek. The patch now include a fix for this as well. The 
testcase was updated to include a seek with a resulting negative offset.

Jerry asked:
> I have not seen what happens if we try to seek a read only file past its
> current end. That would be worth checking.

Nothing much. The position is moved beyond the end. Attempting to read there 
results in a "Fortran runtime error: End of file". Moving beyond the end and 
back works as expected, i.e. read works without problems.

With all the changes in place and no regressions on i686-pc-linux-gnu, ok for 
trunk? 

gcc/fortran:
2007-05-01  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/22539
        * intrinsic.c (add_subroutines): Added FSEEK.
        * intrinsic.h (gfc_resolve_fseek_sub, gfc_check_fseek_sub): New.
        * iresolve.c (gfc_resolve_fseek_sub): New.
        * check.c (gfc_check_fseek_sub): New.
        * intrinsic.texi (FSEEK): Updated.

libgfortran:
2007-05-01  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/22539
        * io/intrinsics.c (fseek_sub): New.
        * io/unix.c (fd_fseek): Change logical and physical offsets only
	if seek succeeds.
        * gfortran.map (fseek_sub): New.

gcc/testsuite:
2007-05-01  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/22539
        * gfortran.dg/fseek.f90: New test.

Regards
	Daniel


-------------- next part --------------
A non-text attachment was scrubbed...
Name: fseek.fortran.patch
Type: text/x-diff
Size: 7041 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070503/98cfd28c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fseek.libgfortran.patch
Type: text/x-diff
Size: 1869 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070503/98cfd28c/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fseek.testsuite.patch
Type: text/x-diff
Size: 1524 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070503/98cfd28c/attachment-0002.bin>


More information about the Fortran mailing list