diff options
Diffstat (limited to 'ylwrap')
-rwxr-xr-x | ylwrap | 47 |
1 files changed, 32 insertions, 15 deletions
@@ -1,6 +1,9 @@ #! /bin/sh # ylwrap - wrapper for lex/yacc invocations. -# Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002 Free Software +# Foundation, Inc. +# # Written by Tom Tromey <tromey@cygnus.com>. # # This program is free software; you can redistribute it and/or modify @@ -44,14 +47,6 @@ case "$input" in ;; esac -# 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 if test "$1" = "--"; then @@ -79,7 +74,10 @@ mkdir $dirname || exit 1 cd $dirname -$prog ${1+"$@"} "$input" +case $# in + 0) $prog "$input" ;; + *) $prog "$@" "$input" ;; +esac status=$? if test $status -eq 0; then @@ -94,6 +92,12 @@ if test $status -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'` + while test "$#" -ne 0; do from="$1" # Handle y_tab.c and y_tab.h output by DOS @@ -114,11 +118,24 @@ if test $status -eq 0; then *) target="../$2";; esac - # 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=$? + # 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. + # + # 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/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + TARGET=`echo "$2" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + sed "/^#/{s,$input_rx,,;s,$from,$2,;s,$FORM,$TO,;}" "$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 |