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