This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]