This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
slightly edited version of suggested patch
[perl5.git] / perly_c.diff
1 *** perly.c.orig        Sun Feb  7 04:48:56 1999
2 --- perly.c     Sun Feb  7 05:30:49 1999
3 ***************
4 *** 7,10 ****
5 --- 7,25 ----
6   #include "perl.h"
7   
8 + #define yydebug           PL_yydebug
9 + #define yynerrs           PL_yynerrs
10 + #define yyerrflag   PL_yyerrflag
11 + #define yychar            PL_yychar
12 + #define yyval     PL_yyval
13 + #define yylval            PL_yylval
14
15 + #ifdef PERL_OBJECT
16 + static void
17 + Dep(CPerlObj *pPerl)
18 + {
19 +     pPerl->deprecate("\"do\" to call subroutines");
20 + }
21 + #define dep() Dep(this)
22 + #else
23   static void
24   dep(void)
25 ***************
26 *** 12,93 ****
27       deprecate("\"do\" to call subroutines");
28   }
29   
30   #line 30 "perly.y"
31 - /* I sense a Big Blue pattern here... */
32 - #if !defined(OEMVS) && !defined(__OPEN_VM) && !defined(POSIX_BC)
33 - #line 34 "perly.y"
34 - typedef union {
35 -     I32       ival;
36 -     char *pval;
37 -     OP *opval;
38 -     GV *gvval;
39 - } YYSTYPE;
40 - #line 42 "perly.y"
41 - #endif /* !OEMVS && !__OPEN_VM && !POSIX_BC */
42
43 - #ifdef USE_PURE_BISON
44 - #define YYLEX_PARAM (&yychar)
45 - #endif
46 - #line 32 "y.tab.c"
47 - #define WORD 257
48 - #define METHOD 258
49 - #define FUNCMETH 259
50 - #define THING 260
51 - #define PMFUNC 261
52 - #define PRIVATEREF 262
53 - #define FUNC0SUB 263
54 - #define UNIOPSUB 264
55 - #define LSTOPSUB 265
56 - #define LABEL 266
57 - #define FORMAT 267
58 - #define SUB 268
59 - #define ANONSUB 269
60 - #define PACKAGE 270
61 - #define USE 271
62 - #define WHILE 272
63 - #define UNTIL 273
64 - #define IF 274
65 - #define UNLESS 275
66 - #define ELSE 276
67 - #define ELSIF 277
68 - #define CONTINUE 278
69 - #define FOR 279
70 - #define LOOPEX 280
71 - #define DOTDOT 281
72 - #define FUNC0 282
73 - #define FUNC1 283
74 - #define FUNC 284
75 - #define UNIOP 285
76 - #define LSTOP 286
77 - #define RELOP 287
78 - #define EQOP 288
79 - #define MULOP 289
80 - #define ADDOP 290
81 - #define DOLSHARP 291
82 - #define DO 292
83 - #define HASHBRACK 293
84 - #define NOAMP 294
85 - #define LOCAL 295
86 - #define MY 296
87 - #define OROP 297
88 - #define ANDOP 298
89 - #define NOTOP 299
90 - #define ASSIGNOP 300
91 - #define OROR 301
92 - #define ANDAND 302
93 - #define BITOROP 303
94 - #define BITANDOP 304
95 - #define SHIFTOP 305
96 - #define MATCHOP 306
97 - #define UMINUS 307
98 - #define REFGEN 308
99 - #define POWOP 309
100 - #define PREINC 310
101 - #define PREDEC 311
102 - #define POSTINC 312
103 - #define POSTDEC 313
104 - #define ARROW 314
105   #define YYERRCODE 256
106 ! short yylhs[] = {                                        -1,
107      45,    0,    9,    7,   10,    8,   11,   11,   11,   12,
108      12,   12,   12,   24,   24,   24,   24,   24,   24,   24,
109 --- 27,35 ----
110       deprecate("\"do\" to call subroutines");
111   }
112 + #endif
113   
114   #line 30 "perly.y"
115   #define YYERRCODE 256
116 ! static short yylhs[] = {                                 -1,
117      45,    0,    9,    7,   10,    8,   11,   11,   11,   12,
118      12,   12,   12,   24,   24,   24,   24,   24,   24,   24,
119 ***************
120 *** 109,113 ****
121      20,   21,   22,   35,   35,   35,   35,
122   };
123 ! short yylen[] = {                                         2,
124       0,    2,    4,    0,    4,    0,    0,    2,    2,    2,
125       1,    2,    3,    1,    1,    3,    3,    3,    3,    3,
126 --- 51,55 ----
127      20,   21,   22,   35,   35,   35,   35,
128   };
129 ! static short yylen[] = {                                  2,
130       0,    2,    4,    0,    4,    0,    0,    2,    2,    2,
131       1,    2,    3,    1,    1,    3,    3,    3,    3,    3,
132 ***************
133 *** 129,133 ****
134       2,    2,    2,    1,    1,    1,    1,
135   };
136 ! short yydefred[] = {                                      1,
137       0,    7,    0,   45,   56,   54,    0,   54,    8,   46,
138       9,   11,    0,   47,   48,   49,    0,    0,    0,   63,
139 --- 71,75 ----
140       2,    2,    2,    1,    1,    1,    1,
141   };
142 ! static short yydefred[] = {                               1,
143       0,    7,    0,   45,   56,   54,    0,   54,    8,   46,
144       9,   11,    0,   47,   48,   49,    0,    0,    0,   63,
145 ***************
146 *** 168,172 ****
147      33,    0,   23,
148   };
149 ! short yydgoto[] = {                                       1,
150       9,   66,   10,   18,   95,   17,   86,  339,   89,  328,
151       3,   11,   12,   68,  344,  263,   70,   71,   72,   73,
152 --- 110,114 ----
153      33,    0,   23,
154   };
155 ! static short yydgoto[] = {                                1,
156       9,   66,   10,   18,   95,   17,   86,  339,   89,  328,
157       3,   11,   12,   68,  344,  263,   70,   71,   72,   73,
158 ***************
159 *** 175,179 ****
160     250,  142,  267,   13,    2,   14,   15,   16,   85,  256,
161   };
162 ! short yysindex[] = {                                      0,
163       0,    0,  -66,    0,    0,    0,  -48,    0,    0,    0,
164       0,    0,  645,    0,    0,    0, -232, -227,  -27,    0,
165 --- 117,121 ----
166     250,  142,  267,   13,    2,   14,   15,   16,   85,  256,
167   };
168 ! static short yysindex[] = {                               0,
169       0,    0,  -66,    0,    0,    0,  -48,    0,    0,    0,
170       0,    0,  645,    0,    0,    0, -232, -227,  -27,    0,
171 ***************
172 *** 214,218 ****
173       0, -238,    0,
174   };
175 ! short yyrindex[] = {                                      0,
176       0,    0,  249,    0,    0,    0,    0,    0,    0,    0,
177       0,    0,    0,    0,    0,    0,  184,    0,    0,    0,
178 --- 156,160 ----
179       0, -238,    0,
180   };
181 ! static short yyrindex[] = {                               0,
182       0,    0,  249,    0,    0,    0,    0,    0,    0,    0,
183       0,    0,    0,    0,    0,    0,  184,    0,    0,    0,
184 ***************
185 *** 253,257 ****
186       0,  154,    0,
187   };
188 ! short yygindex[] = {                                      0,
189       0,    0,    0,  374,  351,    0,  -12,    0,  946,  413,
190     -83,    0,    0,    0, -311,  -13, 4139, 4198,    0,    0,
191 --- 195,199 ----
192       0,  154,    0,
193   };
194 ! static short yygindex[] = {                               0,
195       0,    0,    0,  374,  351,    0,  -12,    0,  946,  413,
196     -83,    0,    0,    0, -311,  -13, 4139, 4198,    0,    0,
197 ***************
198 *** 261,265 ****
199   };
200   #define YYTABLESIZE 4425
201 ! short yytable[] = {                                      69,
202     207,   62,  181,  105,  168,  102,  105,  204,  168,  248,
203      20,  208,   62,  253,   58,  285,  274,  170,  298,  345,
204 --- 203,207 ----
205   };
206   #define YYTABLESIZE 4425
207 ! static short yytable[] = {                               69,
208     207,   62,  181,  105,  168,  102,  105,  204,  168,  248,
209      20,  208,   62,  253,   58,  285,  274,  170,  298,  345,
210 ***************
211 *** 706,710 ****
212       0,    0,    0,    0,  317,
213   };
214 ! short yycheck[] = {                                      13,
215      41,   36,   86,   41,   91,   40,   44,   59,   91,   59,
216      59,   93,   36,  183,   59,   59,   41,   91,   41,  331,
217 --- 648,652 ----
218       0,    0,    0,    0,  317,
219   };
220 ! static short yycheck[] = {                               13,
221      41,   36,   86,   41,   91,   40,   44,   59,   91,   59,
222      59,   93,   36,  183,   59,   59,   41,   91,   41,  331,
223 ***************
224 *** 1157,1161 ****
225   #define YYMAXTOKEN 314
226   #if YYDEBUG
227 ! char *yyname[] = {
228   "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,
229   "'!'",0,0,"'$'","'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,0,0,0,0,0,0,
230 --- 1099,1103 ----
231   #define YYMAXTOKEN 314
232   #if YYDEBUG
233 ! static char *yyname[] = {
234   "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,
235   "'!'",0,0,"'$'","'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,0,0,0,0,0,0,
236 ***************
237 *** 1174,1178 ****
238   "POSTDEC","ARROW",
239   };
240 ! char *yyrule[] = {
241   "$accept : prog",
242   "$$1 :",
243 --- 1116,1120 ----
244   "POSTDEC","ARROW",
245   };
246 ! static char *yyrule[] = {
247   "$accept : prog",
248   "$$1 :",
249 ***************
250 *** 1369,1397 ****
251   #endif
252   #endif
253 - int yydebug;
254 - int yynerrs;
255 - int yyerrflag;
256 - int yychar;
257 - short *yyssp;
258 - YYSTYPE *yyvsp;
259 - YYSTYPE yyval;
260 - YYSTYPE yylval;
261 - short yyss[YYSTACKSIZE];
262 - YYSTYPE yyvs[YYSTACKSIZE];
263 - #define yystacksize YYSTACKSIZE
264   #line 652 "perly.y"
265    /* PROGRAM */
266 ! #line 1385 "y.tab.c"
267   #define YYABORT goto yyabort
268   #define YYACCEPT goto yyaccept
269   #define YYERROR goto yyerrlab
270   int
271 ! yyparse()
272   {
273       register int yym, yyn, yystate;
274   #if YYDEBUG
275       register char *yys;
276       extern char *getenv();
277   
278       if (yys = getenv("YYDEBUG"))
279       {
280 --- 1311,1375 ----
281   #endif
282   #endif
283   #line 652 "perly.y"
284    /* PROGRAM */
285 ! #line 1318 "perly.c"
286   #define YYABORT goto yyabort
287   #define YYACCEPT goto yyaccept
288   #define YYERROR goto yyerrlab
289
290 + struct ysv {
291 +     short* yyss;
292 +     YYSTYPE* yyvs;
293 +     int oldyydebug;
294 +     int oldyynerrs;
295 +     int oldyyerrflag;
296 +     int oldyychar;
297 +     YYSTYPE oldyyval;
298 +     YYSTYPE oldyylval;
299 + };
300
301 + void
302 + yydestruct(void *ptr)
303 + {
304 +     struct ysv* ysave = (struct ysv*)ptr;
305 +     if (ysave->yyss) Safefree(ysave->yyss);
306 +     if (ysave->yyvs) Safefree(ysave->yyvs);
307 +     yydebug   = ysave->oldyydebug;
308 +     yynerrs   = ysave->oldyynerrs;
309 +     yyerrflag = ysave->oldyyerrflag;
310 +     yychar    = ysave->oldyychar;
311 +     yyval     = ysave->oldyyval;
312 +     yylval    = ysave->oldyylval;
313 +     Safefree(ysave);
314 + }
315
316   int
317 ! yyparse(void)
318   {
319       register int yym, yyn, yystate;
320 +     register short *yyssp;
321 +     register YYSTYPE *yyvsp;
322 +     short* yyss;
323 +     YYSTYPE* yyvs;
324 +     unsigned yystacksize = YYSTACKSIZE;
325 +     int retval = 0;
326   #if YYDEBUG
327       register char *yys;
328 + #ifndef __cplusplus
329       extern char *getenv();
330 + #endif
331 + #endif
332
333 +     struct ysv *ysave;
334 +     New(73, ysave, 1, struct ysv);
335 +     SAVEDESTRUCTOR(yydestruct, ysave);
336 +     ysave->oldyydebug = yydebug;
337 +     ysave->oldyynerrs = yynerrs;
338 +     ysave->oldyyerrflag       = yyerrflag;
339 +     ysave->oldyychar  = yychar;
340 +     ysave->oldyyval   = yyval;
341 +     ysave->oldyylval  = yylval;
342   
343 + #if YYDEBUG
344       if (yys = getenv("YYDEBUG"))
345       {
346 ***************
347 *** 1406,1409 ****
348 --- 1384,1397 ----
349       yychar = (-1);
350   
351 +     /*
352 +     ** Initialize private stacks (yyparse may be called from an action)
353 +     */
354 +     New(73, yyss, yystacksize, short);
355 +     New(73, yyvs, yystacksize, YYSTYPE);
356 +     ysave->yyss = yyss;
357 +     ysave->yyvs = yyvs;
358 +     if (!yyvs || !yyss)
359 +       goto yyoverflow;
360
361       yyssp = yyss;
362       yyvsp = yyvs;
363 ***************
364 *** 1431,1440 ****
365   #if YYDEBUG
366           if (yydebug)
367 !             printf("yydebug: state %d, shifting to state %d\n",
368                       yystate, yytable[yyn]);
369   #endif
370           if (yyssp >= yyss + yystacksize - 1)
371           {
372 !             goto yyoverflow;
373           }
374           *++yyssp = yystate = yytable[yyn];
375 --- 1419,1442 ----
376   #if YYDEBUG
377           if (yydebug)
378 !             PerlIO_printf(Perl_debug_log, "yydebug: state %d, shifting to state %d\n",
379                       yystate, yytable[yyn]);
380   #endif
381           if (yyssp >= yyss + yystacksize - 1)
382           {
383 !           /*
384 !           ** reallocate and recover.  Note that pointers
385 !           ** have to be reset, or bad things will happen
386 !           */
387 !           int yyps_index = (yyssp - yyss);
388 !           int yypv_index = (yyvsp - yyvs);
389 !           yystacksize += YYSTACKSIZE;
390 !           ysave->yyvs = yyvs =
391 !               (YYSTYPE*)PerlMem_realloc((char*)yyvs,yystacksize * sizeof(YYSTYPE));
392 !           ysave->yyss = yyss =
393 !               (short*)PerlMem_realloc((char*)yyss,yystacksize * sizeof(short));
394 !           if (!yyvs || !yyss)
395 !               goto yyoverflow;
396 !           yyssp = yyss + yyps_index;
397 !           yyvsp = yyvs + yypv_index;
398           }
399           *++yyssp = yystate = yytable[yyn];
400 ***************
401 *** 1472,1481 ****
402   #if YYDEBUG
403                   if (yydebug)
404 !                     printf("yydebug: state %d, error recovery shifting\
405 !  to state %d\n", *yyssp, yytable[yyn]);
406   #endif
407                   if (yyssp >= yyss + yystacksize - 1)
408                   {
409 !                     goto yyoverflow;
410                   }
411                   *++yyssp = yystate = yytable[yyn];
412 --- 1474,1498 ----
413   #if YYDEBUG
414                   if (yydebug)
415 !                     PerlIO_printf(Perl_debug_log,
416 !                    "yydebug: state %d, error recovery shifting to state %d\n",
417 !                    *yyssp, yytable[yyn]);
418   #endif
419                   if (yyssp >= yyss + yystacksize - 1)
420                   {
421 !                   /*
422 !                   ** reallocate and recover.  Note that pointers
423 !                   ** have to be reset, or bad things will happen
424 !                   */
425 !                   int yyps_index = (yyssp - yyss);
426 !                   int yypv_index = (yyvsp - yyvs);
427 !                   yystacksize += YYSTACKSIZE;
428 !                   ysave->yyvs = yyvs = (YYSTYPE*)PerlMem_realloc((char*)yyvs,
429 !                       yystacksize * sizeof(YYSTYPE));
430 !                   ysave->yyss = yyss = (short*)PerlMem_realloc((char*)yyss,
431 !                       yystacksize * sizeof(short));
432 !                   if (!yyvs || !yyss)
433 !                       goto yyoverflow;
434 !                   yyssp = yyss + yyps_index;
435 !                   yyvsp = yyvs + yypv_index;
436                   }
437                   *++yyssp = yystate = yytable[yyn];
438 ***************
439 *** 1487,1492 ****
440   #if YYDEBUG
441                   if (yydebug)
442 !                     printf("yydebug: error recovery discarding state %d\n",
443 !                             *yyssp);
444   #endif
445                   if (yyssp <= yyss) goto yyabort;
446 --- 1504,1510 ----
447   #if YYDEBUG
448                   if (yydebug)
449 !                     PerlIO_printf(Perl_debug_log,
450 !                       "yydebug: error recovery discarding state %d\n",
451 !                       *yyssp);
452   #endif
453                   if (yyssp <= yyss) goto yyabort;
454 ***************
455 *** 1505,1510 ****
456               if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
457               if (!yys) yys = "illegal-symbol";
458 !             printf("yydebug: state %d, error recovery discards token %d (%s)\n",
459 !                     yystate, yychar, yys);
460           }
461   #endif
462 --- 1523,1529 ----
463               if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
464               if (!yys) yys = "illegal-symbol";
465 !             PerlIO_printf(Perl_debug_log,
466 !               "yydebug: state %d, error recovery discards token %d (%s)\n",
467 !               yystate, yychar, yys);
468           }
469   #endif
470 ***************
471 *** 1515,1519 ****
472   #if YYDEBUG
473       if (yydebug)
474 !         printf("yydebug: state %d, reducing by rule %d (%s)\n",
475                   yystate, yyn, yyrule[yyn]);
476   #endif
477 --- 1534,1538 ----
478   #if YYDEBUG
479       if (yydebug)
480 !         PerlIO_printf(Perl_debug_log, "yydebug: state %d, reducing by rule %d (%s)\n",
481                   yystate, yyn, yyrule[yyn]);
482   #endif
483 ***************
484 *** 2305,2309 ****
485   { yyval.opval = yyvsp[0].opval; }
486   break;
487 ! #line 2308 "y.tab.c"
488       }
489       yyssp -= yym;
490 --- 2324,2328 ----
491   { yyval.opval = yyvsp[0].opval; }
492   break;
493 ! #line 2329 "perly.c"
494       }
495       yyssp -= yym;
496 ***************
497 *** 2315,2320 ****
498   #if YYDEBUG
499           if (yydebug)
500 !             printf("yydebug: after reduction, shifting from state 0 to\
501 !  state %d\n", YYFINAL);
502   #endif
503           yystate = YYFINAL;
504 --- 2334,2340 ----
505   #if YYDEBUG
506           if (yydebug)
507 !             PerlIO_printf(Perl_debug_log,
508 !               "yydebug: after reduction, shifting from state 0 to state %d\n",
509 !               YYFINAL);
510   #endif
511           yystate = YYFINAL;
512 ***************
513 *** 2330,2334 ****
514                   if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
515                   if (!yys) yys = "illegal-symbol";
516 !                 printf("yydebug: state %d, reading %d (%s)\n",
517                           YYFINAL, yychar, yys);
518               }
519 --- 2350,2354 ----
520                   if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
521                   if (!yys) yys = "illegal-symbol";
522 !                 PerlIO_printf(Perl_debug_log, "yydebug: state %d, reading %d (%s)\n",
523                           YYFINAL, yychar, yys);
524               }
525 ***************
526 *** 2345,2354 ****
527   #if YYDEBUG
528       if (yydebug)
529 !         printf("yydebug: after reduction, shifting from state %d \
530 ! to state %d\n", *yyssp, yystate);
531   #endif
532       if (yyssp >= yyss + yystacksize - 1)
533       {
534 !         goto yyoverflow;
535       }
536       *++yyssp = yystate;
537 --- 2365,2389 ----
538   #if YYDEBUG
539       if (yydebug)
540 !         PerlIO_printf(Perl_debug_log,
541 !           "yydebug: after reduction, shifting from state %d to state %d\n",
542 !           *yyssp, yystate);
543   #endif
544       if (yyssp >= yyss + yystacksize - 1)
545       {
546 !       /*
547 !       ** reallocate and recover.  Note that pointers
548 !       ** have to be reset, or bad things will happen
549 !       */
550 !       int yyps_index = (yyssp - yyss);
551 !       int yypv_index = (yyvsp - yyvs);
552 !       yystacksize += YYSTACKSIZE;
553 !       ysave->yyvs = yyvs =
554 !           (YYSTYPE*)PerlMem_realloc((char*)yyvs,yystacksize * sizeof(YYSTYPE));
555 !       ysave->yyss = yyss =
556 !           (short*)PerlMem_realloc((char*)yyss,yystacksize * sizeof(short));
557 !       if (!yyvs || !yyss)
558 !           goto yyoverflow;
559 !       yyssp = yyss + yyps_index;
560 !       yyvsp = yyvs + yypv_index;
561       }
562       *++yyssp = yystate;
563 ***************
564 *** 2356,2363 ****
565       goto yyloop;
566   yyoverflow:
567 !     yyerror("yacc stack overflow");
568   yyabort:
569 !     return (1);
570   yyaccept:
571 !     return (0);
572   }
573 --- 2391,2398 ----
574       goto yyloop;
575   yyoverflow:
576 !     yyerror("Out of memory for yacc stack");
577   yyabort:
578 !     retval = 1;
579   yyaccept:
580 !     return retval;
581   }