3 # Hacks to make it work with Interactive's SysVr3 Version 2.2
4 # doughera@lafvax.lafayette.edu (Andy Dougherty) 3/23/91
6 # Additional information to make the BSD section work with SunOS 4.0.2
7 # tdinger@East.Sun.COM (Tom Dinger) 4/15/1991
15 # Test for BSD 4.3 version.
16 # Also tests for the SunOS 4.0.2 version
17 egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];
18 short[ ]*yys\[ *YYMAXDEPTH *\] *;
19 yyps *= *&yys\[ *-1 *\];
20 yypv *= *&yyv\[ *-1 *\];
21 if *\( *\+\+yyps *>=* *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp
24 if test "$1" = "5"; then
28 if test "$plan" = "unknown"; then
29 # Test for ISC 2.2 version.
30 egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];
31 int[ ]*yys\[ *YYMAXDEPTH *\] *;
32 yyps *= *&yys\[ *-1 *\];
33 yypv *= *&yyv\[ *-1 *\];
34 if *\( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp
37 if test "$1" = "5"; then
43 ##################################################################
44 # The SunOS 4.0.2 version has the comparison fixed already.
45 # Also added are out of memory checks (makes porting the generated
46 # code easier) For most systems, it can't hurt. -- TD
48 echo "Patching perly.c to allow dynamic yacc stack allocation"
49 echo "Assuming bsd4.3 yaccpar"
51 /YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];/c\
52 int yymaxdepth = YYMAXDEPTH;\
53 YYSTYPE *yyv; /* where the values are stored */\
57 /short[ ]*yys\[ *YYMAXDEPTH *\] *;/d
59 /yyps *= *&yys\[ *-1 *\];/d
61 /yypv *= *&yyv\[ *-1 *\];/c\
63 \ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\
64 \ yys = (short*) malloc(yymaxdepth * sizeof(short));\
65 \ if ( !yyv || !yys ) {\
66 \ yyerror( "out of memory" );\
69 \ maxyyps = &yys[yymaxdepth];\
75 /if *( *\+\+yyps *>=* *&yys\[ *YYMAXDEPTH *\] *)/c\
76 \ if( ++yyps >= maxyyps ) {\
77 \ int tv = yypv - yyv;\
78 \ int ts = yyps - yys;\
81 \ yyv = (YYSTYPE*)realloc((char*)yyv,\
82 \ yymaxdepth*sizeof(YYSTYPE));\
83 \ yys = (short*)realloc((char*)yys,\
84 \ yymaxdepth*sizeof(short));\
85 \ if ( !yyv || !yys ) {\
86 \ yyerror( "yacc stack overflow" );\
91 \ maxyyps = &yys[yymaxdepth];\
94 /yacc stack overflow.*}/d
95 /yacc stack overflow/,/}/d
97 sed -f $tmp <$input >$output ;;
99 #######################################################
100 "isc") # Interactive Systems 2.2 version
101 echo "Patching perly.c to allow dynamic yacc stack allocation"
102 echo "Assuming Interactive SysVr3 2.2 yaccpar"
103 # Easier to simply put whole script here than to modify the
104 # bsd script with sed.
105 # Main changes: yaccpar sometimes uses yy_ps and yy_pv
106 # which are local register variables.
107 # if(++yyps > YYMAXDEPTH) had opening brace on next line.
108 # I've kept that brace in along with a call to yyerror if
109 # realloc fails. (Actually, I just don't know how to do
110 # multi-line matches in sed.)
112 /YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];/c\
113 int yymaxdepth = YYMAXDEPTH;\
114 YYSTYPE *yyv; /* where the values are stored */\
118 /int[ ]*yys\[ *YYMAXDEPTH *\] *;/d
120 /yyps *= *&yys\[ *-1 *\];/d
122 /yypv *= *&yyv\[ *-1 *\];/c\
124 \ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\
125 \ yys = (int*) malloc(yymaxdepth * sizeof(int));\
126 \ maxyyps = &yys[yymaxdepth];\
131 /if *( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *)/c\
132 \ if( ++yy_ps >= maxyyps ) {\
133 \ int tv = yy_pv - yyv;\
134 \ int ts = yy_ps - yys;\
137 \ yyv = (YYSTYPE*)realloc((char*)yyv,\
138 \ yymaxdepth*sizeof(YYSTYPE));\
139 \ yys = (int*)realloc((char*)yys,\
140 \ yymaxdepth*sizeof(int));\
141 \ yy_ps = yyps = yys + ts;\
142 \ yy_pv = yypv = yyv + tv;\
143 \ maxyyps = &yys[yymaxdepth];\
145 \ if (yyv == NULL || yys == NULL)
147 sed -f $tmp < $input > $output ;;
149 ######################################################
151 *) mv $input $output;