summaryrefslogtreecommitdiff
path: root/cpp.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpp.c')
-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);