From 21930d2f4ea6ce79b5aa80f4ee028f44ca50cc0a Mon Sep 17 00:00:00 2001 From: ragge Date: Mon, 18 Aug 2008 20:54:10 +0000 Subject: [PATCH] Updates from master repo: Fix two bugs reported by Art Grabowski. --- usr.bin/pcc/cc/cc.c | 18 +++++++------- usr.bin/pcc/cpp/cpp.c | 50 ++++++++++++++++++--------------------- usr.bin/pcc/cpp/scanner.l | 11 ++++++++- 3 files changed, 43 insertions(+), 36 deletions(-) diff --git a/usr.bin/pcc/cc/cc.c b/usr.bin/pcc/cc/cc.c index 0bbe81d23f5..c03829743e2 100644 --- a/usr.bin/pcc/cc/cc.c +++ b/usr.bin/pcc/cc/cc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cc.c,v 1.14 2008/08/17 18:40:12 ragge Exp $ */ +/* $OpenBSD: cc.c,v 1.15 2008/08/18 20:54:10 ragge Exp $ */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * @@ -120,7 +120,7 @@ #define MAXOPT 100 char *tmp3; char *tmp4; -char *outfile; +char *outfile, *ermfile; char *Bprefix(char *); char *copy(char *, int),*setsuf(char *, char); int getsuf(char *); @@ -175,8 +175,8 @@ int pthreads; int xcflag; int ascpp; -char *passp = LIBEXECDIR PREPROCESSOR; -char *pass0 = LIBEXECDIR COMPILER; +char *passp = LIBEXECDIR "/" PREPROCESSOR; +char *pass0 = LIBEXECDIR "/" COMPILER; char *as = ASSEMBLER; char *ld = LINKER; char *Bflag; @@ -667,7 +667,7 @@ main(int argc, char *argv[]) if (!Eflag && !Mflag) av[na++] = tmp4; if (Eflag && outfile) - av[na++] = outfile; + ermfile = av[na++] = outfile; av[na++]=0; if (callsys(passp, av)) {exfail++; eflag++;} @@ -741,7 +741,7 @@ main(int argc, char *argv[]) else tmp3 = setsuf(clist[i], 's'); } - av[na++] = tmp3; + ermfile = av[na++] = tmp3; #if 0 if (proflag) { av[3] = "-XP"; @@ -779,9 +779,9 @@ main(int argc, char *argv[]) av[na++] = "-k"; av[na++] = "-o"; if (outfile && cflag) - av[na++] = outfile; + ermfile = av[na++] = outfile; else - av[na++] = setsuf(clist[i], 'o'); + ermfile = av[na++] = setsuf(clist[i], 'o'); av[na++] = assource; if (dflag) av[na++] = alist; @@ -973,6 +973,8 @@ dexit(int eval) cunlink(tmp3); cunlink(tmp4); } + if (exfail || eflag) + cunlink(ermfile); if (eval == 100) _exit(eval); exit(eval); 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 { diff --git a/usr.bin/pcc/cpp/scanner.l b/usr.bin/pcc/cpp/scanner.l index c22e08a54b4..c2e94b4d5b1 100644 --- a/usr.bin/pcc/cpp/scanner.l +++ b/usr.bin/pcc/cpp/scanner.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scanner.l,v 1.10 2008/08/17 18:40:13 ragge Exp $ */ +/* $OpenBSD: scanner.l,v 1.11 2008/08/18 20:54:10 ragge Exp $ */ /* * Copyright (c) 2004 Anders Magnusson. All rights reserved. @@ -313,6 +313,14 @@ L?\"(\\.|[^\\"])*\" { PRTOUT(STRING); } } . { + if (contr) { + while (input() != '\n') + ; + unput('\n'); + BEGIN 0; + contr = 0; + goto yy; + } if (YYSTATE || slow) return yytext[0]; if (yytext[0] == 6) { /* PRAGS */ @@ -327,6 +335,7 @@ L?\"(\\.|[^\\"])*\" { PRTOUT(STRING); } } else { PRTOUT(yytext[0]); } + yy:; } %% -- 2.20.1