mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 23:33:03 +00:00
* src/main.c (main): Free `infile'.
* src/scan-gram.l (handle_syncline): New. Recognize `#line'. * src/output.c (user_actions_output, symbol_destructors_output) (symbol_printers_output): Use the location's file name, not infile. * src/reader.c (prologue_augment, epilogue_set): Likewise.
This commit is contained in:
@@ -419,5 +419,5 @@ getargs (int argc, char *argv[])
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
infile = argv[optind];
|
||||
infile = xstrdup (argv[optind]);
|
||||
}
|
||||
|
||||
@@ -158,6 +158,8 @@ main (int argc, char *argv[])
|
||||
reduce_free ();
|
||||
conflicts_free ();
|
||||
grammar_free ();
|
||||
/* FIXME: We are leaking all the other file names. */
|
||||
free (infile);
|
||||
|
||||
/* The scanner memory cannot be released right after parsing, as it
|
||||
contains things such as user actions, prologue, epilogue etc. */
|
||||
|
||||
@@ -280,7 +280,7 @@ user_actions_output (FILE *out)
|
||||
fprintf (out, muscle_find ("linef"),
|
||||
rules[r].action_location.first_line,
|
||||
quotearg_style (c_quoting_style,
|
||||
muscle_find ("filename")));
|
||||
rules[r].action_location.file));
|
||||
fprintf (out, " %s\n break;\n\n",
|
||||
rules[r].action);
|
||||
}
|
||||
@@ -381,7 +381,8 @@ symbol_destructors_output (FILE *out)
|
||||
destructor, typename. */
|
||||
fprintf (out, "%s[[[%s]], [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
|
||||
first ? "" : ",\n",
|
||||
infile, symbol->destructor_location.first_line,
|
||||
symbol->destructor_location.file,
|
||||
symbol->destructor_location.first_line,
|
||||
symbol->tag,
|
||||
symbol->number,
|
||||
symbol->destructor,
|
||||
@@ -414,7 +415,8 @@ symbol_printers_output (FILE *out)
|
||||
printer, typename. */
|
||||
fprintf (out, "%s[[[%s]], [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
|
||||
first ? "" : ",\n",
|
||||
infile, symbol->printer_location.first_line,
|
||||
symbol->printer_location.file,
|
||||
symbol->printer_location.first_line,
|
||||
symbol->tag,
|
||||
symbol->number,
|
||||
symbol->printer,
|
||||
|
||||
@@ -74,7 +74,7 @@ prologue_augment (const char *prologue, location_t location)
|
||||
obstack_fgrow2 (oout, muscle_find ("linef"),
|
||||
location.first_line,
|
||||
quotearg_style (c_quoting_style,
|
||||
muscle_find ("filename")));
|
||||
location.file));
|
||||
}
|
||||
obstack_sgrow (oout, prologue);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ epilogue_set (const char *epilogue, location_t location)
|
||||
obstack_fgrow2 (&muscle_obstack, muscle_find ("linef"),
|
||||
location.first_line,
|
||||
quotearg_style (c_quoting_style,
|
||||
muscle_find ("filename")));
|
||||
location.file));
|
||||
}
|
||||
obstack_sgrow (&muscle_obstack, epilogue);
|
||||
obstack_1grow (&muscle_obstack, 0);
|
||||
|
||||
1256
src/scan-gram.c
1256
src/scan-gram.c
File diff suppressed because it is too large
Load Diff
@@ -177,6 +177,7 @@ static void handle_dollar (braced_code_t code_kind,
|
||||
char *cp, location_t location);
|
||||
static void handle_at (braced_code_t code_kind,
|
||||
char *cp, location_t location);
|
||||
static void handle_syncline (char *args, location_t *location);
|
||||
static int convert_ucn_to_byte (char const *hex_text);
|
||||
|
||||
%}
|
||||
@@ -254,6 +255,8 @@ splice (\\[ \f\t\v]*\n)*
|
||||
YY_STEP;
|
||||
}
|
||||
|
||||
^"#line "{int}" \""[^\"]*"\"\n" handle_syncline (yytext + strlen ("#line "), yylloc); YY_STEP;
|
||||
|
||||
"=" return EQUAL;
|
||||
":" rule_length = 0; return COLON;
|
||||
"|" rule_length = 0; return PIPE;
|
||||
@@ -899,6 +902,24 @@ convert_ucn_to_byte (char const *ucn)
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------.
|
||||
| Handle `#line INT "FILE"'. ARGS has already skipped `#line '. |
|
||||
`----------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
handle_syncline (char *args, location_t *location)
|
||||
{
|
||||
int lineno = strtol (args, &args, 10);
|
||||
const char *file = NULL;
|
||||
file = strchr (args, '"') + 1;
|
||||
*strchr (file, '"') = 0;
|
||||
/* FIXME: Leaking... Can't free, as some locations are still
|
||||
pointing to the old file name. */
|
||||
infile = xstrdup (file);
|
||||
location->file = infile;
|
||||
location->last_line = lineno;
|
||||
}
|
||||
|
||||
/*-------------------------.
|
||||
| Initialize the scanner. |
|
||||
`-------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user