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