diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-09-20 19:34:41 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-09-20 19:34:41 +0000 |
commit | fd2824d2bbeedc38b905242d622256c8043184c0 (patch) | |
tree | 69a63a65e5616a532ee6e86b4959f65b8d74f9ea | |
parent | de097d4de987b995212d6eaaebe5e180afbf6967 (diff) |
Fix a case where cpp is not includeing when it is supposed to, beause
it uses a pointer into yytext, which may have been clobbered.
Patch also in ragge's repo.
-rw-r--r-- | usr.bin/pcc/cc/cpp/cpp.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/pcc/cc/cpp/cpp.c b/usr.bin/pcc/cc/cpp/cpp.c index 4833140f38f..f4fc03bff5f 100644 --- a/usr.bin/pcc/cc/cpp/cpp.c +++ b/usr.bin/pcc/cc/cpp/cpp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpp.c,v 1.6 2007/09/18 07:16:01 otto Exp $ */ +/* $OpenBSD: cpp.c,v 1.7 2007/09/20 19:34:40 otto Exp $ */ /* * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). @@ -448,7 +448,7 @@ include() struct incs *w; struct symtab *nl; usch *osp; - usch *fn; + usch *fn, *safefn; int i, c, it; if (flslvl) @@ -482,6 +482,7 @@ again: if (c != '\n') goto bad; it = SYSINC; + safefn = fn; } else { usch *nm = stringbuf; @@ -497,6 +498,7 @@ again: else stringbuf++; } + safefn = stringbuf; savstr(fn); savch(0); while ((c = yylex()) == WSPACE) ; @@ -505,7 +507,7 @@ again: slow = 0; if (pushfile(nm) == 0) return; - stringbuf = nm; + /* XXX may loose stringbuf space */ } /* create search path and try to open file */ @@ -515,13 +517,13 @@ again: usch *nm = stringbuf; savstr(w->dir); savch('/'); - savstr(fn); savch(0); + savstr(safefn); savch(0); if (pushfile(nm) == 0) return; stringbuf = nm; } } - error("cannot find '%s'", fn); + error("cannot find '%s'", safefn); /* error() do not return */ bad: error("bad include"); |