diff options
Diffstat (limited to 'krootwarning/admin/ylwrap')
-rwxr-xr-x | krootwarning/admin/ylwrap | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/krootwarning/admin/ylwrap b/krootwarning/admin/ylwrap index 8aa0314..5ea68e4 100755 --- a/krootwarning/admin/ylwrap +++ b/krootwarning/admin/ylwrap @@ -17,45 +17,40 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + # Usage: -# ylwrap PROGRAM INPUT [OUTPUT DESIRED]... -- [ARGS]... -# * PROGRAM is program to run. +# ylwrap INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... # * INPUT is the input file # * OUTPUT is file PROG generates # * DESIRED is file we actually want +# * PROGRAM is program to run # * ARGS are passed to PROG # Any number of OUTPUT,DESIRED pairs may be used. -# The program to run. -prog="$1" -shift -# Make any relative path in $prog absolute. -case "$prog" in - /* | [A-Za-z]:*) ;; - */*) prog="`pwd`/$prog" ;; -esac - # The input. input="$1" shift case "$input" in - /* | [A-Za-z]:*) + [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) - # Relative path. Make it absolute. Why? Because otherwise any - # debugging info in the generated file will point to the wrong - # place. This is really gross. + # Relative path. Make it absolute. input="`pwd`/$input" ;; esac -# We don't want to use the absolute path if the input in the current -# directory like when making a tar ball. -input_base=`echo $input | sed -e 's|.*/||'` -if test -f $input_base && cmp $input_base $input >/dev/null 2>&1; then - input=$input_base -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 -e 's,\\\\,\\\\\\\\,g' -e 's,\\.,\\\\.,g'` + +echo "got $input_rx" pairlist= while test "$#" -ne 0; do @@ -67,6 +62,15 @@ while test "$#" -ne 0; do shift done +# The program to run. +prog="$1" +shift +# Make any relative path in $prog absolute. +case "$prog" in + [\\/]* | ?:[\\/]*) ;; + *[\\/]*) prog="`pwd`/$prog" ;; +esac + # FIXME: add hostname here for parallel makes that run commands on # other machines. But that might take us over the 14-char limit. dirname=ylwrap$$ @@ -74,15 +78,7 @@ trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 mkdir $dirname || exit 1 cd $dirname -case "$input" in - /* | [A-Za-z]:*) - # Absolute path; do nothing. - ;; - *) - # Make a symbolic link, hard link or hardcopy. - ln -s ../"$input" . > /dev/null 2>&1 || ln ../"$input" . > /dev/null 2>&1 || cp ../"$input" . - ;; -esac + $prog ${1+"$@"} "$input" status=$? @@ -114,10 +110,15 @@ if test $status -eq 0; then # If $2 is an absolute path name, then just use that, # otherwise prepend `../'. case "$2" in - /* | [A-Za-z]:*) target="$2";; + [\\/]* | ?:[\\/]*) target="$2";; *) target="../$2";; esac - mv "$from" "$target" || status=$? + + # Edit out `#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. + sed -e "/^#/ s,$input_rx,," "$from" > "$target" || status=$? else # A missing file is only an error for the first file. This # is a blatant hack to let us support using "yacc -d". If -d |