Patchwork [libgfortran] PR 46010 - I/O: Namelist-reading bug

login
register
mail settings
Submitter Jerry DeLisle
Date Oct. 25, 2010, 7:15 p.m.
Message ID <4CC5D74C.8030104@frontier.com>
Download mbox | patch
Permalink /patch/69167/
State New
Headers show

Comments

Jerry DeLisle - Oct. 25, 2010, 7:15 p.m.
Hi all,

The attached patch is simple and fairly safe.  It adds a couple of conditions to 
assure that nml_parse_qualifier sets the end index for the loop spec.  I will 
add the two test cases in the PR to our testsuite.

Regression tested on x86-64.  OK for trunk?

Jerry

2010-10-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/46010
	* io/list_read.c (nml_parse_qualifier): Add additional conditions for
	setting the end index for loop specification. Fix some whitespace.
Tobias Burnus - Oct. 26, 2010, 5:59 a.m.
Am 25.10.2010 21:15, schrieb Jerry DeLisle:
> The attached patch is simple and fairly safe.  It adds a couple of 
> conditions to assure that nml_parse_qualifier sets the end index for 
> the loop spec.  I will add the two test cases in the PR to our testsuite.
>
> Regression tested on x86-64.  OK for trunk?

OK - but you should also add a changelog item for the write.c change, 
which is for PR 41219.

Tobias

> 2010-10-20  Jerry DeLisle <jvdelisle@gcc.gnu.org>
>
>     PR libgfortran/46010
>     * io/list_read.c (nml_parse_qualifier): Add additional conditions for
>     setting the end index for loop specification. Fix some whitespace.
Jerry DeLisle - Oct. 26, 2010, 1:09 p.m.
On 10/25/2010 10:59 PM, Tobias Burnus wrote:
> Am 25.10.2010 21:15, schrieb Jerry DeLisle:
>> The attached patch is simple and fairly safe. It adds a couple of conditions
>> to assure that nml_parse_qualifier sets the end index for the loop spec. I
>> will add the two test cases in the PR to our testsuite.
>>
>> Regression tested on x86-64. OK for trunk?
>
> OK - but you should also add a changelog item for the write.c change, which is
> for PR 41219.
>
Will do, thanks.

Jerry

Patch

Index: list_read.c
===================================================================
--- list_read.c	(revision 165900)
+++ list_read.c	(working copy)
@@ -2105,8 +2105,10 @@  nml_parse_qualifier (st_parameter_dt *dtp, descrip
 
 		  /*  If -std=f95/2003 or an array section is specified,
 		      do not allow excess data to be processed.  */
-                  if (is_array_section == 1
-		      || !(compile_options.allow_std & GFC_STD_GNU))
+		  if (is_array_section == 1
+		      || !(compile_options.allow_std & GFC_STD_GNU)
+		      || !dtp->u.p.ionml->touched
+		      || dtp->u.p.ionml->type == BT_DERIVED)
 		    ls[dim].end = ls[dim].start;
 		  else
 		    dtp->u.p.expanded_read = 1;
@@ -2121,12 +2123,12 @@  nml_parse_qualifier (st_parameter_dt *dtp, descrip
 	}
 
       if (is_array_section == 1 && dtp->u.p.expanded_read == 1)
-     	{
+	{
 	  int i;
 	  dtp->u.p.expanded_read = 0;
 	  for (i = 0; i < dim; i++)
 	    ls[i].end = ls[i].start;
-      	}
+	}
 
       /* Check the values of the triplet indices.  */
       if ((ls[dim].start > (ssize_t) GFC_DIMENSION_UBOUND(ad[dim]))
Index: write.c
===================================================================
--- write.c	(revision 165900)
+++ write.c	(working copy)
@@ -65,7 +65,7 @@  memcpy4 (gfc_char4_t *dest, const char *source, in
 /* Write out default char4.  */
 
 static void
-write_default_char4 (st_parameter_dt *dtp, gfc_char4_t *source,
+write_default_char4 (st_parameter_dt *dtp, const gfc_char4_t *source,
 		     int src_len, int w_len)
 {
   char *p;