| 1 |
|
#! /bin/sh |
| 2 |
|
# ylwrap - wrapper for lex/yacc invocations. |
| 3 |
|
|
| 4 |
< |
scriptversion=2012-07-14.08; # UTC |
| 4 |
> |
scriptversion=2012-12-21.17; # UTC |
| 5 |
|
|
| 6 |
|
# Copyright (C) 1996-2012 Free Software Foundation, Inc. |
| 7 |
|
# |
| 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' |
| 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] |
| 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 |
< |
rename_sed= |
| 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 |
|
while test "$#" -ne 0; do |
| 136 |
|
if test "$1" = "--"; then |
| 137 |
|
shift |
| 148 |
|
shift |
| 149 |
|
to=$1 |
| 150 |
|
shift |
| 151 |
< |
rename_sed="${rename_sed}s|"`quote_for_sed "$from"`"|$to|g;" |
| 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. |
| 182 |
|
if test $ret -eq 0; then |
| 183 |
|
for from in * |
| 184 |
|
do |
| 185 |
< |
to=`printf '%s\n' "$from" | sed "$rename_sed"` |
| 185 |
> |
to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"` |
| 186 |
|
if test -f "$from"; then |
| 187 |
|
# If $2 is an absolute path name, then just use that, |
| 188 |
|
# otherwise prepend '../'. |
| 205 |
|
# debug information point at an absolute srcdir. Use the real |
| 206 |
|
# output file name, not yy.lex.c for instance. Adjust the |
| 207 |
|
# include guards too. |
| 208 |
< |
FROM=`guard "$from"` |
| 209 |
< |
TARGET=`guard "$to"` |
| 210 |
< |
sed -e "/^#/!b" -e "s|$input_rx|$input_sub_rx|" -e "$rename_sed" \ |
| 211 |
< |
-e "s|$FROM|$TARGET|" "$from" >"$target" || ret=$? |
| 208 |
> |
sed -e "/^#/!b" \ |
| 209 |
> |
-e "s|$input_rx|$input_sub_rx|" \ |
| 210 |
> |
-e "$sed_fix_filenames" \ |
| 211 |
> |
-e "$sed_fix_header_guards" \ |
| 212 |
> |
"$from" >"$target" || ret=$? |
| 213 |
|
|
| 214 |
|
# Check whether files must be updated. |
| 215 |
|
if test "$from" != "$parser"; then |