+inputh=`echo $input|sed 's:\.c$:.h:'`
+if grep '^#ifdef PERL_CORE' $inputh; then
+ : never mind
+else
+ echo "#ifdef PERL_CORE" > $tmp
+ sed -e 's:^typedef union {:#endif /* PERL_CORE */\
+\
+typedef union {:' $inputh >> $tmp
+ mv -f $tmp $inputh
+fi
+
+if grep 'yaccpar 1.8 (Berkeley)' $input >/dev/null 2>&1; then
+ cp $input $output
+ # Don't expect the diff to do everything -- do some by hand
+ if test -f perly_c.diff; then
+ patch -F3 $output <perly_c.diff
+ sed -e '/^[ ]*printf("yydebug:/s/printf(/PerlIO_printf(Perl_debug_log, /' \
+ -e '/^#line /s/"y[.]tab[.]c"/"perly.c"/' \
+ -e '/\[\] *= *[{]/s/^/static /' \
+ -e '/^static static/s/^static //' \
+ -e '/^#define.WORD/,/^#define.ARROW/d' \
+ -e '/^int.yydebug/,/^#define.yystacksize/d' \
+ -e 's/^yyerrlab:$//' \
+ -e 's/^ goto yyerrlab;//' \
+ -e 's/^yynewerror:$//' \
+ -e 's/^ goto yynewerror;//' \
+ -e 's|^static char yysccsid\(.*\)|/* static char yysccsid\1 */|' \
+ < $output > $tmp && mv -f $tmp $output || exit 1
+ rm -rf $input
+ echo "If you need to debug perly.c, you need to fix up the #line"
+ echo "directives yourself."
+ fi
+ exit
+elif grep 'yaccpar 1.9 (Berkeley)' $input >/dev/null 2>&1; then
+ if test -f perly.c.dif9; then
+ patch -F3 $output <perly.c.dif9
+ sed -e '/^[ ]*printf("yydebug:/s/printf(/PerlIO_printf(Perl_debug_log, /' \
+ -e '/^#line /s/"y[.]tab[.]c"/"perly.c"/' \
+ -e '/\[\] *= *[{]/s/^/static /' \
+ -e '/^static static/s/^static //' \
+ -e '/^#define.WORD/,/^#define.ARROW/d' \
+ -e '/^int.yydebug/,/^#define.yystacksize/d' \
+ -e 's/^yyerrlab:$//' \
+ -e 's/^ goto yyerrlab;//' \
+ -e 's/^yynewerror:$//' \
+ -e 's/^ goto yynewerror;//' \
+ -e 's|^static char yysccsid\(.*\)|/* static char yysccsid\1 */|' \
+ < $output > $tmp && mv -f $tmp $output || exit 1
+ rm -rf $input
+ echo "If you need to debug perly.c, you need to fix up the #line"
+ echo "directives yourself."
+ exit 0
+ else
+ echo "Diffs from byacc-1.9 are not available."
+ echo "If you wish to proceed anyway, do"
+ echo "cp $input $output"
+ echo "cp y.tab.h perly.h"
+ echo "and re-run make. Otherwise, I will use the old perly.c"
+ touch perly.c
+ # Exit with error status to stop make.
+ exit 1
+ fi
+fi
+