diff options
author | ragge <ragge> | 2008-08-18 20:50:43 +0000 |
---|---|---|
committer | ragge <ragge> | 2008-08-18 20:50:43 +0000 |
commit | 0436aa8f1a8704855615bd2da09d1b31f5713240 (patch) | |
tree | eac5d262db7c8af0dc2defc818e2d6aea163d9f2 | |
parent | 6119f24fb84d991d1a2e78ccc90212315188e2d8 (diff) |
Fix bug causing an identifier with the same name as a function-like macro
to be moved to the beginning of next line if it is last on the previous.
-rw-r--r-- | cpp.c | 48 |
1 files changed, 22 insertions, 26 deletions
@@ -969,8 +969,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)); /* @@ -996,40 +996,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 { |