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
13 if test -f perly.c.diff; then
15 patch -F3 <perly.c.diff
22 # Test for BSD 4.3 version.
23 # Also tests for the SunOS 4.0.2 version
24 egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];
25 short[ ]*yys\[ *YYMAXDEPTH *\] *;
26 yyps *= *&yys\[ *-1 *\];
27 yypv *= *&yyv\[ *-1 *\];
28 if *\( *\+\+yyps *>=* *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp
31 if test "$1" = "5"; then
35 if test "$plan" = "unknown"; then
36 # Test for ISC 2.2 version.
37 egrep 'YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];
38 int[ ]*yys\[ *YYMAXDEPTH *\] *;
39 yyps *= *&yys\[ *-1 *\];
40 yypv *= *&yyv\[ *-1 *\];
41 if *\( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *\)' $input >$tmp
44 if test "$1" = "5"; then
50 ##################################################################
51 # The SunOS 4.0.2 version has the comparison fixed already.
52 # Also added are out of memory checks (makes porting the generated
53 # code easier) For most systems, it can't hurt. -- TD
55 echo "Patching perly.c to allow dynamic yacc stack allocation"
56 echo "Assuming bsd4.3 yaccpar"
58 /YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];/c\
59 int yymaxdepth = YYMAXDEPTH;\
60 YYSTYPE *yyv; /* where the values are stored */\
64 /short[ ]*yys\[ *YYMAXDEPTH *\] *;/d
66 /yyps *= *&yys\[ *-1 *\];/d
68 /yypv *= *&yyv\[ *-1 *\];/c\
70 \ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\
71 \ yys = (short*) malloc(yymaxdepth * sizeof(short));\
72 \ if ( !yyv || !yys ) {\
73 \ yyerror( "out of memory" );\
76 \ maxyyps = &yys[yymaxdepth];\
82 /if *( *\+\+yyps *>=* *&yys\[ *YYMAXDEPTH *\] *)/c\
83 \ if( ++yyps >= maxyyps ) {\
84 \ int tv = yypv - yyv;\
85 \ int ts = yyps - yys;\
88 \ yyv = (YYSTYPE*)realloc((char*)yyv,\
89 \ yymaxdepth*sizeof(YYSTYPE));\
90 \ yys = (short*)realloc((char*)yys,\
91 \ yymaxdepth*sizeof(short));\
92 \ if ( !yyv || !yys ) {\
93 \ yyerror( "yacc stack overflow" );\
98 \ maxyyps = &yys[yymaxdepth];\
101 /yacc stack overflow.*}/d
102 /yacc stack overflow/,/}/d
104 sed -f $tmp <$input >$output ;;
106 #######################################################
107 "isc") # Interactive Systems 2.2 version
108 echo "Patching perly.c to allow dynamic yacc stack allocation"
109 echo "Assuming Interactive SysVr3 2.2 yaccpar"
110 # Easier to simply put whole script here than to modify the
111 # bsd script with sed.
112 # Main changes: yaccpar sometimes uses yy_ps and yy_pv
113 # which are local register variables.
114 # if(++yyps > YYMAXDEPTH) had opening brace on next line.
115 # I've kept that brace in along with a call to yyerror if
116 # realloc fails. (Actually, I just don't know how to do
117 # multi-line matches in sed.)
119 /YYSTYPE[ ]*yyv\[ *YYMAXDEPTH *\];/c\
120 int yymaxdepth = YYMAXDEPTH;\
121 YYSTYPE *yyv; /* where the values are stored */\
125 /int[ ]*yys\[ *YYMAXDEPTH *\] *;/d
127 /yyps *= *&yys\[ *-1 *\];/d
129 /yypv *= *&yyv\[ *-1 *\];/c\
131 \ yyv = (YYSTYPE*) malloc(yymaxdepth * sizeof(YYSTYPE));\
132 \ yys = (int*) malloc(yymaxdepth * sizeof(int));\
133 \ maxyyps = &yys[yymaxdepth];\
138 /if *( *\+\+yy_ps *>= *&yys\[ *YYMAXDEPTH *\] *)/c\
139 \ if( ++yy_ps >= maxyyps ) {\
140 \ int tv = yy_pv - yyv;\
141 \ int ts = yy_ps - yys;\
144 \ yyv = (YYSTYPE*)realloc((char*)yyv,\
145 \ yymaxdepth*sizeof(YYSTYPE));\
146 \ yys = (int*)realloc((char*)yys,\
147 \ yymaxdepth*sizeof(int));\
148 \ yy_ps = yyps = yys + ts;\
149 \ yy_pv = yypv = yyv + tv;\
150 \ maxyyps = &yys[yymaxdepth];\
152 \ if (yyv == NULL || yys == NULL)
154 sed -f $tmp < $input > $output ;;
156 ######################################################
158 *) sed -e 's/Received token/ *** Received token/' $input >$output;