From 4acc22e5cf47432cec8e196f6f1fefb43453f3b5 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 16:36:07 +0200 Subject: [PATCH 1/8] tests: do not depend on __cplusplus to decide for C++ or C output Since we do support compiling C code with a C++ compiler. * tests/actions.at (Qualified $$ in actions): Use AT_SKEL_CC_IF. --- tests/actions.at | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/actions.at b/tests/actions.at index 8232a007..1ec8ef9a 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1257,8 +1257,6 @@ AT_DATA_GRAMMAR([[input.y]], %debug %code requires { -# include - typedef struct sem_type { int ival; @@ -1267,20 +1265,21 @@ AT_DATA_GRAMMAR([[input.y]], # define YYSTYPE sem_type -#ifdef __cplusplus +]AT_SKEL_CC_IF([[ # include static void report (std::ostream& yyo, int ival, float fval) { yyo << "ival: " << ival << ", fval: " << fval; } -#else +]], [[ +# include static void report (FILE* yyo, int ival, float fval) { fprintf (yyo, "ival: %d, fval: %1.1f", ival, fval); } -#endif +]])[ } %code From 466a2de317ceac0734e25f7a8314ec9ad2735ba5 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 17:00:28 +0200 Subject: [PATCH 2/8] maint: fix some syntax-check issues * cfg.mk: Nuke the following warnings which are confused by our text reports (that state that the error token is number 256). prohibit_magic_number_exit ../../doc/bison.texi:8170:error (256) ../../tests/conflicts.at:570:error (256) ../../tests/conflicts.at:673:error (256) ../../tests/conflicts.at:811:error (256) ../../tests/conflicts.at:1154:error (256) ../../tests/regression.at:281:error (256) ../../tests/regression.at:582:error (256) maint.mk: use EXIT_* values rather than magic number --- cfg.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cfg.mk b/cfg.mk index 2f1a9e94..53855aef 100644 --- a/cfg.mk +++ b/cfg.mk @@ -65,12 +65,14 @@ exclude = \ $(call exclude, \ bindtextdomain=^lib/main.c$$ \ program_name=^lib/main.c$$ \ - prohibit_always-defined_macros=^data/yacc.c|^djgpp/ \ + prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \ prohibit_always-defined_macros+=?|^lib/timevar.c$$ \ prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \ prohibit_always-defined_macros+=?|^tests/regression.at$$ \ prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \ prohibit_empty_lines_at_EOF=^src/parse-gram.[ch]$$ \ + prohibit_magic_number_exit=^doc/bison.texi$$ \ + prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \ require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \ space_tab=^tests/(input|c\+\+)\.at$$ \ trailing_blank=^src/parse-gram.[ch]$$ \ From d35d6dd2cd153a88dd903d85882a9c190c5e607e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 30 Jul 2012 11:10:36 +0200 Subject: [PATCH 3/8] gnulib: update --- gnulib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnulib b/gnulib index dbd91449..ed4e07a0 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit dbd914496c99c52220e5f5ba4121d6cb55fb3beb +Subproject commit ed4e07a077c43052ebb60ea813698f289ba2f367 From 77b214ef4858d2c6129038f53b4a94b92aa1b6c4 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 30 Jul 2012 11:18:23 +0200 Subject: [PATCH 4/8] version 2.6.1 * NEWS: Record release date. --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b99290c9..0da5bdfa 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ GNU Bison NEWS -* Noteworthy changes in release ?.? (????-??-??) [?] +* Noteworthy changes in release 2.6.1 (2012-07-30) [stable] Bison no longer executes user-specified M4 code when processing a grammar. From 9c26b8fc03eaf0e09a5b575aceaf1bfe4860adfc Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 30 Jul 2012 11:47:29 +0200 Subject: [PATCH 5/8] maint: post-release administrivia * NEWS: Add header line for next release. * .prev-version: Record previous version. * cfg.mk (old_NEWS_hash): Auto-update. --- .prev-version | 2 +- NEWS | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.prev-version b/.prev-version index 5154b3f6..6a6a3d8e 100644 --- a/.prev-version +++ b/.prev-version @@ -1 +1 @@ -2.6 +2.6.1 diff --git a/NEWS b/NEWS index 0da5bdfa..f940d8ed 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ GNU Bison NEWS +* Noteworthy changes in release ?.? (????-??-??) [?] + + * Noteworthy changes in release 2.6.1 (2012-07-30) [stable] Bison no longer executes user-specified M4 code when processing a grammar. From 8c707b10e78cbdf9eec1d2f1f7b2a8706645c075 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 30 Jul 2012 14:53:58 +0200 Subject: [PATCH 6/8] gnulib: update --- gnulib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnulib b/gnulib index ed4e07a0..678815ea 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit ed4e07a077c43052ebb60ea813698f289ba2f367 +Subproject commit 678815ea7c4d95e04a0fa6d3b491b3c872c677a7 From dbfcf7a89f749a979031931202b432243ea712bd Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 30 Jul 2012 14:54:27 +0200 Subject: [PATCH 7/8] scanner: restore a missing start condition $ flex src/scan-skel.l src/scan-skel.l:145: multiple <> rules for start condition SC_AT_DIRECTIVE_ARGS src/scan-skel.l:145: multiple <> rules for start condition SC_AT_DIRECTIVE_SKIP_WS This is warning, and it seems there are no means to make it an error. * src/scan-skel.l: Restore the start-condition INITIAL for an <> clause. --- src/scan-skel.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scan-skel.l b/src/scan-skel.l index 862b34fd..ed61b5c8 100644 --- a/src/scan-skel.l +++ b/src/scan-skel.l @@ -91,7 +91,7 @@ static void fail_for_invalid_at (char const *at); \n out_lineno++; ECHO; [^@\n]+ ECHO; -<> { +<> { if (outname) { free (outname); From aaf63e45b65d35bb506e431ffa8360f259ee393c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 30 Jul 2012 18:05:10 +0200 Subject: [PATCH 8/8] use obstack_printf This is not just nicer, it is also much safer, since we were using sprintf... * bootstrap.conf: Require it. * src/system.h (obstack_fgrow1, obstack_fgrow2, obstack_fgrow3) (obstack_fgrow4): Remove. Adjust dependencies. --- bootstrap.conf | 5 ++++- lib/.gitignore | 1 + m4/.gitignore | 1 + src/conflicts.c | 32 ++++++++++++++++---------------- src/muscle-tab.c | 6 +++--- src/muscle-tab.h | 4 ++-- src/output.c | 8 ++++---- src/print_graph.c | 10 +++++----- src/scan-code.l | 16 ++++++++-------- src/system.h | 29 ----------------------------- 10 files changed, 44 insertions(+), 68 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index aa05e340..165d5e7d 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -24,7 +24,10 @@ gnulib_modules=' gettext git-version-gen gitlog-to-changelog gpl-3.0 hash inttypes isnan javacomp-script javaexec-script ldexpl malloc-gnu mbschr mbsrchr - mbswidth obstack perror progname + mbswidth + obstack + obstack-printf + perror progname quote quotearg readme-release realloc-posix diff --git a/lib/.gitignore b/lib/.gitignore index 5eec7430..964d7f45 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -268,3 +268,4 @@ /xmemdup0.c /xmemdup0.h /sys_types.in.h +/obstack_printf.c diff --git a/m4/.gitignore b/m4/.gitignore index 8a24eb00..797ed6df 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -179,3 +179,4 @@ /xalloc.m4 /xsize.m4 /xstrndup.m4 +/obstack-printf.m4 diff --git a/src/conflicts.c b/src/conflicts.c index 9af53a67..ba0b6ed3 100644 --- a/src/conflicts.c +++ b/src/conflicts.c @@ -73,7 +73,7 @@ log_resolution (rule *r, symbol_number token, { case shift_resolution: case right_resolution: - obstack_fgrow2 (&solved_conflicts_obstack, + obstack_printf (&solved_conflicts_obstack, _(" Conflict between rule %d and token %s" " resolved as shift"), r->number, @@ -82,7 +82,7 @@ log_resolution (rule *r, symbol_number token, case reduce_resolution: case left_resolution: - obstack_fgrow2 (&solved_conflicts_obstack, + obstack_printf (&solved_conflicts_obstack, _(" Conflict between rule %d and token %s" " resolved as reduce"), r->number, @@ -90,7 +90,7 @@ log_resolution (rule *r, symbol_number token, break; case nonassoc_resolution: - obstack_fgrow2 (&solved_conflicts_obstack, + obstack_printf (&solved_conflicts_obstack, _(" Conflict between rule %d and token %s" " resolved as an error"), r->number, @@ -102,33 +102,33 @@ log_resolution (rule *r, symbol_number token, switch (resolution) { case shift_resolution: - obstack_fgrow2 (&solved_conflicts_obstack, + obstack_printf (&solved_conflicts_obstack, " (%s < %s)", r->prec->tag, symbols[token]->tag); break; case reduce_resolution: - obstack_fgrow2 (&solved_conflicts_obstack, + obstack_printf (&solved_conflicts_obstack, " (%s < %s)", symbols[token]->tag, r->prec->tag); break; case left_resolution: - obstack_fgrow1 (&solved_conflicts_obstack, + obstack_printf (&solved_conflicts_obstack, " (%%left %s)", symbols[token]->tag); break; case right_resolution: - obstack_fgrow1 (&solved_conflicts_obstack, + obstack_printf (&solved_conflicts_obstack, " (%%right %s)", symbols[token]->tag); break; case nonassoc_resolution: - obstack_fgrow1 (&solved_conflicts_obstack, + obstack_printf (&solved_conflicts_obstack, " (%%nonassoc %s)", symbols[token]->tag); break; @@ -145,7 +145,7 @@ log_resolution (rule *r, symbol_number token, { case shift_resolution: case right_resolution: - obstack_fgrow2 (&solved_conflicts_xml_obstack, + obstack_printf (&solved_conflicts_xml_obstack, " ", r->number, @@ -154,7 +154,7 @@ log_resolution (rule *r, symbol_number token, case reduce_resolution: case left_resolution: - obstack_fgrow2 (&solved_conflicts_xml_obstack, + obstack_printf (&solved_conflicts_xml_obstack, " ", r->number, @@ -162,7 +162,7 @@ log_resolution (rule *r, symbol_number token, break; case nonassoc_resolution: - obstack_fgrow2 (&solved_conflicts_xml_obstack, + obstack_printf (&solved_conflicts_xml_obstack, " ", r->number, @@ -174,33 +174,33 @@ log_resolution (rule *r, symbol_number token, switch (resolution) { case shift_resolution: - obstack_fgrow2 (&solved_conflicts_xml_obstack, + obstack_printf (&solved_conflicts_xml_obstack, "%s < %s", xml_escape_n (0, r->prec->tag), xml_escape_n (1, symbols[token]->tag)); break; case reduce_resolution: - obstack_fgrow2 (&solved_conflicts_xml_obstack, + obstack_printf (&solved_conflicts_xml_obstack, "%s < %s", xml_escape_n (0, symbols[token]->tag), xml_escape_n (1, r->prec->tag)); break; case left_resolution: - obstack_fgrow1 (&solved_conflicts_xml_obstack, + obstack_printf (&solved_conflicts_xml_obstack, "%%left %s", xml_escape (symbols[token]->tag)); break; case right_resolution: - obstack_fgrow1 (&solved_conflicts_xml_obstack, + obstack_printf (&solved_conflicts_xml_obstack, "%%right %s", xml_escape (symbols[token]->tag)); break; case nonassoc_resolution: - obstack_fgrow1 (&solved_conflicts_xml_obstack, + obstack_printf (&solved_conflicts_xml_obstack, "%%nonassoc %s", xml_escape (symbols[token]->tag)); break; diff --git a/src/muscle-tab.c b/src/muscle-tab.c index 5c624982..bd1fd174 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -177,7 +177,7 @@ static void muscle_syncline_grow (char const *key, location loc) { char *extension = NULL; - obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line); + obstack_printf (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line); obstack_quote (&muscle_obstack, quotearg_style (c_quoting_style, loc.start.file)); obstack_sgrow (&muscle_obstack, ")["); @@ -269,9 +269,9 @@ muscle_boundary_grow (char const *key, boundary bound) obstack_sgrow (&muscle_obstack, "[["); obstack_escape (&muscle_obstack, bound.file); obstack_1grow (&muscle_obstack, ':'); - obstack_fgrow1 (&muscle_obstack, "%d", bound.line); + obstack_printf (&muscle_obstack, "%d", bound.line); obstack_1grow (&muscle_obstack, '.'); - obstack_fgrow1 (&muscle_obstack, "%d", bound.column); + obstack_printf (&muscle_obstack, "%d", bound.column); obstack_sgrow (&muscle_obstack, "]]"); obstack_1grow (&muscle_obstack, '\0'); extension = obstack_finish (&muscle_obstack); diff --git a/src/muscle-tab.h b/src/muscle-tab.h index ddbad408..696103f3 100644 --- a/src/muscle-tab.h +++ b/src/muscle-tab.h @@ -43,14 +43,14 @@ extern struct obstack muscle_obstack; #define MUSCLE_INSERT_INT(Key, Value) \ do { \ - obstack_fgrow1 (&muscle_obstack, "%d", Value); \ + obstack_printf (&muscle_obstack, "%d", Value); \ obstack_1grow (&muscle_obstack, 0); \ muscle_insert (Key, obstack_finish (&muscle_obstack)); \ } while (0) #define MUSCLE_INSERT_LONG_INT(Key, Value) \ do { \ - obstack_fgrow1 (&muscle_obstack, "%ld", Value); \ + obstack_printf (&muscle_obstack, "%ld", Value); \ obstack_1grow (&muscle_obstack, 0); \ muscle_insert (Key, obstack_finish (&muscle_obstack)); \ } while (0) diff --git a/src/output.c b/src/output.c index d52a7113..e77a2d1a 100644 --- a/src/output.c +++ b/src/output.c @@ -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); \ } diff --git a/src/print_graph.c b/src/print_graph.c index 8571e147..f5695a7a 100644 --- a/src/print_graph.c +++ b/src/print_graph.c @@ -54,7 +54,7 @@ print_core (struct obstack *oout, state *s) snritems = nitemset; } - obstack_fgrow1 (oout, "%d", s->number); + obstack_printf (oout, "%d", s->number); for (i = 0; i < snritems; i++) { item_number *sp; @@ -68,15 +68,15 @@ print_core (struct obstack *oout, state *s) r = item_number_as_rule_number (*sp); - obstack_fgrow1 (oout, "\n%s -> ", rules[r].lhs->tag); + obstack_printf (oout, "\n%s -> ", rules[r].lhs->tag); for (sp = rules[r].rhs; sp < sp1; sp++) - obstack_fgrow1 (oout, "%s ", symbols[*sp]->tag); + obstack_printf (oout, "%s ", symbols[*sp]->tag); obstack_1grow (oout, '.'); for (/* Nothing */; *sp >= 0; ++sp) - obstack_fgrow1 (oout, " %s", symbols[*sp]->tag); + obstack_printf (oout, " %s", symbols[*sp]->tag); /* Experimental feature: display the lookahead tokens. */ if (report_flag & report_lookahead_tokens @@ -95,7 +95,7 @@ print_core (struct obstack *oout, state *s) obstack_sgrow (oout, "["); BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0) { - obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag); + obstack_printf (oout, "%s%s", sep, symbols[k]->tag); sep = ", "; } obstack_sgrow (oout, "]"); diff --git a/src/scan-code.l b/src/scan-code.l index 31befe91..fa593beb 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -443,30 +443,30 @@ show_sub_messages (const char* cp, bool explicit_bracketing, /* Create the explanation message. */ obstack_init (&msg_buf); - obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at); + obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at); if (contains_dot_or_dash (id)) - obstack_fgrow1 (&msg_buf, "[%s]", id); + obstack_printf (&msg_buf, "[%s]", id); else obstack_sgrow (&msg_buf, id); obstack_sgrow (&msg_buf, tail); if (var->err & VARIANT_HIDDEN) { - obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at); + obstack_printf (&msg_buf, _(", hiding %c"), dollar_or_at); if (contains_dot_or_dash (var->id)) - obstack_fgrow1 (&msg_buf, "[%s]", var->id); + obstack_printf (&msg_buf, "[%s]", var->id); else obstack_sgrow (&msg_buf, var->id); obstack_sgrow (&msg_buf, tail); } - obstack_fgrow1 (&msg_buf, _(" at %s"), at_spec); + obstack_printf (&msg_buf, _(" at %s"), at_spec); if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE) { const char *format = _(", cannot be accessed from mid-rule action at $%d"); - obstack_fgrow1 (&msg_buf, format, midrule_rhs_index); + obstack_printf (&msg_buf, format, midrule_rhs_index); } obstack_1grow (&msg_buf, '\0'); @@ -788,7 +788,7 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) untyped_var_seen = true; } - obstack_fgrow2 (&obstack_for_string, + obstack_printf (&obstack_for_string, "]b4_rhs_value(%d, %d, ", effective_rule_length, n); obstack_quote (&obstack_for_string, type_name); obstack_sgrow (&obstack_for_string, ")["); @@ -838,7 +838,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc) break; default: - obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[", + obstack_printf (&obstack_for_string, "]b4_rhs_location(%d, %d)[", effective_rule_length, n); break; } diff --git a/src/system.h b/src/system.h index 06fd0f0a..1ae6a6b4 100644 --- a/src/system.h +++ b/src/system.h @@ -163,35 +163,6 @@ typedef size_t uintptr_t; # define obstack_sgrow(Obs, Str) \ obstack_grow (Obs, Str, strlen (Str)) -# define obstack_fgrow1(Obs, Format, Arg1) \ - do { \ - char buf[4096]; \ - sprintf (buf, Format, Arg1); \ - obstack_grow (Obs, buf, strlen (buf)); \ - } while (0) - -# define obstack_fgrow2(Obs, Format, Arg1, Arg2) \ - do { \ - char buf[4096]; \ - sprintf (buf, Format, Arg1, Arg2); \ - obstack_grow (Obs, buf, strlen (buf)); \ - } while (0) - -# define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \ - do { \ - char buf[4096]; \ - sprintf (buf, Format, Arg1, Arg2, Arg3); \ - obstack_grow (Obs, buf, strlen (buf)); \ - } while (0) - -# define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \ - do { \ - char buf[4096]; \ - sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \ - obstack_grow (Obs, buf, strlen (buf)); \ - } while (0) - - /* Output Str escaped for our postprocessing (i.e., escape M4 special characters).