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] PR38097 I/O with blanks in exponent fails; BN and BZ


This patch is straight forward. It adds tests for ' ' when reading exponents and inserts the '0' or '' based on the current blank status.

Regression tested on x86-64-gnu-Linux. New test case provided.

OK for trunk?

Regards,

Jerry

2008-11-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libfortran/37294
	* io/read.c (read_f): Take care of BN and BZ in reading of exponents.
Index: read.c
===================================================================
--- read.c	(revision 141879)
+++ read.c	(working copy)
@@ -956,14 +956,26 @@ read_f (st_parameter_dt *dtp, const fnod
      of the exponent in order to take account of the scale factor and
      the d parameter before explict conversion takes place. */
  exp2:
-  if (!isdigit (*p))
+  if (dtp->u.p.blank_status == BLANK_UNSPECIFIED && !isdigit (*p))
+    goto bad_float;
+  else if (*p == ' ')
+    {
+      if (dtp->u.p.blank_status == BLANK_ZERO) *p = '0';
+      if (dtp->u.p.blank_status == BLANK_NULL)
+	{
+	  p++;
+	  w--;
+	}
+    }
+  else if (!isdigit (*p))
     goto bad_float;
 
   exponent = *p - '0';
   p++;
   w--;
 
-  if (dtp->u.p.blank_status == BLANK_UNSPECIFIED) /* Normal processing of exponent */
+  /* Normal processing of exponent */
+  if (dtp->u.p.blank_status == BLANK_UNSPECIFIED)
     {
       while (w > 0 && isdigit (*p))
         {
c     { dg-do run }
c     PR38097 I/O with blanks in exponent fails; BN edit descriptor
c     Test case derived from reporter.
      character(11)  :: a = ' 2.  3 e+ 3'
      character(11)  :: b = ' 2.003 e+ 3'
      real :: f

      f = 0.0
      read (a,'(BZ,E11.0)') f
      if (f .ne. 2003.0) call abort
      f = 0.0
      read (a,'(BN,E11.0)') f
      if (f .ne. 2300.0) call abort
      f = 0.0
      read (b,'(BN,E11.0)') f
      if (f .ne. 2003.0) call abort

      end
c     end of program


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