This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
This is my patch patch.1g for perl5.001.
[perl5.git] / perly.c.diff
1 *** perly.c.orig        Thu Feb  9 17:56:15 1995
2 --- perly.c     Thu Feb  9 17:56:17 1995
3 ***************
4 *** 12,79 ****
5       deprecate("\"do\" to call subroutines");
6   }
7   
8 - #line 29 "perly.y"
9 - typedef union {
10 -     I32       ival;
11 -     char *pval;
12 -     OP *opval;
13 -     GV *gvval;
14 - } YYSTYPE;
15 - #line 23 "y.tab.c"
16 - #define WORD 257
17 - #define METHOD 258
18 - #define FUNCMETH 259
19 - #define THING 260
20 - #define PMFUNC 261
21 - #define PRIVATEREF 262
22 - #define LABEL 263
23 - #define FORMAT 264
24 - #define SUB 265
25 - #define ANONSUB 266
26 - #define PACKAGE 267
27 - #define USE 268
28 - #define WHILE 269
29 - #define UNTIL 270
30 - #define IF 271
31 - #define UNLESS 272
32 - #define ELSE 273
33 - #define ELSIF 274
34 - #define CONTINUE 275
35 - #define FOR 276
36 - #define LOOPEX 277
37 - #define DOTDOT 278
38 - #define FUNC0 279
39 - #define FUNC1 280
40 - #define FUNC 281
41 - #define RELOP 282
42 - #define EQOP 283
43 - #define MULOP 284
44 - #define ADDOP 285
45 - #define DOLSHARP 286
46 - #define DO 287
47 - #define LOCAL 288
48 - #define HASHBRACK 289
49 - #define NOAMP 290
50 - #define OROP 291
51 - #define ANDOP 292
52 - #define NOTOP 293
53 - #define LSTOP 294
54 - #define ASSIGNOP 295
55 - #define OROR 296
56 - #define ANDAND 297
57 - #define BITOROP 298
58 - #define BITANDOP 299
59 - #define UNIOP 300
60 - #define SHIFTOP 301
61 - #define MATCHOP 302
62 - #define UMINUS 303
63 - #define REFGEN 304
64 - #define POWOP 305
65 - #define PREINC 306
66 - #define PREDEC 307
67 - #define POSTINC 308
68 - #define POSTDEC 309
69 - #define ARROW 310
70   #define YYERRCODE 256
71   short yylhs[] = {                                        -1,
72      30,    0,    5,    3,    6,    6,    6,    7,    7,    7,
73 --- 12,17 ----
74 ***************
75 *** 1334,1346 ****
76   int yynerrs;
77   int yyerrflag;
78   int yychar;
79 - short *yyssp;
80 - YYSTYPE *yyvsp;
81   YYSTYPE yyval;
82   YYSTYPE yylval;
83 - short yyss[YYSTACKSIZE];
84 - YYSTYPE yyvs[YYSTACKSIZE];
85 - #define yystacksize YYSTACKSIZE
86   #line 545 "perly.y"
87    /* PROGRAM */
88   #line 1347 "y.tab.c"
89 --- 1272,1279 ----
90 ***************
91 *** 1347,1360 ****
92 --- 1280,1338 ----
93   #define YYABORT goto yyabort
94   #define YYACCEPT goto yyaccept
95   #define YYERROR goto yyerrlab
96
97 + struct ysv {
98 +     short* yyss;
99 +     YYSTYPE* yyvs;
100 +     int oldyydebug;
101 +     int oldyynerrs;
102 +     int oldyyerrflag;
103 +     int oldyychar;
104 +     YYSTYPE oldyyval;
105 +     YYSTYPE oldyylval;
106 + };
107
108 + void
109 + yydestruct(ptr)
110 + void* ptr;
111 + {
112 +     struct ysv* ysave = (struct ysv*)ptr;
113 +     if (ysave->yyss) Safefree(ysave->yyss);
114 +     if (ysave->yyvs) Safefree(ysave->yyvs);
115 +     yydebug   = ysave->oldyydebug;
116 +     yynerrs   = ysave->oldyynerrs;
117 +     yyerrflag = ysave->oldyyerrflag;
118 +     yychar    = ysave->oldyychar;
119 +     yyval     = ysave->oldyyval;
120 +     yylval    = ysave->oldyylval;
121 +     Safefree(ysave);
122 + }
123
124   int
125   yyparse()
126   {
127       register int yym, yyn, yystate;
128 +     register short *yyssp;
129 +     register YYSTYPE *yyvsp;
130 +     short* yyss;
131 +     YYSTYPE* yyvs;
132 +     unsigned yystacksize = YYSTACKSIZE;
133 +     int retval = 0;
134   #if YYDEBUG
135       register char *yys;
136       extern char *getenv();
137 + #endif
138   
139 +     struct ysv *ysave = (struct ysv*)safemalloc(sizeof(struct ysv));
140 +     SAVEDESTRUCTOR(yydestruct, ysave);
141 +     ysave->oldyydebug = yydebug;
142 +     ysave->oldyynerrs = yynerrs;
143 +     ysave->oldyyerrflag       = yyerrflag;
144 +     ysave->oldyychar  = yychar;
145 +     ysave->oldyyval   = yyval;
146 +     ysave->oldyylval  = yylval;
147
148 + #if YYDEBUG
149       if (yys = getenv("YYDEBUG"))
150       {
151           yyn = *yys;
152 ***************
153 *** 1367,1372 ****
154 --- 1345,1358 ----
155       yyerrflag = 0;
156       yychar = (-1);
157   
158 +     /*
159 +     ** Initialize private stacks (yyparse may be called from an action)
160 +     */
161 +     ysave->yyss = yyss = (short*)safemalloc(yystacksize*sizeof(short));
162 +     ysave->yyvs = yyvs = (YYSTYPE*)safemalloc(yystacksize*sizeof(YYSTYPE));
163 +     if (!yyvs || !yyss)
164 +       goto yyoverflow;
165
166       yyssp = yyss;
167       yyvsp = yyvs;
168       *yyssp = yystate = 0;
169 ***************
170 *** 1382,1388 ****
171               yys = 0;
172               if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
173               if (!yys) yys = "illegal-symbol";
174 !             printf("yydebug: state %d, reading %d (%s)\n", yystate,
175                       yychar, yys);
176           }
177   #endif
178 --- 1368,1374 ----
179               yys = 0;
180               if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
181               if (!yys) yys = "illegal-symbol";
182 !             fprintf(stderr, "yydebug: state %d, reading %d (%s)\n", yystate,
183                       yychar, yys);
184           }
185   #endif
186 ***************
187 *** 1392,1403 ****
188       {
189   #if YYDEBUG
190           if (yydebug)
191 !             printf("yydebug: state %d, shifting to state %d\n",
192                       yystate, yytable[yyn]);
193   #endif
194           if (yyssp >= yyss + yystacksize - 1)
195           {
196 !             goto yyoverflow;
197           }
198           *++yyssp = yystate = yytable[yyn];
199           *++yyvsp = yylval;
200 --- 1378,1403 ----
201       {
202   #if YYDEBUG
203           if (yydebug)
204 !             fprintf(stderr, "yydebug: state %d, shifting to state %d\n",
205                       yystate, yytable[yyn]);
206   #endif
207           if (yyssp >= yyss + yystacksize - 1)
208           {
209 !           /*
210 !           ** reallocate and recover.  Note that pointers
211 !           ** have to be reset, or bad things will happen
212 !           */
213 !           int yyps_index = (yyssp - yyss);
214 !           int yypv_index = (yyvsp - yyvs);
215 !           yystacksize += YYSTACKSIZE;
216 !           ysave->yyvs = yyvs =
217 !               (YYSTYPE*)realloc((char*)yyvs,yystacksize * sizeof(YYSTYPE));
218 !           ysave->yyss = yyss =
219 !               (short*)realloc((char*)yyss,yystacksize * sizeof(short));
220 !           if (!yyvs || !yyss)
221 !               goto yyoverflow;
222 !           yyssp = yyss + yyps_index;
223 !           yyvsp = yyvs + yypv_index;
224           }
225           *++yyssp = yystate = yytable[yyn];
226           *++yyvsp = yylval;
227 ***************
228 *** 1433,1444 ****
229               {
230   #if YYDEBUG
231                   if (yydebug)
232 !                     printf("yydebug: state %d, error recovery shifting\
233 !  to state %d\n", *yyssp, yytable[yyn]);
234   #endif
235                   if (yyssp >= yyss + yystacksize - 1)
236                   {
237 !                     goto yyoverflow;
238                   }
239                   *++yyssp = yystate = yytable[yyn];
240                   *++yyvsp = yylval;
241 --- 1433,1459 ----
242               {
243   #if YYDEBUG
244                   if (yydebug)
245 !                     fprintf(stderr,
246 !                    "yydebug: state %d, error recovery shifting to state %d\n",
247 !                    *yyssp, yytable[yyn]);
248   #endif
249                   if (yyssp >= yyss + yystacksize - 1)
250                   {
251 !                   /*
252 !                   ** reallocate and recover.  Note that pointers
253 !                   ** have to be reset, or bad things will happen
254 !                   */
255 !                   int yyps_index = (yyssp - yyss);
256 !                   int yypv_index = (yyvsp - yyvs);
257 !                   yystacksize += YYSTACKSIZE;
258 !                   ysave->yyvs = yyvs = (YYSTYPE*)realloc((char*)yyvs,
259 !                       yystacksize * sizeof(YYSTYPE));
260 !                   ysave->yyss = yyss = (short*)realloc((char*)yyss,
261 !                       yystacksize * sizeof(short));
262 !                   if (!yyvs || !yyss)
263 !                       goto yyoverflow;
264 !                   yyssp = yyss + yyps_index;
265 !                   yyvsp = yyvs + yypv_index;
266                   }
267                   *++yyssp = yystate = yytable[yyn];
268                   *++yyvsp = yylval;
269 ***************
270 *** 1448,1455 ****
271               {
272   #if YYDEBUG
273                   if (yydebug)
274 !                     printf("yydebug: error recovery discarding state %d\n",
275 !                             *yyssp);
276   #endif
277                   if (yyssp <= yyss) goto yyabort;
278                   --yyssp;
279 --- 1463,1471 ----
280               {
281   #if YYDEBUG
282                   if (yydebug)
283 !                     fprintf(stderr,
284 !                       "yydebug: error recovery discarding state %d\n",
285 !                       *yyssp);
286   #endif
287                   if (yyssp <= yyss) goto yyabort;
288                   --yyssp;
289 ***************
290 *** 1466,1473 ****
291               yys = 0;
292               if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
293               if (!yys) yys = "illegal-symbol";
294 !             printf("yydebug: state %d, error recovery discards token %d (%s)\n",
295 !                     yystate, yychar, yys);
296           }
297   #endif
298           yychar = (-1);
299 --- 1482,1490 ----
300               yys = 0;
301               if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
302               if (!yys) yys = "illegal-symbol";
303 !             fprintf(stderr,
304 !               "yydebug: state %d, error recovery discards token %d (%s)\n",
305 !               yystate, yychar, yys);
306           }
307   #endif
308           yychar = (-1);
309 ***************
310 *** 1476,1482 ****
311   yyreduce:
312   #if YYDEBUG
313       if (yydebug)
314 !         printf("yydebug: state %d, reducing by rule %d (%s)\n",
315                   yystate, yyn, yyrule[yyn]);
316   #endif
317       yym = yylen[yyn];
318 --- 1493,1499 ----
319   yyreduce:
320   #if YYDEBUG
321       if (yydebug)
322 !         fprintf(stderr, "yydebug: state %d, reducing by rule %d (%s)\n",
323                   yystate, yyn, yyrule[yyn]);
324   #endif
325       yym = yylen[yyn];
326 ***************
327 *** 2163,2170 ****
328       {
329   #if YYDEBUG
330           if (yydebug)
331 !             printf("yydebug: after reduction, shifting from state 0 to\
332 !  state %d\n", YYFINAL);
333   #endif
334           yystate = YYFINAL;
335           *++yyssp = YYFINAL;
336 --- 2180,2188 ----
337       {
338   #if YYDEBUG
339           if (yydebug)
340 !             fprintf(stderr,
341 !               "yydebug: after reduction, shifting from state 0 to state %d\n",
342 !               YYFINAL);
343   #endif
344           yystate = YYFINAL;
345           *++yyssp = YYFINAL;
346 ***************
347 *** 2178,2184 ****
348                   yys = 0;
349                   if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
350                   if (!yys) yys = "illegal-symbol";
351 !                 printf("yydebug: state %d, reading %d (%s)\n",
352                           YYFINAL, yychar, yys);
353               }
354   #endif
355 --- 2196,2202 ----
356                   yys = 0;
357                   if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
358                   if (!yys) yys = "illegal-symbol";
359 !                 fprintf(stderr, "yydebug: state %d, reading %d (%s)\n",
360                           YYFINAL, yychar, yys);
361               }
362   #endif
363 ***************
364 *** 2193,2212 ****
365           yystate = yydgoto[yym];
366   #if YYDEBUG
367       if (yydebug)
368 !         printf("yydebug: after reduction, shifting from state %d \
369 ! to state %d\n", *yyssp, yystate);
370   #endif
371       if (yyssp >= yyss + yystacksize - 1)
372       {
373 !         goto yyoverflow;
374       }
375       *++yyssp = yystate;
376       *++yyvsp = yyval;
377       goto yyloop;
378   yyoverflow:
379 !     yyerror("yacc stack overflow");
380   yyabort:
381 !     return (1);
382   yyaccept:
383 !     return (0);
384   }
385 --- 2211,2245 ----
386           yystate = yydgoto[yym];
387   #if YYDEBUG
388       if (yydebug)
389 !         fprintf(stderr,
390 !           "yydebug: after reduction, shifting from state %d to state %d\n",
391 !           *yyssp, yystate);
392   #endif
393       if (yyssp >= yyss + yystacksize - 1)
394       {
395 !       /*
396 !       ** reallocate and recover.  Note that pointers
397 !       ** have to be reset, or bad things will happen
398 !       */
399 !       int yyps_index = (yyssp - yyss);
400 !       int yypv_index = (yyvsp - yyvs);
401 !       yystacksize += YYSTACKSIZE;
402 !       ysave->yyvs = yyvs =
403 !           (YYSTYPE*)realloc((char*)yyvs,yystacksize * sizeof(YYSTYPE));
404 !       ysave->yyss = yyss =
405 !           (short*)realloc((char*)yyss,yystacksize * sizeof(short));
406 !       if (!yyvs || !yyss)
407 !           goto yyoverflow;
408 !       yyssp = yyss + yyps_index;
409 !       yyvsp = yyvs + yypv_index;
410       }
411       *++yyssp = yystate;
412       *++yyvsp = yyval;
413       goto yyloop;
414   yyoverflow:
415 !     yyerror("Out of memory for yacc stack");
416   yyabort:
417 !     retval = 1;
418   yyaccept:
419 !     return retval;
420   }