From 7255b1aa61c29d289d90c368e07ea01beb813bc6 Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 12 Oct 1989 11:16:02 +0000 Subject: [PATCH] some fixes, f.i. process # in actual parameter list --- util/cpp/preprocess.c | 6 ++++-- util/cpp/replace.c | 2 +- util/cpp/skip.c | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/util/cpp/preprocess.c b/util/cpp/preprocess.c index 38a3cd71c..20dbaee6b 100644 --- a/util/cpp/preprocess.c +++ b/util/cpp/preprocess.c @@ -81,6 +81,7 @@ preprocess(fn) for (;;) { if (c & 0200) { if (c == EOI) { + newline(); flush(op-_obuf); return; } @@ -102,6 +103,7 @@ preprocess(fn) echo(c); } else if (c == EOI) { + newline(); flush(op - _obuf); return; } @@ -149,6 +151,7 @@ preprocess(fn) break; } else if (c == EOI) { + newline(); flush(op-_obuf); return; } @@ -161,8 +164,7 @@ preprocess(fn) } else if (c == '\'') escaped = 1; } - } - while (escaped || c != stopc); + } while (escaped || c != stopc); echo(c); if (c == '\n') break; /* Don't eat # */ diff --git a/util/cpp/replace.c b/util/cpp/replace.c index af8c3df59..4c5320397 100644 --- a/util/cpp/replace.c +++ b/util/cpp/replace.c @@ -67,7 +67,7 @@ replace(idef) LoadChar(c); c = skipspaces(c,1); if (c != '(') { /* no replacement if no () */ - error("macro %s needs arguments", + warning("macro %s needs arguments", idef->id_text); PushBack(); return 0; diff --git a/util/cpp/skip.c b/util/cpp/skip.c index 42a6697a3..de2be7eb7 100644 --- a/util/cpp/skip.c +++ b/util/cpp/skip.c @@ -16,12 +16,17 @@ skipspaces(ch, skipnl) /* skipspaces() skips any white space and returns the first non-space character. */ + register int nlseen = 0; + for (;;) { - while (class(ch) == STSKIP) + while (class(ch) == STSKIP) { + nlseen = 0; LoadChar(ch); + } if (skipnl && class(ch) == STNL) { LoadChar(ch); ++LineNumber; + nlseen++; continue; } /* How about "\\\n"????????? */ @@ -36,7 +41,13 @@ skipspaces(ch, skipnl) return '/'; } } - else + else if (nlseen && ch == '#') { + domacro(); + LoadChar(ch); + /* ch is the first character of a line. This means + * that nlseen will still be true. + */ + } else return ch; } } -- 2.34.1