case '9':
{
/* It's a number. */
- int got_dot = 0, got_e = 0, toktype;
+ int got_dot = 0, got_e = 0, got_p = 0, toktype;
const char *p = tokstart;
int hex = input_radix > 10;
/* This test includes !hex because 'e' is a valid hex digit
and thus does not indicate a floating point number when
the radix is hex. */
- if (!hex && !got_e && (*p == 'e' || *p == 'E'))
+ if (!hex && !got_e && !got_p && (*p == 'e' || *p == 'E'))
got_dot = got_e = 1;
+ else if (!got_e && !got_p && (*p == 'p' || *p == 'P'))
+ got_dot = got_p = 1;
/* This test does not include !hex, because a '.' always indicates
a decimal floating point number regardless of the radix. */
else if (!got_dot && *p == '.')
got_dot = 1;
- else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
+ else if (((got_e && (p[-1] == 'e' || p[-1] == 'E'))
+ || (got_p && (p[-1] == 'p' || p[-1] == 'P')))
&& (*p == '-' || *p == '+'))
/* This is the sign of the exponent, not the end of the
number. */
break;
}
toktype = parse_number (par_state, tokstart, p - tokstart,
- got_dot|got_e, &yylval);
+ got_dot | got_e | got_p, &yylval);
if (toktype == ERROR)
{
char *err_copy = (char *) alloca (p - tokstart + 1);
gdb_test "p 1.5l" " = 1.5"
# Test hexadecimal floating point.
- set test "p 0x1.1"
- gdb_test_multiple $test $test {
- -re " = 1\\.0625\r\n$gdb_prompt $" {
- pass $test
- }
- -re "Invalid number \"0x1\\.1\"\\.\r\n$gdb_prompt $" {
- # Older glibc does not support hex float, newer does.
- xfail $test
- }
+ foreach {num result} {
+ 0x1.1 1.0625
+ 0x1.8480000000000p+6 97.125
+ 0x1.8480000000000p6 97.125
+ 0x00.1p0 0.0625
+ 0x00.1p1 0.125
+ 0x00.1p-1 0.03125
+ } {
+ gdb_test "p $num" " = [string_to_regexp $result]"
}
}