fixed bug, added -o option
authoreck <none@none>
Tue, 31 Oct 1989 10:02:48 +0000 (10:02 +0000)
committereck <none@none>
Tue, 31 Oct 1989 10:02:48 +0000 (10:02 +0000)
lang/cem/cpp.ansi/Makefile
lang/cem/cpp.ansi/domacro.c
lang/cem/cpp.ansi/options.c
lang/cem/cpp.ansi/preprocess.c
lang/cem/cpp.ansi/replace.c

index dfdb839..117964c 100644 (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
index 1d19ec0..e844d99 100644 (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");
        }
index cb83406..736078e 100644 (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;
index fdd6f7c..50f78db 100644 (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();
index 6177b7f..7cd3d57 100644 (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.
                */