diff options
author | Akim Demaille <akim@lrde.epita.fr> | 2012-12-03 15:59:57 +0100 |
---|---|---|
committer | Akim Demaille <akim@lrde.epita.fr> | 2012-12-03 15:59:57 +0100 |
commit | 03dbf629d54bab4b5903f35c881bb240511d1f39 (patch) | |
tree | d79fe6ca3869c1eb397a61b7007b044bcdf46ac6 /src/scan-gram.l | |
parent | 1c7ec959b1dddfbf594d5b76572e4b473c055be2 (diff) | |
download | bison-03dbf629d54bab4b5903f35c881bb240511d1f39.tar.gz |
parser: accept #line NUM
* src/scan-gram.l (scanner): Accept '#line NUM'.
(handle_syncline): Adjust to the possible missing file name.
Diffstat (limited to 'src/scan-gram.l')
-rw-r--r-- | src/scan-gram.l | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/scan-gram.l b/src/scan-gram.l index fd6458fa..5e78cb9b 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -157,7 +157,7 @@ splice (\\[ \f\t\v]*\n)* /* #line directives are not documented, and may be withdrawn or modified in future versions of Bison. */ - ^"#line "{int}" \"".*"\"\n" { + ^"#line "{int}(" \"".*"\"")?"\n" { handle_syncline (yytext + sizeof "#line " - 1, *loc); } } @@ -845,23 +845,27 @@ convert_ucn_to_byte (char const *ucn) } -/*----------------------------------------------------------------. -| Handle '#line INT "FILE"'. ARGS has already skipped '#line '. | -`----------------------------------------------------------------*/ +/*---------------------------------------------------------------------. +| Handle '#line INT( "FILE")?\n'. ARGS has already skipped '#line '. | +`---------------------------------------------------------------------*/ static void handle_syncline (char *args, location loc) { - char *after_num; - unsigned long int lineno = strtoul (args, &after_num, 10); - char *file = mbschr (after_num, '"') + 1; - *mbschr (file, '"') = '\0'; + char *file; + unsigned long int lineno = strtoul (args, &file, 10); if (INT_MAX <= lineno) { warn_at (loc, _("line number overflow")); lineno = INT_MAX; } - current_file = uniqstr_new (file); + + file = mbschr (file, '"'); + if (file) + { + *mbschr (file + 1, '"') = '\0'; + current_file = uniqstr_new (file + 1); + } boundary_set (&scanner_cursor, current_file, lineno, 1); } |