From 17c8aaf5078f15d4cd621a5428a82080a7f4c516 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 12 Dec 2008 17:03:37 +0000 Subject: [PATCH] gdb * macroexp.c (get_pp_number): Require digit after leading ".". Correctly handle suffixes. gdb/testsuite * gdb.base/macscp.exp: New regression test. --- gdb/ChangeLog | 5 +++++ gdb/macroexp.c | 18 ++++++++++-------- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.base/macscp.exp | 8 ++++++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9a1956911ed..1b31438ccf4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2008-12-11 Tom Tromey + + * macroexp.c (get_pp_number): Require digit after leading ".". + Correctly handle suffixes. + 2008-12-11 Tom Tromey * macrocmd.c (macro_define_command): Skip whitespace after diff --git a/gdb/macroexp.c b/gdb/macroexp.c index 7fb23ce65b3..dda3592db31 100644 --- a/gdb/macroexp.c +++ b/gdb/macroexp.c @@ -278,20 +278,22 @@ get_pp_number (struct macro_buffer *tok, char *p, char *end) { if (p < end && (macro_is_digit (*p) - || *p == '.')) + || (*p == '.' + && p + 2 <= end + && macro_is_digit (p[1])))) { char *tok_start = p; while (p < end) { - if (macro_is_digit (*p) - || macro_is_identifier_nondigit (*p) - || *p == '.') - p++; - else if (p + 2 <= end - && strchr ("eEpP.", *p) - && (p[1] == '+' || p[1] == '-')) + if (p + 2 <= end + && strchr ("eEpP", *p) + && (p[1] == '+' || p[1] == '-')) p += 2; + else if (macro_is_digit (*p) + || macro_is_identifier_nondigit (*p) + || *p == '.') + p++; else break; } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index cc5e3655bce..71f97129236 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-12-11 Tom Tromey + + * gdb.base/macscp.exp: New regression test. + 2008-12-11 Tom Tromey * gdb.base/macscp.exp: Print "address.addr". diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp index f7553a5c986..b6d6016dba5 100644 --- a/gdb/testsuite/gdb.base/macscp.exp +++ b/gdb/testsuite/gdb.base/macscp.exp @@ -656,3 +656,11 @@ gdb_test "print str(maude)" \ gdb_test "print xstr(maude)" \ " = \"5\"" \ "stringify with substitution" + +# Regression test for pp-number bug. +gdb_test "macro define si_addr fields.fault.si_addr" \ + "" \ + "define si_addr macro" +gdb_test "macro expand siginfo.si_addr" \ + "expands to: siginfo.fields.fault.si_addr" \ + "macro expand siginfo.si_addr" -- 2.30.2