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