This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

[gfortran] patch for PR18398, problem with sequential formattedreads.


the problem:

123456789012  (to see the columns of the data)

     1.00000
     2.00000
     3.00000

read with F15.5 edit descriptor.


read_sf was detecting the eol, terminating the input of that item 
and setting the flag; and then next_record_r was consuming 
everything to the next eol, which means the second line of input
had disappeared.

i think the done flag here is not needed.. when eor has been
seen it is a bad idea to eat more input chars, period. 

tested on i686/gnu linux with no additional testsuite failures.
no changes to the NIST results.

all examples posted with the bug (thanks guys !) are also corrected
by this patch.




--bud

2004-12-07  Bud Davis  <bdavis9659@comcast.net

	PR fortran/18398
	* transfer.c (next_record_r): always skip the
	eol search if it was found during sf_read.


! { dg-do run }
! pr18398, missing data on sequential formatted reads
! test contributed by Thomas.Koenig@online.de
      open(7,status='scratch')
      write (7,'(F12.5)') 1.0, 2.0, 3.0
      rewind(7)
      read(7,'(F15.5)') a,b
!   note the read format is wider than the write
      if (abs(a-1.0) .gt. 1e-5) call abort
      if (abs(b-2.0) .gt. 1e-5) call abort
      end



Index: gcc/libgfortran/io/transfer.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/transfer.c,v
retrieving revision 1.23
diff -c -3 -p -r1.23 transfer.c
*** gcc/libgfortran/io/transfer.c	24 Dec 2004 00:29:07 -0000	1.23
--- gcc/libgfortran/io/transfer.c	6 Jan 2005 05:56:03 -0000
*************** next_record_r (int done)
*** 1209,1215 ****
  
      case FORMATTED_SEQUENTIAL:
        length = 1;
!       if (sf_seen_eor && done)
           break;
  
        do
--- 1209,1216 ----
  
      case FORMATTED_SEQUENTIAL:
        length = 1;
!       /* sf_read has already terminated input because of an '\n'  */
!       if (sf_seen_eor) 
           break;
  
        do









 



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