#!/bin/sh

O_FILE=`echo $1 | sed "s/\.C//"`
O_FILE=$O_FILE".o"

if [ -f $O_FILE ]
then
  exit 0
fi

BAK_FILE=$1".bak"

echo

if [ -f $BAK_FILE ]
then
	echo Could not fix bison error, aborting...
	echo
	exit 1
fi

echo Bison problem encountered, trying to fix $1
echo

cp $1 $BAK_FILE

sed -i "s/void \*malloc (YYSIZE_T)/void \*malloc (YYSIZE_T) throw()/" $1
sed -i "s/void free (void \*)/void free (void \*) throw()/" $1

make &&
echo Could fix bison error, everything seems ok now!
