From: Akim Demaille <demaille@gostai.com>
Date: Tue, 12 Aug 2008 19:48:44 +0000 (+0200)
Subject: --trace=muscles
X-Git-Tag: v2.5_rc1~269
X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/c65e52923780b0b20fbb8dcb2f14d14f08163798?ds=sidebyside

--trace=muscles

	* src/getargs.h, src/getargs.c (trace_muscle): New.
	(trace_types, trace_args): Support it.
	* src/output.c (output_skeleton): Use it.
(cherry picked from commit 5263bea9f7d576c20938619af2197eb5b47a90c3)
---

diff --git a/ChangeLog b/ChangeLog
index f4c31a44..e3c305b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-10  Akim Demaille  <demaille@gostai.com>
+
+	--trace=muscles
+	* src/getargs.h, src/getargs.c (trace_muscle): New.
+	(trace_types, trace_args): Support it.
+	* src/output.c (output_skeleton): Use it.
+
 2008-11-10  Akim Demaille  <demaille@gostai.com>
 
 	muscles_output.
diff --git a/src/getargs.c b/src/getargs.c
index 9ffa4cf5..aebc2401 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -176,6 +176,7 @@ static const char * const trace_args[] =
   "grammar    - reading, reducing the grammar",
   "resource   - memory consumption (where available)",
   "sets       - grammar sets: firsts, nullable etc.",
+  "muscles    - m4 definitions passed to the skeleton",
   "tools      - m4 invocation",
   "m4         - m4 traces",
   "skeleton   - skeleton postprocessing",
@@ -194,6 +195,7 @@ static const int trace_types[] =
   trace_grammar,
   trace_resource,
   trace_sets,
+  trace_muscles,
   trace_tools,
   trace_m4,
   trace_skeleton,
diff --git a/src/getargs.h b/src/getargs.h
index 8d27e717..11390674 100644
--- a/src/getargs.h
+++ b/src/getargs.h
@@ -106,6 +106,7 @@ enum trace
     trace_time      = 1 << 8,  /**< Time consumption. */
     trace_skeleton  = 1 << 9,  /**< Skeleton postprocessing. */
     trace_m4        = 1 << 10, /**< M4 traces. */
+    trace_muscles   = 1 << 11, /**< M4 definitions of the muscles. */
     trace_all       = ~0       /**< All of the above.  */
   };
 /** What debug items bison displays during its run.  */
diff --git a/src/output.c b/src/output.c
index 7eb35185..f7251473 100644
--- a/src/output.c
+++ b/src/output.c
@@ -488,7 +488,6 @@ static void
 output_skeleton (void)
 {
   FILE *in;
-  FILE *out;
   int filter_fd[2];
   char const *argv[9];
   pid_t pid;
@@ -576,12 +575,17 @@ output_skeleton (void)
   free (full_m4bison);
   free (full_skeleton);
 
-  out = fdopen (filter_fd[0], "w");
-  if (! out)
-    error (EXIT_FAILURE, get_errno (),
-	   "fdopen");
-  muscles_output (out);
-  xfclose (out);
+
+  if (trace_flag & trace_muscles)
+    muscles_output (stderr);
+  {
+    FILE *out = fdopen (filter_fd[0], "w");
+    if (! out)
+      error (EXIT_FAILURE, get_errno (),
+             "fdopen");
+    muscles_output (out);
+    xfclose (out);
+  }
 
   /* Read and process m4's output.  */
   timevar_push (TV_M4);