Thu May 21 13:14:25 1998 John Metzler <jmetzler@cygnus.com>
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index a70691fce97fc96dc02562fbf0ea83fb82bff038..7316ae8a1b9d3276aa1cbddc1c52713932e7cfdb 100644 (file)
@@ -298,15 +298,6 @@ exp        :       exp '.' name
                          write_exp_elt_opcode (STRUCTOP_STRUCT); }
        ;
 
-/* start-sanitize-gm
-Need to find a better way to do this...
-exp    :       exp '@' name
-                       { write_exp_elt_opcode (STRUCTOP_FIELD);
-                         write_exp_string ($3);
-                         write_exp_elt_opcode (STRUCTOP_FIELD);
-                       }
- end-sanitize-gm */
-
 exp    :       exp '.' qualified_name
                        { /* exp.type::name becomes exp.*(&type::name) */
                          /* Note: this doesn't work if name is a
@@ -933,28 +924,32 @@ parse_number (p, len, parsed_float, putithere)
 
   if (parsed_float)
     {
-      char c;
-
       /* 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))
-       sscanf (p, "%g", &putithere->typed_val_float.dval);
+       num = sscanf (p, "%g%c", (float *) &putithere->typed_val_float.dval,&c);
       else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
-       sscanf (p, "%lg", &putithere->typed_val_float.dval);
+       num = sscanf (p, "%lg%c", (double *) &putithere->typed_val_float.dval,&c);
       else
        {
-#ifdef PRINTF_HAS_LONG_DOUBLE
-         sscanf (p, "%Lg", &putithere->typed_val_float.dval);
+#ifdef SCANF_HAS_LONG_DOUBLE
+         num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval,&c);
 #else
          /* Scan it into a double, then assign it to the long double.
             This at least wins with values representable in the range
             of doubles. */
          double temp;
-         sscanf (p, "%lg", &temp);
+         num = sscanf (p, "%lg%c", &temp,&c);
          putithere->typed_val_float.dval = temp;
 #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).  */
 
       c = tolower (p[len - 1]);
This page took 0.023948 seconds and 4 git commands to generate.