[PATCH,gfortran] Fix for PR 17941
Steve Kargl
sgk@troutmask.apl.washington.edu
Sat Jan 15 21:03:00 GMT 2005
On Sat, Jan 15, 2005 at 09:57:01PM +0100, FX Coudert wrote:
> >2005-01-15 Steven G. Kargl <kargls@comcast.net>
> >
> > PR fortran/17941
> > * primary.c (match_const_complex_part): Deal with whitespace in
> > between
> > uniary sign and the number
>
> unary
>
> >+ /* Record the presences of uniary minus sign and gobble any whitespace
> >+ between the minus sign and number. */
>
> "presence" and "unary"?
>
> >+ /* Record the presences of uniary plus sign and gobble any whitespace
> >+ between the plus sign and number. */
>
> Here again.
>
Thanks.
See new patch.
--
Steve
-------------- next part --------------
Index: primary.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/primary.c,v
retrieving revision 1.15
diff -u -b -u -b -B -r1.15 primary.c
--- primary.c 3 Jan 2005 21:43:50 -0000 1.15
+++ primary.c 15 Jan 2005 21:00:34 -0000
@@ -1004,7 +1004,7 @@
static match
match_const_complex_part (gfc_expr ** result)
{
- int kind, seen_digits, seen_dp, count;
+ int kind, seen_digits, seen_dp, count, seen_sign;
char *p, c, exp_char, *buffer;
locus old_loc;
@@ -1013,12 +1013,28 @@
seen_dp = 0;
seen_digits = 0;
+ seen_sign = 0;
count = 0;
exp_char = ' ';
c = gfc_next_char ();
- if (c == '-' || c == '+')
+
+ /* Record the presence of unary minus sign and gobble any whitespace
+ between the minus sign and number. */
+ if (c == '-')
{
+ seen_sign = -1;
+ gfc_gobble_whitespace ();
+ c = gfc_next_char ();
+ count++;
+ }
+
+ /* Record the presences of unary plus sign and gobble any whitespace
+ between the plus sign and number. */
+ if (c == '+')
+ {
+ seen_sign = 1;
+ gfc_gobble_whitespace ();
c = gfc_next_char ();
count++;
}
@@ -1077,14 +1093,21 @@
gfc_gobble_whitespace ();
buffer = alloca (count + 1);
- memset (buffer, '\0', count + 1);
+ p = buffer;
+
+ /* Set the sign if present. */
+ if (seen_sign != 0)
+ {
+ *p++ = gfc_next_char ();
+ gfc_gobble_whitespace ();
+ count--;
+ }
/* Hack for mpfr_set_str(). */
- p = buffer;
while (count > 0)
{
c = gfc_next_char ();
- if (c == 'd' || c == 'q')
+ if (c == 'd' || c == 'q') /* FIXME: c can never be 'q', here! */
c = 'e';
*p++ = c;
count--;
More information about the Fortran
mailing list