]> git.saurik.com Git - bison.git/blobdiff - src/output.c
Merge remote-tracking branch 'origin/maint'
[bison.git] / src / output.c
index 76895d661471269e81fe757ffa4b10282b8c06f5..4fe11ccb79cc7bcbf3365aeda8758f69323ae5d2 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <concat-filename.h>
 #include <configmake.h>
-#include <error.h>
 #include <filename.h>
 #include <get-errno.h>
 #include <quotearg.h>
@@ -403,9 +402,16 @@ prepare_symbol_definitions (void)
       const char *key;
       const char *value;
 
-#define SET_KEY(Entry)                                                  \
-      obstack_fgrow2 (&format_obstack, "symbol(%d, %s)", i, Entry);     \
-      obstack_1grow (&format_obstack, 0);                               \
+#define SET_KEY(Entry)                                          \
+      obstack_fgrow2 (&format_obstack, "symbol(%d, %s)",        \
+                      i, Entry);                                \
+      obstack_1grow (&format_obstack, 0);                       \
+      key = obstack_finish (&format_obstack);
+
+#define SET_KEY2(Entry, Suffix)                                 \
+      obstack_fgrow3 (&format_obstack, "symbol(%d, %s_%s)",     \
+                      i, Entry, Suffix);                        \
+      obstack_1grow (&format_obstack, 0);                       \
       key = obstack_finish (&format_obstack);
 
       // Whether the symbol has an identifier.
@@ -437,28 +443,30 @@ prepare_symbol_definitions (void)
       SET_KEY("type");
       MUSCLE_INSERT_STRING (key, sym->type_name ? sym->type_name : "");
 
-#define CODE_PROP(PropName)                                             \
-      do {                                                              \
-        code_props const *p = symbol_ ## PropName ## _get (sym);        \
-        SET_KEY("has_" #PropName);                                      \
-        MUSCLE_INSERT_INT (key, !!p->code);                             \
-                                                                        \
-        if (p->code)                                                    \
-          {                                                             \
-            SET_KEY(#PropName "_file");                                 \
-            MUSCLE_INSERT_STRING (key, p->location.start.file);         \
-                                                                        \
-            SET_KEY(#PropName "_line");                                 \
-            MUSCLE_INSERT_INT (key, p->location.start.line);            \
-                                                                        \
-            SET_KEY(#PropName);                                         \
-            MUSCLE_INSERT_STRING_RAW (key, p->code);                    \
-          }                                                             \
-      } while (0)
-
-      CODE_PROP(destructor);
-      CODE_PROP(printer);
-#undef CODE_PROP
+      {
+        int j;
+        for (j = 0; j < CODE_PROPS_SIZE; ++j)
+          {
+            /* "printer", not "%printer".  */
+            char const *pname = code_props_type_string (j) + 1;
+            code_props const *p = symbol_code_props_get (sym, j);
+            SET_KEY2("has", pname);
+            MUSCLE_INSERT_INT (key, !!p->code);
+
+            if (p->code)
+              {
+                SET_KEY2(pname, "file");
+                MUSCLE_INSERT_STRING (key, p->location.start.file);
+
+                SET_KEY2(pname, "line");
+                MUSCLE_INSERT_INT (key, p->location.start.line);
+
+                SET_KEY(pname);
+                MUSCLE_INSERT_STRING_RAW (key, p->code);
+              }
+          }
+      }
+#undef SET_KEY2
 #undef SET_KEY
     }
 }
@@ -579,8 +587,8 @@ output_skeleton (void)
   char *m4sugar = xconcatenated_filename (datadir, "m4sugar/m4sugar.m4", NULL);
   char *m4bison = xconcatenated_filename (datadir, "bison.m4", NULL);
   char *skel = (IS_PATH_WITH_DIR (skeleton)
-               ? xstrdup (skeleton)
-               : xconcatenated_filename (datadir, skeleton, NULL));
+                ? xstrdup (skeleton)
+                : xconcatenated_filename (datadir, skeleton, NULL));
 
   /* Test whether m4sugar.m4 is readable, to check for proper
      installation.  A faulty installation can cause deadlock, so a