7 egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];
8 short[ ]*yys\[ *YYMAXDEPTH *\] *;
9 yyps *= *&yys\[ *-1 *\];
10 yypv *= *&yyv\[ *-1 *\];
11 if *\( *\+\+yyps *> *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp
15 5) echo "Patching perly.c to allow dynamic yacc stack allocation";;
16 *) mv $input $output; rm -f $tmp; exit;;
20 /YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];/c\
21 int yymaxdepth = YYMAXDEPTH;\
22 YYSTYPE *yyv; /* where the values are stored */\
26 /short[ ]*yys\[ *YYMAXDEPTH *\] *;/d
28 /yyps *= *&yys\[ *-1 *\];/d
30 /yypv *= *&yyv\[ *-1 *\];/c\
32 \ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\
33 \ yys = (short*) malloc(yymaxdepth * sizeof(short));\
34 \ maxyyps = &yys[yymaxdepth];\
40 /if *( *\+\+yyps *> *&yys\[ *YYMAXDEPTH *\] *)/c\
41 \ if( ++yyps >= maxyyps ) {\
42 \ int tv = yypv - yyv;\
43 \ int ts = yyps - yys;\
46 \ yyv = (YYSTYPE*)realloc((char*)yyv,\
47 \ yymaxdepth*sizeof(YYSTYPE));\
48 \ yys = (short*)realloc((char*)yys,\
49 \ yymaxdepth*sizeof(short));\
52 \ maxyyps = &yys[yymaxdepth];\
55 /yacc stack overflow.*}/d
56 /yacc stack overflow/,/}/d
59 sed -f $tmp <$input >$output