]> git.saurik.com Git - bison.git/blobdiff - src/output.c
--help: include a place to report translation issues
[bison.git] / src / output.c
index e157460d0863be63828f601f7ba9968733776ab9..e77a2d1a0fc85a75d6f6bec202d96351778dfef2 100644 (file)
@@ -70,7 +70,7 @@ Name (char const *name,                                                       \
   int i;                                                               \
   int j = 1;                                                           \
                                                                        \
-  obstack_fgrow1 (&format_obstack, "%6d", first);                      \
+  obstack_printf (&format_obstack, "%6d", first);                      \
   for (i = begin; i < end; ++i)                                                \
     {                                                                  \
       obstack_1grow (&format_obstack, ',');                            \
@@ -81,7 +81,7 @@ Name (char const *name,                                                       \
        }                                                               \
       else                                                             \
        ++j;                                                            \
-      obstack_fgrow1 (&format_obstack, "%6d", table_data[i]);          \
+      obstack_printf (&format_obstack, "%6d", table_data[i]);          \
       if (table_data[i] < min)                                         \
        min = table_data[i];                                            \
       if (max < table_data[i])                                         \
@@ -93,10 +93,10 @@ Name (char const *name,                                                     \
   lmin = min;                                                          \
   lmax = max;                                                          \
   /* Build `NAME_min' and `NAME_max' in the obstack. */                        \
-  obstack_fgrow1 (&format_obstack, "%s_min", name);                    \
+  obstack_printf (&format_obstack, "%s_min", name);                    \
   obstack_1grow (&format_obstack, 0);                                  \
   MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin);     \
-  obstack_fgrow1 (&format_obstack, "%s_max", name);                    \
+  obstack_printf (&format_obstack, "%s_max", name);                    \
   obstack_1grow (&format_obstack, 0);                                  \
   MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax);     \
 }
@@ -110,29 +110,39 @@ GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_item_number_table, item_number)
 GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
 
 
-/*--------------------------------------------------------------------.
-| Print to OUT a representation of STRING escaped both for C and M4.  |
-`--------------------------------------------------------------------*/
+/*----------------------------------------------------------------.
+| Print to OUT a representation of CP quoted and escaped for M4.  |
+`----------------------------------------------------------------*/
 
 static void
-escaped_output (FILE *out, char const *string)
+quoted_output (FILE *out, char const *cp)
 {
-  char const *p;
   fprintf (out, "[[");
 
-  for (p = quotearg_style (c_quoting_style, string); *p; p++)
-    switch (*p)
+  for (; *cp; cp++)
+    switch (*cp)
       {
       case '$': fputs ("$][", out); break;
       case '@': fputs ("@@",  out); break;
       case '[': fputs ("@{",  out); break;
       case ']': fputs ("@}",  out); break;
-      default: fputc (*p, out); break;
+      default:  fputc (*cp,   out); break;
       }
 
   fprintf (out, "]]");
 }
 
+/*----------------------------------------------------------------.
+| Print to OUT a representation of STRING quoted and escaped both |
+| for C and M4.                                                   |
+`----------------------------------------------------------------*/
+
+static void
+string_output (FILE *out, char const *string)
+{
+  quoted_output (out, quotearg_style (c_quoting_style, string));
+}
+
 
 /*------------------------------------------------------------------.
 | Prepare the muscles related to the symbols: translate, tname, and |
@@ -299,7 +309,7 @@ user_actions_output (FILE *out)
       {
        fprintf (out, "b4_case(%d, [b4_syncline(%d, ", r + 1,
                 rules[r].action_location.start.line);
-       escaped_output (out, rules[r].action_location.start.file);
+       string_output (out, rules[r].action_location.start.file);
        fprintf (out, ")\n[    %s]])\n\n", rules[r].action);
       }
   fputs ("])\n\n", out);
@@ -405,12 +415,15 @@ symbol_code_props_output (FILE *out, char const *what,
              code, optional typename.  */
           fprintf (out, "%s[", sep);
           sep = ",\n";
-          escaped_output (out, loc.start.file);
+          string_output (out, loc.start.file);
           fprintf (out, ", %d, ", loc.start.line);
-          escaped_output (out, sym->tag);
+          quoted_output (out, sym->tag);
           fprintf (out, ", %d, [[%s]]", sym->number, code);
           if (sym->type_name)
-            fprintf (out, ", [[%s]]", sym->type_name);
+            {
+              fputs (", ", out);
+              quoted_output (out, sym->type_name);
+            }
           fputc (']', out);
         }
     }