diff options
author | Doug Evans <dje@google.com> | 2010-08-19 13:33:15 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2010-08-19 13:33:15 +0000 |
commit | d30f5e1f70ffa9fab08ccdacdba1bd6365d2511d (patch) | |
tree | a578156b090268842ed34a2a077d2eb6b6519cd2 /gdb/jv-exp.y | |
parent | 2837d59e6b7e523fee86a5a5a050ecb5554ccd1b (diff) | |
download | gdb-d30f5e1f70ffa9fab08ccdacdba1bd6365d2511d.zip gdb-d30f5e1f70ffa9fab08ccdacdba1bd6365d2511d.tar.gz gdb-d30f5e1f70ffa9fab08ccdacdba1bd6365d2511d.tar.bz2 |
PR exp/11926
* parser-defs.h (parse_float, parse_c_float): Declare.
* parse.c (parse_float, parse_c_float): New function.
* c-exp.y (parse_number): Call parse_c_float.
* objc-exp.y (parse_number): Ditto.
* p-exp.y (parse_number): Ditto. Use ANSI/ISO-style definition.
* jv-exp.y (parse_number): Call parse_float, fix suffix handling.
testsuite/
* gdb.base/printcmds.exp (test_float_accepted): New function.
Move existing float tests there. Add tests for floats with suffixes.
(test_float_rejected): New function.
* gdb.java/jv-print.exp (test_float_accepted): New function.
(test_float_rejected): New function.
* gdb.objc/print.exp: New file.
* gdb.pascal/print.exp: New file.
* lib/objc.exp: New file.
Diffstat (limited to 'gdb/jv-exp.y')
-rw-r--r-- | gdb/jv-exp.y | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y index 8109e0c..678a434 100644 --- a/gdb/jv-exp.y +++ b/gdb/jv-exp.y @@ -703,25 +703,28 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere) if (parsed_float) { - /* 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 */ - num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c", - &putithere->typed_val_float.dval, &c); - p[len] = saved_char; /* restore the input stream */ - if (num != 1) /* check scanf found ONLY a float ... */ + const char *suffix; + int suffix_len; + + if (! parse_float (p, len, &putithere->typed_val_float.dval, &suffix)) return ERROR; - /* See if it has `f' or `d' suffix (float or double). */ - c = tolower (p[len - 1]); + suffix_len = p + len - suffix; - if (c == 'f' || c == 'F') - putithere->typed_val_float.type = parse_type->builtin_float; - else if (isdigit (c) || c == '.' || c == 'd' || c == 'D') + if (suffix_len == 0) putithere->typed_val_float.type = parse_type->builtin_double; + else if (suffix_len == 1) + { + /* See if it has `f' or `d' suffix (float or double). */ + if (tolower (*suffix) == 'f') + putithere->typed_val_float.type = + parse_type->builtin_float; + else if (tolower (*suffix) == 'd') + putithere->typed_val_float.type = + parse_type->builtin_double; + else + return ERROR; + } else return ERROR; |