Also recognize 'defined' without parentheses
authorceriel <none@none>
Wed, 25 Oct 1989 14:23:08 +0000 (14:23 +0000)
committerceriel <none@none>
Wed, 25 Oct 1989 14:23:08 +0000 (14:23 +0000)
lang/cem/cemcom/domacro.c
lang/cem/cemcom/replace.c
util/cpp/domacro.c
util/cpp/replace.c

index 4e080f0..d427d51 100644 (file)
@@ -34,7 +34,7 @@ PRIVATE char ifstack[IFDEPTH];        /* if-stack: the content of an entry is */
 
 int    nestlevel = -1;
 
-PRIVATE struct idf *
+struct idf *
 GetIdentifier()
 {
        /*      returns a pointer to the descriptor of the identifier that is
index 1aed93c..d1d577f 100644 (file)
@@ -69,19 +69,32 @@ replace(idef)
                        return 0;
                }
                LoadChar(c);
-               c = skipspaces(c,1);
+               c = skipspaces(c,! (mac->mc_flag & FUNC));
                if (c != '(') {         /* no replacement if no ()      */
-                       lexerror("(warning) macro %s needs arguments",
-                               idef->id_text);
                        PushBack();
-                       return 0;
+                       if (! (mac->mc_flag & FUNC)) {
+                               lexerror("(warning) macro %s needs arguments",
+                                       idef->id_text);
+                               return 0;
+                       }
                }
-               actpars = getactuals(idef);     /* get act.param. list  */
                if (mac->mc_flag & FUNC) {
-                       struct idf *param = str2idf(*actpars);
-
+                       struct idf *param;
+                       extern struct idf *GetIdentifier();
+
+                       UnknownIdIsZero = 0;
+                       param = GetIdentifier();
+                       UnknownIdIsZero = 1;
+                       if (c == '(') {
+                               LoadChar(c);
+                               c = skipspaces(c,0);
+                               if (c != ')') error(") missing");
+                       }
+                       if (! param) {
+                               error("identifier missing");
+                       }
                        repl = new_mlist();
-                       if (param->id_macro) 
+                       if (param && param->id_macro) 
                                reptext = "1";
                        else
                                reptext = "0";
@@ -93,6 +106,7 @@ replace(idef)
                        repl->m_mac = mac;
                        return 1;
                }
+               actpars = getactuals(idef);     /* get act.param. list  */
        }
        repl = new_mlist();
        repl->m_mac = mac;
index fc57ab3..63b9901 100644 (file)
@@ -34,7 +34,7 @@ int nestlevel = -1;
 int svnestlevel[30] = {-1};
 int nestcount;
 
-PRIVATE char *
+char *
 GetIdentifier()
 {
        /*      returns a pointer to the descriptor of the identifier that is
index 4c53203..a8bccb1 100644 (file)
@@ -65,17 +65,30 @@ replace(idef)
                        return 0;
                }
                LoadChar(c);
-               c = skipspaces(c,1);
+               c = skipspaces(c,! (mac->mc_flag & FUNC));
                if (c != '(') {         /* no replacement if no ()      */
-                       warning("macro %s needs arguments",
-                               idef->id_text);
                        PushBack();
-                       return 0;
+                       if (! (mac->mc_flag & FUNC)) {
+                               warning("macro %s needs arguments",
+                                       idef->id_text);
+                               return 0;
+                       }
                }
-               actpars = getactuals(idef);     /* get act.param. list  */
                if (mac->mc_flag & FUNC) {
-                       struct idf *param = findidf(*actpars);
-
+                       struct idf *param;
+                       extern struct idf *GetIdentifier();
+
+                       UnknownIdIsZero = 0;
+                       param = GetIdentifier();
+                       UnknownIdIsZero = 1;
+                       if (c == '(') {
+                               LoadChar(c);
+                               c = skipspaces(c, 0);
+                               if (c != ')') error(") missing");
+                       }
+                       if (! param) {
+                               error("identifier missing");
+                       }
                        repl = new_mlist();
                        if (param && param->id_macro) 
                                reptext = "1";
@@ -90,6 +103,7 @@ replace(idef)
                        repl->m_mac = mac;
                        return 1;
                }
+               actpars = getactuals(idef);     /* get act.param. list  */
        }
 
        repl = new_mlist();