summaryrefslogtreecommitdiff
path: root/lib/ylwrap
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 /lib/ylwrap
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 'lib/ylwrap')
-rwxr-xr-xlib/ylwrap12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/ylwrap b/lib/ylwrap
index 8a202882f..6879d8deb 100755
--- a/lib/ylwrap
+++ b/lib/ylwrap
@@ -79,6 +79,8 @@ quote_for_sed ()
# The input.
input="$1"
shift
+# We'll later need for a correct munging of "#line" directives.
+input_sub_rx=`get_dirname "$input" | quote_for_sed`
case "$input" in
[\\/]* | ?:[\\/]*)
# Absolute path; do nothing.
@@ -170,15 +172,11 @@ if test $ret -eq 0; then
realtarget="$target"
target="tmp-`echo $target | sed s/.*[\\/]//g`"
fi
- # Edit out '#line' or '#' directives.
- #
+ # Munge "#line" or "#" directives.
# We don't want the resulting debug information to point at
- # an absolute srcdir; it is better for it to just mention the
- # .y file with no path.
- #
+ # an absolute srcdir.
# We want to use the real output file name, not yy.lex.c for
# instance.
- #
# We want the include guards to be adjusted too.
FROM=`echo "$from" | sed \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
@@ -187,7 +185,7 @@ if test $ret -eq 0; then
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
- sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
+ sed -e "/^#/!b" -e "s,$input_rx,$input_sub_rx," -e "s,$from,$2," \
-e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
# Check whether header files must be updated.