3 # Hacks to make it work with Interactive's SysVr3 Version 2.2
4 # doughera@lafvax.lafayette.edu (Andy Dougherty) 3/23/91
12 # Test for BSD 4.3 version.
13 egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];
14 short[ ]*yys\[ *YYMAXDEPTH *\] *;
15 yyps *= *&yys\[ *-1 *\];
16 yypv *= *&yyv\[ *-1 *\];
17 if *\( *\+\+yyps *> *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp
20 if test "$1" = "5"; then
24 if test "$plan" = "unknown"; then
25 # Test for ISC 2.2 version.
26 egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];
27 int[ ]*yys\[ *YYMAXDEPTH *\] *;
28 yyps *= *&yys\[ *-1 *\];
29 yypv *= *&yyv\[ *-1 *\];
30 if *\( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp
33 if test "$1" = "5"; then
39 #######################################################
41 echo "Patching perly.c to allow dynamic yacc stack allocation"
42 echo "Assuming bsd4.3 yaccpar"
44 /YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];/c\
45 int yymaxdepth = YYMAXDEPTH;\
46 YYSTYPE *yyv; /* where the values are stored */\
50 /short[ ]*yys\[ *YYMAXDEPTH *\] *;/d
52 /yyps *= *&yys\[ *-1 *\];/d
54 /yypv *= *&yyv\[ *-1 *\];/c\
56 \ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\
57 \ yys = (short*) malloc(yymaxdepth * sizeof(short));\
58 \ maxyyps = &yys[yymaxdepth];\
64 /if *( *\+\+yyps *> *&yys\[ *YYMAXDEPTH *\] *)/c\
65 \ if( ++yyps >= maxyyps ) {\
66 \ int tv = yypv - yyv;\
67 \ int ts = yyps - yys;\
70 \ yyv = (YYSTYPE*)realloc((char*)yyv,\
71 \ yymaxdepth*sizeof(YYSTYPE));\
72 \ yys = (short*)realloc((char*)yys,\
73 \ yymaxdepth*sizeof(short));\
76 \ maxyyps = &yys[yymaxdepth];\
79 /yacc stack overflow.*}/d
80 /yacc stack overflow/,/}/d
82 sed -f $tmp <$input >$output ;;
84 #######################################################
85 "isc") # Interactive Systems 2.2 version
86 echo "Patching perly.c to allow dynamic yacc stack allocation"
87 echo "Assuming Interactive SysVr3 2.2 yaccpar"
88 # Easier to simply put whole script here than to modify the
89 # bsd script with sed.
90 # Main changes: yaccpar sometimes uses yy_ps and yy_pv
91 # which are local register variables.
92 # if(++yyps > YYMAXDEPTH) had opening brace on next line.
93 # I've kept that brace in along with a call to yyerror if
94 # realloc fails. (Actually, I just don't know how to do
95 # multi-line matches in sed.)
97 /YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];/c\
98 int yymaxdepth = YYMAXDEPTH;\
99 YYSTYPE *yyv; /* where the values are stored */\
103 /int[ ]*yys\[ *YYMAXDEPTH *\] *;/d
105 /yyps *= *&yys\[ *-1 *\];/d
107 /yypv *= *&yyv\[ *-1 *\];/c\
109 \ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\
110 \ yys = (int*) malloc(yymaxdepth * sizeof(int));\
111 \ maxyyps = &yys[yymaxdepth];\
116 /if *( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *)/c\
117 \ if( ++yy_ps >= maxyyps ) {\
118 \ int tv = yy_pv - yyv;\
119 \ int ts = yy_ps - yys;\
122 \ yyv = (YYSTYPE*)realloc((char*)yyv,\
123 \ yymaxdepth*sizeof(YYSTYPE));\
124 \ yys = (int*)realloc((char*)yys,\
125 \ yymaxdepth*sizeof(int));\
126 \ yy_ps = yyps = yys + ts;\
127 \ yy_pv = yypv = yyv + tv;\
128 \ maxyyps = &yys[yymaxdepth];\
130 \ if (yyv == NULL || yys == NULL)
132 sed -f $tmp < $input > $output ;;
134 ######################################################
136 *) mv $input $output;