summaryrefslogtreecommitdiff
path: root/usr.bin/pcc/cpp/cpp.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/pcc/cpp/cpp.c')
-rw-r--r--usr.bin/pcc/cpp/cpp.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/usr.bin/pcc/cpp/cpp.c b/usr.bin/pcc/cpp/cpp.c
index 3e435aca41b..928aa375f02 100644
--- a/usr.bin/pcc/cpp/cpp.c
+++ b/usr.bin/pcc/cpp/cpp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpp.c,v 1.10 2008/08/17 18:40:13 ragge Exp $ */
+/* $OpenBSD: cpp.c,v 1.11 2008/08/18 20:54:10 ragge Exp $ */
/*
* Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se).
@@ -965,8 +965,8 @@ struct symtab *sp;
struct recur *rp;
{
struct recur rp2;
- register usch *vp, *cp;
- int c, rv = 0, ws;
+ register usch *vp, *cp, *obp;
+ int c, nl;
DPRINT(("subst: %s\n", sp->namep));
/*
@@ -992,40 +992,36 @@ struct recur *rp;
/* should we be here at all? */
/* check if identifier is followed by parentheses */
- rv = 1;
- ws = 0;
+
+ obp = stringbuf;
+ nl = 0;
do {
- c = yylex();
+ c = cinput();
+ *stringbuf++ = c;
if (c == WARN) {
gotwarn++;
if (rp == NULL)
- goto noid;
- } else if (c == WSPACE || c == '\n')
- ws = 1;
- } while (c == WSPACE || c == '\n' || c == WARN);
-
- cp = (usch *)yytext;
- while (*cp)
- cp++;
- while (cp > (usch *)yytext)
- cunput(*--cp);
+ break;
+ }
+ if (c == '\n')
+ nl++;
+ } while (c == ' ' || c == '\t' || c == '\n' ||
+ c == '\r' || c == WARN);
+
DPRINT(("c %d\n", c));
if (c == '(' ) {
+ cunput(c);
+ stringbuf = obp;
+ ifiles->lineno += nl;
expdef(vp, &rp2, gotwarn);
- return rv;
+ return 1;
} else {
- /* restore identifier */
-noid: while (gotwarn--)
- cunput(WARN);
- if (ws)
- cunput(' ');
- cp = sp->namep;
- while (*cp)
- cp++;
- while (cp > sp->namep)
- cunput(*--cp);
+ *stringbuf = 0;
+ unpstr(obp);
+ unpstr(sp->namep);
if ((c = yylex()) != IDENT)
error("internal sync error");
+ stringbuf = obp;
return 0;
}
} else {