This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, libgfortran] PR31052 Bad IOSTAT values when readings NAMELISTs past EOF
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Fortran List <fortran at gcc dot gnu dot org>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 09 Mar 2007 20:43:01 -0800
- Subject: [patch, libgfortran] PR31052 Bad IOSTAT values when readings NAMELISTs past EOF
:addpatch fortran:
Hi,
This problem was not quite what I originally thought. The function test_endfile
was setting the endfile flag to AT_ENDFILE for the test case provided in the PR.
Commenting out test_endfile in st_rewind resolves the test case but regresses
dev_null.f90. All other test cases past. So, it appears that test_endfile is
needed for the special case when rewinding /dev/null. This seems weird to me to
begin with, but how does one determine that a file is /dev/null?
Regardless, the attached patch resolves this issue by adding the additional
condition that the file_length is zero before setting end_file to AT_ENDFILE.
Fully regression tested on x86-64-Gnu/Linux.
On the test case, I will convert the case in the PR to an equivalent testsuite
version.
OK for trunk and then 4.2 after the branch freezes and reopens later?
Regards,
Jerry
2007-03-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/31052
* io/open.c (test_endfile): Add condition of file_length equal to zero
to prevent incorrect setting of endfile flag to AT_ENDFILE.
(new_unit): Fix typo in comment.
Index: open.c
===================================================================
*** open.c (revision 122763)
--- open.c (working copy)
*************** static const st_option convert_opt[] =
*** 117,123 ****
void
test_endfile (gfc_unit * u)
{
! if (u->endfile == NO_ENDFILE && file_length (u->s) == file_position (u->s))
u->endfile = AT_ENDFILE;
}
--- 117,125 ----
void
test_endfile (gfc_unit * u)
{
! if (u->endfile == NO_ENDFILE
! && file_length (u->s) == file_position (u->s)
! && file_length (u->s) == 0)
u->endfile = AT_ENDFILE;
}
*************** new_unit (st_parameter_open *opp, gfc_un
*** 488,494 ****
/* Curiously, the standard requires that the
position specifier be ignored for new files so a newly connected
! file starts out that the initial point. We still need to figure
out if the file is at the end or not. */
test_endfile (u);
--- 490,496 ----
/* Curiously, the standard requires that the
position specifier be ignored for new files so a newly connected
! file starts out at the initial point. We still need to figure
out if the file is at the end or not. */
test_endfile (u);