summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gfortran.dg/complex_read.f9058
-rw-r--r--gcc/testsuite/gfortran.dg/past_eor.f9022
-rw-r--r--libgfortran/ChangeLog8
-rw-r--r--libgfortran/io/list_read.c14
-rw-r--r--libgfortran/io/read.c8
6 files changed, 111 insertions, 7 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3f187ae65b2..9b305504628 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,9 +1,7 @@
-2005-07-13 Jeff Law <law@redhat.com>
+2005-07-13 Paul Thomas <pault@gcc.gnu.org>
- * gcc.dg/tree-ssa/pr22051-2.c: Tweak expected output to allow
- additional casts.
-
- * gcc.dg/tree-ssa/pr22321.c: New test
+ * gfortran.dg/past_eor.f90: New.
+ * gfortran.dg/complex_read.f90: New.
2005-07-13 Paolo Bonzini <bonzini@gnu.org>
diff --git a/gcc/testsuite/gfortran.dg/complex_read.f90 b/gcc/testsuite/gfortran.dg/complex_read.f90
new file mode 100644
index 00000000000..c12b66c5b43
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/complex_read.f90
@@ -0,0 +1,58 @@
+! { 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 one line form.
+
+ write (10, *) " ( 0.99 , 9.9 )"
+ rewind (10)
+ read (10,*) a
+ if (a.ne.(0.99, 9.90)) call abort ()
+
+! Test a new record after the.comma (the original bug).
+
+ rewind (10)
+ write (10, *) " ( 99.0 ,"
+ write (10, *) " 999.0 )"
+ rewind (10)
+ read (10,*) a
+ if (a.ne.(99.0, 999.0)) call abort ()
+
+! Test a new record before the.comma
+
+ rewind (10)
+ write (10, *) " ( 0.99 "
+ write (10, *) " , 9.9 )"
+ rewind (10)
+ read (10,*) a
+ if (a.ne.(0.99, 9.90)) call abort ()
+
+! Test a new records before and after the.comma
+
+ rewind (10)
+ write (10, *) " ( 99.0 "
+ write (10, *) ", "
+ write (10, *) " 999.0 )"
+ rewind (10)
+ read (10,*) a
+ if (a.ne.(99.0, 999.0)) call abort ()
+
+! Test a new records and blank records before and after the.comma
+
+ rewind (10)
+ write (10, *) " ( 0.99 "
+ write (10, *) " "
+ write (10, *) ", "
+ write (10, *) " "
+ write (10, *) " 9.9 )"
+ rewind (10)
+ read (10,*) a
+ if (a.ne.(0.99, 9.9)) call abort ()
+
+ close (10)
+end program complex_read
+
diff --git a/gcc/testsuite/gfortran.dg/past_eor.f90 b/gcc/testsuite/gfortran.dg/past_eor.f90
new file mode 100644
index 00000000000..e89ed227266
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/past_eor.f90
@@ -0,0 +1,22 @@
+! { dg-do run }
+! Test of the fix to the bug triggered by NIST fm908.for.
+! Contributed by Paul Thomas <pault@gcc.gnu.org>
+!
+program past_eor
+ character(len=82) :: buffer
+ real :: a(2), b(2), c(2), d(2), e(2)
+
+ e = (/2.34,2.456/)
+
+! tests 28-31 from fm908.for
+
+ buffer = ' 2.34 , 2.456 2.34 , 2.456 0.234E01, 2.456E00&
+ & 0.234E+001, 2.456E-000'
+
+ READ (UNIT=buffer,FMT=10) a, b, c, d
+10 FORMAT (2(2(G7.5,1X),2X),2(G10.4E2,1X),1X,2(G11.7E4,1X))
+
+ if (any (a.ne.e).or.any (b.ne.e).or.any (c.ne.e).or.any (d.ne.e)) call abort ()
+
+end program past_eor
+
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 093043d7108..25f55c7398a 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,11 @@
+2005-07-13 Paul Thomas <pault@gcc.gnu.org>
+
+ * io/read.c (read_complex): Prevent X formatting during reads
+ from going beyond EOR to fix NIST fm908.FOR failure.
+ * io/list_read.c (read_complex): Allow complex data in list-
+ directed reads to have eols either side of the comma to
+ fix NIST FM906.FOR failure.
+
2005-07-12 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/21593
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 3d62d8c845e..df99e7858a7 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -984,11 +984,25 @@ read_complex (int length)
if (parse_real (value, length))
return;
+eol_1:
eat_spaces ();
+ c = next_char ();
+ if (c == '\n' || c== '\r')
+ goto eol_1;
+ else
+ unget_char (c);
+
if (next_char () != ',')
goto bad_complex;
+eol_2:
eat_spaces ();
+ c = next_char ();
+ if (c == '\n' || c== '\r')
+ goto eol_2;
+ else
+ unget_char (c);
+
if (parse_real (value + length, length))
return;
diff --git a/libgfortran/io/read.c b/libgfortran/io/read.c
index 101652ca8dc..4cfad8d7785 100644
--- a/libgfortran/io/read.c
+++ b/libgfortran/io/read.c
@@ -784,8 +784,12 @@ read_f (fnode * f, char *dest, int length)
void
read_x (fnode * f)
{
- int n;
+ int n, m;
n = f->u.n;
- read_block (&n);
+ m = (int)current_unit->bytes_left;
+ if (f->format == FMT_X)
+ n = (n > m) ? m : n;
+ if (n)
+ read_block (&n);
}
OpenPOWER on IntegriCloud