summaryrefslogtreecommitdiff
path: root/t/yacc-line.sh
diff options
context:
space:
mode:
authorNikolai Weibull <now@bitwi.se>2012-05-16 18:16:41 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-05-16 18:26:26 +0200
commitb6359a5f310160c8a4a2e8e8c0105408412ce400 (patch)
treee1f04b788fcebfab10c74ab68e512da11eb4bd3b /t/yacc-line.sh
parent0ce63a38ab7c87502504ba7d2319886d4f4a7d15 (diff)
downloadautomake-b6359a5f310160c8a4a2e8e8c0105408412ce400.tar.gz
ylwrap: preserve subdirectories in "#line" munging
If Automake is used in non-recursive mode and one of the inputs is a yacc file, for example, "src/grammar.y", ylwrap will remove too many directories from the output file when it adjusts the paths in it. This results in #line directives referring to "grammar.y" instead of "src/grammar.y". This is a result of $input_rx simply taking all the directory components of the absolute input path and removing them. One solution is to store the path passed to ylwrap and replace $input_rx with it. This is what we do. Suggestion and initial patch (without tests) by Nikolai Weibull: <http://lists.gnu.org/archive/html/automake/2012-05/msg00013.html> Final patch by Stefano Lattarini. * lib/ylwrap ($input_sub_rx): New. When munging the #line directives, substitute '$input_rx' with it, instead of stripping it altogether. Adjust comments. * t/yacc-line.sh, t/lex-line: Adjust and extend. * NEWS, THANKS: Update. Copyright-paperwork-exempt: yes Co-authored-by: Stefano Lattarini <stefano.lattarini@gmail.com> Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't/yacc-line.sh')
-rwxr-xr-xt/yacc-line.sh28
1 files changed, 20 insertions, 8 deletions
diff --git a/t/yacc-line.sh b/t/yacc-line.sh
index 090b72b57..d12215766 100755
--- a/t/yacc-line.sh
+++ b/t/yacc-line.sh
@@ -94,18 +94,30 @@ for vpath in : false; do
# For debugging,
ls -l . sub sub/dir
- $FGREP '.y' $c_outputs
+ $EGREP 'line|\.y' $c_outputs
# Adjusted "#line" should not contain reference to the builddir.
- $EGREP '#.*line.*(build|\.\.).*\.y' $c_outputs && Exit 1
+ grep '#.*line.*build.*\.y' $c_outputs && Exit 1
+ # Adjusted "#line" should not contain reference to the absolute
+ # srcdir.
+ $EGREP '#.*line *"?/.*\.y' $c_outputs && Exit 1
# Adjusted "#line" should not contain reference to the default
# output file names, e.g., 'y.tab.c' and 'y.tab.h'.
- $EGREP '#.*line.*y\.tab\.' $c_outputs && Exit 1
- # Don't be excessively strict in grepping, to avoid spurious failures.
- grep '#.*line.*zardoz\.y' zardoz.c
- grep '#.*line.*quux\.y' bar-quux.c
- grep '#.*line.*zardoz\.y' sub/foo-zardoz.c
- grep '#.*line.*quux\.y' sub/dir/quux.c
+ grep '#.*line.*y\.tab\.' $c_outputs && Exit 1
+ # Look out for a silly regression.
+ grep "#.*\.y.*\.y" $c_outputs && Exit 1
+ if $vpath; then
+ grep '#.*line.*"\.\./zardoz\.y"' zardoz.c
+ grep '#.*line.*"\.\./dir/quux\.y"' bar-quux.c
+ grep '#.*line.*"\.\./\.\./sub/zardoz\.y"' sub/foo-zardoz.c
+ grep '#.*line.*"\.\./\.\./sub/dir/quux\.y"' sub/dir/quux.c
+ else
+ grep '#.*line.*"zardoz\.y"' zardoz.c
+ grep '#.*line.*"dir/quux\.y"' bar-quux.c
+ grep '#.*line.*"zardoz\.y"' sub/foo-zardoz.c
+ grep '#.*line.*"dir/quux\.y"' sub/dir/quux.c
+ fi
+
cd $srcdir
done