This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, libgfortran] Fix PR26554 incorrect behaviour when reading a logical variable from a string
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Fortran List <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 04 Mar 2006 16:06:39 -0800
- Subject: [Patch, libgfortran] Fix PR26554 incorrect behaviour when reading a logical variable from a string
The attached patch fixes this PR. In order to handle the namelist reads in
pr26136 we need to read ahead to see if there is an equal sign. We should not
keep looking if we are not in namelist mode.
I will commit this with a test case under simple and obvious rule tomorrow
unless otherwise notified.
Regards,
Jerry
2006-03-04 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/26554
* io/list_read.c (read_logical): Return the value if not in namelist
mode.
Index: io/list_read.c
===================================================================
*** io/list_read.c (revision 111630)
--- io/list_read.c (working copy)
*************** read_logical (st_parameter_dt *dtp, int
*** 647,664 ****
c = next_char (dtp);
if (is_separator(c))
{
unget_char (dtp, c);
eat_separator (dtp);
c = next_char (dtp);
if (c != '=')
{
unget_char (dtp, c);
! 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);
! return;
}
}
--- 647,663 ----
c = next_char (dtp);
if (is_separator(c))
{
+ /* All done if this is not a namelist read. */
+ if (!dtp->u.p.namelist_mode)
+ goto logical_done;
+
unget_char (dtp, c);
eat_separator (dtp);
c = next_char (dtp);
if (c != '=')
{
unget_char (dtp, c);
! goto logical_done;
}
}
*************** read_logical (st_parameter_dt *dtp, int
*** 670,676 ****
dtp->u.p.item_count = 0;
return;
}
! }
bad_logical:
--- 669,676 ----
dtp->u.p.item_count = 0;
return;
}
!
! }
bad_logical:
*************** read_logical (st_parameter_dt *dtp, int
*** 681,686 ****
--- 681,695 ----
dtp->u.p.item_count);
generate_error (&dtp->common, ERROR_READ_VALUE, message);
+ return;
+
+ 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);
}