automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] ylwrap: rename header inclusion in generated parsers


From: Akim Demaille
Subject: [PATCH 3/3] ylwrap: rename header inclusion in generated parsers
Date: Thu, 12 Jul 2012 15:51:59 +0200

* lib/am/yacc.am (am__yacc_c2h): Shorten.
* lib/ylwrap (rename_sed): New.
(main loop): Use it the rename the dependencies to other files.
* t/yacc-d-basic.sh: Exercize this case, even if bison/yacc was
not issueing such an include.
---
 lib/am/yacc.am    |  3 +--
 lib/ylwrap        | 15 ++++++++-------
 t/yacc-d-basic.sh |  9 ++++++++-
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/lib/am/yacc.am b/lib/am/yacc.am
index e74259f..fa0dc4c 100644
--- a/lib/am/yacc.am
+++ b/lib/am/yacc.am
@@ -37,8 +37,7 @@ if %?MAINTAINER-MODE%
 @address@hidden = test -f $@ ||
 endif %?MAINTAINER-MODE%
 ## The 's/c$/h/' substitution *must* be the last one.
-am__yacc_c2h = sed -e s/cc$$/hh/ -e s/cpp$$/hpp/ -e s/cxx$$/hxx/ \
-                  -e s/c++$$/h++/ -e s/c$$/h/
+am__yacc_c2h = sed 's/cc$$/hh/;s/cpp$$/hpp/;s/cxx$$/hxx/;s/c++$$/h++/;s/c$$/h/'
 endif %?FIRST%
 
 ?GENERIC?%EXT%%DERIVED-EXT%:
diff --git a/lib/ylwrap b/lib/ylwrap
index 06b4706..0b6ae10 100755
--- a/lib/ylwrap
+++ b/lib/ylwrap
@@ -113,6 +113,8 @@ fi
 
 # The list of file to rename: FROM TO...
 pairlist=
+# A sed program to s/FROM/TO/g for all the FROM/TO.
+rename_sed=
 while test "$#" -ne 0; do
   if test "$1" = "--"; then
     shift
@@ -130,6 +132,7 @@ while test "$#" -ne 0; do
   to=$1
   shift
   pairlist="$pairlist $from $to"
+  rename_sed="${rename_sed}s,$from,$to,g;"
 done
 
 # The program to run.
@@ -187,16 +190,14 @@ if test $ret -eq 0; then
         realtarget="$target"
         target="tmp-`echo $target | sed s/.*[\\/]//g`"
       fi
-      # Munge "#line" or "#" directives.
-      # We don't want the resulting debug information to point at
-      # 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.
+      # Munge "#line" or "#" directives.  We don't want the resulting
+      # debug information to point at 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=`guard "$from"`
       TARGET=`guard "$to"`
 
-      sed -e "/^#/!b" -e "s,$input_rx,$input_sub_rx," -e "s,$from,$to," \
+      sed -e "/^#/!b" -e "s,$input_rx,$input_sub_rx," -e "$rename_sed" \
           -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
 
       # Check whether header files must be updated.
diff --git a/t/yacc-d-basic.sh b/t/yacc-d-basic.sh
index 91fbc62..72872f2 100755
--- a/t/yacc-d-basic.sh
+++ b/t/yacc-d-basic.sh
@@ -54,7 +54,14 @@ void yyerror (char *s) {}
 x : 'x' {};
 %%
 END
-cp foo/parse.y bar/parse.y
+# Using ylwrap, we actually generate y.tab.[ch].  Unfortunately, we
+# forgot to rename #include "y.tab.h" into #include "parse.h" during
+# the conversion from y.tab.c to parse.c.  This was OK when Bison was
+# not issuing such an #include (up to 2.6).
+#
+# To make sure that we perform this conversion, in bar/parse.y, use
+# y.tab.h instead of parse.c.
+sed -e 's/parse\.h/y.tab.h/' <foo/parse.y >bar/parse.y
 
 cat > foo/main.c << 'END'
 #include "parse.h"
-- 
1.7.11.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]