re PR libfortran/19155 ([4.0 only] blanks not treated as zeros in 'E' format read...
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>
Sun, 12 Jun 2005 19:59:17 +0000 (21:59 +0200)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Sun, 12 Jun 2005 19:59:17 +0000 (19:59 +0000)
PR libfortran/19155
* io/read.c (read_f): Take care of spaces after initial sign.
* gfortran.dg/pr19155.f: Add test.

From-SVN: r100861

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr19155.f
libgfortran/ChangeLog
libgfortran/io/read.c

index 72c1e8811a32cc08f086dcce2ce49fba2024f1fc..7278d612927406a7a1d83691b4af95a48ca289e0 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-12  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR libfortran/19155
+       * gfortran.dg/pr19155.f: Add test.
+
 2005-06-12  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * gfortran.dg/f2c_7.f90: New test.
index ccd391520b129677ee7160fbbfbe3e9f5fbf1148..6387c3f9ce32a722dbff38ecccd0735d58d11261 100644 (file)
@@ -5,6 +5,7 @@
 ! but doesn't require us to issue an error. Since g77 accepts this as zero,
 ! we do the same.
       real a
+      character*10 c
       a = 42
       open (19,status='scratch')
       write (19,'(A15)') 'E+00'
@@ -12,4 +13,8 @@
       read (19,'(E15.8)') a
       if (a .ne. 0) call abort
       close (19)
+
+      c = "+         "
+      read (c,"(F10.4)") a
+      if (a /= 0) call abort
       end
index 86a04e804b2120d64ec5b6845b12f1a3cc28b0b5..79e09f670422390d997dde8df38bac67cc8791fe 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-12  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR libfortran/19155
+       * io/read.c (read_f): Take care of spaces after initial sign.
+
 2005-06-09  Thomas Koenig  <Thomas.Koenig@online.de>
 
        PR libfortran/21480
index 1c8b3b0daa8d6b6ae3a34a09505c1fd77a9f13cb..fbd38f13becd3624722283d8df5e8fdd9e7a012d 100644 (file)
@@ -504,23 +504,7 @@ read_f (fnode * f, char *dest, int length)
 
   p = eat_leading_spaces (&w, p);
   if (w == 0)
-    {
-      switch (length)
-       {
-       case 4:
-         *((float *) dest) = 0.0f;
-         break;
-
-       case 8:
-         *((double *) dest) = 0.0;
-         break;
-
-       default:
-         internal_error ("Unsupported real kind during IO");
-       }
-
-      return;
-    }
+    goto zero;
 
   /* Optional sign */
 
@@ -529,12 +513,13 @@ read_f (fnode * f, char *dest, int length)
       if (*p == '-')
         val_sign = -1;
       p++;
-
-      if (--w == 0)
-       goto bad_float;
+      w--;
     }
 
   exponent_sign = 1;
+  p = eat_leading_spaces (&w, p);
+  if (w == 0)
+    goto zero;
 
   /* A digit, a '.' or a exponent character ('e', 'E', 'd' or 'D')
      is required at this point */
@@ -604,6 +589,23 @@ read_f (fnode * f, char *dest, int length)
   generate_error (ERROR_READ_VALUE, "Bad value during floating point read");
   return;
 
+  /* The value read is zero */
+ zero:
+  switch (length)
+    {
+      case 4:
+       *((float *) dest) = 0.0f;
+       break;
+
+      case 8:
+       *((double *) dest) = 0.0;
+       break;
+
+      default:
+       internal_error ("Unsupported real kind during IO");
+    }
+  return;
+
   /* At this point the start of an exponent has been found */
  exp1:
   while (w > 0 && *p == ' ')