3 # Copyright © 2021 Nick Bowler
5 # Fake bison program for testing the bison detection macro.
7 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
8 # This is free software: you are free to do what the fuck you want to.
9 # There is NO WARRANTY, to the extent permitted by law.
11 : "${FAKE_BISON_VERSION=2.4.0}"
22 --defines) use_header
=true
;;
23 --defines=*) use_header
=true outheader
=${arg%*=} ;;
28 if test x
"$infile" = x
""; then
29 printf '%s: error: no input file\n' "$argv0" 1>&2
33 outfile
=${infile%.y}.tab.c
35 test ${outheader:+y} || outheader
=${outfile%.c}.h
38 exec 3<"$infile" 4>"$outfile"
40 copy_header
=false copy_impl
=false
41 while read line
<&3; do
44 save_IFS
=$IFS IFS
=$IFS\".
45 set x
$FAKE_BISON_VERSION 0 0 0; shift
46 fake_major
=$1 fake_minor
=$2 fake_revision
=$3
47 set x
${line#*\"} 0 0 0; shift
48 req_major
=$1 req_minor
=$2 req_revision
=$3
51 test $fake_major -ge $req_major ||
exit 1
52 if test $fake_major -eq $req_major; then
53 test $fake_minor -ge $req_minor ||
exit 1
54 if test $fake_minor -eq $req_minor; then
55 test $fake_revision -ge $req_revision ||
exit 1
63 requires|provides
) copy_header
=true copy_impl
=true
;;
64 top
) copy_impl
=true
;;
68 copy_header
=false copy_impl
=false
74 $copy_header && printf '%s\n' "$line" >&5
75 $copy_impl && printf '%s\n' "$line" >&4
87 while read line
<&3; do