From 05ac60f348b722ec6157cf57c31d8165466ec3ec Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Mar 2005 06:41:39 +0000 Subject: [PATCH] * src/output.c (escaped_output): Renamed from escaped_file_name_output, since we now use it for symbol tags as well. All uses changed. (symbol_destructors_output, symbol_printers_output): Escape symbol tags too. Problem reported by Matyas Forstner in . * src/muscle_tab.c (muscle_code_grow): Don't quote numbers; it's not needed. * src/output.c (user_actions_output, token_definitions_output, symbol_destructors_output, symbol_printers_output): Likewise. * src/reader.c (prologue_augment): Likewise. * src/scan-gram.l (handle_action_dollar, handle_action_at): Likewise. --- ChangeLog | 22 +++++++++++++++++++++- src/muscle_tab.c | 5 +++-- src/output.c | 38 +++++++++++++++++--------------------- src/reader.c | 6 +++--- src/scan-gram.l | 8 ++++---- 5 files changed, 48 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa5787c6..e894e202 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2005-03-06 Paul Eggert + + * src/output.c (escaped_output): Renamed from + escaped_file_name_output, since we now use it for symbol tags as + well. All uses changed. + (symbol_destructors_output, symbol_printers_output): + Escape symbol tags too. + Problem reported by Matyas Forstner in + . + + * src/muscle_tab.c (muscle_code_grow): Don't quote numbers; it's + not needed. + * src/output.c (user_actions_output, token_definitions_output, + symbol_destructors_output, symbol_printers_output): Likewise. + * src/reader.c (prologue_augment): Likewise. + * src/scan-gram.l (handle_action_dollar, handle_action_at): Likewise. + + * src/vcg.c (output_edge): Don't quote linestyle arg. + Problem reported by twlevo@xs4all.nl. + 2005-02-28 Paul Eggert * doc/bison.texinfo (Semantic Tokens): Fix scoping problem in @@ -13160,7 +13180,7 @@ ----- Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, -1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/src/muscle_tab.c b/src/muscle_tab.c index c1f675b9..93d44cc9 100644 --- a/src/muscle_tab.c +++ b/src/muscle_tab.c @@ -1,6 +1,7 @@ /* Muscle table manager for Bison. - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -163,7 +164,7 @@ void muscle_code_grow (const char *key, const char *val, location loc) { char *extension = NULL; - obstack_fgrow1 (&muscle_obstack, "]b4_syncline([[%d]], [[", loc.start.line); + obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line); MUSCLE_OBSTACK_SGROW (&muscle_obstack, quotearg_style (c_quoting_style, loc.start.file)); obstack_sgrow (&muscle_obstack, "]])[\n"); diff --git a/src/output.c b/src/output.c index 55a3d47e..2278784e 100644 --- a/src/output.c +++ b/src/output.c @@ -1,6 +1,6 @@ /* Output the generated parsing program for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004 + Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -113,17 +113,17 @@ 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 FILENAME escaped both for C and M4. | -`----------------------------------------------------------------------*/ +/*--------------------------------------------------------------------. +| Print to OUT a representation of STRING escaped both for C and M4. | +`--------------------------------------------------------------------*/ static void -escaped_file_name_output (FILE *out, char const *filename) +escaped_output (FILE *out, char const *string) { char const *p; fprintf (out, "[["); - for (p = quotearg_style (c_quoting_style, filename); *p; p++) + for (p = quotearg_style (c_quoting_style, string); *p; p++) switch (*p) { case '$': fputs ("$][", out); break; @@ -300,9 +300,9 @@ user_actions_output (FILE *out) { fprintf (out, " case %d:\n", r + 1); - fprintf (out, "]b4_syncline([[%d]], ", + fprintf (out, "]b4_syncline(%d, ", rules[r].action_location.start.line); - escaped_file_name_output (out, rules[r].action_location.start.file); + escaped_output (out, rules[r].action_location.start.file); fprintf (out, ")[\n"); fprintf (out, " %s\n break;\n\n", rules[r].action); @@ -375,7 +375,7 @@ token_definitions_output (FILE *out) if (strchr (sym->tag, '.') || strchr (sym->tag, '$')) continue; - fprintf (out, "%s[[[%s]], [%d]]", + fprintf (out, "%s[[[%s]], %d]", sep, sym->tag, number); sep = ",\n"; } @@ -404,12 +404,10 @@ symbol_destructors_output (FILE *out) destructor, optional typename. */ fprintf (out, "%s[", sep); sep = ",\n"; - escaped_file_name_output (out, sym->destructor_location.start.file); - fprintf (out, ", [[%d]], [[%s]], [[%d]], [[%s]]", - sym->destructor_location.start.line, - sym->tag, - sym->number, - sym->destructor); + escaped_output (out, sym->destructor_location.start.file); + fprintf (out, ", %d, ", sym->destructor_location.start.line); + escaped_output (out, sym->tag); + fprintf (out, ", %d, [[%s]]", sym->number, sym->destructor); if (sym->type_name) fprintf (out, ", [[%s]]", sym->type_name); fputc (']', out); @@ -439,12 +437,10 @@ symbol_printers_output (FILE *out) printer, optional typename. */ fprintf (out, "%s[", sep); sep = ",\n"; - escaped_file_name_output (out, sym->printer_location.start.file); - fprintf (out, ", [[%d]], [[%s]], [[%d]], [[%s]]", - sym->printer_location.start.line, - sym->tag, - sym->number, - sym->printer); + escaped_output (out, sym->printer_location.start.file); + fprintf (out, ", %d, ", sym->printer_location.start.line); + escaped_output (out, sym->tag); + fprintf (out, ", %d, [[%s]]", sym->number, sym->printer); if (sym->type_name) fprintf (out, ", [[%s]]", sym->type_name); fputc (']', out); diff --git a/src/reader.c b/src/reader.c index e7016b23..b6200c91 100644 --- a/src/reader.c +++ b/src/reader.c @@ -1,7 +1,7 @@ /* Input parser for Bison - Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000, 2001, 2002, 2003, + 2005 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -74,7 +74,7 @@ prologue_augment (const char *prologue, location loc) struct obstack *oout = !typed ? &pre_prologue_obstack : &post_prologue_obstack; - obstack_fgrow1 (oout, "]b4_syncline([[%d]], [[", loc.start.line); + obstack_fgrow1 (oout, "]b4_syncline(%d, [[", loc.start.line); MUSCLE_OBSTACK_SGROW (oout, quotearg_style (c_quoting_style, loc.start.file)); obstack_sgrow (oout, "]])[\n"); diff --git a/src/scan-gram.l b/src/scan-gram.l index 7541bf9f..adf97616 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -1,6 +1,6 @@ /* Bison Grammar Scanner -*- C -*- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -413,7 +413,7 @@ splice (\\[ \f\t\v]*\n)* unsigned long int c = strtoul (yytext + 1, 0, 8); if (UCHAR_MAX < c) complain_at (*loc, _("invalid escape sequence: %s"), quote (yytext)); - else if (! c) + else if (! c) complain_at (*loc, _("invalid null character: %s"), quote (yytext)); else obstack_1grow (&obstack_for_string, c); @@ -805,7 +805,7 @@ handle_action_dollar (char *text, location loc) if (!type_name) type_name = ""; obstack_fgrow3 (&obstack_for_string, - "]b4_rhs_value([%d], [%d], [%s])[", + "]b4_rhs_value(%d, %d, [%s])[", rule_length, n, type_name); } else @@ -874,7 +874,7 @@ handle_action_at (char *text, location loc) if (INT_MIN <= num && num <= rule_length && ! get_errno ()) { int n = num; - obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location([%d], [%d])[", + obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[", rule_length, n); } else -- 2.47.2