grammars: fix display of nul character in error message

Reported by Marc Mendiola.
http://lists.gnu.org/archive/html/help-bison/2012-10/msg00017.html

* gnulib: Update to get quote_mem.
* src/scan-gram.l: Use it.
* tests/input.at (Invalid inputs): Additional checks.
* tests/named-refs.at: Likewise.
This commit is contained in:
Akim Demaille
2012-11-01 13:47:12 +01:00
parent baf0bd6145
commit 95066e9208
5 changed files with 28 additions and 13 deletions

2
NEWS
View File

@@ -14,6 +14,8 @@ GNU Bison NEWS
Other issues in the test suite have been addressed. Other issues in the test suite have been addressed.
Nul characters are correctly displayed in error messages.
* Noteworthy changes in release 2.6.4 (2012-10-23) [stable] * Noteworthy changes in release 2.6.4 (2012-10-23) [stable]
Bison 2.6.3's --version was incorrect. This release fixes this issue. Bison 2.6.3's --version was incorrect. This release fixes this issue.

1
THANKS
View File

@@ -64,6 +64,7 @@ Laurent Mascherpa laurent.mascherpa@epita.fr
Lie Yan lie.yan@kaust.edu.sa Lie Yan lie.yan@kaust.edu.sa
Magnus Fromreide magfr@lysator.liu.se Magnus Fromreide magfr@lysator.liu.se
Marc Autret autret_m@epita.fr Marc Autret autret_m@epita.fr
Marc Mendiola mmendiol@usc.edu
Martin Jacobs martin.jacobs@arcor.de Martin Jacobs martin.jacobs@arcor.de
Martin Mokrejs mmokrejs@natur.cuni.cz Martin Mokrejs mmokrejs@natur.cuni.cz
Martin Nylin martin.nylin@linuxmail.org Martin Nylin martin.nylin@linuxmail.org

View File

@@ -291,7 +291,7 @@ splice (\\[ \f\t\v]*\n)*
} }
. { . {
complain_at (*loc, _("invalid character: %s"), quote (yytext)); complain_at (*loc, _("invalid character: %s"), quote_mem (yytext, yyleng));
} }
<<EOF>> { <<EOF>> {
@@ -375,7 +375,7 @@ splice (\\[ \f\t\v]*\n)*
} }
. { . {
complain_at (*loc, _("invalid character in bracketed name: %s"), complain_at (*loc, _("invalid character in bracketed name: %s"),
quote (yytext)); quote_mem (yytext, yyleng));
} }
<<EOF>> { <<EOF>> {
BEGIN bracketed_id_context_state; BEGIN bracketed_id_context_state;

View File

@@ -27,7 +27,8 @@ AT_BANNER([[Input Processing.]])
AT_SETUP([Invalid inputs]) AT_SETUP([Invalid inputs])
AT_DATA([input.y], AT_DATA([input.y],
[[%% [[\000\001\002\377?
%%
? ?
default: 'a' } default: 'a' }
%& %&
@@ -35,17 +36,23 @@ default: 'a' }
%- %-
%{ %{
]]) ]])
AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' input.y || exit 77]])
AT_BISON_CHECK([input.y], [1], [], AT_BISON_CHECK([input.y], [1], [],
[[input.y:2.1: invalid character: '?' [[input.y:1.1: invalid character: '\0'
input.y:3.14: invalid character: '}' input.y:1.1: invalid character: '\001'
input.y:4.1: invalid character: '%' input.y:1.1: invalid character: '\002'
input.y:4.2: invalid character: '&' input.y:1.1: invalid character: '\377'
input.y:5.1-17: invalid directive: '%a-does-not-exist' input.y:1.2: invalid character: '?'
input.y:6.1: invalid character: '%' input.y:3.1: invalid character: '?'
input.y:6.2: invalid character: '-' input.y:4.14: invalid character: '}'
input.y:7.1-8.0: missing '%}' at end of file input.y:5.1: invalid character: '%'
input.y:7.1-8.0: syntax error, unexpected %{...%} input.y:5.2: invalid character: '&'
input.y:6.1-17: invalid directive: '%a-does-not-exist'
input.y:7.1: invalid character: '%'
input.y:7.2: invalid character: '-'
input.y:8.1-9.0: missing '%}' at end of file
input.y:8.1-9.0: syntax error, unexpected %{...%}
]]) ]])
AT_CLEANUP AT_CLEANUP

View File

@@ -443,14 +443,19 @@ AT_SETUP([Stray symbols in brackets])
AT_DATA_GRAMMAR([test.y], AT_DATA_GRAMMAR([test.y],
[[ [[
%% %%
start: foo[ /* aaa */ *&-.+ ] bar start: foo[ /* aaa */ *&-.+\000\001\002\377 ] bar
{ s = $foo; } { s = $foo; }
]]) ]])
AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' test.y || exit 77]])
AT_BISON_CHECK([-o test.c test.y], 1, [], AT_BISON_CHECK([-o test.c test.y], 1, [],
[[test.y:11.23: invalid character in bracketed name: '*' [[test.y:11.23: invalid character in bracketed name: '*'
test.y:11.24: invalid character in bracketed name: '&' test.y:11.24: invalid character in bracketed name: '&'
test.y:11.25: invalid character in bracketed name: '-' test.y:11.25: invalid character in bracketed name: '-'
test.y:11.27: invalid character in bracketed name: '+' test.y:11.27: invalid character in bracketed name: '+'
test.y:11.28: invalid character in bracketed name: '\0'
test.y:11.28: invalid character in bracketed name: '\001'
test.y:11.28: invalid character in bracketed name: '\002'
test.y:11.28: invalid character in bracketed name: '\377'
]]) ]])
AT_CLEANUP AT_CLEANUP