Integrate mainline.
[p5sagit/p5-mst-13.2.git] / perly_c.diff
CommitLineData
ed423f7a 1--- perly.c.orig Mon Aug 5 15:02:10 2002
2+++ perly.c Mon Aug 5 15:08:41 2002
3@@ -1,5 +1,5 @@
4 #ifndef lint
5-static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/91";
6+/* static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/91"; */
7 #endif
8 #define YYBYACC 1
9 #line 16 "perly.y"
10@@ -9,7 +9,7 @@
11 #ifdef EBCDIC
12 #undef YYDEBUG
13 #endif
14-#define dep() deprecate("\"do\" to call subroutines")
15+#define dep() deprecate_old("\"do\" to call subroutines")
16
17 /* stuff included here to make perly_c.diff apply better */
18
19@@ -50,72 +50,9 @@
20 #define yylex yylex_r
21 #endif
22
23-#line 54 "y.tab.c"
24-#define WORD 257
25-#define METHOD 258
26-#define FUNCMETH 259
27-#define THING 260
28-#define PMFUNC 261
29-#define PRIVATEREF 262
30-#define FUNC0SUB 263
31-#define UNIOPSUB 264
32-#define LSTOPSUB 265
33-#define LABEL 266
34-#define FORMAT 267
35-#define SUB 268
36-#define ANONSUB 269
37-#define PACKAGE 270
38-#define USE 271
39-#define WHILE 272
40-#define UNTIL 273
41-#define IF 274
42-#define UNLESS 275
43-#define ELSE 276
44-#define ELSIF 277
45-#define CONTINUE 278
46-#define FOR 279
47-#define LOOPEX 280
48-#define DOTDOT 281
49-#define FUNC0 282
50-#define FUNC1 283
51-#define FUNC 284
52-#define UNIOP 285
53-#define LSTOP 286
54-#define RELOP 287
55-#define EQOP 288
56-#define MULOP 289
57-#define ADDOP 290
58-#define DOLSHARP 291
59-#define DO 292
60-#define HASHBRACK 293
61-#define NOAMP 294
62-#define LOCAL 295
63-#define MY 296
64-#define MYSUB 297
65-#define COLONATTR 298
66-#define PREC_LOW 299
67-#define OROP 300
68-#define DOROP 301
69-#define ANDOP 302
70-#define NOTOP 303
71-#define ASSIGNOP 304
72-#define OROR 305
73-#define DORDOR 306
74-#define ANDAND 307
75-#define BITOROP 308
76-#define BITANDOP 309
77-#define SHIFTOP 310
78-#define MATCHOP 311
79-#define UMINUS 312
80-#define REFGEN 313
81-#define POWOP 314
82-#define PREINC 315
83-#define PREDEC 316
84-#define POSTINC 317
85-#define POSTDEC 318
86-#define ARROW 319
87+#line 54 "perly.c"
88 #define YYERRCODE 256
89-short yylhs[] = { -1,
90+static short yylhs[] = { -1,
91 0, 9, 7, 6, 10, 8, 11, 11, 11, 12,
92 12, 12, 12, 25, 25, 25, 25, 25, 25, 25,
93 15, 15, 15, 14, 14, 43, 43, 13, 13, 13,
94@@ -137,7 +74,7 @@
95 49, 49, 49, 34, 34, 35, 35, 35, 44, 24,
96 19, 20, 21, 22, 23, 36, 36, 36, 36,
97 };
98-short yylen[] = { 2,
99+static short yylen[] = { 2,
100 2, 4, 0, 0, 4, 0, 0, 2, 2, 2,
101 1, 2, 3, 1, 1, 3, 3, 3, 3, 3,
102 0, 2, 6, 7, 7, 0, 2, 8, 8, 10,
103@@ -159,7 +96,7 @@
104 1, 1, 1, 0, 1, 0, 1, 2, 1, 2,
105 2, 2, 2, 2, 2, 1, 1, 1, 1,
106 };
107-short yydefred[] = { 4,
108+static short yydefred[] = { 4,
109 0, 7, 0, 45, 58, 56, 0, 56, 56, 8,
110 46, 9, 11, 48, 0, 47, 49, 50, 0, 0,
111 0, 70, 71, 0, 14, 3, 175, 0, 0, 156,
112@@ -201,7 +138,7 @@
113 0, 32, 0, 0, 0, 22, 0, 0, 0, 31,
114 5, 0, 30, 0, 0, 33, 0, 23,
115 };
116-short yydgoto[] = { 1,
117+static short yydgoto[] = { 1,
118 10, 11, 20, 104, 19, 2, 95, 374, 98, 363,
119 3, 12, 13, 70, 379, 289, 72, 73, 74, 75,
120 76, 77, 78, 79, 295, 81, 296, 285, 287, 290,
121@@ -209,7 +146,7 @@
122 196, 331, 156, 293, 275, 227, 14, 83, 137, 84,
123 85, 86, 87, 15, 16, 17, 18, 93, 282,
124 };
125-short yysindex[] = { 0,
126+static short yysindex[] = { 0,
127 0, 0, -183, 0, 0, 0, -57, 0, 0, 0,
128 0, 0, 0, 0, 820, 0, 0, 0, -222, -208,
129 7, 0, 0, -208, 0, 0, 0, -31, -31, 0,
130@@ -251,7 +188,7 @@
131 179, 0, 1860, -168, 352, 0, 2214, -168, 298, 0,
132 0, 299, 0, 179, 179, 0, -256, 0,
133 };
134-short yyrindex[] = { 0,
135+static short yyrindex[] = { 0,
136 0, 0, 372, 0, 0, 0, 0, 0, 0, 0,
137 0, 0, 0, 0, 0, 0, 0, 0, 219, 0,
138 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
139@@ -293,7 +230,7 @@
140 0, 0, 370, 91, 881, 0, 0, 91, 0, 0,
141 0, 0, 0, 0, 0, 0, 187, 0,
142 };
143-short yygindex[] = { 0,
144+static short yygindex[] = { 0,
145 0, 0, 29, 378, 0, 0, -55, 0, 676, 567,
146 -94, 0, 0, 0, -355, -15, 2480, 0, 650, 364,
147 380, 0, 0, 0, 412, 755, 0, 0, 291, -202,
148@@ -302,7 +239,7 @@
149 0, 0, 0, 0, 0, 0, 0, 0, 0,
150 };
151 #define YYTABLESIZE 5052
152-short yytable[] = { 71,
153+static short yytable[] = { 71,
154 199, 22, 60, 229, 65, 65, 222, 297, 60, 111,
155 380, 200, 279, 329, 65, 300, 62, 64, 258, 377,
156 378, 161, 15, 184, 161, 220, 230, 187, 65, 67,
157@@ -810,7 +747,7 @@
158 0, 0, 0, 0, 0, 115, 115, 115, 0, 115,
159 115, 115,
160 };
161-short yycheck[] = { 15,
162+static short yycheck[] = { 15,
163 95, 59, 59, 41, 36, 36, 59, 210, 123, 40,
164 366, 100, 201, 59, 36, 41, 59, 59, 40, 276,
165 277, 41, 41, 40, 44, 40, 93, 91, 36, 37,
166@@ -1324,7 +1261,7 @@
167 #endif
168 #define YYMAXTOKEN 319
169 #if YYDEBUG
170-char *yyname[] = {
171+static char *yyname[] = {
172 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
173 "'!'",0,0,"'$'","'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,0,0,0,0,0,0,
174 0,0,0,0,0,"':'","';'",0,0,0,"'?'","'@'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
175@@ -1341,7 +1278,7 @@
176 "DORDOR","ANDAND","BITOROP","BITANDOP","SHIFTOP","MATCHOP","UMINUS","REFGEN",
177 "POWOP","PREINC","PREDEC","POSTINC","POSTDEC","ARROW",
178 };
179-char *yyrule[] = {
180+static char *yyrule[] = {
181 "$accept : prog",
182 "prog : progstart lineseq",
183 "block : '{' remember lineseq '}'",
184@@ -1558,17 +1495,6 @@
185 #define YYMAXDEPTH 500
186 #endif
187 #endif
188-int yydebug;
189-int yynerrs;
190-int yyerrflag;
191-int yychar;
192-short *yyssp;
193-YYSTYPE *yyvsp;
194-YYSTYPE yyval;
195-YYSTYPE yylval;
196-short yyss[YYSTACKSIZE];
197-YYSTYPE yyvs[YYSTACKSIZE];
198-#define yystacksize YYSTACKSIZE
199 #line 797 "perly.y"
200 /* PROGRAM */
201
202@@ -1579,7 +1505,7 @@
203 #endif
204 #define yyparse() Perl_yyparse(pTHX)
205
206-#line 1583 "y.tab.c"
207+#line 1509 "perly.c"
208 #define YYABORT goto yyabort
209 #define YYACCEPT goto yyaccept
210 #define YYERROR goto yyerrlab
211@@ -1587,11 +1513,31 @@
212 yyparse()
213 {
214 register int yym, yyn, yystate;
215+ register short *yyssp;
216+ register YYSTYPE *yyvsp;
217+ short* yyss;
218+ YYSTYPE* yyvs;
219+ unsigned yystacksize = YYSTACKSIZE;
220+ int retval = 0;
221 #if YYDEBUG
222 register char *yys;
223- extern char *getenv();
224+#endif
225+
226+ struct ysv *ysave;
227+#ifdef USE_ITHREADS
228+ ENTER; /* force yydestruct() before we return */
229+#endif
230+ New(73, ysave, 1, struct ysv);
231+ SAVEDESTRUCTOR_X(yydestruct, ysave);
232+ ysave->oldyydebug = yydebug;
233+ ysave->oldyynerrs = yynerrs;
234+ ysave->oldyyerrflag = yyerrflag;
235+ ysave->oldyychar = yychar;
236+ ysave->oldyyval = yyval;
237+ ysave->oldyylval = yylval;
238
239- if (yys = getenv("YYDEBUG"))
240+#if YYDEBUG
241+ if ((yys = getenv("YYDEBUG")))
242 {
243 yyn = *yys;
244 if (yyn >= '0' && yyn <= '9')
245@@ -1603,12 +1549,22 @@
246 yyerrflag = 0;
247 yychar = (-1);
248
249+ /*
250+ ** Initialize private stacks (yyparse may be called from an action)
251+ */
252+ New(73, yyss, yystacksize, short);
253+ New(73, yyvs, yystacksize, YYSTYPE);
254+ ysave->yyss = yyss;
255+ ysave->yyvs = yyvs;
256+ if (!yyvs || !yyss)
257+ goto yyoverflow;
258+
259 yyssp = yyss;
260 yyvsp = yyvs;
261 *yyssp = yystate = 0;
262
263 yyloop:
264- if (yyn = yydefred[yystate]) goto yyreduce;
265+ if ((yyn = yydefred[yystate])) goto yyreduce;
266 if (yychar < 0)
267 {
268 if ((yychar = yylex()) < 0) yychar = 0;
269@@ -1618,7 +1574,7 @@
270 yys = 0;
271 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
272 if (!yys) yys = "illegal-symbol";
273- printf("yydebug: state %d, reading %d (%s)\n", yystate,
274+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, reading %d (%s)\n", yystate,
275 yychar, yys);
276 }
277 #endif
278@@ -1628,12 +1584,24 @@
279 {
280 #if YYDEBUG
281 if (yydebug)
282- printf("yydebug: state %d, shifting to state %d\n",
283+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, shifting to state %d\n",
284 yystate, yytable[yyn]);
285 #endif
286 if (yyssp >= yyss + yystacksize - 1)
287 {
288+ /*
289+ ** reallocate and recover. Note that pointers
290+ ** have to be reset, or bad things will happen
291+ */
292+ int yyps_index = (yyssp - yyss);
293+ int yypv_index = (yyvsp - yyvs);
294+ yystacksize += YYSTACKSIZE;
295+ ysave->yyvs = Renew(yyvs, yystacksize, YYSTYPE);
296+ ysave->yyss = Renew(yyss, yystacksize, short);
297+ if (!yyvs || !yyss)
298 goto yyoverflow;
299+ yyssp = yyss + yyps_index;
300+ yyvsp = yyvs + yypv_index;
301 }
302 *++yyssp = yystate = yytable[yyn];
303 *++yyvsp = yylval;
304@@ -1649,14 +1617,14 @@
305 }
306 if (yyerrflag) goto yyinrecovery;
307 #ifdef lint
308- goto yynewerror;
309+
310 #endif
311-yynewerror:
312+
313 yyerror("syntax error");
314 #ifdef lint
315- goto yyerrlab;
316+
317 #endif
318-yyerrlab:
319+
320 ++yynerrs;
321 yyinrecovery:
322 if (yyerrflag < 3)
323@@ -1669,12 +1637,24 @@
324 {
325 #if YYDEBUG
326 if (yydebug)
327- printf("yydebug: state %d, error recovery shifting\
328+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, error recovery shifting\
329 to state %d\n", *yyssp, yytable[yyn]);
330 #endif
331 if (yyssp >= yyss + yystacksize - 1)
332 {
333+ /*
334+ ** reallocate and recover. Note that pointers
335+ ** have to be reset, or bad things will happen
336+ */
337+ int yyps_index = (yyssp - yyss);
338+ int yypv_index = (yyvsp - yyvs);
339+ yystacksize += YYSTACKSIZE;
340+ ysave->yyvs = Renew(yyvs, yystacksize, YYSTYPE);
341+ ysave->yyss = Renew(yyss, yystacksize, short);
342+ if (!yyvs || !yyss)
343 goto yyoverflow;
344+ yyssp = yyss + yyps_index;
345+ yyvsp = yyvs + yypv_index;
346 }
347 *++yyssp = yystate = yytable[yyn];
348 *++yyvsp = yylval;
349@@ -1684,7 +1664,7 @@
350 {
351 #if YYDEBUG
352 if (yydebug)
353- printf("yydebug: error recovery discarding state %d\n",
354+ PerlIO_printf(Perl_debug_log, "yydebug: error recovery discarding state %d\n",
355 *yyssp);
356 #endif
357 if (yyssp <= yyss) goto yyabort;
358@@ -1702,7 +1682,7 @@
359 yys = 0;
360 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
361 if (!yys) yys = "illegal-symbol";
362- printf("yydebug: state %d, error recovery discards token %d (%s)\n",
363+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, error recovery discards token %d (%s)\n",
364 yystate, yychar, yys);
365 }
366 #endif
367@@ -1712,7 +1692,7 @@
368 yyreduce:
369 #if YYDEBUG
370 if (yydebug)
371- printf("yydebug: state %d, reducing by rule %d (%s)\n",
372+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, reducing by rule %d (%s)\n",
373 yystate, yyn, yyrule[yyn]);
374 #endif
375 yym = yylen[yyn];
376@@ -2583,7 +2563,7 @@
377 #line 794 "perly.y"
378 { yyval.opval = yyvsp[0].opval; }
379 break;
380-#line 2587 "y.tab.c"
381+#line 2567 "perly.c"
382 }
383 yyssp -= yym;
384 yystate = *yyssp;
385@@ -2593,7 +2573,7 @@
386 {
387 #if YYDEBUG
388 if (yydebug)
389- printf("yydebug: after reduction, shifting from state 0 to\
390+ PerlIO_printf(Perl_debug_log, "yydebug: after reduction, shifting from state 0 to\
391 state %d\n", YYFINAL);
392 #endif
393 yystate = YYFINAL;
394@@ -2608,7 +2588,7 @@
395 yys = 0;
396 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
397 if (!yys) yys = "illegal-symbol";
398- printf("yydebug: state %d, reading %d (%s)\n",
399+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, reading %d (%s)\n",
400 YYFINAL, yychar, yys);
401 }
402 #endif
403@@ -2623,20 +2603,50 @@
404 yystate = yydgoto[yym];
405 #if YYDEBUG
406 if (yydebug)
407- printf("yydebug: after reduction, shifting from state %d \
408+ PerlIO_printf(Perl_debug_log, "yydebug: after reduction, shifting from state %d \
409 to state %d\n", *yyssp, yystate);
410 #endif
411 if (yyssp >= yyss + yystacksize - 1)
412 {
413+ /*
414+ ** reallocate and recover. Note that pointers
415+ ** have to be reset, or bad things will happen
416+ */
417+ int yyps_index = (yyssp - yyss);
418+ int yypv_index = (yyvsp - yyvs);
419+ yystacksize += YYSTACKSIZE;
420+ ysave->yyvs = Renew(yyvs, yystacksize, YYSTYPE);
421+ ysave->yyss = Renew(yyss, yystacksize, short);
422+ if (!yyvs || !yyss)
423 goto yyoverflow;
424+ yyssp = yyss + yyps_index;
425+ yyvsp = yyvs + yypv_index;
426 }
427 *++yyssp = yystate;
428 *++yyvsp = yyval;
429 goto yyloop;
430 yyoverflow:
431- yyerror("yacc stack overflow");
432+ yyerror("Out of memory for yacc stack");
433 yyabort:
434- return (1);
435+ retval = 1;
436 yyaccept:
437- return (0);
438+#ifdef USE_ITHREADS
439+ LEAVE; /* force yydestruct() before we return */
440+#endif
441+ return retval;
442+}
443+
444+static void
445+yydestruct(pTHX_ void *ptr)
446+{
447+ struct ysv* ysave = (struct ysv*)ptr;
448+ if (ysave->yyss) Safefree(ysave->yyss);
449+ if (ysave->yyvs) Safefree(ysave->yyvs);
450+ yydebug = ysave->oldyydebug;
451+ yynerrs = ysave->oldyynerrs;
452+ yyerrflag = ysave->oldyyerrflag;
453+ yychar = ysave->oldyychar;
454+ yyval = ysave->oldyyval;
455+ yylval = ysave->oldyylval;
456+ Safefree(ysave);
457 }