summaryrefslogtreecommitdiff
path: root/ylwrap
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2013-03-27 12:03:58 +0100
committerMichael Biebl <biebl@debian.org>2013-03-27 12:03:58 +0100
commitd7c2f609d30d5e4d2c69dd2dc7305bd8ec5736ec (patch)
treeab4cde54583b0e1eb92fdafe0eb7282b7923daa9 /ylwrap
parent86831d7a4f485e19befa8cc500d17766798ad07c (diff)
downloadrsyslog-d7c2f609d30d5e4d2c69dd2dc7305bd8ec5736ec.tar.gz
Imported Upstream version 7.3.9upstream/7.3.9
Diffstat (limited to 'ylwrap')
-rwxr-xr-xylwrap38
1 files changed, 22 insertions, 16 deletions
diff --git a/ylwrap b/ylwrap
index 9253635..6879d8d 100755
--- a/ylwrap
+++ b/ylwrap
@@ -3,8 +3,7 @@
scriptversion=2011-08-25.18; # UTC
-# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
-# 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
#
# Written by Tom Tromey <tromey@cygnus.com>.
#
@@ -32,7 +31,7 @@ scriptversion=2011-08-25.18; # UTC
case "$1" in
'')
- echo "$0: No files given. Try \`$0 --help' for more information." 1>&2
+ echo "$0: No files given. Try '$0 --help' for more information." 1>&2
exit 1
;;
--basedir)
@@ -63,10 +62,25 @@ EOF
;;
esac
+get_dirname ()
+{
+ case $1 in
+ */*|*\\*) printf '%s\n' "$1" | sed -e 's,\([\\/]\)[^\\/]*$,\1,';;
+ # Otherwise, we want the empty string (not ".").
+ esac
+}
+
+quote_for_sed ()
+{
+ # FIXME: really we should care about more than '.' and '\'.
+ sed -e 's,[\\.],\\&,g'
+}
# 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.
@@ -126,11 +140,7 @@ if test $ret -eq 0; then
y_tab_nodot="yes"
fi
- # The directory holding the input.
- input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
- # Quote $INPUT_DIR so we can use it in a regexp.
- # FIXME: really we should care about more than `.' and `\'.
- input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
+ input_rx=`get_dirname "$input" | quote_for_sed`
while test "$#" -ne 0; do
from="$1"
@@ -146,7 +156,7 @@ if test $ret -eq 0; then
fi
if test -f "$from"; then
# If $2 is an absolute path name, then just use that,
- # otherwise prepend `../'.
+ # otherwise prepend '../'.
case "$2" in
[\\/]* | ?:[\\/]*) target="$2";;
*) target="../$2";;
@@ -162,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/'\
@@ -179,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.