This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, libgfortran] PR26880 Fix Can't read after non-advancing write with rewind
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Fortran List <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 26 Mar 2006 21:53:29 -0800
- Subject: [Patch, libgfortran] PR26880 Fix Can't read after non-advancing write with rewind
I will commit the following patch as obvious:
Regression tested, NIST tested, IO tested.
The attached test case covers this PR and PR26661.
Regards,
Jerry
Index: io/file_pos.c
===================================================================
*** io/file_pos.c (revision 112399)
--- io/file_pos.c (working copy)
*************** st_rewind (st_parameter_filepos *fpp)
*** 312,317 ****
--- 312,318 ----
u->endfile = NO_ENDFILE;
u->current_record = 0;
u->bytes_left = 0;
+ u->read_bad = 0;
test_endfile (u);
}
/* Update position for INQUIRE. */
! { dg-do run }
! PR 26661 : Test reading X's past file end with no LF or CR.
! PR 26880 : Tests that rewind clears the gfc_unit read_bad flag.
! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org>.
implicit none
character(3) a(4)
integer i
open (10)
10 format(A,$)
write(10,10)' abc def ghi jkl'
rewind(10)
read(10,20)(a(i),i=1,4)
if (a(4).ne."jkl") call abort()
20 format(1x,a3,1x,a3,1x,a3,1x,a3,10x)
close(10, status="delete")
end