From: eck Date: Tue, 31 Oct 1989 10:02:48 +0000 (+0000) Subject: fixed bug, added -o option X-Git-Tag: release-5-5~2124 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=bdbbf32404562af2fb423b35bccd1e3284136a77;p=ack.git fixed bug, added -o option --- diff --git a/lang/cem/cpp.ansi/Makefile b/lang/cem/cpp.ansi/Makefile index dfdb83986..117964cc4 100644 --- a/lang/cem/cpp.ansi/Makefile +++ b/lang/cem/cpp.ansi/Makefile @@ -77,7 +77,7 @@ GENERATED = tokenfile.g Lpars.h LLfiles LL.output lint.out \ all: cc cc: hfiles LLfiles - make "EMHOME="$(EMHOME) ncpp + make "EMHOME="$(EMHOME) "CC="$(CC) ncpp hfiles: Parameters char.c ./make.hfiles Parameters diff --git a/lang/cem/cpp.ansi/domacro.c b/lang/cem/cpp.ansi/domacro.c index 1d19ec0d4..e844d99c8 100644 --- a/lang/cem/cpp.ansi/domacro.c +++ b/lang/cem/cpp.ansi/domacro.c @@ -23,6 +23,7 @@ #include "macro.h" #include "bits.h" +extern char options[]; extern char **inctable; /* list of include directories */ extern char *getwdir(); char ifstack[IFDEPTH]; /* if-stack: the content of an entry is */ @@ -225,8 +226,10 @@ int to_endif; error("#else after #else"); ++(ifstack[nestlevel]); if (!to_endif && nestlevel == skiplevel) { - if (SkipToNewLine(1)) - strict("garbage following #else"); + if (SkipToNewLine(1)) { + if (!options['o']) + strict("garbage following #else"); + } NoUnstack--; return; } @@ -235,8 +238,10 @@ int to_endif; case K_ENDIF: assert(nestlevel > svnestlevel[nestcount]); if (nestlevel == skiplevel) { - if (SkipToNewLine(1)) - strict("garbage following #endif"); + if (SkipToNewLine(1)) { + if (!options['o']) + strict("garbage following #endif"); + } nestlevel--; NoUnstack--; return; @@ -377,8 +382,10 @@ do_elif() do_else() { - if (SkipToNewLine(1)) - strict("garbage following #else"); + if (SkipToNewLine(1)) { + if (!options['o']) + strict("garbage following #else"); + } if (nestlevel <= svnestlevel[nestcount]) error("#else without corresponding #if"); else { /* mark this level as else-d */ @@ -392,8 +399,10 @@ do_else() do_endif() { - if (SkipToNewLine(1)) - strict("garbage following #endif"); + if (SkipToNewLine(1)) { + if (!options['o']) + strict("garbage following #endif"); + } if (nestlevel <= svnestlevel[nestcount]) { error("#endif without corresponding #if"); } diff --git a/lang/cem/cpp.ansi/options.c b/lang/cem/cpp.ansi/options.c index cb83406c6..736078e14 100644 --- a/lang/cem/cpp.ansi/options.c +++ b/lang/cem/cpp.ansi/options.c @@ -31,6 +31,9 @@ do_option(text) default: error("illegal option: %c", text[-1]); break; + case 'o': /* ignore garbage after #else or #endif */ + options['o'] = 1; + break; case 'C' : /* comment output */ options['C'] = 1; break; diff --git a/lang/cem/cpp.ansi/preprocess.c b/lang/cem/cpp.ansi/preprocess.c index fdd6f7ca3..50f78db97 100644 --- a/lang/cem/cpp.ansi/preprocess.c +++ b/lang/cem/cpp.ansi/preprocess.c @@ -205,12 +205,16 @@ preprocess(fn) continue; } case STNUM: + /* The following code is quit ugly. This because + * ..3 == . .3 , whereas ...3 == ... 3 + */ echo(c); if (c == '.') { c = GetChar(); if (c == '.') { if ((c = GetChar()) == '.') { echo('.'); echo('.'); + c = GetChar(); continue; } UnGetChar(); diff --git a/lang/cem/cpp.ansi/replace.c b/lang/cem/cpp.ansi/replace.c index 6177b7fbf..7cd3d574c 100644 --- a/lang/cem/cpp.ansi/replace.c +++ b/lang/cem/cpp.ansi/replace.c @@ -532,7 +532,7 @@ macro2buffer(repl, idf, args) replacement list. */ if (repl->r_ptr == repl->r_text - && is_wsp(*repl->r_text)) { + && is_wsp(*repl->r_ptr)) { err = 1; break; } @@ -590,7 +590,7 @@ macro2buffer(repl, idf, args) assert(n > 0); /* This is VERY dirty, we look ahead for the - ## operater. If it's found we use the raw + ## operator. If it's found we use the raw argument buffer instead of the expanded one. */