some fixes, f.i. process # in actual parameter list
authorceriel <none@none>
Thu, 12 Oct 1989 11:16:02 +0000 (11:16 +0000)
committerceriel <none@none>
Thu, 12 Oct 1989 11:16:02 +0000 (11:16 +0000)
util/cpp/preprocess.c
util/cpp/replace.c
util/cpp/skip.c

index 38a3cd7..20dbaee 100644 (file)
@@ -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 # */
index af8c3df..4c53203 100644 (file)
@@ -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;
index 42a6697..de2be7e 100644 (file)
@@ -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;
        }
 }