public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch,libgfortran] PR35627 [4.3, 4.4 regression] namelist read error
@ 2008-03-20  2:01 Jerry DeLisle
  0 siblings, 0 replies; only message in thread
From: Jerry DeLisle @ 2008-03-20  2:01 UTC (permalink / raw)
  To: Fortran List; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 826 bytes --]

I plan to commit the attached patch as obvious/simple.  The failure was not 
clearing the index for the line_buffer used for read ahead in read_logical.  The 
patch moves this clearing of item_count into free_line to avoid similar problems 
in the future and simplify the code. I will commit the test case from the PR

Regression tested on X86-64_linux-gnu.

Regards,

Jerry

2008-03-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/35627
	* io/list_read.c (free_line): Clear the line buffer enable flag and
	reset the index into line_buffer, aka item_count.
	(next_char): Cleanup whitespace.
	(read_logical): Use unget_char to assure that the first character of the
	bad logical is saved in case it is part of an object name. Remove the
	clearing of index and flag that is now in free_line.
	(read_real): Likewise.

[-- Attachment #2: pr35627.diff --]
[-- Type: text/x-patch, Size: 1652 bytes --]

Index: list_read.c
===================================================================
--- list_read.c	(revision 133302)
+++ list_read.c	(working copy)
@@ -120,6 +120,9 @@ free_saved (st_parameter_dt *dtp)
 static void
 free_line (st_parameter_dt *dtp)
 {
+  dtp->u.p.item_count = 0;
+  dtp->u.p.line_buffer_enabled = 0;
+
   if (dtp->u.p.line_buffer == NULL)
     return;
 
@@ -157,8 +160,8 @@ next_char (st_parameter_dt *dtp)
 	  goto done;
 	}
 
-        dtp->u.p.item_count = 0;
-	dtp->u.p.line_buffer_enabled = 0;
+      dtp->u.p.item_count = 0;
+      dtp->u.p.line_buffer_enabled = 0;
     }    
 
   /* Handle the end-of-record and end-of-file conditions for
@@ -685,6 +688,9 @@ read_logical (st_parameter_dt *dtp, int 
       return;			/* Null value.  */
 
     default:
+      /* Save the character in case it is the beginning
+	 of the next object name. */
+      unget_char (dtp, c);
       goto bad_logical;
     }
 
@@ -700,8 +706,6 @@ read_logical (st_parameter_dt *dtp, int 
 
   unget_char (dtp, c);
   eat_separator (dtp);
-  dtp->u.p.item_count = 0;
-  dtp->u.p.line_buffer_enabled = 0;
   set_integer ((int *) dtp->u.p.value, v, length);
   free_line (dtp);
 
@@ -755,8 +759,6 @@ read_logical (st_parameter_dt *dtp, int 
 
  logical_done:
 
-  dtp->u.p.item_count = 0;
-  dtp->u.p.line_buffer_enabled = 0;
   dtp->u.p.saved_type = BT_LOGICAL;
   dtp->u.p.saved_length = length;
   set_integer ((int *) dtp->u.p.value, v, length);
@@ -1640,8 +1642,6 @@ read_real (st_parameter_dt *dtp, int len
       push_char (dtp, 'n');
     }
 
-  dtp->u.p.item_count = 0;
-  dtp->u.p.line_buffer_enabled = 0;
   free_line (dtp);
   goto done;
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-03-20  1:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-20  2:01 [patch,libgfortran] PR35627 [4.3, 4.4 regression] namelist read error Jerry DeLisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).