summaryrefslogtreecommitdiff
path: root/perly.fixer
diff options
context:
space:
mode:
authorLarry Wall <lwall@netlabs.com>1991-03-21 00:00:00 +0000
committerLarry Wall <lwall@netlabs.com>1991-03-21 00:00:00 +0000
commitfe14fcc35f78a371a174a1d14256c2f35ae4262b (patch)
treed472cb1055c47b9701cb0840969aacdbdbc9354a /perly.fixer
parent27e2fb84680b9cc1db17238d5bf10b97626f477f (diff)
downloadperl-fe14fcc35f78a371a174a1d14256c2f35ae4262b.tar.gz
perl 4.0.00: (no release announcement available)perl-4.0.00
So far, 4.0 is still a beta test version. For the last production version, look in pub/perl.3.0/kits@44.
Diffstat (limited to 'perly.fixer')
-rw-r--r--perly.fixer60
1 files changed, 60 insertions, 0 deletions
diff --git a/perly.fixer b/perly.fixer
new file mode 100644
index 0000000000..b91c0e099b
--- /dev/null
+++ b/perly.fixer
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+input=$1
+output=$2
+tmp=/tmp/f$$
+
+egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];
+short[ ]*yys\[ *YYMAXDEPTH *\] *;
+yyps *= *&yys\[ *-1 *\];
+yypv *= *&yyv\[ *-1 *\];
+if *\( *\+\+yyps *> *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp
+set `wc -l $tmp`
+
+case "$1" in
+5) echo "Patching perly.c to allow dynamic yacc stack allocation";;
+*) mv $input $output; rm -f $tmp; exit;;
+esac
+
+cat >$tmp <<'END'
+/YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];/c\
+int yymaxdepth = YYMAXDEPTH;\
+YYSTYPE *yyv; /* where the values are stored */\
+short *yys;\
+short *maxyyps;
+
+/short[ ]*yys\[ *YYMAXDEPTH *\] *;/d
+
+/yyps *= *&yys\[ *-1 *\];/d
+
+/yypv *= *&yyv\[ *-1 *\];/c\
+\ if (!yyv) {\
+\ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\
+\ yys = (short*) malloc(yymaxdepth * sizeof(short));\
+\ maxyyps = &yys[yymaxdepth];\
+\ }\
+\ yyps = &yys[-1];\
+\ yypv = &yyv[-1];
+
+
+/if *( *\+\+yyps *> *&yys\[ *YYMAXDEPTH *\] *)/c\
+\ if( ++yyps >= maxyyps ) {\
+\ int tv = yypv - yyv;\
+\ int ts = yyps - yys;\
+\
+\ yymaxdepth *= 2;\
+\ yyv = (YYSTYPE*)realloc((char*)yyv,\
+\ yymaxdepth*sizeof(YYSTYPE));\
+\ yys = (short*)realloc((char*)yys,\
+\ yymaxdepth*sizeof(short));\
+\ yyps = yys + ts;\
+\ yypv = yyv + tv;\
+\ maxyyps = &yys[yymaxdepth];\
+\ }
+
+/yacc stack overflow.*}/d
+/yacc stack overflow/,/}/d
+END
+
+sed -f $tmp <$input >$output
+rm -rf $tmp $input