[gfortran] Patch for list directed input problems

Bud Davis bdavis@gfortran.org
Tue Feb 8 19:14:00 GMT 2005


Below is a patch that is a joint work by Paul Thomas and myself.
{ i confess, most of the work was paul !! }

It corrects some errors in list directed reads; detecting a separator
properly when a null item or a repeat count exists.

No additional failures on i686/gnu/linux. The test suite file
provided fails before and passes after the application of this
patch.

No change to the NIST test suite.


--bud


2004-02-07  Paul Thomas <paulthomas2@wannado.fr>
	    Bud Davis  <bdavis@gfortran.org>

	* io/list_read.c (read_real): Handle separators properly
	in list directed read.



C { dg-do run }
C Test of gfortran list directed read> check delimiters are correctly
C treated.  Written in f77 so that g77 will run for comparison.
C
C f , e and i edit reads are terminated separately by read_real.c
C
C PThomas                                                   Jan 2005
C BDavis        
      program list_read_4
      integer i(10),l(10),k,j 
      real x(10),y(10)
C expected results
      data y / 1.0,2.0,3.0,-1.0,-1.0,-1.0,4.0,4.0,99.0,99.0 /
      data l /1,2,3,-1,-1,-1,4,4,99,99/
C put them in a file
      open (10,status="scratch")
      write (10,*) " 1.0, 2.0 , 3.0,, 2* , 2*4.0 , 5*99.0"
      write (10,*) " 1.0e0, 2.0e0 , 3.0e0,, 2* , 2*4.0e0 , 5*99.0e0"
      write (10,*) " 1,   2 ,   3,,   2* , 2*4 ,   5*99"
      write (10,*) " 1,   2 ,   3,,   2* , 2*4 ,   5*99"
      rewind (10)
C
      do k = 1,10
        x(k) = -1.0
      enddo
      read (10,*,iostat=ier) x
      if (ier.ne.0) call abort
      do k = 1,10
         if (x(k).ne.y(k)) call abort
         x(k) = -1
      end do
      READ(10,*,iostat=ier) x
      if (ier.ne.0) call abort
      do k = 1,10
         if (x(k).ne.y(k)) call abort
         x(k) = -1
      end do
      READ(10,*,iostat=ier) x
      if (ier.ne.0) call abort
      do k = 1,10
         if (x(k).ne.y(k)) call abort
         x(k) = -1
      end do
C integer
      do k = 1,10
        i(k) = -1
      end do 
      READ(10,*,iostat=ier) (i(j),j=1,10)
      if (ier.ne.0) call abort
      do k = 1,10
         if (i(k).ne.y(k)) call abort
         i(k) = -1
      end do
      end
Index: gcc/libgfortran/io/list_read.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/list_read.c,v
retrieving revision 1.13
diff -c -3 -p -r1.13 list_read.c
*** gcc/libgfortran/io/list_read.c	12 Jan 2005 21:27:31 -0000	1.13
--- gcc/libgfortran/io/list_read.c	8 Feb 2005 01:53:46 -0000
*************** read_real (int length)
*** 1052,1059 ****
  	  goto got_repeat;
  
  	CASE_SEPARATORS:
-           if (c != '\n' &&  c != ',')
-             unget_char (c);    /* Real number that is just a digit-string.  */
  	  goto done;
  
  	default:
--- 1052,1057 ----
*************** read_real (int length)
*** 1164,1171 ****
  	  break;
  
  	CASE_SEPARATORS:
- 	  unget_char (c);
- 	  eat_separator ();
  	  goto done;
  
  	default:
--- 1162,1167 ----
*************** read_real (int length)
*** 1174,1179 ****
--- 1170,1177 ----
      }
  
   done:
+   unget_char (c);
+   eat_separator ();
    push_char ('\0');
    if (convert_real (value, saved_string, length))
      return;




More information about the Gcc-patches mailing list