From ccb3ac8a121682a5fc5fd767f80872ef3e5c7b47 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 27 Jul 2008 01:58:01 +0000 Subject: gdb: PR gdb/1136: * macroexp.c (get_punctuator) : Rearrange to put longer tokens first. gdb/testsuite: * gdb.base/macscp.exp: Add test for macro lexing bug. --- gdb/macroexp.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'gdb/macroexp.c') diff --git a/gdb/macroexp.c b/gdb/macroexp.c index 0cb9575..8102bc0 100644 --- a/gdb/macroexp.c +++ b/gdb/macroexp.c @@ -416,16 +416,27 @@ get_punctuator (struct macro_buffer *tok, char *p, char *end) { /* Here, speed is much less important than correctness and clarity. */ - /* ISO/IEC 9899:1999 (E) Section 6.4.6 Paragraph 1 */ + /* ISO/IEC 9899:1999 (E) Section 6.4.6 Paragraph 1. + Note that this table is ordered in a special way. A punctuator + which is a prefix of another punctuator must appear after its + "extension". Otherwise, the wrong token will be returned. */ static const char * const punctuators[] = { - "[", "]", "(", ")", "{", "}", ".", "->", - "++", "--", "&", "*", "+", "-", "~", "!", - "/", "%", "<<", ">>", "<", ">", "<=", ">=", "==", "!=", - "^", "|", "&&", "||", - "?", ":", ";", "...", - "=", "*=", "/=", "%=", "+=", "-=", "<<=", ">>=", "&=", "^=", "|=", - ",", "#", "##", - "<:", ":>", "<%", "%>", "%:", "%:%:", + "[", "]", "(", ")", "{", "}", "?", ";", ",", "~", + "...", ".", + "->", "--", "-=", "-", + "++", "+=", "+", + "*=", "*", + "!=", "!", + "&&", "&=", "&", + "/=", "/", + "%>", "%:%:", "%:", "%=", "%", + "^=", "^", + "##", "#", + ":>", ":", + "||", "|=", "|", + "<<=", "<<", "<=", "<:", "<%", "<", + ">>=", ">>", ">=", ">", + "==", "=", 0 }; -- cgit v1.1