escape properly the file names in #line for printer/destructor

Reported by Jannick.
http://lists.gnu.org/archive/html/bug-bison/2017-05/msg00001.html

"Amusingly" enough, we have the same problem with %defines when the
parser file name has backslashes or quotes: we generate #includes with
an incorrect C string.

* src/output.c (prepare_symbol_definitions): Escape properly the file
names before passing them to M4.
* data/bison.m4, data/lalr1.cc: Don't simply put the file name between
two quotes (that should have been strong enough a smell...), expect
the string to be properly quoted.
* tests/synclines.at: New tests to check this.
This commit is contained in:
Akim Demaille
2018-08-18 09:59:48 +02:00
parent cb4e7ecefa
commit adf0425d11
6 changed files with 101 additions and 3 deletions

6
NEWS
View File

@@ -86,6 +86,12 @@ GNU Bison NEWS
were issued with #lines in the middle of C code.
*** Printer and destructor with broken #line directives
The #line directives were not properly escaped when emitting the code for
%printer/%destructor, which resulted in compiler errors if there are
backslashes or double-quotes in the grammar file name.
* Noteworthy changes in release 3.0.5 (2018-05-27) [stable]
** Bug fixes