This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: Typo in Porting/pumpkin/pod ?
[perl5.git] / perly.fixer
index 951da00..16ea925 100755 (executable)
@@ -2,7 +2,7 @@
 
 # Fix up yacc output to allow dynamic allocation.  Since perly.c
 # is now provided with the perl source, this should not be necessary.
-#  
+#
 # However, if the user wishes to use byacc, or wishes to try another 
 # compiler compiler (e.g. bison or yacc), this script will get run.
 # See makefile run_byacc target for more details.
 #
 # Additional information to make the BSD section work with SunOS 4.0.2
 #   tdinger@East.Sun.COM (Tom Dinger)  4/15/1991
+#
+# Also edit some practices gcc -Wall finds questionable.
+#  
 
 input=$1
 output=$2
 tmp=/tmp/f$$
 
+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
-    if test -f perly.c.diff; then
-       patch -F3 $output <perly.c.diff
+    # 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."
@@ -50,7 +93,7 @@ echo "Warning: the yacc you have used is not directly supported by perl."
 echo "The perly.fixer script will attempt to make some changes to the generated"
 echo "file. The changes may be incomplete and that might lead to problems later"
 echo "(especially with complex scripts). You may need to apply the changes"
-echo "embedded in perl.fixer (and/or perly.c.dif*) by hand."
+echo "embedded in perl.fixer (and/or perly_c.dif*) by hand."
 echo ""
 
 # Below, we check for various characteristic yaccpar outputs.
@@ -90,7 +133,7 @@ case "$plan" in
     # Also added are out of memory checks (makes porting the generated
     # code easier) For most systems, it can't hurt. -- TD
     "bsd43")
-       echo "Attempting to path perly.c to allow dynamic yacc stack allocation"
+       echo "Attempting to patch perly.c to allow dynamic yacc stack allocation"
        echo "Assuming bsd4.3 yaccpar"
        cat >$tmp <<'END'
 /YYSTYPE[      ]*yyv\[ *YYMAXDEPTH *\];/c\
@@ -145,7 +188,7 @@ END
 
     #######################################################
     "isc") # Interactive Systems 2.2  version
-       echo "Attempting to path perly.c to allow dynamic yacc stack allocation"
+       echo "Attempting to patch perly.c to allow dynamic yacc stack allocation"
        echo "Assuming Interactive SysVr3 2.2 yaccpar"
        # Easier to simply put whole script here than to modify the
        # bsd script with sed.