| 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. |
| 140 |
|
y_tab_nodot="yes" |
| 141 |
|
fi |
| 142 |
|
|
| 143 |
< |
# 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'` |
| 143 |
> |
input_rx=`get_dirname "$input" | quote_for_sed` |
| 144 |
|
|
| 145 |
|
while test "$#" -ne 0; do |
| 146 |
|
from="$1" |
| 172 |
|
realtarget="$target" |
| 173 |
|
target="tmp-`echo $target | sed s/.*[\\/]//g`" |
| 174 |
|
fi |
| 175 |
< |
# Edit out '#line' or '#' directives. |
| 165 |
< |
# |
| 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 |
| 168 |
< |
# .y file with no path. |
| 169 |
< |
# |
| 177 |
> |
# an absolute srcdir. |
| 178 |
|
# We want to use the real output file name, not yy.lex.c for |
| 179 |
|
# instance. |
| 172 |
– |
# |
| 180 |
|
# We want the include guards to be adjusted too. |
| 181 |
|
FROM=`echo "$from" | sed \ |
| 182 |
|
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ |
| 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. |