ylwrap: preserve subdirectories in "#line" munging
authorNikolai Weibull <now@bitwi.se>
Wed, 16 May 2012 16:16:41 +0000 (18:16 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 16 May 2012 16:26:26 +0000 (18:26 +0200)
commitb6359a5f310160c8a4a2e8e8c0105408412ce400
treee1f04b788fcebfab10c74ab68e512da11eb4bd3b
parent0ce63a38ab7c87502504ba7d2319886d4f4a7d15
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>
NEWS
THANKS
lib/ylwrap
t/lex-line.sh
t/yacc-line.sh