X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/35c8bce761056f470189967ccc824e04467151df..92112241d1458d5df77a0d57b4e82dca2637735a:/perly.fixer diff --git a/perly.fixer b/perly.fixer old mode 100644 new mode 100755 index 33d1c5c..98296a7 --- a/perly.fixer +++ b/perly.fixer @@ -1,20 +1,58 @@ #!/bin/sh +# 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. +# +# Currently, only byacc version 1.8 is supported. +# # Hacks to make it work with Interactive's SysVr3 Version 2.2 # doughera@lafvax.lafayette.edu (Andy Dougherty) 3/23/91 +# +# Additional information to make the BSD section work with SunOS 4.0.2 +# tdinger@East.Sun.COM (Tom Dinger) 4/15/1991 input=$1 output=$2 tmp=/tmp/f$$ +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 /dev/null 2>&1; then + if test -f perly.c.dif9; then + patch -F3 $output *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp +if *\( *\+\+yyps *>=* *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp 2>/dev/null set `wc -l $tmp` if test "$1" = "5"; then @@ -22,12 +60,12 @@ if test "$1" = "5"; then fi if test "$plan" = "unknown"; then - # Test for ISC 2.2 version. + # Test for ISC 2.2 version (probably generic SysVr3). egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\]; int[ ]*yys\[ *YYMAXDEPTH *\] *; yyps *= *&yys\[ *-1 *\]; yypv *= *&yyv\[ *-1 *\]; -if *\( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp +if *\( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp 2>/dev/null set `wc -l $tmp` if test "$1" = "5"; then @@ -36,7 +74,10 @@ if *\( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp fi case "$plan" in - ####################################################### + ################################################################## + # The SunOS 4.0.2 version has the comparison fixed already. + # Also added are out of memory checks (makes porting the generated + # code easier) For most systems, it can't hurt. -- TD "bsd43") echo "Patching perly.c to allow dynamic yacc stack allocation" echo "Assuming bsd4.3 yaccpar" @@ -53,15 +94,19 @@ short *maxyyps; /yypv *= *&yyv\[ *-1 *\];/c\ \ if (!yyv) {\ -\ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\ -\ yys = (short*) malloc(yymaxdepth * sizeof(short));\ +\ yyv = (YYSTYPE*) safemalloc(yymaxdepth * sizeof(YYSTYPE));\ +\ yys = (short*) safemalloc(yymaxdepth * sizeof(short));\ +\ if ( !yyv || !yys ) {\ +\ yyerror( "out of memory" );\ +\ return(1);\ +\ }\ \ maxyyps = &yys[yymaxdepth];\ \ }\ \ yyps = &yys[-1];\ \ yypv = &yyv[-1]; -/if *( *\+\+yyps *> *&yys\[ *YYMAXDEPTH *\] *)/c\ +/if *( *\+\+yyps *>=* *&yys\[ *YYMAXDEPTH *\] *)/c\ \ if( ++yyps >= maxyyps ) {\ \ int tv = yypv - yyv;\ \ int ts = yyps - yys;\ @@ -71,6 +116,10 @@ short *maxyyps; \ yymaxdepth*sizeof(YYSTYPE));\ \ yys = (short*)realloc((char*)yys,\ \ yymaxdepth*sizeof(short));\ +\ if ( !yyv || !yys ) {\ +\ yyerror( "yacc stack overflow" );\ +\ return(1);\ +\ }\ \ yyps = yys + ts;\ \ yypv = yyv + tv;\ \ maxyyps = &yys[yymaxdepth];\ @@ -106,8 +155,8 @@ int *maxyyps; /yypv *= *&yyv\[ *-1 *\];/c\ \ if (!yyv) {\ -\ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\ -\ yys = (int*) malloc(yymaxdepth * sizeof(int));\ +\ yyv = (YYSTYPE*) safemalloc(yymaxdepth * sizeof(YYSTYPE));\ +\ yys = (int*) safemalloc(yymaxdepth * sizeof(int));\ \ maxyyps = &yys[yymaxdepth];\ \ }\ \ yyps = &yys[-1];\ @@ -133,7 +182,7 @@ END ###################################################### # Plan still unknown - *) mv $input $output; + *) sed -e 's/Received token/ *** Received token/' $input >$output; esac rm -rf $tmp $input