From: Akim Demaille Date: Mon, 17 Dec 2001 17:31:10 +0000 (+0000) Subject: * src/files.c (output_files): Free the output_obstack. X-Git-Tag: before-m4-back-end~119 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/64d15509b6b63eb620a6f8ab5c4c9cc4ffaaa304 * src/files.c (output_files): Free the output_obstack. * src/main.c (main): Call print and print_graph conditionally. * src/print.c (print): Work unconditionally. * src/print_graph.c (print_graph): Work unconditionally. * src/conflicts.c (log_resolution): Output only if verbose_flag. --- diff --git a/ChangeLog b/ChangeLog index 411d2313..7323c624 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-12-17 Akim Demaille + + * src/files.c (output_files): Free the output_obstack. + * src/main.c (main): Call print and print_graph conditionally. + * src/print.c (print): Work unconditionally. + * src/print_graph.c (print_graph): Work unconditionally. + * src/conflicts.c (log_resolution): Output only if verbose_flag. + 2001-12-16 Marc Autret * src/output.c (actions_output): Fix. When we use %no-lines, diff --git a/src/conflicts.c b/src/conflicts.c index 6542c943..c3dd8394 100644 --- a/src/conflicts.c +++ b/src/conflicts.c @@ -40,10 +40,11 @@ static unsigned *lookaheadset = NULL; static inline void log_resolution (int state, int LAno, int token, char *resolution) { - obstack_fgrow4 (&output_obstack, - _("\ + if (verbose_flag) + obstack_fgrow4 (&output_obstack, + _("\ Conflict in state %d between rule %d and token %s resolved as %s.\n"), - state, LAruleno[LAno], tags[token], resolution); + state, LAruleno[LAno], tags[token], resolution); } diff --git a/src/files.c b/src/files.c index 726ec917..b6fed391 100644 --- a/src/files.c +++ b/src/files.c @@ -489,12 +489,13 @@ output_files (void) char *temp_name; obstack_save (&attrs_obstack, attrsfile); - obstack_free (&attrs_obstack, NULL); temp_name = stringappend (short_base_name, EXT_GUARD_C); #ifndef MSDOS temp_name = stringappend (temp_name, src_extension); #endif /* MSDOS */ obstack_save (&guard_obstack, temp_name); - obstack_free (&guard_obstack, NULL); } + + obstack_free (&guard_obstack, NULL); + obstack_free (&attrs_obstack, NULL); } diff --git a/src/main.c b/src/main.c index 1a3911d2..f53228e6 100644 --- a/src/main.c +++ b/src/main.c @@ -93,10 +93,12 @@ main (int argc, char *argv[]) exit (1); /* Output the detailed report on the grammar. */ - print_results (); + if (verbose_flag) + print_results (); /* Output the VCG graph. */ - print_graph (); + if (graph_flag) + print_graph (); /* Output the tables and the parser to ftable. In file output. */ output (); diff --git a/src/print.c b/src/print.c index 0a2d0209..d7d04eab 100644 --- a/src/print.c +++ b/src/print.c @@ -307,35 +307,33 @@ print_grammar (FILE *out) void print_results (void) { - if (verbose_flag) - { - int i; + int i; - /* We used to use just .out if SPEC_NAME_PREFIX (-p) was used, but - that conflicts with Posix. */ - FILE *out = xfopen (spec_verbose_file, "w"); + /* We used to use just .out if SPEC_NAME_PREFIX (-p) was used, but + that conflicts with Posix. */ + FILE *out = xfopen (spec_verbose_file, "w"); - size_t size = obstack_object_size (&output_obstack); - fwrite (obstack_finish (&output_obstack), 1, size, out); - if (size) - fputs ("\n\n", out); + size_t size = obstack_object_size (&output_obstack); + fwrite (obstack_finish (&output_obstack), 1, size, out); + obstack_free (&output_obstack, NULL); - reduce_output (out); - conflicts_output (out); + if (size) + fputs ("\n\n", out); - print_grammar (out); + reduce_output (out); + conflicts_output (out); - /* New experimental feature: output all the items of a state, - not only its kernel. Requires to run closure, which need - memory allocation/deallocation. */ - if (trace_flag) - new_closure (nitems); - for (i = 0; i < nstates; i++) - print_state (out, i); - if (trace_flag) - free_closure (); + print_grammar (out); - xfclose (out); - } - obstack_free (&output_obstack, NULL); + /* New experimental feature: output all the items of a state, + not only its kernel. Requires to run closure, which need + memory allocation/deallocation. */ + if (trace_flag) + new_closure (nitems); + for (i = 0; i < nstates; i++) + print_state (out, i); + if (trace_flag) + free_closure (); + + xfclose (out); } diff --git a/src/print_graph.c b/src/print_graph.c index 5045ed0f..d187480c 100644 --- a/src/print_graph.c +++ b/src/print_graph.c @@ -207,9 +207,6 @@ print_graph (void) { int i; - if (!graph_flag) - return; - /* Output file. */ fgraph = xfopen (spec_graph_file, "w");