diff options
author | Bosco Garc?a <jbgg.gnu@gmail.com> | 2019-08-22 12:54:06 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2019-08-22 12:54:06 +0100 |
commit | a3197745b1edfd711e345b7c94c68be85eb11e48 (patch) | |
tree | c277a5d5c856563d1cd4d64a2e76ce9c5418b0d6 /gas/atof-generic.c | |
parent | 43771869e5021b6bdc02b6eaae103a33c05a821c (diff) | |
download | gdb-a3197745b1edfd711e345b7c94c68be85eb11e48.zip gdb-a3197745b1edfd711e345b7c94c68be85eb11e48.tar.gz gdb-a3197745b1edfd711e345b7c94c68be85eb11e48.tar.bz2 |
Fix the assembler's floating point number parser so that it can correctly handle numbers encoded as a leading decimal point, followed by zeroes, followed by a non-zero sequence.
* atof-generic.c (atof_generic): Do not ignore leading zeros if
they appear after a decimal point.
* testsuite/gas/all/float.s: Extend test to include a number with
a leading decimal point followed by several zeroes.
* testsuite/gas/i386/fp.s: Likewise.
* testsuite/gas/i386/fp.d: Update expected output.
Diffstat (limited to 'gas/atof-generic.c')
-rw-r--r-- | gas/atof-generic.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/gas/atof-generic.c b/gas/atof-generic.c index 40ee910..345ccef 100644 --- a/gas/atof-generic.c +++ b/gas/atof-generic.c @@ -184,23 +184,42 @@ atof_generic (/* return pointer to just AFTER number we read. */ #ifndef OLD_FLOAT_READS /* Ignore trailing 0's after the decimal point. The original code here - * (ifdef'd out) does not do this, and numbers like - * 4.29496729600000000000e+09 (2**31) - * come out inexact for some reason related to length of the digit - * string. - */ + (ifdef'd out) does not do this, and numbers like + 4.29496729600000000000e+09 (2**31) + come out inexact for some reason related to length of the digit + string. */ + + /* The case number_of_digits_before_decimal = 0 is handled for + deleting zeros after decimal. In this case the decimal mark and + the first zero digits after decimal mark are skipped. */ + seen_significant_digit = 0; + signed long subtract_decimal_exponent = 0; + if (c && IS_DECIMAL_MARK (c)) { - unsigned int zeros = 0; /* Length of current string of zeros */ + unsigned int zeros = 0; /* Length of current string of zeros. */ + + if (number_of_digits_before_decimal == 0) + /* Skip decimal mark. */ + first_digit++; for (p++; (c = *p) && ISDIGIT (c); p++) { if (c == '0') { - zeros++; + if (number_of_digits_before_decimal == 0 + && !seen_significant_digit) + { + /* Skip '0' and the decimal mark. */ + first_digit++; + subtract_decimal_exponent--; + } + else + zeros++; } else { + seen_significant_digit = 1; number_of_digits_after_decimal += 1 + zeros; zeros = 0; } @@ -287,6 +306,12 @@ atof_generic (/* return pointer to just AFTER number we read. */ } } +#ifndef OLD_FLOAT_READS + /* Subtract_decimal_exponent != 0 when number_of_digits_before_decimal = 0 + and first digit after decimal is '0'. */ + decimal_exponent += subtract_decimal_exponent; +#endif + *address_of_string_pointer = p; number_of_digits_available = |