mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 02: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:
@@ -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