ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.1.0beta5/ylwrap
(Generate patch)

Comparing:
ircd-hybrid-7.3/ylwrap (file contents), Revision 1029 by michael, Sun Nov 8 13:10:50 2009 UTC vs.
ircd-hybrid-8/ylwrap (file contents), Revision 1504 by michael, Thu Aug 16 18:03:00 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=2012-07-14.08; # 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 30 | Line 29 | scriptversion=2009-04-28.21; # UTC
29   # bugs to <bug-automake@gnu.org> or send patches to
30   # <automake-patches@gnu.org>.
31  
32 + get_dirname ()
33 + {
34 +  case $1 in
35 +    */*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';;
36 +    # Otherwise,  we want the empty string (not ".").
37 +  esac
38 + }
39 +
40 + # guard FILE
41 + # ----------
42 + # The CPP macro used to guard inclusion of FILE.
43 + guard()
44 + {
45 +  printf '%s\n' "$from" \
46 +    | sed \
47 +        -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
48 +        -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'
49 + }
50 +
51 + # quote_for_sed [STRING]
52 + # ----------------------
53 + # Return STRING (or stdin) quoted to be used as a sed pattern.
54 + quote_for_sed ()
55 + {
56 +  case $# in
57 +    0) cat;;
58 +    1) printf '%s\n' "$1";;
59 +  esac \
60 +    | sed -e 's|[][\\.*]|\\&|g'
61 + }
62 +
63   case "$1" in
64    '')
65 <    echo "$0: No files given.  Try \`$0 --help' for more information." 1>&2
65 >    echo "$0: No files given.  Try '$0 --help' for more information." 1>&2
66      exit 1
67      ;;
68    --basedir)
# Line 67 | Line 97 | esac
97   # The input.
98   input="$1"
99   shift
100 + # We'll later need for a correct munging of "#line" directives.
101 + input_sub_rx=`get_dirname "$input" | quote_for_sed`
102   case "$input" in
103    [\\/]* | ?:[\\/]*)
104      # Absolute path; do nothing.
# Line 76 | Line 108 | case "$input" in
108      input="`pwd`/$input"
109      ;;
110   esac
111 + input_rx=`get_dirname "$input" | quote_for_sed`
112 +
113 + # Since DOS filename conventions don't allow two dots,
114 + # the DOS version of Bison writes out y_tab.c instead of y.tab.c
115 + # and y_tab.h instead of y.tab.h. Test to see if this is the case.
116 + y_tab_nodot=false
117 + if test -f y_tab.c || test -f y_tab.h; then
118 +  y_tab_nodot=true
119 + fi
120  
121 < pairlist=
121 > # The parser itself, the first file, is the destination of the .y.c
122 > # rule in the Makefile.
123 > parser=$1
124 > # A sed program to s/FROM/TO/g for all the FROM/TO so that, for
125 > # instance, we rename #include "y.tab.h" into #include "parse.h"
126 > # during the conversion from y.tab.c to parse.c.
127 > rename_sed=
128   while test "$#" -ne 0; do
129    if test "$1" = "--"; then
130      shift
131      break
132    fi
133 <  pairlist="$pairlist $1"
133 >  from=$1
134 >  # Handle y_tab.c and y_tab.h output by DOS
135 >  if $y_tab_nodot; then
136 >    case $from in
137 >      "y.tab.c") from=y_tab.c;;
138 >      "y.tab.h") from=y_tab.h;;
139 >    esac
140 >  fi
141    shift
142 +  to=$1
143 +  shift
144 +  rename_sed="${rename_sed}s|"`quote_for_sed "$from"`"|$to|g;"
145   done
146  
147   # The program to run.
# Line 99 | Line 156 | esac
156   # FIXME: add hostname here for parallel makes that run commands on
157   # other machines.  But that might take us over the 14-char limit.
158   dirname=ylwrap$$
159 < trap "cd '`pwd`'; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
159 > do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
160 > trap "ret=129; $do_exit" 1
161 > trap "ret=130; $do_exit" 2
162 > trap "ret=141; $do_exit" 13
163 > trap "ret=143; $do_exit" 15
164   mkdir $dirname || exit 1
165  
166   cd $dirname
# Line 111 | Line 172 | esac
172   ret=$?
173  
174   if test $ret -eq 0; then
175 <  set X $pairlist
176 <  shift
177 <  first=yes
117 <  # Since DOS filename conventions don't allow two dots,
118 <  # the DOS version of Bison writes out y_tab.c instead of y.tab.c
119 <  # and y_tab.h instead of y.tab.h. Test to see if this is the case.
120 <  y_tab_nodot="no"
121 <  if test -f y_tab.c || test -f y_tab.h; then
122 <    y_tab_nodot="yes"
123 <  fi
124 <
125 <  # 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'`
130 <
131 <  while test "$#" -ne 0; do
132 <    from="$1"
133 <    # Handle y_tab.c and y_tab.h output by DOS
134 <    if test $y_tab_nodot = "yes"; then
135 <      if test $from = "y.tab.c"; then
136 <        from="y_tab.c"
137 <      else
138 <        if test $from = "y.tab.h"; then
139 <          from="y_tab.h"
140 <        fi
141 <      fi
142 <    fi
175 >  for from in *
176 >  do
177 >    to=`printf '%s\n' "$from" | sed "$rename_sed"`
178      if test -f "$from"; then
179        # If $2 is an absolute path name, then just use that,
180 <      # otherwise prepend `../'.
181 <      case "$2" in
182 <        [\\/]* | ?:[\\/]*) target="$2";;
183 <        *) target="../$2";;
180 >      # otherwise prepend '../'.
181 >      case $to in
182 >        [\\/]* | ?:[\\/]*) target=$to;;
183 >        *) target="../$to";;
184        esac
185  
186 <      # We do not want to overwrite a header file if it hasn't
187 <      # changed.  This avoid useless recompilations.  However the
188 <      # parser itself (the first file) should always be updated,
189 <      # because it is the destination of the .y.c rule in the
190 <      # Makefile.  Divert the output of all other files to a temporary
191 <      # file so we can compare them to existing versions.
192 <      if test $first = no; then
193 <        realtarget="$target"
159 <        target="tmp-`echo $target | sed s/.*[\\/]//g`"
186 >      # Do not overwrite unchanged header files to avoid useless
187 >      # recompilations.  Always update the parser itself: it is the
188 >      # destination of the .y.c rule in the Makefile.  Divert the
189 >      # output of all other files to a temporary file so we can
190 >      # compare them to existing versions.
191 >      if test $from != $parser; then
192 >        realtarget="$target"
193 >        target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'`
194        fi
195 <      # Edit out `#line' or `#' directives.
196 <      #
197 <      # We don't want the resulting debug information to point at
198 <      # an absolute srcdir; it is better for it to just mention the
199 <      # .y file with no path.
200 <      #
201 <      # We want to use the real output file name, not yy.lex.c for
202 <      # instance.
203 <      #
204 <      # We want the include guards to be adjusted too.
205 <      FROM=`echo "$from" | sed \
206 <            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
207 <            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
208 <      TARGET=`echo "$2" | sed \
209 <            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
210 <            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
211 <
178 <      sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
179 <          -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
180 <
181 <      # Check whether header files must be updated.
182 <      if test $first = no; then
183 <        if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
184 <          echo "$2" is unchanged
185 <          rm -f "$target"
186 <        else
187 <          echo updating "$2"
195 >
196 >      # Munge "#line" or "#" directives.  Don't let the resulting
197 >      # debug information point at an absolute srcdir.  Use the real
198 >      # output file name, not yy.lex.c for instance.  Adjust the
199 >      # include guards too.
200 >      FROM=`guard "$from"`
201 >      TARGET=`guard "$to"`
202 >      sed -e "/^#/!b" -e "s|$input_rx|$input_sub_rx|" -e "$rename_sed" \
203 >          -e "s|$FROM|$TARGET|" "$from" >"$target" || ret=$?
204 >
205 >      # Check whether files must be updated.
206 >      if test "$from" != "$parser"; then
207 >        if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
208 >          echo "$to is unchanged"
209 >          rm -f "$target"
210 >        else
211 >          echo "updating $to"
212            mv -f "$target" "$realtarget"
213          fi
214        fi
215      else
216 <      # A missing file is only an error for the first file.  This
217 <      # is a blatant hack to let us support using "yacc -d".  If -d
218 <      # is not specified, we don't want an error when the header
219 <      # file is "missing".
196 <      if test $first = yes; then
216 >      # A missing file is only an error for the parser.  This is a
217 >      # blatant hack to let us support using "yacc -d".  If -d is not
218 >      # specified, don't fail when the header file is "missing".
219 >      if test "$from" = "$parser"; then
220          ret=1
221        fi
222      fi
200    shift
201    shift
202    first=no
223    done
204 else
205  ret=$?
224   fi
225  
226   # Remove the directory.

Diff Legend

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