warnings: don't complain about m4_foo and b4_foo when from the user

Currently, occurrences of these identifiers in the user's input yield
spurious warnings.

To tell the difference between a legitimate m4_foo from the user, and
a bad m4_foo coming from a non-evaluated macro of a skeleton, escape
the user's identifiers as m4@'_foo.  We already use @' as a special
sequence to be stripped from the skeleton's output.

See <https://lists.gnu.org/r/bug-bison/2021-10/msg00026.html> and
previous commit ("warnings: be less picky about occurrences of m4_/b4_
in the output").

* src/flex-scanner.h (OBSTACK_SGROW): New.
* src/output.c (output_escaped): Escape m4_ and b4_.
* src/scan-code.l: Likewise.
* src/system.h (obstack_escape): Likewise.
And rewrite as a function.
* tests/skeletons.at (Suspicious sequences): Make sure the user can
use m4_foo/b4_foo without spurious warnings.
This commit is contained in:
Akim Demaille
2021-11-07 09:27:52 +01:00
parent c95d0dd5f5
commit 6571c2d1b1
6 changed files with 94 additions and 25 deletions

View File

@@ -197,6 +197,9 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
<*>
{
"b4_" STRING_SGROW ("b4@'_");
"m4_" STRING_SGROW ("m4@'_");
/* Escape M4 quoting characters in C code. */
[$@\[\]] obstack_escape (&obstack_for_string, yytext);