Skip to content

Commit

Permalink
muscles: fix handling of the "@'" escape
Browse files Browse the repository at this point in the history
When we use `b4_` or `m4_` somewhere in the input, it is escaped as
`b4@'_`/`m4@'_` so that the warning about unexpanded b4_foo/m4_foo
macros does not fire.

But in the case of muscles, the `@'` escape was not recognized, and an
assertion was triggered.

Reported by Han Zheng.
<#91>

* src/muscle-tab.c (COMMON_DECODE): Handle `@'`.
* tests/skeletons.at (Suspicious sequences): Check that case.
  • Loading branch information
akimd committed Sep 4, 2022
1 parent eb83487 commit 6376364
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/muscle-tab.c
Expand Up @@ -294,10 +294,11 @@ muscle_location_grow (char const *key, location loc)
case '@': \
switch (*++(Value)) \
{ \
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
default: aver (false); break; \
case '\'': /* Ignore "@'" */ break; \
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
default: aver (false); break; \
} \
break; \
default: \
Expand Down
15 changes: 15 additions & 0 deletions tests/skeletons.at
Expand Up @@ -369,5 +369,20 @@ AT_BISON_CHECK([[input1.y]], [], [],
input1.tab.c:13: warning: suspicious sequence in the output: m4@&t@_poison [-Wother]
]])

# Regression test for <https://github.com/akimd/bison/issues/91>.
AT_DATA([[input2.y]],
[[%define parse.trace {m4@&t@_foo}
%debug
%%
exp:
]])

AT_BISON_CHECK([[input2.y]], [1], [],
[[input2.y:1.1-28: warning: %define variable 'parse.trace' requires keyword values [-Wdeprecated]
input2.y:1.1-28: error: invalid value for %define Boolean variable 'parse.trace'
input2.y:2.1-6: error: %define variable 'parse.trace' redefined
input2.y:1.1-28: note: previous definition
input2.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]])

AT_CLEANUP

0 comments on commit 6376364

Please sign in to comment.