summaryrefslogtreecommitdiff
path: root/perly.fixer
diff options
context:
space:
mode:
authorLarry Wall <lwall@netlabs.com>1991-04-11 20:32:32 +0000
committerLarry Wall <lwall@netlabs.com>1991-04-11 20:32:32 +0000
commit35c8bce761056f470189967ccc824e04467151df (patch)
tree9ee76bba81900f86af5a1070bdd69d3987201c52 /perly.fixer
parent1c3d792e8fc9c2a36edfbd6c01156ef7e635040f (diff)
downloadperl-35c8bce761056f470189967ccc824e04467151df.tar.gz
perl 4.0 patch 2: Patch 1 continued
Diffstat (limited to 'perly.fixer')
-rw-r--r--perly.fixer93
1 files changed, 86 insertions, 7 deletions
diff --git a/perly.fixer b/perly.fixer
index b91c0e099b..33d1c5cd1a 100644
--- a/perly.fixer
+++ b/perly.fixer
@@ -1,22 +1,46 @@
#!/bin/sh
+# Hacks to make it work with Interactive's SysVr3 Version 2.2
+# doughera@lafvax.lafayette.edu (Andy Dougherty) 3/23/91
+
input=$1
output=$2
tmp=/tmp/f$$
+plan="unknown"
+
+# Test for BSD 4.3 version.
egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];
-short[ ]*yys\[ *YYMAXDEPTH *\] *;
+short[ ]*yys\[ *YYMAXDEPTH *\] *;
yyps *= *&yys\[ *-1 *\];
yypv *= *&yyv\[ *-1 *\];
if *\( *\+\+yyps *> *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp
+
set `wc -l $tmp`
+if test "$1" = "5"; then
+ plan="bsd43"
+fi
-case "$1" in
-5) echo "Patching perly.c to allow dynamic yacc stack allocation";;
-*) mv $input $output; rm -f $tmp; exit;;
-esac
+if test "$plan" = "unknown"; then
+ # Test for ISC 2.2 version.
+egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];
+int[ ]*yys\[ *YYMAXDEPTH *\] *;
+yyps *= *&yys\[ *-1 *\];
+yypv *= *&yyv\[ *-1 *\];
+if *\( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp
+
+ set `wc -l $tmp`
+ if test "$1" = "5"; then
+ plan="isc"
+ fi
+fi
-cat >$tmp <<'END'
+case "$plan" in
+ #######################################################
+ "bsd43")
+ echo "Patching perly.c to allow dynamic yacc stack allocation"
+ echo "Assuming bsd4.3 yaccpar"
+ cat >$tmp <<'END'
/YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];/c\
int yymaxdepth = YYMAXDEPTH;\
YYSTYPE *yyv; /* where the values are stored */\
@@ -55,6 +79,61 @@ short *maxyyps;
/yacc stack overflow.*}/d
/yacc stack overflow/,/}/d
END
+ sed -f $tmp <$input >$output ;;
+
+ #######################################################
+ "isc") # Interactive Systems 2.2 version
+ echo "Patching 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.
+ # Main changes: yaccpar sometimes uses yy_ps and yy_pv
+ # which are local register variables.
+ # if(++yyps > YYMAXDEPTH) had opening brace on next line.
+ # I've kept that brace in along with a call to yyerror if
+ # realloc fails. (Actually, I just don't know how to do
+ # multi-line matches in sed.)
+ cat > $tmp << 'END'
+/YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];/c\
+int yymaxdepth = YYMAXDEPTH;\
+YYSTYPE *yyv; /* where the values are stored */\
+int *yys;\
+int *maxyyps;
+
+/int[ ]*yys\[ *YYMAXDEPTH *\] *;/d
+
+/yyps *= *&yys\[ *-1 *\];/d
+
+/yypv *= *&yyv\[ *-1 *\];/c\
+\ if (!yyv) {\
+\ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\
+\ yys = (int*) malloc(yymaxdepth * sizeof(int));\
+\ maxyyps = &yys[yymaxdepth];\
+\ }\
+\ yyps = &yys[-1];\
+\ yypv = &yyv[-1];
+
+/if *( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *)/c\
+\ if( ++yy_ps >= maxyyps ) {\
+\ int tv = yy_pv - yyv;\
+\ int ts = yy_ps - yys;\
+\
+\ yymaxdepth *= 2;\
+\ yyv = (YYSTYPE*)realloc((char*)yyv,\
+\ yymaxdepth*sizeof(YYSTYPE));\
+\ yys = (int*)realloc((char*)yys,\
+\ yymaxdepth*sizeof(int));\
+\ yy_ps = yyps = yys + ts;\
+\ yy_pv = yypv = yyv + tv;\
+\ maxyyps = &yys[yymaxdepth];\
+\ }\
+\ if (yyv == NULL || yys == NULL)
+END
+ sed -f $tmp < $input > $output ;;
+
+ ######################################################
+ # Plan still unknown
+ *) mv $input $output;
+esac
-sed -f $tmp <$input >$output
rm -rf $tmp $input