ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/ylwrap
(Generate patch)

Comparing:
ircd-hybrid/ylwrap (file contents), Revision 1028 by michael, Sun Nov 8 13:03:38 2009 UTC vs.
ircd-hybrid-8/ylwrap (file contents), Revision 1425 by michael, Wed Jun 6 08:44:22 2012 UTC

# Line 1 | Line 1
1   #! /bin/sh
2   # ylwrap - wrapper for lex/yacc invocations.
3  
4 < scriptversion=2009-04-28.21; # UTC
4 > scriptversion=2011-08-25.18; # UTC
5  
6 < # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
7 < # 2007, 2009 Free Software Foundation, Inc.
6 > # Copyright (C) 1996-2012 Free Software Foundation, Inc.
7   #
8   # Written by Tom Tromey <tromey@cygnus.com>.
9   #
# Line 32 | Line 31 | scriptversion=2009-04-28.21; # UTC
31  
32   case "$1" in
33    '')
34 <    echo "$0: No files given.  Try \`$0 --help' for more information." 1>&2
34 >    echo "$0: No files given.  Try '$0 --help' for more information." 1>&2
35      exit 1
36      ;;
37    --basedir)
# Line 63 | Line 62 | EOF
62      ;;
63   esac
64  
65 + get_dirname ()
66 + {
67 +  case $1 in
68 +    */*|*\\*) printf '%s\n' "$1" | sed -e 's,\([\\/]\)[^\\/]*$,\1,';;
69 +    # Otherwise,  we want the empty string (not ".").
70 +  esac
71 + }
72 +
73 + quote_for_sed ()
74 + {
75 +  # FIXME: really we should care about more than '.' and '\'.
76 +  sed -e 's,[\\.],\\&,g'
77 + }
78  
79   # The input.
80   input="$1"
81   shift
82 + # We'll later need for a correct munging of "#line" directives.
83 + input_sub_rx=`get_dirname "$input" | quote_for_sed`
84   case "$input" in
85    [\\/]* | ?:[\\/]*)
86      # Absolute path; do nothing.
# Line 99 | Line 113 | esac
113   # FIXME: add hostname here for parallel makes that run commands on
114   # other machines.  But that might take us over the 14-char limit.
115   dirname=ylwrap$$
116 < trap "cd '`pwd`'; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
116 > do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
117 > trap "ret=129; $do_exit" 1
118 > trap "ret=130; $do_exit" 2
119 > trap "ret=141; $do_exit" 13
120 > trap "ret=143; $do_exit" 15
121   mkdir $dirname || exit 1
122  
123   cd $dirname
# Line 122 | Line 140 | if test $ret -eq 0; then
140      y_tab_nodot="yes"
141    fi
142  
143 <  # The directory holding the input.
126 <  input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
127 <  # Quote $INPUT_DIR so we can use it in a regexp.
128 <  # FIXME: really we should care about more than `.' and `\'.
129 <  input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
143 >  input_rx=`get_dirname "$input" | quote_for_sed`
144  
145    while test "$#" -ne 0; do
146      from="$1"
147      # Handle y_tab.c and y_tab.h output by DOS
148      if test $y_tab_nodot = "yes"; then
149        if test $from = "y.tab.c"; then
150 <        from="y_tab.c"
150 >        from="y_tab.c"
151        else
152 <        if test $from = "y.tab.h"; then
153 <          from="y_tab.h"
154 <        fi
152 >        if test $from = "y.tab.h"; then
153 >          from="y_tab.h"
154 >        fi
155        fi
156      fi
157      if test -f "$from"; then
158        # If $2 is an absolute path name, then just use that,
159 <      # otherwise prepend `../'.
159 >      # otherwise prepend '../'.
160        case "$2" in
161 <        [\\/]* | ?:[\\/]*) target="$2";;
162 <        *) target="../$2";;
161 >        [\\/]* | ?:[\\/]*) target="$2";;
162 >        *) target="../$2";;
163        esac
164  
165        # We do not want to overwrite a header file if it hasn't
# Line 155 | Line 169 | if test $ret -eq 0; then
169        # Makefile.  Divert the output of all other files to a temporary
170        # file so we can compare them to existing versions.
171        if test $first = no; then
172 <        realtarget="$target"
173 <        target="tmp-`echo $target | sed s/.*[\\/]//g`"
172 >        realtarget="$target"
173 >        target="tmp-`echo $target | sed s/.*[\\/]//g`"
174        fi
175 <      # Edit out `#line' or `#' directives.
162 <      #
175 >      # Munge "#line" or "#" directives.
176        # We don't want the resulting debug information to point at
177 <      # an absolute srcdir; it is better for it to just mention the
165 <      # .y file with no path.
166 <      #
177 >      # an absolute srcdir.
178        # We want to use the real output file name, not yy.lex.c for
179        # instance.
169      #
180        # We want the include guards to be adjusted too.
181        FROM=`echo "$from" | sed \
182              -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
# Line 175 | Line 185 | if test $ret -eq 0; then
185              -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
186              -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
187  
188 <      sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
188 >      sed -e "/^#/!b" -e "s,$input_rx,$input_sub_rx," -e "s,$from,$2," \
189            -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
190  
191        # Check whether header files must be updated.
192        if test $first = no; then
193 <        if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
194 <          echo "$2" is unchanged
195 <          rm -f "$target"
196 <        else
193 >        if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
194 >          echo "$2" is unchanged
195 >          rm -f "$target"
196 >        else
197            echo updating "$2"
198            mv -f "$target" "$realtarget"
199          fi

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)