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-8/ylwrap (file contents), Revision 1375 by michael, Fri Apr 27 08:01:46 2012 UTC vs.
ircd-hybrid/branches/8.2.x/ylwrap (file contents), Revision 8746 by michael, Thu Dec 27 19:54:45 2018 UTC

# Line 1 | Line 1
1   #! /bin/sh
2   # ylwrap - wrapper for lex/yacc invocations.
3  
4 < scriptversion=2011-08-25.18; # UTC
4 > scriptversion=2018-03-07.03; # UTC
5  
6 < # Copyright (C) 1996-2012 Free Software Foundation, Inc.
6 > # Copyright (C) 1996-2018 Free Software Foundation, Inc.
7   #
8   # Written by Tom Tromey <tromey@cygnus.com>.
9   #
# Line 18 | Line 18 | scriptversion=2011-08-25.18; # UTC
18   # GNU General Public License for more details.
19   #
20   # You should have received a copy of the GNU General Public License
21 < # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 > # along with this program.  If not, see <https://www.gnu.org/licenses/>.
22  
23   # As a special exception to the GNU General Public License, if you
24   # distribute this file as part of a program that contains a
# Line 29 | Line 29 | scriptversion=2011-08-25.18; # 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' "$1"                                                    \
46 +    | sed                                                               \
47 +        -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'   \
48 +        -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'                        \
49 +        -e 's/__*/_/g'
50 + }
51 +
52 + # quote_for_sed [STRING]
53 + # ----------------------
54 + # Return STRING (or stdin) quoted to be used as a sed pattern.
55 + quote_for_sed ()
56 + {
57 +  case $# in
58 +    0) cat;;
59 +    1) printf '%s\n' "$1";;
60 +  esac \
61 +    | sed -e 's|[][\\.*]|\\&|g'
62 + }
63 +
64   case "$1" in
65    '')
66      echo "$0: No files given.  Try '$0 --help' for more information." 1>&2
# Line 64 | Line 96 | esac
96  
97  
98   # The input.
99 < input="$1"
99 > input=$1
100   shift
101 < case "$input" in
101 > # We'll later need for a correct munging of "#line" directives.
102 > input_sub_rx=`get_dirname "$input" | quote_for_sed`
103 > case $input in
104    [\\/]* | ?:[\\/]*)
105      # Absolute path; do nothing.
106      ;;
107    *)
108      # Relative path.  Make it absolute.
109 <    input="`pwd`/$input"
109 >    input=`pwd`/$input
110      ;;
111   esac
112 + input_rx=`get_dirname "$input" | quote_for_sed`
113 +
114 + # Since DOS filename conventions don't allow two dots,
115 + # the DOS version of Bison writes out y_tab.c instead of y.tab.c
116 + # and y_tab.h instead of y.tab.h. Test to see if this is the case.
117 + y_tab_nodot=false
118 + if test -f y_tab.c || test -f y_tab.h; then
119 +  y_tab_nodot=true
120 + fi
121 +
122 + # The parser itself, the first file, is the destination of the .y.c
123 + # rule in the Makefile.
124 + parser=$1
125 +
126 + # A sed program to s/FROM/TO/g for all the FROM/TO so that, for
127 + # instance, we rename #include "y.tab.h" into #include "parse.h"
128 + # during the conversion from y.tab.c to parse.c.
129 + sed_fix_filenames=
130 +
131 + # Also rename header guards, as Bison 2.7 for instance uses its header
132 + # guard in its implementation file.
133 + sed_fix_header_guards=
134  
135 < pairlist=
136 < while test "$#" -ne 0; do
81 <  if test "$1" = "--"; then
135 > while test $# -ne 0; do
136 >  if test x"$1" = x"--"; then
137      shift
138      break
139    fi
140 <  pairlist="$pairlist $1"
140 >  from=$1
141 >  # Handle y_tab.c and y_tab.h output by DOS
142 >  if $y_tab_nodot; then
143 >    case $from in
144 >      "y.tab.c") from=y_tab.c;;
145 >      "y.tab.h") from=y_tab.h;;
146 >    esac
147 >  fi
148 >  shift
149 >  to=$1
150    shift
151 +  sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;"
152 +  sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;"
153   done
154  
155   # The program to run.
156 < prog="$1"
156 > prog=$1
157   shift
158   # Make any relative path in $prog absolute.
159 < case "$prog" in
159 > case $prog in
160    [\\/]* | ?:[\\/]*) ;;
161 <  *[\\/]*) prog="`pwd`/$prog" ;;
161 >  *[\\/]*) prog=`pwd`/$prog ;;
162   esac
163  
98 # FIXME: add hostname here for parallel makes that run commands on
99 # other machines.  But that might take us over the 14-char limit.
164   dirname=ylwrap$$
165   do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
166   trap "ret=129; $do_exit" 1
# Line 114 | Line 178 | esac
178   ret=$?
179  
180   if test $ret -eq 0; then
181 <  set X $pairlist
182 <  shift
183 <  first=yes
120 <  # Since DOS filename conventions don't allow two dots,
121 <  # the DOS version of Bison writes out y_tab.c instead of y.tab.c
122 <  # and y_tab.h instead of y.tab.h. Test to see if this is the case.
123 <  y_tab_nodot="no"
124 <  if test -f y_tab.c || test -f y_tab.h; then
125 <    y_tab_nodot="yes"
126 <  fi
127 <
128 <  # The directory holding the input.
129 <  input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
130 <  # Quote $INPUT_DIR so we can use it in a regexp.
131 <  # FIXME: really we should care about more than '.' and '\'.
132 <  input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
133 <
134 <  while test "$#" -ne 0; do
135 <    from="$1"
136 <    # Handle y_tab.c and y_tab.h output by DOS
137 <    if test $y_tab_nodot = "yes"; then
138 <      if test $from = "y.tab.c"; then
139 <        from="y_tab.c"
140 <      else
141 <        if test $from = "y.tab.h"; then
142 <          from="y_tab.h"
143 <        fi
144 <      fi
145 <    fi
181 >  for from in *
182 >  do
183 >    to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"`
184      if test -f "$from"; then
185        # If $2 is an absolute path name, then just use that,
186        # otherwise prepend '../'.
187 <      case "$2" in
188 <        [\\/]* | ?:[\\/]*) target="$2";;
189 <        *) target="../$2";;
187 >      case $to in
188 >        [\\/]* | ?:[\\/]*) target=$to;;
189 >        *) target=../$to;;
190        esac
191  
192 <      # We do not want to overwrite a header file if it hasn't
193 <      # changed.  This avoid useless recompilations.  However the
194 <      # parser itself (the first file) should always be updated,
195 <      # because it is the destination of the .y.c rule in the
196 <      # Makefile.  Divert the output of all other files to a temporary
197 <      # file so we can compare them to existing versions.
198 <      if test $first = no; then
199 <        realtarget="$target"
162 <        target="tmp-`echo $target | sed s/.*[\\/]//g`"
192 >      # Do not overwrite unchanged header files to avoid useless
193 >      # recompilations.  Always update the parser itself: it is the
194 >      # destination of the .y.c rule in the Makefile.  Divert the
195 >      # output of all other files to a temporary file so we can
196 >      # compare them to existing versions.
197 >      if test $from != $parser; then
198 >        realtarget=$target
199 >        target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'`
200        fi
164      # Edit out '#line' or '#' directives.
165      #
166      # We don't want the resulting debug information to point at
167      # an absolute srcdir; it is better for it to just mention the
168      # .y file with no path.
169      #
170      # We want to use the real output file name, not yy.lex.c for
171      # instance.
172      #
173      # We want the include guards to be adjusted too.
174      FROM=`echo "$from" | sed \
175            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
176            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
177      TARGET=`echo "$2" | sed \
178            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
179            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
201  
202 <      sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
203 <          -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
202 >      # Munge "#line" or "#" directives.  Don't let the resulting
203 >      # debug information point at an absolute srcdir.  Use the real
204 >      # output file name, not yy.lex.c for instance.  Adjust the
205 >      # include guards too.
206 >      sed -e "/^#/!b"                           \
207 >          -e "s|$input_rx|$input_sub_rx|"       \
208 >          -e "$sed_fix_filenames"               \
209 >          -e "$sed_fix_header_guards"           \
210 >        "$from" >"$target" || ret=$?
211  
212 <      # Check whether header files must be updated.
213 <      if test $first = no; then
212 >      # Check whether files must be updated.
213 >      if test "$from" != "$parser"; then
214          if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
215 <          echo "$2" is unchanged
215 >          echo "$to is unchanged"
216            rm -f "$target"
217          else
218 <          echo updating "$2"
218 >          echo "updating $to"
219            mv -f "$target" "$realtarget"
220          fi
221        fi
222      else
223 <      # A missing file is only an error for the first file.  This
224 <      # is a blatant hack to let us support using "yacc -d".  If -d
225 <      # is not specified, we don't want an error when the header
226 <      # file is "missing".
199 <      if test $first = yes; then
223 >      # A missing file is only an error for the parser.  This is a
224 >      # blatant hack to let us support using "yacc -d".  If -d is not
225 >      # specified, don't fail when the header file is "missing".
226 >      if test "$from" = "$parser"; then
227          ret=1
228        fi
229      fi
203    shift
204    shift
205    first=no
230    done
207 else
208  ret=$?
231   fi
232  
233   # Remove the directory.
# Line 217 | Line 239 | exit $ret
239   # Local Variables:
240   # mode: shell-script
241   # sh-indentation: 2
242 < # eval: (add-hook 'write-file-hooks 'time-stamp)
242 > # eval: (add-hook 'before-save-hook 'time-stamp)
243   # time-stamp-start: "scriptversion="
244   # time-stamp-format: "%:y-%02m-%02d.%02H"
245 < # time-stamp-time-zone: "UTC"
245 > # time-stamp-time-zone: "UTC0"
246   # time-stamp-end: "; # UTC"
247   # End:

Comparing:
ircd-hybrid-8/ylwrap (property svn:eol-style), Revision 1375 by michael, Fri Apr 27 08:01:46 2012 UTC vs.
ircd-hybrid/branches/8.2.x/ylwrap (property svn:eol-style), Revision 8746 by michael, Thu Dec 27 19:54:45 2018 UTC

# Line 0 | Line 1
1 + native

Diff Legend

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