Mon Apr 28 17:27:40 1997 Michael Snyder <msnyder@cleaver.cygnus.com>
* c-exp.y, java-exp.y: make parse_number reject "123DEADBEEF". (fix by Bob Manson).
This commit is contained in:
parent
6a85a617df
commit
d030f469c1
3 changed files with 24 additions and 12 deletions
|
@ -1,5 +1,7 @@
|
||||||
Mon Apr 28 17:27:40 1997 Michael Snyder <msnyder@cleaver.cygnus.com>
|
Mon Apr 28 17:27:40 1997 Michael Snyder <msnyder@cleaver.cygnus.com>
|
||||||
|
|
||||||
|
* c-exp.y, java-exp.y: make parse_number reject "123DEADBEEF".
|
||||||
|
(fix by Bob Manson).
|
||||||
* top.c: change "to enable to enable" to "to enable" in a couple
|
* top.c: change "to enable to enable" to "to enable" in a couple
|
||||||
of help strings.
|
of help strings.
|
||||||
|
|
||||||
|
|
18
gdb/c-exp.y
18
gdb/c-exp.y
|
@ -933,28 +933,32 @@ parse_number (p, len, parsed_float, putithere)
|
||||||
|
|
||||||
if (parsed_float)
|
if (parsed_float)
|
||||||
{
|
{
|
||||||
char c;
|
|
||||||
|
|
||||||
/* It's a float since it contains a point or an exponent. */
|
/* It's a float since it contains a point or an exponent. */
|
||||||
|
char c;
|
||||||
|
int num = 0; /* number of tokens scanned by scanf */
|
||||||
|
char saved_char = p[len];
|
||||||
|
|
||||||
|
p[len] = 0; /* null-terminate the token */
|
||||||
if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
|
if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
|
||||||
sscanf (p, "%g", &putithere->typed_val_float.dval);
|
num = sscanf (p, "%g%c", &putithere->typed_val_float.dval,&c);
|
||||||
else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
|
else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
|
||||||
sscanf (p, "%lg", &putithere->typed_val_float.dval);
|
num = sscanf (p, "%lg%c", &putithere->typed_val_float.dval,&c);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef PRINTF_HAS_LONG_DOUBLE
|
#ifdef PRINTF_HAS_LONG_DOUBLE
|
||||||
sscanf (p, "%Lg", &putithere->typed_val_float.dval);
|
num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval,&c);
|
||||||
#else
|
#else
|
||||||
/* Scan it into a double, then assign it to the long double.
|
/* Scan it into a double, then assign it to the long double.
|
||||||
This at least wins with values representable in the range
|
This at least wins with values representable in the range
|
||||||
of doubles. */
|
of doubles. */
|
||||||
double temp;
|
double temp;
|
||||||
sscanf (p, "%lg", &temp);
|
num = sscanf (p, "%lg%c", &temp,&c);
|
||||||
putithere->typed_val_float.dval = temp;
|
putithere->typed_val_float.dval = temp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
p[len] = saved_char; /* restore the input stream */
|
||||||
|
if (num != 1) /* check scanf found ONLY a float ... */
|
||||||
|
return ERROR;
|
||||||
/* See if it has `f' or `l' suffix (float or long double). */
|
/* See if it has `f' or `l' suffix (float or long double). */
|
||||||
|
|
||||||
c = tolower (p[len - 1]);
|
c = tolower (p[len - 1]);
|
||||||
|
|
|
@ -646,25 +646,31 @@ parse_number (p, len, parsed_float, putithere)
|
||||||
if (parsed_float)
|
if (parsed_float)
|
||||||
{
|
{
|
||||||
/* It's a float since it contains a point or an exponent. */
|
/* It's a float since it contains a point or an exponent. */
|
||||||
|
char c;
|
||||||
|
int num = 0; /* number of tokens scanned by scanf */
|
||||||
|
char saved_char = p[len];
|
||||||
|
|
||||||
|
p[len] = 0; /* null-terminate the token */
|
||||||
if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
|
if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
|
||||||
sscanf (p, "%g", &putithere->typed_val_float.dval);
|
num = sscanf (p, "%g%c", &putithere->typed_val_float.dval, &c);
|
||||||
else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
|
else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
|
||||||
sscanf (p, "%lg", &putithere->typed_val_float.dval);
|
num = sscanf (p, "%lg%c", &putithere->typed_val_float.dval, &c);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef PRINTF_HAS_LONG_DOUBLE
|
#ifdef PRINTF_HAS_LONG_DOUBLE
|
||||||
sscanf (p, "%Lg", &putithere->typed_val_float.dval);
|
num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval, &c);
|
||||||
#else
|
#else
|
||||||
/* Scan it into a double, then assign it to the long double.
|
/* Scan it into a double, then assign it to the long double.
|
||||||
This at least wins with values representable in the range
|
This at least wins with values representable in the range
|
||||||
of doubles. */
|
of doubles. */
|
||||||
double temp;
|
double temp;
|
||||||
sscanf (p, "%lg", &temp);
|
num = sscanf (p, "%lg%c", &temp, &c);
|
||||||
putithere->typed_val_float.dval = temp;
|
putithere->typed_val_float.dval = temp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
p[len] = saved_char; /* restore the input stream */
|
||||||
|
if (num != 1) /* check scanf found ONLY a float ... */
|
||||||
|
return ERROR;
|
||||||
/* See if it has `f' or `d' suffix (float or double). */
|
/* See if it has `f' or `d' suffix (float or double). */
|
||||||
|
|
||||||
c = tolower (p[len - 1]);
|
c = tolower (p[len - 1]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue