From d30f5e1f70ffa9fab08ccdacdba1bd6365d2511d Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Thu, 19 Aug 2010 13:33:15 +0000 Subject: 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. --- gdb/p-exp.y | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'gdb/p-exp.y') diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 2aec487..19f5ceb 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -791,11 +791,7 @@ name_not_typename : NAME /*** Needs some error checking for the float case ***/ static int -parse_number (p, len, parsed_float, putithere) - char *p; - int len; - int parsed_float; - YYSTYPE *putithere; +parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere) { /* FIXME: Shouldn't these be unsigned? We don't deal with negative values here, and we do kind of silly things like cast to unsigned. */ @@ -820,30 +816,10 @@ parse_number (p, len, parsed_float, 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 ... */ + if (! parse_c_float (parse_gdbarch, p, len, + &putithere->typed_val_float.dval, + &putithere->typed_val_float.type)) return ERROR; - /* See if it has `f' or `l' suffix (float or long double). */ - - c = tolower (p[len - 1]); - - if (c == 'f') - putithere->typed_val_float.type = parse_type->builtin_float; - else if (c == 'l') - putithere->typed_val_float.type = parse_type->builtin_long_double; - else if (isdigit (c) || c == '.') - putithere->typed_val_float.type = parse_type->builtin_double; - else - return ERROR; - return FLOAT; } -- cgit v1.1