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] Fix NIST fm906.for


The attached is a fix for a problem with list-directed reading of complex variables over two lines.

According to the standard:

10.8.2: "..... The end of record may occur between the comma and the imaginary part only if the entire constant is as long as, or longer than, and entire record. The only embedded blanks permitted within a complex constant are between the comma and the end of record and 1 blank on the following line."

The NIST test complies with neither condition...

C INPUT DATA TO THIS SEGMENT CONSISTS OF 12 CARD IMAGES IN COL. 1-44 00270906
COL. 1-----------------------------------------44 00280906
CARD 1 2.5D0 00290906
CARD 2 1.5 2.5D0 3.5E0 00300906
CARD 3 (3.0,4.0) 00310906
CARD 4 (1.0,0.0) (0.0,0.0) (0.0,3.0) 00320906
CARD 5 2, 2.5D0, 2.5D0, T, (3.0,4.0), 'TEST' 00330906
CARD 6 ( 2.5 , 3.5 ) 00340906
CARD 7 (1.0 , 00350906
CARD 8 2.0) 00360906
CARD 9 , (2.0, 3.0),,6.0D0, 2*, 00370906
CARD 10 1.0D0 (2.0, 2.0) 3.0D0 (4.0, 4.0) 5.0D0 00380906
CARD 11 6.0D0 (7.0, 7.0) / 8.0D0 (9.0, 9.0) 10.0D0 00390906
CARD 12 2.0D0 4.0D0 / 6.0D0 8.0D0 10.0D0 00400906
C***** 00410906
C***** S P E C I F I C A T I O N S SEGMENT 372 00420906


...the complex variable being read from lines 7 and 8. However, every other compiler seems to ignore the niceties and handle this input successfully.

The attached patch does likewise.

Regtested on RH9/Athlon. OK for 4.1?

Paul T

2005-07-10 Paul Thomas  <pault@gcc.gnu.org>

	* list_read.c (read_complex): Allow complex input to be spread
	over two lines to fix NIST fm906.for failure.

2005-07-10  Paul Thomas  <pault@gcc.gnu.org>

	* gfortran.dg/complex_read.f90: New.



Index: gcc/libgfortran/io/list_read.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/list_read.c,v
retrieving revision 1.24
diff -c -3 -p -r1.24 list_read.c
*** gcc/libgfortran/io/list_read.c	23 Jun 2005 18:50:24 -0000	1.24
--- gcc/libgfortran/io/list_read.c	10 Jul 2005 19:35:09 -0000
*************** read_complex (int length)
*** 989,994 ****
--- 989,1000 ----
      goto bad_complex;
  
    eat_spaces ();
+   c = next_char ();
+   if (c == '\n' || c== '\r')
+     eat_spaces ();
+   else
+     unget_char (c);
+ 
    if (parse_real (value + length, length))
      return;
  


!===================================================================

! { dg-do run }
! Test of the fix to the bug in NIST fm906.for.
! Contributed by Paul Thomas  <pault@gcc.gnu.org>
!
program complex_read
  complex            ::  a
  open (10, status="scratch")

! Test that we have not broken the standard form.

  write (10, *) " ( 0.99  ,  9.9  )"
  rewind (10)
  read (10,*) a
  rewind (10)
  if (a.ne.(0.99,9.90)) call abort ()

! Test the broken bit.

  write (10, *) " ( 99.0  ,"
  write (10, *) " 999.0  )"
  rewind (10)
  read (10,*) a
  close (10)
  if (a.ne.(99.0,999.0)) call abort ()

end program complex_read


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