Bring back our local ylwrap fix.
authorChristos Zoulas <christos@zoulas.com>
Tue, 6 Jan 2009 20:39:06 +0000 (20:39 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 6 Jan 2009 20:39:06 +0000 (20:39 +0000)
ylwrap

diff --git a/ylwrap b/ylwrap
index 7278b6a357313bf7dded6fd121757f976242e825..80cd57fae2cc97c6e642d0e37bb5607eb62819d8 100755 (executable)
--- a/ylwrap
+++ b/ylwrap
@@ -177,8 +177,21 @@ if test $ret -eq 0; then
             -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
             -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
 
+      prefix=`echo $input | sed \
+               -e 's,^.*/,,g' \
+               -e 's/_parse.[yl]$/_/g' \
+               -e 's/_tok.[yl]$/_/g'`
+
+      case $prefix in
+      *.y)
+             code_prefix="$(basename $prefix _gram.y)_yy";;
+      *.l)
+             code_prefix="$(basename $prefix _lex.l)_yy";;
+      *)
+             code_prefix="$prefix";;
+      esac
       sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
-          -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
+          -e "s,$FROM,$TARGET," "$from" | sed "s/yy/$code_prefix/g" > "$target" || ret=$?
 
       # Check whether header files must be updated.
       if test $first = no; then