This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
[perl5.git] / perly_c.diff
CommitLineData
88697ed3
SP
1--- perly.c.orig Thu Apr 7 10:51:31 2005
2+++ perly.c Thu Apr 7 10:54:13 2005
368fcb04
NC
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
88697ed3 9 #line 25 "perly.y"
368fcb04
NC
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,70 +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 ANDOP 301
69-#define NOTOP 302
70-#define ASSIGNOP 303
71-#define OROR 304
72-#define ANDAND 305
73-#define BITOROP 306
74-#define BITANDOP 307
75-#define SHIFTOP 308
76-#define MATCHOP 309
77-#define UMINUS 310
78-#define REFGEN 311
79-#define POWOP 312
80-#define PREINC 313
81-#define PREDEC 314
82-#define POSTINC 315
83-#define POSTDEC 316
84-#define ARROW 317
85+#line 54 "perly.c"
86 #define YYERRCODE 256
87-short yylhs[] = { -1,
88+static short yylhs[] = { -1,
89 0, 9, 7, 6, 10, 8, 11, 11, 11, 12,
90 12, 12, 12, 25, 25, 25, 25, 25, 25, 25,
91 15, 15, 15, 14, 14, 43, 43, 13, 13, 13,
92@@ -135,7 +74,7 @@
93 49, 34, 34, 35, 35, 35, 44, 24, 19, 20,
94 21, 22, 23, 36, 36, 36, 36,
95 };
96-short yylen[] = { 2,
97+static short yylen[] = { 2,
98 2, 4, 0, 0, 4, 0, 0, 2, 2, 2,
99 1, 2, 3, 1, 1, 3, 3, 3, 3, 3,
100 0, 2, 6, 7, 7, 0, 2, 8, 8, 10,
101@@ -157,7 +96,7 @@
102 1, 0, 1, 0, 1, 2, 1, 2, 2, 2,
103 2, 2, 2, 1, 1, 1, 1,
104 };
105-short yydefred[] = { 4,
106+static short yydefred[] = { 4,
107 0, 7, 0, 45, 58, 56, 0, 56, 56, 8,
108 46, 9, 11, 48, 0, 47, 49, 50, 0, 0,
109 0, 70, 71, 0, 14, 3, 173, 0, 0, 154,
110@@ -199,7 +138,7 @@
111 0, 22, 0, 0, 0, 31, 5, 0, 30, 0,
112 0, 33, 0, 23,
113 };
114-short yydgoto[] = { 1,
115+static short yydgoto[] = { 1,
116 10, 11, 20, 104, 19, 2, 95, 370, 98, 359,
117 3, 12, 13, 70, 375, 285, 72, 73, 74, 75,
118 76, 77, 78, 79, 291, 81, 292, 281, 283, 286,
119@@ -207,7 +146,7 @@
120 194, 327, 156, 289, 271, 225, 14, 83, 137, 84,
121 85, 86, 87, 15, 16, 17, 18, 93, 278,
122 };
123-short yysindex[] = { 0,
124+static short yysindex[] = { 0,
125 0, 0, -132, 0, 0, 0, -51, 0, 0, 0,
126 0, 0, 0, 0, 650, 0, 0, 0, -239, -215,
127 5, 0, 0, -215, 0, 0, 0, -31, -31, 0,
128@@ -249,7 +188,7 @@
129 449, 0, 2181, -150, 340, 0, 0, 355, 0, 216,
130 216, 0, -123, 0,
131 };
132-short yyrindex[] = { 0,
133+static short yyrindex[] = { 0,
134 0, 0, 247, 0, 0, 0, 0, 0, 0, 0,
135 0, 0, 0, 0, 0, 0, 0, 0, 274, 0,
136 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
137@@ -291,7 +230,7 @@
138 917, 0, 0, 119, 0, 0, 0, 0, 0, 0,
139 0, 0, 179, 0,
140 };
141-short yygindex[] = { 0,
142+static short yygindex[] = { 0,
143 0, 0, 196, 425, 0, 0, -2, 0, 37, 634,
144 -94, 0, 0, 0, -323, -15, 2445, 0, 999, 414,
145 417, 0, 0, 0, 463, -43, 0, 0, 321, -198,
146@@ -300,7 +239,7 @@
147 0, 0, 0, 0, 0, 0, 0, 0, 0,
148 };
149 #define YYTABLESIZE 4568
150-short yytable[] = { 71,
151+static short yytable[] = { 71,
152 197, 65, 121, 227, 65, 111, 220, 22, 198, 293,
153 139, 296, 315, 275, 305, 102, 273, 88, 113, 228,
154 60, 113, 279, 65, 317, 60, 182, 254, 325, 101,
155@@ -759,7 +698,7 @@
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
157 0, 0, 0, 0, 0, 0, 77, 77,
158 };
159-short yycheck[] = { 15,
160+static short yycheck[] = { 15,
161 95, 36, 46, 41, 36, 40, 59, 59, 100, 208,
162 54, 41, 59, 199, 41, 40, 196, 257, 41, 93,
163 123, 44, 202, 36, 93, 59, 40, 40, 59, 29,
164@@ -1224,7 +1163,7 @@
165 #endif
166 #define YYMAXTOKEN 317
167 #if YYDEBUG
168-char *yyname[] = {
169+static char *yyname[] = {
170 "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,
171 "'!'",0,0,"'$'","'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,0,0,0,0,0,0,
172 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@@ -1241,7 +1180,7 @@
174 "ANDAND","BITOROP","BITANDOP","SHIFTOP","MATCHOP","UMINUS","REFGEN","POWOP",
175 "PREINC","PREDEC","POSTINC","POSTDEC","ARROW",
176 };
177-char *yyrule[] = {
178+static char *yyrule[] = {
179 "$accept : prog",
180 "prog : progstart lineseq",
181 "block : '{' remember lineseq '}'",
182@@ -1456,17 +1395,6 @@
183 #define YYMAXDEPTH 500
184 #endif
185 #endif
186-int yydebug;
187-int yynerrs;
188-int yyerrflag;
189-int yychar;
190-short *yyssp;
191-YYSTYPE *yyvsp;
192-YYSTYPE yyval;
193-YYSTYPE yylval;
194-short yyss[YYSTACKSIZE];
195-YYSTYPE yyvs[YYSTACKSIZE];
196-#define yystacksize YYSTACKSIZE
88697ed3 197 #line 804 "perly.y"
368fcb04
NC
198 /* PROGRAM */
199
200@@ -1477,7 +1405,7 @@
201 #endif
202 #define yyparse() Perl_yyparse(pTHX)
203
204-#line 1481 "y.tab.c"
205+#line 1409 "perly.c"
206 #define YYABORT goto yyabort
207 #define YYACCEPT goto yyaccept
208 #define YYERROR goto yyerrlab
209@@ -1485,11 +1413,31 @@
210 yyparse()
211 {
212 register int yym, yyn, yystate;
213+ register short *yyssp;
214+ register YYSTYPE *yyvsp;
215+ short* yyss;
216+ YYSTYPE* yyvs;
217+ unsigned yystacksize = YYSTACKSIZE;
218+ int retval = 0;
219 #if YYDEBUG
220 register char *yys;
221- extern char *getenv();
222+#endif
223+
224+ struct ysv *ysave;
225+#ifdef USE_ITHREADS
226+ ENTER; /* force yydestruct() before we return */
227+#endif
228+ New(73, ysave, 1, struct ysv);
229+ SAVEDESTRUCTOR_X(yydestruct, ysave);
230+ ysave->oldyydebug = yydebug;
231+ ysave->oldyynerrs = yynerrs;
232+ ysave->oldyyerrflag = yyerrflag;
233+ ysave->oldyychar = yychar;
234+ ysave->oldyyval = yyval;
235+ ysave->oldyylval = yylval;
236
237- if (yys = getenv("YYDEBUG"))
238+#if YYDEBUG
239+ if ((yys = getenv("YYDEBUG")))
240 {
241 yyn = *yys;
242 if (yyn >= '0' && yyn <= '9')
243@@ -1501,12 +1449,22 @@
244 yyerrflag = 0;
245 yychar = (-1);
246
247+ /*
248+ ** Initialize private stacks (yyparse may be called from an action)
249+ */
250+ New(73, yyss, yystacksize, short);
251+ New(73, yyvs, yystacksize, YYSTYPE);
252+ ysave->yyss = yyss;
253+ ysave->yyvs = yyvs;
254+ if (!yyvs || !yyss)
255+ goto yyoverflow;
256+
257 yyssp = yyss;
258 yyvsp = yyvs;
259 *yyssp = yystate = 0;
260
261 yyloop:
262- if (yyn = yydefred[yystate]) goto yyreduce;
263+ if ((yyn = yydefred[yystate])) goto yyreduce;
264 if (yychar < 0)
265 {
266 if ((yychar = yylex()) < 0) yychar = 0;
267@@ -1516,7 +1474,7 @@
268 yys = 0;
269 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
270 if (!yys) yys = "illegal-symbol";
271- printf("yydebug: state %d, reading %d (%s)\n", yystate,
272+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, reading %d (%s)\n", yystate,
273 yychar, yys);
274 }
275 #endif
276@@ -1526,12 +1484,24 @@
277 {
278 #if YYDEBUG
279 if (yydebug)
280- printf("yydebug: state %d, shifting to state %d\n",
281+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, shifting to state %d\n",
282 yystate, yytable[yyn]);
283 #endif
284 if (yyssp >= yyss + yystacksize - 1)
285 {
286+ /*
287+ ** reallocate and recover. Note that pointers
288+ ** have to be reset, or bad things will happen
289+ */
290+ int yyps_index = (yyssp - yyss);
291+ int yypv_index = (yyvsp - yyvs);
292+ yystacksize += YYSTACKSIZE;
293+ ysave->yyvs = Renew(yyvs, yystacksize, YYSTYPE);
294+ ysave->yyss = Renew(yyss, yystacksize, short);
295+ if (!yyvs || !yyss)
296 goto yyoverflow;
297+ yyssp = yyss + yyps_index;
298+ yyvsp = yyvs + yypv_index;
299 }
300 *++yyssp = yystate = yytable[yyn];
301 *++yyvsp = yylval;
302@@ -1547,14 +1517,14 @@
303 }
304 if (yyerrflag) goto yyinrecovery;
305 #ifdef lint
306- goto yynewerror;
307+
308 #endif
309-yynewerror:
310+
311 yyerror("syntax error");
312 #ifdef lint
313- goto yyerrlab;
314+
315 #endif
316-yyerrlab:
317+
318 ++yynerrs;
319 yyinrecovery:
320 if (yyerrflag < 3)
321@@ -1567,12 +1537,24 @@
322 {
323 #if YYDEBUG
324 if (yydebug)
325- printf("yydebug: state %d, error recovery shifting\
326+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, error recovery shifting\
327 to state %d\n", *yyssp, yytable[yyn]);
328 #endif
329 if (yyssp >= yyss + yystacksize - 1)
330 {
331+ /*
332+ ** reallocate and recover. Note that pointers
333+ ** have to be reset, or bad things will happen
334+ */
335+ int yyps_index = (yyssp - yyss);
336+ int yypv_index = (yyvsp - yyvs);
337+ yystacksize += YYSTACKSIZE;
338+ ysave->yyvs = Renew(yyvs, yystacksize, YYSTYPE);
339+ ysave->yyss = Renew(yyss, yystacksize, short);
340+ if (!yyvs || !yyss)
341 goto yyoverflow;
342+ yyssp = yyss + yyps_index;
343+ yyvsp = yyvs + yypv_index;
344 }
345 *++yyssp = yystate = yytable[yyn];
346 *++yyvsp = yylval;
347@@ -1582,7 +1564,7 @@
348 {
349 #if YYDEBUG
350 if (yydebug)
351- printf("yydebug: error recovery discarding state %d\n",
352+ PerlIO_printf(Perl_debug_log, "yydebug: error recovery discarding state %d\n",
353 *yyssp);
354 #endif
355 if (yyssp <= yyss) goto yyabort;
356@@ -1600,7 +1582,7 @@
357 yys = 0;
358 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
359 if (!yys) yys = "illegal-symbol";
360- printf("yydebug: state %d, error recovery discards token %d (%s)\n",
361+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, error recovery discards token %d (%s)\n",
362 yystate, yychar, yys);
363 }
364 #endif
365@@ -1610,7 +1592,7 @@
366 yyreduce:
367 #if YYDEBUG
368 if (yydebug)
369- printf("yydebug: state %d, reducing by rule %d (%s)\n",
370+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, reducing by rule %d (%s)\n",
371 yystate, yyn, yyrule[yyn]);
372 #endif
373 yym = yylen[yyn];
88697ed3 374@@ -2485,7 +2467,7 @@
368fcb04
NC
375 {
376 #if YYDEBUG
377 if (yydebug)
378- printf("yydebug: after reduction, shifting from state 0 to\
379+ PerlIO_printf(Perl_debug_log, "yydebug: after reduction, shifting from state 0 to\
380 state %d\n", YYFINAL);
381 #endif
382 yystate = YYFINAL;
88697ed3 383@@ -2500,7 +2482,7 @@
368fcb04
NC
384 yys = 0;
385 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
386 if (!yys) yys = "illegal-symbol";
387- printf("yydebug: state %d, reading %d (%s)\n",
388+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, reading %d (%s)\n",
389 YYFINAL, yychar, yys);
390 }
391 #endif
88697ed3 392@@ -2515,20 +2497,50 @@
368fcb04
NC
393 yystate = yydgoto[yym];
394 #if YYDEBUG
395 if (yydebug)
396- printf("yydebug: after reduction, shifting from state %d \
397+ PerlIO_printf(Perl_debug_log, "yydebug: after reduction, shifting from state %d \
398 to state %d\n", *yyssp, yystate);
399 #endif
400 if (yyssp >= yyss + yystacksize - 1)
401 {
402+ /*
403+ ** reallocate and recover. Note that pointers
404+ ** have to be reset, or bad things will happen
405+ */
406+ int yyps_index = (yyssp - yyss);
407+ int yypv_index = (yyvsp - yyvs);
408+ yystacksize += YYSTACKSIZE;
409+ ysave->yyvs = Renew(yyvs, yystacksize, YYSTYPE);
410+ ysave->yyss = Renew(yyss, yystacksize, short);
411+ if (!yyvs || !yyss)
412 goto yyoverflow;
413+ yyssp = yyss + yyps_index;
414+ yyvsp = yyvs + yypv_index;
415 }
416 *++yyssp = yystate;
417 *++yyvsp = yyval;
418 goto yyloop;
419 yyoverflow:
420- yyerror("yacc stack overflow");
421+ yyerror("Out of memory for yacc stack");
422 yyabort:
423- return (1);
424+ retval = 1;
425 yyaccept:
426- return (0);
427+#ifdef USE_ITHREADS
428+ LEAVE; /* force yydestruct() before we return */
429+#endif
430+ return retval;
431+}
432+
433+static void
434+yydestruct(pTHX_ void *ptr)
435+{
436+ struct ysv* ysave = (struct ysv*)ptr;
437+ if (ysave->yyss) Safefree(ysave->yyss);
438+ if (ysave->yyvs) Safefree(ysave->yyvs);
439+ yydebug = ysave->oldyydebug;
440+ yynerrs = ysave->oldyynerrs;
441+ yyerrflag = ysave->oldyyerrflag;
442+ yychar = ysave->oldyychar;
443+ yyval = ysave->oldyyval;
444+ yylval = ysave->oldyylval;
445+ Safefree(ysave);
446 }