portability: beware of max () with MSVC
[bison.git] / tests / bison.in
blobf3b05b5bd5fc4b66988c546c9198eb5f9cc63ecb
1 #! @SHELL@
2 # @configure_input@
3 # Wrapper around a non installed bison to make it work as an installed one.
5 # Copyright (C) 2001-2015, 2018-2020 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 abs_top_srcdir='@abs_top_srcdir@'
21 abs_top_builddir='@abs_top_builddir@'
22 : ${PERL='@PERL@'}
24 # Use the shipped files, not those installed.
25 BISON_PKGDATADIR=$abs_top_srcdir/data
26 export BISON_PKGDATADIR
28 stderr=tmp-bison.$$
30 # If stderr is a tty, force --color=yes to simulate --color=auto
31 # although we save and modify stderr.
32 if test -t 2; then
33     set x --color=yes ${1+"$@"}
34     shift
37 # We redirect stderr, which breaks the computation of the terminal
38 # screen width.  So export COLUMNS to Bison, hoping for the shell to
39 # have defined it.
40 : ${COLUMNS=`(tput cols) 2>/dev/null || echo 132`}
41 export COLUMNS
42 $PREBISON "$abs_top_builddir/src/bison" ${1+"$@"} 2>"$stderr"
43 status=$?
45 # Neutralize path differences in error messages so that check and
46 # installcheck behave the same way.
47 sed -e "s,$abs_top_builddir/src/,,g" <"$stderr" >&2
48 rm -f "$stderr"
50 # As a special dark magic, if we are actually using this wrapper to
51 # compile Bison's src/parse-gram.y, post-process the synclines to
52 # avoid dependencies on the user's set up (srcdir vs. builddir).
53 for i
55   case $i in
56     */src/parse-gram.y)
57     if $PERL --version >/dev/null; then
58       # We are called by ylwrap which (if it's an old version) still
59       # uses y.tab.*, and post-processes the synclines on y.tab.c
60       # itself.  Don't let it do it.  Besides, it leaves
61       # "parse-gram.y" as the source, dropping the src/ part.
62       $PERL -pi -e 's{"y\.tab\.}{"parse-gram.}g;'                       \
63                 -e 's{"(?:.*/)?(parse-gram\.[chy])"}{"src/$1"}g;'       \
64                 -e 's{GRAM_Y_TAB_H}{GRAM_SRC_PARSE_GRAM_H}g;'           \
65            y.tab.[ch]
66     fi
67     ;;
68   esac
69 done
71 exit $status
73 # Local Variables:
74 # mode: shell-script
75 # End: