summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorragge <ragge>2009-08-08 07:25:53 +0000
committerragge <ragge>2009-08-08 07:25:53 +0000
commitac70bf447306c8a27768e6a509a2612b618257f7 (patch)
tree86a41294e1ab72ad74a351d0987f165e37c38e1a
parentcd8b090362cccd068c74f35b6ea5fa5daae8f111 (diff)
Must accept identifiers beginning with a digit in macro expansion, so that
macro replacement of concatenated strings work. Actually this fix also solved a long-standing problem. Fixes Jira#PCC-69 by Jonathan Gray.
-rw-r--r--cpp.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/cpp.c b/cpp.c
index 6b08c92..8e6c370 100644
--- a/cpp.c
+++ b/cpp.c
@@ -1070,6 +1070,18 @@ struct recur *rp;
}
/*
+ * Maybe an indentifier (for macro expansion).
+ */
+static int
+mayid(usch *s)
+{
+ for (; *s; s++)
+ if (!isdigit(*s) && !isalpha(*s) && *s != '_')
+ return 0;
+ return 1;
+}
+
+/*
* do macro-expansion until WARN character read.
* read from lex buffer and store result on heap.
* will recurse into lookup() for recursive expansion.
@@ -1098,6 +1110,10 @@ expmac(struct recur *rp)
case NOEXP: noexp++; break;
case EXPAND: noexp--; break;
+ case NUMBER: /* handled as ident if no .+- in it */
+ if (!mayid((usch *)yytext))
+ goto def;
+ /* FALLTHROUGH */
case IDENT:
/*
* Handle argument concatenation here.
@@ -1120,7 +1136,8 @@ expmac(struct recur *rp)
DDPRINT(("id1: typ %d noexp %d orgexp %d\n",
c, noexp, orgexp));
- if (c == IDENT) { /* XXX numbers? */
+ if (c == IDENT ||
+ (c == NUMBER && mayid((usch *)yytext))) {
DDPRINT(("id2: str %s\n", yytext));
/* OK to always expand here? */
savstr((usch *)yytext);