fixed bug, added -o option

This commit is contained in:
eck 1989-10-31 10:02:48 +00:00
parent cccb0dd197
commit bdbbf32404
5 changed files with 27 additions and 11 deletions

View file

@ -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

View file

@ -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");
}

View file

@ -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;

View file

@ -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();

View file

@ -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.
*/