[dummy merge]
[p5sagit/p5-mst-13.2.git] / pp_ctl.c
CommitLineData
a0d0e21e 1/* pp_ctl.c
2 *
9607fc9c 3 * Copyright (c) 1991-1997, Larry Wall
a0d0e21e 4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
8 */
9
10/*
11 * Now far ahead the Road has gone,
12 * And I must follow, if I can,
13 * Pursuing it with eager feet,
14 * Until it joins some larger way
15 * Where many paths and errands meet.
16 * And whither then? I cannot say.
17 */
18
19#include "EXTERN.h"
20#include "perl.h"
21
22#ifndef WORD_ALIGN
23#define WORD_ALIGN sizeof(U16)
24#endif
25
54310121 26#define DOCATCH(o) ((CATCH_GET == TRUE) ? docatch(o) : (o))
1e422769 27
28static OP *docatch _((OP *o));
a0d0e21e 29static OP *doeval _((int gimme));
fc36a67e 30static OP *dofindlabel _((OP *op, char *label, OP **opstack, OP **oplimit));
a0d0e21e 31static void doparseform _((SV *sv));
32static I32 dopoptoeval _((I32 startingblock));
33static I32 dopoptolabel _((char *label));
34static I32 dopoptoloop _((I32 startingblock));
35static I32 dopoptosub _((I32 startingblock));
36static void save_lines _((AV *array, SV *sv));
a0d0e21e 37static int sortcv _((const void *, const void *));
bbce6d69 38static int sortcmp _((const void *, const void *));
39static int sortcmp_locale _((const void *, const void *));
a0d0e21e 40
41static I32 sortcxix;
42
43PP(pp_wantarray)
44{
45 dSP;
46 I32 cxix;
47 EXTEND(SP, 1);
48
49 cxix = dopoptosub(cxstack_ix);
50 if (cxix < 0)
51 RETPUSHUNDEF;
52
54310121 53 switch (cxstack[cxix].blk_gimme) {
54 case G_ARRAY:
a0d0e21e 55 RETPUSHYES;
54310121 56 case G_SCALAR:
a0d0e21e 57 RETPUSHNO;
54310121 58 default:
59 RETPUSHUNDEF;
60 }
a0d0e21e 61}
62
63PP(pp_regcmaybe)
64{
65 return NORMAL;
66}
67
68PP(pp_regcomp) {
69 dSP;
70 register PMOP *pm = (PMOP*)cLOGOP->op_other;
71 register char *t;
72 SV *tmpstr;
73 STRLEN len;
74
75 tmpstr = POPs;
76 t = SvPV(tmpstr, len);
77
4633a7c4 78 /* JMR: Check against the last compiled regexp */
79 if ( ! pm->op_pmregexp || ! pm->op_pmregexp->precomp
80 || strnNE(pm->op_pmregexp->precomp, t, len)
81 || pm->op_pmregexp->precomp[len]) {
82 if (pm->op_pmregexp) {
83 pregfree(pm->op_pmregexp);
84 pm->op_pmregexp = Null(REGEXP*); /* crucial if regcomp aborts */
85 }
a0d0e21e 86
4633a7c4 87 pm->op_pmflags = pm->op_pmpermflags; /* reset case sensitivity */
88 pm->op_pmregexp = pregcomp(t, t + len, pm);
89 }
a0d0e21e 90
91 if (!pm->op_pmregexp->prelen && curpm)
92 pm = curpm;
93 else if (strEQ("\\s+", pm->op_pmregexp->precomp))
94 pm->op_pmflags |= PMf_WHITE;
95
96 if (pm->op_pmflags & PMf_KEEP) {
c90c0ff4 97 pm->op_private &= ~OPpRUNTIME; /* no point compiling again */
a0d0e21e 98 hoistmust(pm);
99 cLOGOP->op_first->op_next = op->op_next;
a0d0e21e 100 }
101 RETURN;
102}
103
104PP(pp_substcont)
105{
106 dSP;
107 register PMOP *pm = (PMOP*) cLOGOP->op_other;
108 register CONTEXT *cx = &cxstack[cxstack_ix];
109 register SV *dstr = cx->sb_dstr;
110 register char *s = cx->sb_s;
111 register char *m = cx->sb_m;
112 char *orig = cx->sb_orig;
c07a80fd 113 register REGEXP *rx = cx->sb_rx;
a0d0e21e 114
c90c0ff4 115 rxres_restore(&cx->sb_rxres, rx);
116
a0d0e21e 117 if (cx->sb_iters++) {
118 if (cx->sb_iters > cx->sb_maxiters)
119 DIE("Substitution loop");
120
71be2cbc 121 if (!cx->sb_rxtainted)
122 cx->sb_rxtainted = SvTAINTED(TOPs);
a0d0e21e 123 sv_catsv(dstr, POPs);
a0d0e21e 124
125 /* Are we done */
e50aee73 126 if (cx->sb_once || !pregexec(rx, s, cx->sb_strend, orig,
a0d0e21e 127 s == m, Nullsv, cx->sb_safebase))
128 {
129 SV *targ = cx->sb_targ;
130 sv_catpvn(dstr, s, cx->sb_strend - s);
748a9306 131
9212bbba 132 TAINT_IF(cx->sb_rxtainted || rx->exec_tainted);
133
4633a7c4 134 (void)SvOOK_off(targ);
cb0b1708 135 Safefree(SvPVX(targ));
748a9306 136 SvPVX(targ) = SvPVX(dstr);
137 SvCUR_set(targ, SvCUR(dstr));
138 SvLEN_set(targ, SvLEN(dstr));
139 SvPVX(dstr) = 0;
140 sv_free(dstr);
a0d0e21e 141 (void)SvPOK_only(targ);
142 SvSETMAGIC(targ);
9212bbba 143 SvTAINT(targ);
5cd24f17 144
a0d0e21e 145 PUSHs(sv_2mortal(newSViv((I32)cx->sb_iters - 1)));
4633a7c4 146 LEAVE_SCOPE(cx->sb_oldsave);
a0d0e21e 147 POPSUBST(cx);
148 RETURNOP(pm->op_next);
149 }
150 }
151 if (rx->subbase && rx->subbase != orig) {
152 m = s;
153 s = orig;
154 cx->sb_orig = orig = rx->subbase;
155 s = orig + (m - s);
156 cx->sb_strend = s + (cx->sb_strend - m);
157 }
158 cx->sb_m = m = rx->startp[0];
159 sv_catpvn(dstr, s, m-s);
160 cx->sb_s = rx->endp[0];
71be2cbc 161 cx->sb_rxtainted |= rx->exec_tainted;
c90c0ff4 162 rxres_save(&cx->sb_rxres, rx);
a0d0e21e 163 RETURNOP(pm->op_pmreplstart);
164}
165
c90c0ff4 166void
167rxres_save(rsp, rx)
168void **rsp;
169REGEXP *rx;
170{
171 UV *p = (UV*)*rsp;
172 U32 i;
173
174 if (!p || p[1] < rx->nparens) {
175 i = 6 + rx->nparens * 2;
176 if (!p)
177 New(501, p, i, UV);
178 else
179 Renew(p, i, UV);
180 *rsp = (void*)p;
181 }
182
183 *p++ = (UV)rx->subbase;
184 rx->subbase = Nullch;
185
186 *p++ = rx->nparens;
187
188 *p++ = (UV)rx->subbeg;
189 *p++ = (UV)rx->subend;
190 for (i = 0; i <= rx->nparens; ++i) {
191 *p++ = (UV)rx->startp[i];
192 *p++ = (UV)rx->endp[i];
193 }
194}
195
196void
197rxres_restore(rsp, rx)
198void **rsp;
199REGEXP *rx;
200{
201 UV *p = (UV*)*rsp;
202 U32 i;
203
204 Safefree(rx->subbase);
205 rx->subbase = (char*)(*p);
206 *p++ = 0;
207
208 rx->nparens = *p++;
209
210 rx->subbeg = (char*)(*p++);
211 rx->subend = (char*)(*p++);
212 for (i = 0; i <= rx->nparens; ++i) {
213 rx->startp[i] = (char*)(*p++);
214 rx->endp[i] = (char*)(*p++);
215 }
216}
217
218void
219rxres_free(rsp)
220void **rsp;
221{
222 UV *p = (UV*)*rsp;
223
224 if (p) {
225 Safefree((char*)(*p));
226 Safefree(p);
227 *rsp = Null(void*);
228 }
229}
230
a0d0e21e 231PP(pp_formline)
232{
233 dSP; dMARK; dORIGMARK;
234 register SV *form = *++MARK;
235 register U16 *fpc;
236 register char *t;
237 register char *f;
238 register char *s;
239 register char *send;
240 register I32 arg;
241 register SV *sv;
242 char *item;
243 I32 itemsize;
244 I32 fieldsize;
245 I32 lines = 0;
246 bool chopspace = (strchr(chopset, ' ') != Nullch);
247 char *chophere;
248 char *linemark;
a0d0e21e 249 double value;
250 bool gotsome;
251 STRLEN len;
252
55497cff 253 if (!SvMAGICAL(form) || !SvCOMPILED(form)) {
a0d0e21e 254 SvREADONLY_off(form);
255 doparseform(form);
256 }
257
258 SvPV_force(formtarget, len);
259 t = SvGROW(formtarget, len + SvCUR(form) + 1); /* XXX SvCUR bad */
260 t += len;
261 f = SvPV(form, len);
262 /* need to jump to the next word */
263 s = f + len + WORD_ALIGN - SvCUR(form) % WORD_ALIGN;
264
265 fpc = (U16*)s;
266
267 for (;;) {
268 DEBUG_f( {
269 char *name = "???";
270 arg = -1;
271 switch (*fpc) {
272 case FF_LITERAL: arg = fpc[1]; name = "LITERAL"; break;
273 case FF_BLANK: arg = fpc[1]; name = "BLANK"; break;
274 case FF_SKIP: arg = fpc[1]; name = "SKIP"; break;
275 case FF_FETCH: arg = fpc[1]; name = "FETCH"; break;
276 case FF_DECIMAL: arg = fpc[1]; name = "DECIMAL"; break;
277
278 case FF_CHECKNL: name = "CHECKNL"; break;
279 case FF_CHECKCHOP: name = "CHECKCHOP"; break;
280 case FF_SPACE: name = "SPACE"; break;
281 case FF_HALFSPACE: name = "HALFSPACE"; break;
282 case FF_ITEM: name = "ITEM"; break;
283 case FF_CHOP: name = "CHOP"; break;
284 case FF_LINEGLOB: name = "LINEGLOB"; break;
285 case FF_NEWLINE: name = "NEWLINE"; break;
286 case FF_MORE: name = "MORE"; break;
287 case FF_LINEMARK: name = "LINEMARK"; break;
288 case FF_END: name = "END"; break;
289 }
290 if (arg >= 0)
760ac839 291 PerlIO_printf(PerlIO_stderr(), "%-16s%ld\n", name, (long) arg);
a0d0e21e 292 else
760ac839 293 PerlIO_printf(PerlIO_stderr(), "%-16s\n", name);
a0d0e21e 294 } )
295 switch (*fpc++) {
296 case FF_LINEMARK:
297 linemark = t;
a0d0e21e 298 lines++;
299 gotsome = FALSE;
300 break;
301
302 case FF_LITERAL:
303 arg = *fpc++;
304 while (arg--)
305 *t++ = *f++;
306 break;
307
308 case FF_SKIP:
309 f += *fpc++;
310 break;
311
312 case FF_FETCH:
313 arg = *fpc++;
314 f += arg;
315 fieldsize = arg;
316
317 if (MARK < SP)
318 sv = *++MARK;
319 else {
320 sv = &sv_no;
321 if (dowarn)
322 warn("Not enough format arguments");
323 }
324 break;
325
326 case FF_CHECKNL:
327 item = s = SvPV(sv, len);
328 itemsize = len;
329 if (itemsize > fieldsize)
330 itemsize = fieldsize;
331 send = chophere = s + itemsize;
332 while (s < send) {
333 if (*s & ~31)
334 gotsome = TRUE;
335 else if (*s == '\n')
336 break;
337 s++;
338 }
339 itemsize = s - item;
340 break;
341
342 case FF_CHECKCHOP:
343 item = s = SvPV(sv, len);
344 itemsize = len;
345 if (itemsize <= fieldsize) {
346 send = chophere = s + itemsize;
347 while (s < send) {
348 if (*s == '\r') {
349 itemsize = s - item;
350 break;
351 }
352 if (*s++ & ~31)
353 gotsome = TRUE;
354 }
355 }
356 else {
357 itemsize = fieldsize;
358 send = chophere = s + itemsize;
359 while (s < send || (s == send && isSPACE(*s))) {
360 if (isSPACE(*s)) {
361 if (chopspace)
362 chophere = s;
363 if (*s == '\r')
364 break;
365 }
366 else {
367 if (*s & ~31)
368 gotsome = TRUE;
369 if (strchr(chopset, *s))
370 chophere = s + 1;
371 }
372 s++;
373 }
374 itemsize = chophere - item;
375 }
376 break;
377
378 case FF_SPACE:
379 arg = fieldsize - itemsize;
380 if (arg) {
381 fieldsize -= arg;
382 while (arg-- > 0)
383 *t++ = ' ';
384 }
385 break;
386
387 case FF_HALFSPACE:
388 arg = fieldsize - itemsize;
389 if (arg) {
390 arg /= 2;
391 fieldsize -= arg;
392 while (arg-- > 0)
393 *t++ = ' ';
394 }
395 break;
396
397 case FF_ITEM:
398 arg = itemsize;
399 s = item;
400 while (arg--) {
401#if 'z' - 'a' != 25
402 int ch = *t++ = *s++;
403 if (!iscntrl(ch))
404 t[-1] = ' ';
405#else
406 if ( !((*t++ = *s++) & ~31) )
407 t[-1] = ' ';
408#endif
409
410 }
411 break;
412
413 case FF_CHOP:
414 s = chophere;
415 if (chopspace) {
416 while (*s && isSPACE(*s))
417 s++;
418 }
419 sv_chop(sv,s);
420 break;
421
422 case FF_LINEGLOB:
423 item = s = SvPV(sv, len);
424 itemsize = len;
425 if (itemsize) {
426 gotsome = TRUE;
427 send = s + itemsize;
428 while (s < send) {
429 if (*s++ == '\n') {
430 if (s == send)
431 itemsize--;
432 else
433 lines++;
434 }
435 }
436 SvCUR_set(formtarget, t - SvPVX(formtarget));
437 sv_catpvn(formtarget, item, itemsize);
438 SvGROW(formtarget, SvCUR(formtarget) + SvCUR(form) + 1);
439 t = SvPVX(formtarget) + SvCUR(formtarget);
440 }
441 break;
442
443 case FF_DECIMAL:
444 /* If the field is marked with ^ and the value is undefined,
445 blank it out. */
446 arg = *fpc++;
447 if ((arg & 512) && !SvOK(sv)) {
448 arg = fieldsize;
449 while (arg--)
450 *t++ = ' ';
451 break;
452 }
453 gotsome = TRUE;
454 value = SvNV(sv);
bbce6d69 455 /* Formats aren't yet marked for locales, so assume "yes". */
36477c24 456 SET_NUMERIC_LOCAL();
a0d0e21e 457 if (arg & 256) {
458 sprintf(t, "%#*.*f", (int) fieldsize, (int) arg & 255, value);
459 } else {
460 sprintf(t, "%*.0f", (int) fieldsize, value);
461 }
462 t += fieldsize;
463 break;
464
465 case FF_NEWLINE:
466 f++;
467 while (t-- > linemark && *t == ' ') ;
468 t++;
469 *t++ = '\n';
470 break;
471
472 case FF_BLANK:
473 arg = *fpc++;
474 if (gotsome) {
475 if (arg) { /* repeat until fields exhausted? */
476 *t = '\0';
477 SvCUR_set(formtarget, t - SvPVX(formtarget));
478 lines += FmLINES(formtarget);
479 if (lines == 200) {
480 arg = t - linemark;
481 if (strnEQ(linemark, linemark - arg, arg))
482 DIE("Runaway format");
483 }
484 FmLINES(formtarget) = lines;
485 SP = ORIGMARK;
486 RETURNOP(cLISTOP->op_first);
487 }
488 }
489 else {
490 t = linemark;
491 lines--;
492 }
493 break;
494
495 case FF_MORE:
496 if (itemsize) {
497 arg = fieldsize - itemsize;
498 if (arg) {
499 fieldsize -= arg;
500 while (arg-- > 0)
501 *t++ = ' ';
502 }
503 s = t - 3;
504 if (strnEQ(s," ",3)) {
505 while (s > SvPVX(formtarget) && isSPACE(s[-1]))
506 s--;
507 }
508 *s++ = '.';
509 *s++ = '.';
510 *s++ = '.';
511 }
512 break;
513
514 case FF_END:
515 *t = '\0';
516 SvCUR_set(formtarget, t - SvPVX(formtarget));
517 FmLINES(formtarget) += lines;
518 SP = ORIGMARK;
519 RETPUSHYES;
520 }
521 }
522}
523
524PP(pp_grepstart)
525{
526 dSP;
527 SV *src;
528
529 if (stack_base + *markstack_ptr == sp) {
530 (void)POPMARK;
54310121 531 if (GIMME_V == G_SCALAR)
a0d0e21e 532 XPUSHs(&sv_no);
533 RETURNOP(op->op_next->op_next);
534 }
535 stack_sp = stack_base + *markstack_ptr + 1;
536 pp_pushmark(); /* push dst */
537 pp_pushmark(); /* push src */
538 ENTER; /* enter outer scope */
539
540 SAVETMPS;
541 SAVESPTR(GvSV(defgv));
542
543 ENTER; /* enter inner scope */
544 SAVESPTR(curpm);
545
546 src = stack_base[*markstack_ptr];
547 SvTEMP_off(src);
548 GvSV(defgv) = src;
549
550 PUTBACK;
551 if (op->op_type == OP_MAPSTART)
552 pp_pushmark(); /* push top */
553 return ((LOGOP*)op->op_next)->op_other;
554}
555
556PP(pp_mapstart)
557{
558 DIE("panic: mapstart"); /* uses grepstart */
559}
560
561PP(pp_mapwhile)
562{
563 dSP;
564 I32 diff = (sp - stack_base) - *markstack_ptr;
565 I32 count;
566 I32 shift;
567 SV** src;
568 SV** dst;
569
570 ++markstack_ptr[-1];
571 if (diff) {
572 if (diff > markstack_ptr[-1] - markstack_ptr[-2]) {
573 shift = diff - (markstack_ptr[-1] - markstack_ptr[-2]);
574 count = (sp - stack_base) - markstack_ptr[-1] + 2;
575
576 EXTEND(sp,shift);
577 src = sp;
578 dst = (sp += shift);
579 markstack_ptr[-1] += shift;
580 *markstack_ptr += shift;
581 while (--count)
582 *dst-- = *src--;
583 }
584 dst = stack_base + (markstack_ptr[-2] += diff) - 1;
585 ++diff;
586 while (--diff)
587 *dst-- = SvTEMP(TOPs) ? POPs : sv_mortalcopy(POPs);
588 }
589 LEAVE; /* exit inner scope */
590
591 /* All done yet? */
592 if (markstack_ptr[-1] > *markstack_ptr) {
593 I32 items;
54310121 594 I32 gimme = GIMME_V;
a0d0e21e 595
596 (void)POPMARK; /* pop top */
597 LEAVE; /* exit outer scope */
598 (void)POPMARK; /* pop src */
599 items = --*markstack_ptr - markstack_ptr[-1];
600 (void)POPMARK; /* pop dst */
601 SP = stack_base + POPMARK; /* pop original mark */
54310121 602 if (gimme == G_SCALAR) {
a0d0e21e 603 dTARGET;
604 XPUSHi(items);
a0d0e21e 605 }
54310121 606 else if (gimme == G_ARRAY)
607 SP += items;
a0d0e21e 608 RETURN;
609 }
610 else {
611 SV *src;
612
613 ENTER; /* enter inner scope */
614 SAVESPTR(curpm);
615
616 src = stack_base[markstack_ptr[-1]];
617 SvTEMP_off(src);
618 GvSV(defgv) = src;
619
620 RETURNOP(cLOGOP->op_other);
621 }
622}
623
624
625PP(pp_sort)
626{
627 dSP; dMARK; dORIGMARK;
628 register SV **up;
629 SV **myorigmark = ORIGMARK;
630 register I32 max;
631 HV *stash;
632 GV *gv;
633 CV *cv;
634 I32 gimme = GIMME;
635 OP* nextop = op->op_next;
636
637 if (gimme != G_ARRAY) {
638 SP = MARK;
639 RETPUSHUNDEF;
640 }
641
642 if (op->op_flags & OPf_STACKED) {
643 ENTER;
644 if (op->op_flags & OPf_SPECIAL) {
645 OP *kid = cLISTOP->op_first->op_sibling; /* pass pushmark */
646 kid = kUNOP->op_first; /* pass rv2gv */
647 kid = kUNOP->op_first; /* pass leave */
648 sortcop = kid->op_next;
649 stash = curcop->cop_stash;
650 }
651 else {
652 cv = sv_2cv(*++MARK, &stash, &gv, 0);
653 if (!(cv && CvROOT(cv))) {
654 if (gv) {
655 SV *tmpstr = sv_newmortal();
e5cf08de 656 gv_efullname3(tmpstr, gv, Nullch);
a0d0e21e 657 if (cv && CvXSUB(cv))
658 DIE("Xsub \"%s\" called in sort", SvPVX(tmpstr));
659 DIE("Undefined sort subroutine \"%s\" called",
660 SvPVX(tmpstr));
661 }
662 if (cv) {
663 if (CvXSUB(cv))
664 DIE("Xsub called in sort");
665 DIE("Undefined subroutine in sort");
666 }
667 DIE("Not a CODE reference in sort");
668 }
669 sortcop = CvSTART(cv);
670 SAVESPTR(CvROOT(cv)->op_ppaddr);
671 CvROOT(cv)->op_ppaddr = ppaddr[OP_NULL];
b3933176 672
a0d0e21e 673 SAVESPTR(curpad);
674 curpad = AvARRAY((AV*)AvARRAY(CvPADLIST(cv))[1]);
675 }
676 }
677 else {
678 sortcop = Nullop;
679 stash = curcop->cop_stash;
680 }
681
682 up = myorigmark + 1;
683 while (MARK < SP) { /* This may or may not shift down one here. */
684 /*SUPPRESS 560*/
685 if (*up = *++MARK) { /* Weed out nulls. */
9f8d30d5 686 SvTEMP_off(*up);
687 if (!sortcop && !SvPOK(*up))
a0d0e21e 688 (void)sv_2pv(*up, &na);
a0d0e21e 689 up++;
690 }
691 }
692 max = --up - myorigmark;
693 if (sortcop) {
694 if (max > 1) {
695 AV *oldstack;
696 CONTEXT *cx;
697 SV** newsp;
54310121 698 bool oldcatch = CATCH_GET;
a0d0e21e 699
700 SAVETMPS;
701 SAVESPTR(op);
702
1ce6579f 703 oldstack = curstack;
a0d0e21e 704 if (!sortstack) {
705 sortstack = newAV();
706 AvREAL_off(sortstack);
707 av_extend(sortstack, 32);
708 }
54310121 709 CATCH_SET(TRUE);
1ce6579f 710 SWITCHSTACK(curstack, sortstack);
a0d0e21e 711 if (sortstash != stash) {
712 firstgv = gv_fetchpv("a", TRUE, SVt_PV);
713 secondgv = gv_fetchpv("b", TRUE, SVt_PV);
714 sortstash = stash;
715 }
716
717 SAVESPTR(GvSV(firstgv));
718 SAVESPTR(GvSV(secondgv));
b3933176 719
0a753a76 720 PUSHBLOCK(cx, CXt_NULL, stack_base);
b3933176 721 if (!(op->op_flags & OPf_SPECIAL)) {
722 bool hasargs = FALSE;
723 cx->cx_type = CXt_SUB;
724 cx->blk_gimme = G_SCALAR;
725 PUSHSUB(cx);
726 if (!CvDEPTH(cv))
3e3baf6d 727 (void)SvREFCNT_inc(cv); /* in preparation for POPSUB */
b3933176 728 }
a0d0e21e 729 sortcxix = cxstack_ix;
730
731 qsort((char*)(myorigmark+1), max, sizeof(SV*), sortcv);
732
733 POPBLOCK(cx,curpm);
734 SWITCHSTACK(sortstack, oldstack);
54310121 735 CATCH_SET(oldcatch);
a0d0e21e 736 }
737 LEAVE;
738 }
739 else {
740 if (max > 1) {
741 MEXTEND(SP, 20); /* Can't afford stack realloc on signal. */
bbce6d69 742 qsort((char*)(ORIGMARK+1), max, sizeof(SV*),
743 (op->op_private & OPpLOCALE) ? sortcmp_locale : sortcmp);
a0d0e21e 744 }
745 }
746 stack_sp = ORIGMARK + max;
747 return nextop;
748}
749
750/* Range stuff. */
751
752PP(pp_range)
753{
754 if (GIMME == G_ARRAY)
755 return cCONDOP->op_true;
756 return SvTRUEx(PAD_SV(op->op_targ)) ? cCONDOP->op_false : cCONDOP->op_true;
757}
758
759PP(pp_flip)
760{
761 dSP;
762
763 if (GIMME == G_ARRAY) {
764 RETURNOP(((CONDOP*)cUNOP->op_first)->op_false);
765 }
766 else {
767 dTOPss;
768 SV *targ = PAD_SV(op->op_targ);
769
770 if ((op->op_private & OPpFLIP_LINENUM)
771 ? last_in_gv && SvIV(sv) == IoLINES(GvIOp(last_in_gv))
772 : SvTRUE(sv) ) {
773 sv_setiv(PAD_SV(cUNOP->op_first->op_targ), 1);
774 if (op->op_flags & OPf_SPECIAL) {
775 sv_setiv(targ, 1);
3e3baf6d 776 SETs(targ);
a0d0e21e 777 RETURN;
778 }
779 else {
780 sv_setiv(targ, 0);
781 sp--;
782 RETURNOP(((CONDOP*)cUNOP->op_first)->op_false);
783 }
784 }
785 sv_setpv(TARG, "");
786 SETs(targ);
787 RETURN;
788 }
789}
790
791PP(pp_flop)
792{
793 dSP;
794
795 if (GIMME == G_ARRAY) {
796 dPOPPOPssrl;
797 register I32 i;
798 register SV *sv;
799 I32 max;
800
4633a7c4 801 if (SvNIOKp(left) || !SvPOKp(left) ||
bbce6d69 802 (looks_like_number(left) && *SvPVX(left) != '0') )
803 {
a0d0e21e 804 i = SvIV(left);
805 max = SvIV(right);
bbce6d69 806 if (max >= i) {
807 EXTEND_MORTAL(max - i + 1);
a0d0e21e 808 EXTEND(SP, max - i + 1);
bbce6d69 809 }
a0d0e21e 810 while (i <= max) {
bbce6d69 811 sv = sv_2mortal(newSViv(i++));
a0d0e21e 812 PUSHs(sv);
813 }
814 }
815 else {
816 SV *final = sv_mortalcopy(right);
817 STRLEN len;
818 char *tmps = SvPV(final, len);
819
820 sv = sv_mortalcopy(left);
4633a7c4 821 while (!SvNIOKp(sv) && SvCUR(sv) <= len &&
a0d0e21e 822 strNE(SvPVX(sv),tmps) ) {
823 XPUSHs(sv);
824 sv = sv_2mortal(newSVsv(sv));
825 sv_inc(sv);
826 }
827 if (strEQ(SvPVX(sv),tmps))
828 XPUSHs(sv);
829 }
830 }
831 else {
832 dTOPss;
833 SV *targ = PAD_SV(cUNOP->op_first->op_targ);
834 sv_inc(targ);
835 if ((op->op_private & OPpFLIP_LINENUM)
836 ? last_in_gv && SvIV(sv) == IoLINES(GvIOp(last_in_gv))
837 : SvTRUE(sv) ) {
838 sv_setiv(PAD_SV(((UNOP*)cUNOP->op_first)->op_first->op_targ), 0);
839 sv_catpv(targ, "E0");
840 }
841 SETs(targ);
842 }
843
844 RETURN;
845}
846
847/* Control. */
848
849static I32
850dopoptolabel(label)
851char *label;
852{
853 register I32 i;
854 register CONTEXT *cx;
855
856 for (i = cxstack_ix; i >= 0; i--) {
857 cx = &cxstack[i];
858 switch (cx->cx_type) {
859 case CXt_SUBST:
860 if (dowarn)
861 warn("Exiting substitution via %s", op_name[op->op_type]);
862 break;
863 case CXt_SUB:
864 if (dowarn)
865 warn("Exiting subroutine via %s", op_name[op->op_type]);
866 break;
867 case CXt_EVAL:
868 if (dowarn)
869 warn("Exiting eval via %s", op_name[op->op_type]);
870 break;
0a753a76 871 case CXt_NULL:
872 if (dowarn)
873 warn("Exiting pseudo-block via %s", op_name[op->op_type]);
874 return -1;
a0d0e21e 875 case CXt_LOOP:
876 if (!cx->blk_loop.label ||
877 strNE(label, cx->blk_loop.label) ) {
68dc0745 878 DEBUG_l(deb("(Skipping label #%ld %s)\n",
879 (long)i, cx->blk_loop.label));
a0d0e21e 880 continue;
881 }
68dc0745 882 DEBUG_l( deb("(Found label #%ld %s)\n", (long)i, label));
a0d0e21e 883 return i;
884 }
885 }
886 return i;
887}
888
e50aee73 889I32
890dowantarray()
891{
54310121 892 I32 gimme = block_gimme();
893 return (gimme == G_VOID) ? G_SCALAR : gimme;
894}
895
896I32
897block_gimme()
898{
e50aee73 899 I32 cxix;
900
901 cxix = dopoptosub(cxstack_ix);
902 if (cxix < 0)
46fc3d4c 903 return G_VOID;
e50aee73 904
54310121 905 switch (cxstack[cxix].blk_gimme) {
906 case G_VOID:
907 return G_VOID;
908 case G_SCALAR:
e50aee73 909 return G_SCALAR;
54310121 910 case G_ARRAY:
911 return G_ARRAY;
912 default:
913 croak("panic: bad gimme: %d\n", cxstack[cxix].blk_gimme);
914 }
e50aee73 915}
916
a0d0e21e 917static I32
918dopoptosub(startingblock)
919I32 startingblock;
920{
921 I32 i;
922 register CONTEXT *cx;
923 for (i = startingblock; i >= 0; i--) {
924 cx = &cxstack[i];
925 switch (cx->cx_type) {
926 default:
927 continue;
928 case CXt_EVAL:
929 case CXt_SUB:
68dc0745 930 DEBUG_l( deb("(Found sub #%ld)\n", (long)i));
a0d0e21e 931 return i;
932 }
933 }
934 return i;
935}
936
937static I32
938dopoptoeval(startingblock)
939I32 startingblock;
940{
941 I32 i;
942 register CONTEXT *cx;
943 for (i = startingblock; i >= 0; i--) {
944 cx = &cxstack[i];
945 switch (cx->cx_type) {
946 default:
947 continue;
948 case CXt_EVAL:
68dc0745 949 DEBUG_l( deb("(Found eval #%ld)\n", (long)i));
a0d0e21e 950 return i;
951 }
952 }
953 return i;
954}
955
956static I32
957dopoptoloop(startingblock)
958I32 startingblock;
959{
960 I32 i;
961 register CONTEXT *cx;
962 for (i = startingblock; i >= 0; i--) {
963 cx = &cxstack[i];
964 switch (cx->cx_type) {
965 case CXt_SUBST:
966 if (dowarn)
5f05dabc 967 warn("Exiting substitution via %s", op_name[op->op_type]);
a0d0e21e 968 break;
969 case CXt_SUB:
970 if (dowarn)
971 warn("Exiting subroutine via %s", op_name[op->op_type]);
972 break;
973 case CXt_EVAL:
974 if (dowarn)
975 warn("Exiting eval via %s", op_name[op->op_type]);
976 break;
0a753a76 977 case CXt_NULL:
978 if (dowarn)
979 warn("Exiting pseudo-block via %s", op_name[op->op_type]);
980 return -1;
a0d0e21e 981 case CXt_LOOP:
68dc0745 982 DEBUG_l( deb("(Found loop #%ld)\n", (long)i));
a0d0e21e 983 return i;
984 }
985 }
986 return i;
987}
988
989void
990dounwind(cxix)
991I32 cxix;
992{
993 register CONTEXT *cx;
994 SV **newsp;
995 I32 optype;
996
997 while (cxstack_ix > cxix) {
c90c0ff4 998 cx = &cxstack[cxstack_ix];
999 DEBUG_l(PerlIO_printf(Perl_debug_log, "Unwinding block %ld, type %s\n",
1000 (long) cxstack_ix+1, block_type[cx->cx_type]));
a0d0e21e 1001 /* Note: we don't need to restore the base context info till the end. */
1002 switch (cx->cx_type) {
c90c0ff4 1003 case CXt_SUBST:
1004 POPSUBST(cx);
1005 continue; /* not break */
a0d0e21e 1006 case CXt_SUB:
1007 POPSUB(cx);
1008 break;
1009 case CXt_EVAL:
1010 POPEVAL(cx);
1011 break;
1012 case CXt_LOOP:
1013 POPLOOP(cx);
1014 break;
0a753a76 1015 case CXt_NULL:
a0d0e21e 1016 break;
1017 }
c90c0ff4 1018 cxstack_ix--;
a0d0e21e 1019 }
1020}
1021
a0d0e21e 1022OP *
1023die_where(message)
1024char *message;
1025{
1026 if (in_eval) {
1027 I32 cxix;
1028 register CONTEXT *cx;
1029 I32 gimme;
1030 SV **newsp;
1031
4633a7c4 1032 if (in_eval & 4) {
1033 SV **svp;
1034 STRLEN klen = strlen(message);
1035
1036 svp = hv_fetch(GvHV(errgv), message, klen, TRUE);
1037 if (svp) {
1038 if (!SvIOK(*svp)) {
1039 static char prefix[] = "\t(in cleanup) ";
1040 sv_upgrade(*svp, SVt_IV);
1041 (void)SvIOK_only(*svp);
1042 SvGROW(GvSV(errgv), SvCUR(GvSV(errgv))+sizeof(prefix)+klen);
1043 sv_catpvn(GvSV(errgv), prefix, sizeof(prefix)-1);
1044 sv_catpvn(GvSV(errgv), message, klen);
1045 }
1046 sv_inc(*svp);
1047 }
1048 }
1049 else
c07a80fd 1050 sv_setpv(GvSV(errgv), message);
4633a7c4 1051
a0d0e21e 1052 cxix = dopoptoeval(cxstack_ix);
1053 if (cxix >= 0) {
1054 I32 optype;
1055
1056 if (cxix < cxstack_ix)
1057 dounwind(cxix);
1058
1059 POPBLOCK(cx,curpm);
1060 if (cx->cx_type != CXt_EVAL) {
760ac839 1061 PerlIO_printf(PerlIO_stderr(), "panic: die %s", message);
a0d0e21e 1062 my_exit(1);
1063 }
1064 POPEVAL(cx);
1065
1066 if (gimme == G_SCALAR)
1067 *++newsp = &sv_undef;
1068 stack_sp = newsp;
1069
1070 LEAVE;
748a9306 1071
7a2e2cd6 1072 if (optype == OP_REQUIRE) {
1073 char* msg = SvPVx(GvSV(errgv), na);
1074 DIE("%s", *msg ? msg : "Compilation failed in require");
1075 }
a0d0e21e 1076 return pop_return();
1077 }
1078 }
760ac839 1079 PerlIO_printf(PerlIO_stderr(), "%s",message);
1080 PerlIO_flush(PerlIO_stderr());
f86702cc 1081 my_failure_exit();
1082 /* NOTREACHED */
a0d0e21e 1083 return 0;
1084}
1085
1086PP(pp_xor)
1087{
1088 dSP; dPOPTOPssrl;
1089 if (SvTRUE(left) != SvTRUE(right))
1090 RETSETYES;
1091 else
1092 RETSETNO;
1093}
1094
1095PP(pp_andassign)
1096{
1097 dSP;
1098 if (!SvTRUE(TOPs))
1099 RETURN;
1100 else
1101 RETURNOP(cLOGOP->op_other);
1102}
1103
1104PP(pp_orassign)
1105{
1106 dSP;
1107 if (SvTRUE(TOPs))
1108 RETURN;
1109 else
1110 RETURNOP(cLOGOP->op_other);
1111}
1112
1113#ifdef DEPRECATED
1114PP(pp_entersubr)
1115{
1116 dSP;
1117 SV** mark = (stack_base + *markstack_ptr + 1);
1118 SV* cv = *mark;
1119 while (mark < sp) { /* emulate old interface */
1120 *mark = mark[1];
1121 mark++;
1122 }
1123 *sp = cv;
1124 return pp_entersub();
1125}
1126#endif
1127
1128PP(pp_caller)
1129{
1130 dSP;
1131 register I32 cxix = dopoptosub(cxstack_ix);
1132 register CONTEXT *cx;
1133 I32 dbcxix;
54310121 1134 I32 gimme;
a0d0e21e 1135 SV *sv;
1136 I32 count = 0;
1137
1138 if (MAXARG)
1139 count = POPi;
1140 EXTEND(SP, 6);
1141 for (;;) {
1142 if (cxix < 0) {
1143 if (GIMME != G_ARRAY)
1144 RETPUSHUNDEF;
1145 RETURN;
1146 }
1147 if (DBsub && cxix >= 0 &&
1148 cxstack[cxix].blk_sub.cv == GvCV(DBsub))
1149 count++;
1150 if (!count--)
1151 break;
1152 cxix = dopoptosub(cxix - 1);
1153 }
1154 cx = &cxstack[cxix];
06a5b730 1155 if (cxstack[cxix].cx_type == CXt_SUB) {
1156 dbcxix = dopoptosub(cxix - 1);
1157 /* We expect that cxstack[dbcxix] is CXt_SUB, anyway, the
1158 field below is defined for any cx. */
1159 if (DBsub && dbcxix >= 0 && cxstack[dbcxix].blk_sub.cv == GvCV(DBsub))
1160 cx = &cxstack[dbcxix];
1161 }
1162
a0d0e21e 1163 if (GIMME != G_ARRAY) {
1164 dTARGET;
1165
1166 sv_setpv(TARG, HvNAME(cx->blk_oldcop->cop_stash));
1167 PUSHs(TARG);
1168 RETURN;
1169 }
a0d0e21e 1170
1171 PUSHs(sv_2mortal(newSVpv(HvNAME(cx->blk_oldcop->cop_stash), 0)));
1172 PUSHs(sv_2mortal(newSVpv(SvPVX(GvSV(cx->blk_oldcop->cop_filegv)), 0)));
1173 PUSHs(sv_2mortal(newSViv((I32)cx->blk_oldcop->cop_line)));
1174 if (!MAXARG)
1175 RETURN;
06a5b730 1176 if (cx->cx_type == CXt_SUB) { /* So is cxstack[dbcxix]. */
a0d0e21e 1177 sv = NEWSV(49, 0);
e5cf08de 1178 gv_efullname3(sv, CvGV(cxstack[cxix].blk_sub.cv), Nullch);
a0d0e21e 1179 PUSHs(sv_2mortal(sv));
1180 PUSHs(sv_2mortal(newSViv((I32)cx->blk_sub.hasargs)));
1181 }
1182 else {
1183 PUSHs(sv_2mortal(newSVpv("(eval)",0)));
1184 PUSHs(sv_2mortal(newSViv(0)));
1185 }
54310121 1186 gimme = (I32)cx->blk_gimme;
1187 if (gimme == G_VOID)
1188 PUSHs(&sv_undef);
1189 else
1190 PUSHs(sv_2mortal(newSViv(gimme & G_ARRAY)));
4633a7c4 1191 if (cx->cx_type == CXt_EVAL) {
06a5b730 1192 if (cx->blk_eval.old_op_type == OP_ENTEREVAL) {
4633a7c4 1193 PUSHs(cx->blk_eval.cur_text);
06a5b730 1194 PUSHs(&sv_no);
1195 }
1196 else if (cx->blk_eval.old_name) { /* Try blocks have old_name == 0. */
1197 /* Require, put the name. */
1198 PUSHs(sv_2mortal(newSVpv(cx->blk_eval.old_name, 0)));
1199 PUSHs(&sv_yes);
1200 }
4633a7c4 1201 }
1202 else if (cx->cx_type == CXt_SUB &&
1203 cx->blk_sub.hasargs &&
1204 curcop->cop_stash == debstash)
1205 {
a0d0e21e 1206 AV *ary = cx->blk_sub.argarray;
1207 int off = AvARRAY(ary) - AvALLOC(ary);
1208
1209 if (!dbargs) {
1210 GV* tmpgv;
1211 dbargs = GvAV(gv_AVadd(tmpgv = gv_fetchpv("DB::args", TRUE,
1212 SVt_PVAV)));
a5f75d66 1213 GvMULTI_on(tmpgv);
a0d0e21e 1214 AvREAL_off(dbargs); /* XXX Should be REIFY */
1215 }
1216
1217 if (AvMAX(dbargs) < AvFILL(ary) + off)
1218 av_extend(dbargs, AvFILL(ary) + off);
1219 Copy(AvALLOC(ary), AvARRAY(dbargs), AvFILL(ary) + 1 + off, SV*);
1220 AvFILL(dbargs) = AvFILL(ary) + off;
1221 }
1222 RETURN;
1223}
1224
1225static int
1226sortcv(a, b)
1227const void *a;
1228const void *b;
1229{
9607fc9c 1230 SV * const *str1 = (SV * const *)a;
1231 SV * const *str2 = (SV * const *)b;
748a9306 1232 I32 oldsaveix = savestack_ix;
a0d0e21e 1233 I32 oldscopeix = scopestack_ix;
1234 I32 result;
1235 GvSV(firstgv) = *str1;
1236 GvSV(secondgv) = *str2;
1237 stack_sp = stack_base;
1238 op = sortcop;
a6c477ed 1239 runops();
a0d0e21e 1240 if (stack_sp != stack_base + 1)
1241 croak("Sort subroutine didn't return single value");
748a9306 1242 if (!SvNIOKp(*stack_sp))
a0d0e21e 1243 croak("Sort subroutine didn't return a numeric value");
1244 result = SvIV(*stack_sp);
1245 while (scopestack_ix > oldscopeix) {
1246 LEAVE;
1247 }
748a9306 1248 leave_scope(oldsaveix);
a0d0e21e 1249 return result;
1250}
1251
1252static int
1253sortcmp(a, b)
1254const void *a;
1255const void *b;
1256{
9607fc9c 1257 return sv_cmp(*(SV * const *)a, *(SV * const *)b);
bbce6d69 1258}
e5cf08de 1259
bbce6d69 1260static int
1261sortcmp_locale(a, b)
1262const void *a;
1263const void *b;
1264{
9607fc9c 1265 return sv_cmp_locale(*(SV * const *)a, *(SV * const *)b);
a0d0e21e 1266}
1267
1268PP(pp_reset)
1269{
1270 dSP;
1271 char *tmps;
1272
1273 if (MAXARG < 1)
1274 tmps = "";
1275 else
1276 tmps = POPp;
1277 sv_reset(tmps, curcop->cop_stash);
1278 PUSHs(&sv_yes);
1279 RETURN;
1280}
1281
1282PP(pp_lineseq)
1283{
1284 return NORMAL;
1285}
1286
1287PP(pp_dbstate)
1288{
1289 curcop = (COP*)op;
1290 TAINT_NOT; /* Each statement is presumed innocent */
1291 stack_sp = stack_base + cxstack[cxstack_ix].blk_oldsp;
1292 FREETMPS;
1293
1294 if (op->op_private || SvIV(DBsingle) || SvIV(DBsignal) || SvIV(DBtrace))
1295 {
1296 SV **sp;
1297 register CV *cv;
1298 register CONTEXT *cx;
748a9306 1299 I32 gimme = G_ARRAY;
a0d0e21e 1300 I32 hasargs;
1301 GV *gv;
1302
a0d0e21e 1303 gv = DBgv;
1304 cv = GvCV(gv);
a0d0e21e 1305 if (!cv)
1306 DIE("No DB::DB routine defined");
1307
06a5b730 1308 if (CvDEPTH(cv) >= 1 && !(debug & (1<<30))) /* don't do recursive DB::DB call */
a0d0e21e 1309 return NORMAL;
748a9306 1310
4633a7c4 1311 ENTER;
1312 SAVETMPS;
1313
748a9306 1314 SAVEI32(debug);
55497cff 1315 SAVESTACK_POS();
748a9306 1316 debug = 0;
1317 hasargs = 0;
1318 sp = stack_sp;
1319
a0d0e21e 1320 push_return(op->op_next);
748a9306 1321 PUSHBLOCK(cx, CXt_SUB, sp);
a0d0e21e 1322 PUSHSUB(cx);
1323 CvDEPTH(cv)++;
1324 (void)SvREFCNT_inc(cv);
1325 SAVESPTR(curpad);
1326 curpad = AvARRAY((AV*)*av_fetch(CvPADLIST(cv),1,FALSE));
1327 RETURNOP(CvSTART(cv));
1328 }
1329 else
1330 return NORMAL;
1331}
1332
1333PP(pp_scope)
1334{
1335 return NORMAL;
1336}
1337
1338PP(pp_enteriter)
1339{
1340 dSP; dMARK;
1341 register CONTEXT *cx;
54310121 1342 I32 gimme = GIMME_V;
a0d0e21e 1343 SV **svp;
1344
4633a7c4 1345 ENTER;
1346 SAVETMPS;
1347
a0d0e21e 1348 if (op->op_targ)
1349 svp = &curpad[op->op_targ]; /* "my" variable */
1350 else
1351 svp = &GvSV((GV*)POPs); /* symbol table variable */
1352
4633a7c4 1353 SAVESPTR(*svp);
1354
a0d0e21e 1355 ENTER;
1356
1357 PUSHBLOCK(cx, CXt_LOOP, SP);
1358 PUSHLOOP(cx, svp, MARK);
44a8e56a 1359 if (op->op_flags & OPf_STACKED)
1360 cx->blk_loop.iterary = (AV*)SvREFCNT_inc(POPs);
4633a7c4 1361 else {
1ce6579f 1362 cx->blk_loop.iterary = curstack;
1363 AvFILL(curstack) = sp - stack_base;
4633a7c4 1364 cx->blk_loop.iterix = MARK - stack_base;
1365 }
a0d0e21e 1366
1367 RETURN;
1368}
1369
1370PP(pp_enterloop)
1371{
1372 dSP;
1373 register CONTEXT *cx;
54310121 1374 I32 gimme = GIMME_V;
a0d0e21e 1375
1376 ENTER;
1377 SAVETMPS;
1378 ENTER;
1379
1380 PUSHBLOCK(cx, CXt_LOOP, SP);
1381 PUSHLOOP(cx, 0, SP);
1382
1383 RETURN;
1384}
1385
1386PP(pp_leaveloop)
1387{
1388 dSP;
1389 register CONTEXT *cx;
f86702cc 1390 struct block_loop cxloop;
a0d0e21e 1391 I32 gimme;
1392 SV **newsp;
1393 PMOP *newpm;
1394 SV **mark;
1395
1396 POPBLOCK(cx,newpm);
4fdae800 1397 mark = newsp;
f86702cc 1398 POPLOOP1(cx); /* Delay POPLOOP2 until stack values are safe */
1399
a1f49e72 1400 TAINT_NOT;
54310121 1401 if (gimme == G_VOID)
1402 ; /* do nothing */
1403 else if (gimme == G_SCALAR) {
1404 if (mark < SP)
1405 *++newsp = sv_mortalcopy(*SP);
1406 else
1407 *++newsp = &sv_undef;
a0d0e21e 1408 }
1409 else {
a1f49e72 1410 while (mark < SP) {
a0d0e21e 1411 *++newsp = sv_mortalcopy(*++mark);
a1f49e72 1412 TAINT_NOT; /* Each item is independent */
1413 }
a0d0e21e 1414 }
f86702cc 1415 SP = newsp;
1416 PUTBACK;
1417
1418 POPLOOP2(); /* Stack values are safe: release loop vars ... */
1419 curpm = newpm; /* ... and pop $1 et al */
1420
a0d0e21e 1421 LEAVE;
1422 LEAVE;
1423
f86702cc 1424 return NORMAL;
a0d0e21e 1425}
1426
1427PP(pp_return)
1428{
1429 dSP; dMARK;
1430 I32 cxix;
1431 register CONTEXT *cx;
f86702cc 1432 struct block_sub cxsub;
1433 bool popsub2 = FALSE;
a0d0e21e 1434 I32 gimme;
1435 SV **newsp;
1436 PMOP *newpm;
1437 I32 optype = 0;
1438
1ce6579f 1439 if (curstack == sortstack) {
b3933176 1440 if (cxstack_ix == sortcxix || dopoptosub(cxstack_ix) <= sortcxix) {
16d20bd9 1441 if (cxstack_ix > sortcxix)
1442 dounwind(sortcxix);
1ce6579f 1443 AvARRAY(curstack)[1] = *SP;
a0d0e21e 1444 stack_sp = stack_base + 1;
1445 return 0;
1446 }
1447 }
1448
1449 cxix = dopoptosub(cxstack_ix);
1450 if (cxix < 0)
1451 DIE("Can't return outside a subroutine");
1452 if (cxix < cxstack_ix)
1453 dounwind(cxix);
1454
1455 POPBLOCK(cx,newpm);
1456 switch (cx->cx_type) {
1457 case CXt_SUB:
f86702cc 1458 POPSUB1(cx); /* Delay POPSUB2 until stack values are safe */
1459 popsub2 = TRUE;
a0d0e21e 1460 break;
1461 case CXt_EVAL:
1462 POPEVAL(cx);
748a9306 1463 if (optype == OP_REQUIRE &&
1464 (MARK == SP || (gimme == G_SCALAR && !SvTRUE(*SP))) )
1465 {
54310121 1466 /* Unassume the success we assumed earlier. */
748a9306 1467 char *name = cx->blk_eval.old_name;
1468 (void)hv_delete(GvHVn(incgv), name, strlen(name), G_DISCARD);
1469 DIE("%s did not return a true value", name);
1470 }
a0d0e21e 1471 break;
1472 default:
1473 DIE("panic: return");
a0d0e21e 1474 }
1475
a1f49e72 1476 TAINT_NOT;
a0d0e21e 1477 if (gimme == G_SCALAR) {
1478 if (MARK < SP)
f86702cc 1479 *++newsp = (popsub2 && SvTEMP(*SP))
1480 ? *SP : sv_mortalcopy(*SP);
a0d0e21e 1481 else
1482 *++newsp = &sv_undef;
a0d0e21e 1483 }
54310121 1484 else if (gimme == G_ARRAY) {
a1f49e72 1485 while (++MARK <= SP) {
f86702cc 1486 *++newsp = (popsub2 && SvTEMP(*MARK))
1487 ? *MARK : sv_mortalcopy(*MARK);
a1f49e72 1488 TAINT_NOT; /* Each item is independent */
1489 }
a0d0e21e 1490 }
a0d0e21e 1491 stack_sp = newsp;
1492
f86702cc 1493 /* Stack values are safe: */
1494 if (popsub2) {
1495 POPSUB2(); /* release CV and @_ ... */
1496 }
1497 curpm = newpm; /* ... and pop $1 et al */
1498
a0d0e21e 1499 LEAVE;
1500 return pop_return();
1501}
1502
1503PP(pp_last)
1504{
1505 dSP;
1506 I32 cxix;
1507 register CONTEXT *cx;
f86702cc 1508 struct block_loop cxloop;
1509 struct block_sub cxsub;
1510 I32 pop2 = 0;
a0d0e21e 1511 I32 gimme;
1512 I32 optype;
1513 OP *nextop;
1514 SV **newsp;
1515 PMOP *newpm;
1516 SV **mark = stack_base + cxstack[cxstack_ix].blk_oldsp;
a0d0e21e 1517
1518 if (op->op_flags & OPf_SPECIAL) {
1519 cxix = dopoptoloop(cxstack_ix);
1520 if (cxix < 0)
1521 DIE("Can't \"last\" outside a block");
1522 }
1523 else {
1524 cxix = dopoptolabel(cPVOP->op_pv);
1525 if (cxix < 0)
1526 DIE("Label not found for \"last %s\"", cPVOP->op_pv);
1527 }
1528 if (cxix < cxstack_ix)
1529 dounwind(cxix);
1530
1531 POPBLOCK(cx,newpm);
1532 switch (cx->cx_type) {
1533 case CXt_LOOP:
f86702cc 1534 POPLOOP1(cx); /* Delay POPLOOP2 until stack values are safe */
1535 pop2 = CXt_LOOP;
4fdae800 1536 nextop = cxloop.last_op->op_next;
a0d0e21e 1537 break;
f86702cc 1538 case CXt_SUB:
1539 POPSUB1(cx); /* Delay POPSUB2 until stack values are safe */
1540 pop2 = CXt_SUB;
a0d0e21e 1541 nextop = pop_return();
1542 break;
f86702cc 1543 case CXt_EVAL:
1544 POPEVAL(cx);
a0d0e21e 1545 nextop = pop_return();
1546 break;
1547 default:
1548 DIE("panic: last");
a0d0e21e 1549 }
1550
a1f49e72 1551 TAINT_NOT;
a0d0e21e 1552 if (gimme == G_SCALAR) {
f86702cc 1553 if (MARK < SP)
1554 *++newsp = ((pop2 == CXt_SUB) && SvTEMP(*SP))
1555 ? *SP : sv_mortalcopy(*SP);
a0d0e21e 1556 else
1557 *++newsp = &sv_undef;
1558 }
54310121 1559 else if (gimme == G_ARRAY) {
a1f49e72 1560 while (++MARK <= SP) {
f86702cc 1561 *++newsp = ((pop2 == CXt_SUB) && SvTEMP(*MARK))
1562 ? *MARK : sv_mortalcopy(*MARK);
a1f49e72 1563 TAINT_NOT; /* Each item is independent */
1564 }
f86702cc 1565 }
1566 SP = newsp;
1567 PUTBACK;
1568
1569 /* Stack values are safe: */
1570 switch (pop2) {
1571 case CXt_LOOP:
1572 POPLOOP2(); /* release loop vars ... */
4fdae800 1573 LEAVE;
f86702cc 1574 break;
1575 case CXt_SUB:
1576 POPSUB2(); /* release CV and @_ ... */
1577 break;
a0d0e21e 1578 }
f86702cc 1579 curpm = newpm; /* ... and pop $1 et al */
a0d0e21e 1580
1581 LEAVE;
f86702cc 1582 return nextop;
a0d0e21e 1583}
1584
1585PP(pp_next)
1586{
1587 I32 cxix;
1588 register CONTEXT *cx;
1589 I32 oldsave;
1590
1591 if (op->op_flags & OPf_SPECIAL) {
1592 cxix = dopoptoloop(cxstack_ix);
1593 if (cxix < 0)
1594 DIE("Can't \"next\" outside a block");
1595 }
1596 else {
1597 cxix = dopoptolabel(cPVOP->op_pv);
1598 if (cxix < 0)
1599 DIE("Label not found for \"next %s\"", cPVOP->op_pv);
1600 }
1601 if (cxix < cxstack_ix)
1602 dounwind(cxix);
1603
1604 TOPBLOCK(cx);
1605 oldsave = scopestack[scopestack_ix - 1];
1606 LEAVE_SCOPE(oldsave);
1607 return cx->blk_loop.next_op;
1608}
1609
1610PP(pp_redo)
1611{
1612 I32 cxix;
1613 register CONTEXT *cx;
1614 I32 oldsave;
1615
1616 if (op->op_flags & OPf_SPECIAL) {
1617 cxix = dopoptoloop(cxstack_ix);
1618 if (cxix < 0)
1619 DIE("Can't \"redo\" outside a block");
1620 }
1621 else {
1622 cxix = dopoptolabel(cPVOP->op_pv);
1623 if (cxix < 0)
1624 DIE("Label not found for \"redo %s\"", cPVOP->op_pv);
1625 }
1626 if (cxix < cxstack_ix)
1627 dounwind(cxix);
1628
1629 TOPBLOCK(cx);
1630 oldsave = scopestack[scopestack_ix - 1];
1631 LEAVE_SCOPE(oldsave);
1632 return cx->blk_loop.redo_op;
1633}
1634
1635static OP* lastgotoprobe;
1636
1637static OP *
fc36a67e 1638dofindlabel(op,label,opstack,oplimit)
a0d0e21e 1639OP *op;
1640char *label;
1641OP **opstack;
fc36a67e 1642OP **oplimit;
a0d0e21e 1643{
1644 OP *kid;
1645 OP **ops = opstack;
fc36a67e 1646 static char too_deep[] = "Target of goto is too deeply nested";
a0d0e21e 1647
fc36a67e 1648 if (ops >= oplimit)
1649 croak(too_deep);
a0d0e21e 1650 if (op->op_type == OP_LEAVE ||
1651 op->op_type == OP_SCOPE ||
1652 op->op_type == OP_LEAVELOOP ||
1653 op->op_type == OP_LEAVETRY)
fc36a67e 1654 {
1655 *ops++ = cUNOP->op_first;
1656 if (ops >= oplimit)
1657 croak(too_deep);
1658 }
a0d0e21e 1659 *ops = 0;
1660 if (op->op_flags & OPf_KIDS) {
1661 /* First try all the kids at this level, since that's likeliest. */
1662 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling) {
1663 if ((kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) &&
1664 kCOP->cop_label && strEQ(kCOP->cop_label, label))
1665 return kid;
1666 }
1667 for (kid = cUNOP->op_first; kid; kid = kid->op_sibling) {
1668 if (kid == lastgotoprobe)
1669 continue;
fc36a67e 1670 if ((kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) &&
1671 (ops == opstack ||
1672 (ops[-1]->op_type != OP_NEXTSTATE &&
1673 ops[-1]->op_type != OP_DBSTATE)))
1674 *ops++ = kid;
1675 if (op = dofindlabel(kid, label, ops, oplimit))
a0d0e21e 1676 return op;
1677 }
1678 }
1679 *ops = 0;
1680 return 0;
1681}
1682
1683PP(pp_dump)
1684{
1685 return pp_goto(ARGS);
1686 /*NOTREACHED*/
1687}
1688
1689PP(pp_goto)
1690{
1691 dSP;
1692 OP *retop = 0;
1693 I32 ix;
1694 register CONTEXT *cx;
fc36a67e 1695#define GOTO_DEPTH 64
1696 OP *enterops[GOTO_DEPTH];
a0d0e21e 1697 char *label;
1698 int do_dump = (op->op_type == OP_DUMP);
1699
1700 label = 0;
1701 if (op->op_flags & OPf_STACKED) {
1702 SV *sv = POPs;
1703
1704 /* This egregious kludge implements goto &subroutine */
1705 if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVCV) {
1706 I32 cxix;
1707 register CONTEXT *cx;
1708 CV* cv = (CV*)SvRV(sv);
1709 SV** mark;
1710 I32 items = 0;
1711 I32 oldsave;
1712
4aa0a1f7 1713 if (!CvROOT(cv) && !CvXSUB(cv)) {
1714 if (CvGV(cv)) {
1715 SV *tmpstr = sv_newmortal();
e5cf08de 1716 gv_efullname3(tmpstr, CvGV(cv), Nullch);
4aa0a1f7 1717 DIE("Goto undefined subroutine &%s",SvPVX(tmpstr));
1718 }
1719 DIE("Goto undefined subroutine");
1720 }
1721
a0d0e21e 1722 /* First do some returnish stuff. */
1723 cxix = dopoptosub(cxstack_ix);
1724 if (cxix < 0)
1725 DIE("Can't goto subroutine outside a subroutine");
1726 if (cxix < cxstack_ix)
1727 dounwind(cxix);
1728 TOPBLOCK(cx);
1729 mark = stack_sp;
1730 if (cx->blk_sub.hasargs) { /* put @_ back onto stack */
1731 AV* av = cx->blk_sub.argarray;
1732
1733 items = AvFILL(av) + 1;
1ce6579f 1734 stack_sp++;
1735 EXTEND(stack_sp, items); /* @_ could have been extended. */
1736 Copy(AvARRAY(av), stack_sp, items, SV*);
a0d0e21e 1737 stack_sp += items;
2c05e328 1738 SvREFCNT_dec(GvAV(defgv));
a0d0e21e 1739 GvAV(defgv) = cx->blk_sub.savearray;
a0d0e21e 1740 AvREAL_off(av);
4633a7c4 1741 av_clear(av);
a0d0e21e 1742 }
1743 if (!(CvDEPTH(cx->blk_sub.cv) = cx->blk_sub.olddepth))
1744 SvREFCNT_dec(cx->blk_sub.cv);
1745 oldsave = scopestack[scopestack_ix - 1];
1746 LEAVE_SCOPE(oldsave);
1747
1748 /* Now do some callish stuff. */
1749 SAVETMPS;
1750 if (CvXSUB(cv)) {
1751 if (CvOLDSTYLE(cv)) {
ecfc5424 1752 I32 (*fp3)_((int,int,int));
a0d0e21e 1753 while (sp > mark) {
1754 sp[1] = sp[0];
1755 sp--;
1756 }
ecfc5424 1757 fp3 = (I32(*)_((int,int,int)))CvXSUB(cv);
1758 items = (*fp3)(CvXSUBANY(cv).any_i32,
1759 mark - stack_base + 1,
1760 items);
a0d0e21e 1761 sp = stack_base + items;
1762 }
1763 else {
1ce6579f 1764 stack_sp--; /* There is no cv arg. */
a0d0e21e 1765 (void)(*CvXSUB(cv))(cv);
1766 }
1767 LEAVE;
1768 return pop_return();
1769 }
1770 else {
1771 AV* padlist = CvPADLIST(cv);
1772 SV** svp = AvARRAY(padlist);
1773 cx->blk_sub.cv = cv;
1774 cx->blk_sub.olddepth = CvDEPTH(cv);
1775 CvDEPTH(cv)++;
1776 if (CvDEPTH(cv) < 2)
1777 (void)SvREFCNT_inc(cv);
1778 else { /* save temporaries on recursion? */
1779 if (CvDEPTH(cv) == 100 && dowarn)
44a8e56a 1780 sub_crush_depth(cv);
a0d0e21e 1781 if (CvDEPTH(cv) > AvFILL(padlist)) {
1782 AV *newpad = newAV();
4aa0a1f7 1783 SV **oldpad = AvARRAY(svp[CvDEPTH(cv)-1]);
a0d0e21e 1784 I32 ix = AvFILL((AV*)svp[1]);
1785 svp = AvARRAY(svp[0]);
748a9306 1786 for ( ;ix > 0; ix--) {
a0d0e21e 1787 if (svp[ix] != &sv_undef) {
748a9306 1788 char *name = SvPVX(svp[ix]);
5f05dabc 1789 if ((SvFLAGS(svp[ix]) & SVf_FAKE)
1790 || *name == '&')
1791 {
1792 /* outer lexical or anon code */
748a9306 1793 av_store(newpad, ix,
4aa0a1f7 1794 SvREFCNT_inc(oldpad[ix]) );
748a9306 1795 }
1796 else { /* our own lexical */
1797 if (*name == '@')
1798 av_store(newpad, ix, sv = (SV*)newAV());
1799 else if (*name == '%')
1800 av_store(newpad, ix, sv = (SV*)newHV());
1801 else
1802 av_store(newpad, ix, sv = NEWSV(0,0));
1803 SvPADMY_on(sv);
1804 }
a0d0e21e 1805 }
1806 else {
748a9306 1807 av_store(newpad, ix, sv = NEWSV(0,0));
a0d0e21e 1808 SvPADTMP_on(sv);
1809 }
1810 }
1811 if (cx->blk_sub.hasargs) {
1812 AV* av = newAV();
1813 av_extend(av, 0);
1814 av_store(newpad, 0, (SV*)av);
1815 AvFLAGS(av) = AVf_REIFY;
1816 }
1817 av_store(padlist, CvDEPTH(cv), (SV*)newpad);
1818 AvFILL(padlist) = CvDEPTH(cv);
1819 svp = AvARRAY(padlist);
1820 }
1821 }
1822 SAVESPTR(curpad);
1823 curpad = AvARRAY((AV*)svp[CvDEPTH(cv)]);
1824 if (cx->blk_sub.hasargs) {
1825 AV* av = (AV*)curpad[0];
1826 SV** ary;
1827
1828 cx->blk_sub.savearray = GvAV(defgv);
1829 cx->blk_sub.argarray = av;
2c05e328 1830 GvAV(defgv) = (AV*)SvREFCNT_inc(av);
a0d0e21e 1831 ++mark;
1832
1833 if (items >= AvMAX(av) + 1) {
1834 ary = AvALLOC(av);
1835 if (AvARRAY(av) != ary) {
1836 AvMAX(av) += AvARRAY(av) - AvALLOC(av);
1837 SvPVX(av) = (char*)ary;
1838 }
1839 if (items >= AvMAX(av) + 1) {
1840 AvMAX(av) = items - 1;
1841 Renew(ary,items+1,SV*);
1842 AvALLOC(av) = ary;
1843 SvPVX(av) = (char*)ary;
1844 }
1845 }
1846 Copy(mark,AvARRAY(av),items,SV*);
1847 AvFILL(av) = items - 1;
1848
1849 while (items--) {
1850 if (*mark)
1851 SvTEMP_off(*mark);
1852 mark++;
1853 }
1854 }
84902520 1855 if (PERLDB_SUB && curstash != debstash) {
44a8e56a 1856 /*
1857 * We do not care about using sv to call CV;
1858 * it's for informational purposes only.
1859 */
1ce6579f 1860 SV *sv = GvSV(DBsub);
1861 save_item(sv);
e5cf08de 1862 gv_efullname3(sv, CvGV(cv), Nullch);
1ce6579f 1863 }
a0d0e21e 1864 RETURNOP(CvSTART(cv));
1865 }
1866 }
1867 else
1868 label = SvPV(sv,na);
1869 }
1870 else if (op->op_flags & OPf_SPECIAL) {
1871 if (! do_dump)
1872 DIE("goto must have label");
1873 }
1874 else
1875 label = cPVOP->op_pv;
1876
1877 if (label && *label) {
1878 OP *gotoprobe = 0;
1879
1880 /* find label */
1881
1882 lastgotoprobe = 0;
1883 *enterops = 0;
1884 for (ix = cxstack_ix; ix >= 0; ix--) {
1885 cx = &cxstack[ix];
1886 switch (cx->cx_type) {
a0d0e21e 1887 case CXt_EVAL:
1888 gotoprobe = eval_root; /* XXX not good for nested eval */
1889 break;
1890 case CXt_LOOP:
1891 gotoprobe = cx->blk_oldcop->op_sibling;
1892 break;
1893 case CXt_SUBST:
1894 continue;
1895 case CXt_BLOCK:
1896 if (ix)
1897 gotoprobe = cx->blk_oldcop->op_sibling;
1898 else
1899 gotoprobe = main_root;
1900 break;
b3933176 1901 case CXt_SUB:
1902 if (CvDEPTH(cx->blk_sub.cv)) {
1903 gotoprobe = CvROOT(cx->blk_sub.cv);
1904 break;
1905 }
1906 /* FALL THROUGH */
0a753a76 1907 case CXt_NULL:
1908 DIE("Can't \"goto\" outside a block");
a0d0e21e 1909 default:
1910 if (ix)
1911 DIE("panic: goto");
68dc0745 1912 gotoprobe = main_root;
a0d0e21e 1913 break;
1914 }
fc36a67e 1915 retop = dofindlabel(gotoprobe, label,
1916 enterops, enterops + GOTO_DEPTH);
a0d0e21e 1917 if (retop)
1918 break;
1919 lastgotoprobe = gotoprobe;
1920 }
1921 if (!retop)
1922 DIE("Can't find label %s", label);
1923
1924 /* pop unwanted frames */
1925
1926 if (ix < cxstack_ix) {
1927 I32 oldsave;
1928
1929 if (ix < 0)
1930 ix = 0;
1931 dounwind(ix);
1932 TOPBLOCK(cx);
1933 oldsave = scopestack[scopestack_ix];
1934 LEAVE_SCOPE(oldsave);
1935 }
1936
1937 /* push wanted frames */
1938
748a9306 1939 if (*enterops && enterops[1]) {
a0d0e21e 1940 OP *oldop = op;
748a9306 1941 for (ix = 1; enterops[ix]; ix++) {
a0d0e21e 1942 op = enterops[ix];
84902520 1943 /* Eventually we may want to stack the needed arguments
1944 * for each op. For now, we punt on the hard ones. */
1945 if (op->op_type == OP_ENTERITER)
1946 DIE("Can't \"goto\" into the middle of a foreach loop",
1947 label);
a0d0e21e 1948 (*op->op_ppaddr)();
1949 }
1950 op = oldop;
1951 }
1952 }
1953
1954 if (do_dump) {
a5f75d66 1955#ifdef VMS
1956 if (!retop) retop = main_start;
1957#endif
a0d0e21e 1958 restartop = retop;
1959 do_undump = TRUE;
1960
1961 my_unexec();
1962
1963 restartop = 0; /* hmm, must be GNU unexec().. */
1964 do_undump = FALSE;
1965 }
1966
1ce6579f 1967 if (curstack == signalstack) {
748a9306 1968 restartop = retop;
54310121 1969 JMPENV_JUMP(3);
748a9306 1970 }
1971
a0d0e21e 1972 RETURNOP(retop);
1973}
1974
1975PP(pp_exit)
1976{
1977 dSP;
1978 I32 anum;
1979
1980 if (MAXARG < 1)
1981 anum = 0;
ff0cee69 1982 else {
a0d0e21e 1983 anum = SvIVx(POPs);
ff0cee69 1984#ifdef VMSISH_EXIT
1985 if (anum == 1 && VMSISH_EXIT)
1986 anum = 0;
1987#endif
1988 }
a0d0e21e 1989 my_exit(anum);
1990 PUSHs(&sv_undef);
1991 RETURN;
1992}
1993
1994#ifdef NOTYET
1995PP(pp_nswitch)
1996{
1997 dSP;
1998 double value = SvNVx(GvSV(cCOP->cop_gv));
1999 register I32 match = I_32(value);
2000
2001 if (value < 0.0) {
2002 if (((double)match) > value)
2003 --match; /* was fractional--truncate other way */
2004 }
2005 match -= cCOP->uop.scop.scop_offset;
2006 if (match < 0)
2007 match = 0;
2008 else if (match > cCOP->uop.scop.scop_max)
2009 match = cCOP->uop.scop.scop_max;
2010 op = cCOP->uop.scop.scop_next[match];
2011 RETURNOP(op);
2012}
2013
2014PP(pp_cswitch)
2015{
2016 dSP;
2017 register I32 match;
2018
2019 if (multiline)
2020 op = op->op_next; /* can't assume anything */
2021 else {
2022 match = *(SvPVx(GvSV(cCOP->cop_gv), na)) & 255;
2023 match -= cCOP->uop.scop.scop_offset;
2024 if (match < 0)
2025 match = 0;
2026 else if (match > cCOP->uop.scop.scop_max)
2027 match = cCOP->uop.scop.scop_max;
2028 op = cCOP->uop.scop.scop_next[match];
2029 }
2030 RETURNOP(op);
2031}
2032#endif
2033
2034/* Eval. */
2035
2036static void
2037save_lines(array, sv)
2038AV *array;
2039SV *sv;
2040{
2041 register char *s = SvPVX(sv);
2042 register char *send = SvPVX(sv) + SvCUR(sv);
2043 register char *t;
2044 register I32 line = 1;
2045
2046 while (s && s < send) {
2047 SV *tmpstr = NEWSV(85,0);
2048
2049 sv_upgrade(tmpstr, SVt_PVMG);
2050 t = strchr(s, '\n');
2051 if (t)
2052 t++;
2053 else
2054 t = send;
2055
2056 sv_setpvn(tmpstr, s, t - s);
2057 av_store(array, line++, tmpstr);
2058 s = t;
2059 }
2060}
2061
2062static OP *
1e422769 2063docatch(o)
2064OP *o;
2065{
2066 int ret;
035902c7 2067 I32 oldrunlevel = runlevel;
1e422769 2068 OP *oldop = op;
54310121 2069 dJMPENV;
1e422769 2070
2071 op = o;
1e422769 2072#ifdef DEBUGGING
54310121 2073 assert(CATCH_GET == TRUE);
035902c7 2074 DEBUG_l(deb("(Setting up local jumplevel, runlevel = %ld)\n", (long)runlevel+1));
1e422769 2075#endif
22921e25 2076 JMPENV_PUSH(ret);
2077 switch (ret) {
1e422769 2078 default: /* topmost level handles it */
54310121 2079 JMPENV_POP;
1e422769 2080 runlevel = oldrunlevel;
1e422769 2081 op = oldop;
54310121 2082 JMPENV_JUMP(ret);
1e422769 2083 /* NOTREACHED */
2084 case 3:
2085 if (!restartop) {
2086 PerlIO_printf(PerlIO_stderr(), "panic: restartop\n");
2087 break;
2088 }
1e422769 2089 op = restartop;
2090 restartop = 0;
2091 /* FALL THROUGH */
2092 case 0:
2093 runops();
2094 break;
2095 }
54310121 2096 JMPENV_POP;
1e422769 2097 runlevel = oldrunlevel;
1e422769 2098 op = oldop;
2099 return Nullop;
2100}
2101
2102static OP *
a0d0e21e 2103doeval(gimme)
2104int gimme;
2105{
2106 dSP;
2107 OP *saveop = op;
2108 HV *newstash;
ff3ff8d1 2109 CV *caller;
748a9306 2110 AV* comppadlist;
a0d0e21e 2111
2112 in_eval = 1;
2113
1ce6579f 2114 PUSHMARK(SP);
2115
a0d0e21e 2116 /* set up a scratch pad */
2117
55497cff 2118 SAVEI32(padix);
a0d0e21e 2119 SAVESPTR(curpad);
2120 SAVESPTR(comppad);
2121 SAVESPTR(comppad_name);
55497cff 2122 SAVEI32(comppad_name_fill);
2123 SAVEI32(min_intro_pending);
2124 SAVEI32(max_intro_pending);
748a9306 2125
ff3ff8d1 2126 caller = compcv;
748a9306 2127 SAVESPTR(compcv);
2128 compcv = (CV*)NEWSV(1104,0);
2129 sv_upgrade((SV *)compcv, SVt_PVCV);
07055b4c 2130 CvUNIQUE_on(compcv);
748a9306 2131
a0d0e21e 2132 comppad = newAV();
2133 comppad_name = newAV();
2134 comppad_name_fill = 0;
2135 min_intro_pending = 0;
2136 av_push(comppad, Nullsv);
2137 curpad = AvARRAY(comppad);
2138 padix = 0;
2139
748a9306 2140 comppadlist = newAV();
2141 AvREAL_off(comppadlist);
8e07c86e 2142 av_store(comppadlist, 0, (SV*)comppad_name);
2143 av_store(comppadlist, 1, (SV*)comppad);
748a9306 2144 CvPADLIST(compcv) = comppadlist;
2c05e328 2145
2146 if (saveop->op_type != OP_REQUIRE)
2147 CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc(caller);
07055b4c 2148
8e07c86e 2149 SAVEFREESV(compcv);
748a9306 2150
a0d0e21e 2151 /* make sure we compile in the right package */
2152
2153 newstash = curcop->cop_stash;
2154 if (curstash != newstash) {
2155 SAVESPTR(curstash);
2156 curstash = newstash;
2157 }
2158 SAVESPTR(beginav);
2159 beginav = newAV();
2160 SAVEFREESV(beginav);
2161
2162 /* try to compile it */
2163
2164 eval_root = Nullop;
2165 error_count = 0;
2166 curcop = &compiling;
2167 curcop->cop_arybase = 0;
c07a80fd 2168 SvREFCNT_dec(rs);
2169 rs = newSVpv("\n", 1);
1ce6579f 2170 if (saveop->op_flags & OPf_SPECIAL)
2171 in_eval |= 4;
2172 else
2173 sv_setpv(GvSV(errgv),"");
a0d0e21e 2174 if (yyparse() || error_count || !eval_root) {
2175 SV **newsp;
2176 I32 gimme;
2177 CONTEXT *cx;
2178 I32 optype;
2179
2180 op = saveop;
2181 if (eval_root) {
2182 op_free(eval_root);
2183 eval_root = Nullop;
2184 }
1ce6579f 2185 SP = stack_base + POPMARK; /* pop original mark */
a0d0e21e 2186 POPBLOCK(cx,curpm);
2187 POPEVAL(cx);
2188 pop_return();
2189 lex_end();
2190 LEAVE;
7a2e2cd6 2191 if (optype == OP_REQUIRE) {
2192 char* msg = SvPVx(GvSV(errgv), na);
2193 DIE("%s", *msg ? msg : "Compilation failed in require");
2194 }
c07a80fd 2195 SvREFCNT_dec(rs);
2196 rs = SvREFCNT_inc(nrs);
a0d0e21e 2197 RETPUSHUNDEF;
2198 }
c07a80fd 2199 SvREFCNT_dec(rs);
2200 rs = SvREFCNT_inc(nrs);
a0d0e21e 2201 compiling.cop_line = 0;
a0d0e21e 2202 SAVEFREEOP(eval_root);
54310121 2203 if (gimme & G_VOID)
2204 scalarvoid(eval_root);
2205 else if (gimme & G_ARRAY)
a0d0e21e 2206 list(eval_root);
2207 else
2208 scalar(eval_root);
2209
2210 DEBUG_x(dump_eval());
2211
55497cff 2212 /* Register with debugger: */
84902520 2213 if (PERLDB_INTER && saveop->op_type == OP_REQUIRE) {
55497cff 2214 CV *cv = perl_get_cv("DB::postponed", FALSE);
55497cff 2215 if (cv) {
2216 dSP;
2217 PUSHMARK(sp);
2218 XPUSHs((SV*)compiling.cop_filegv);
2219 PUTBACK;
2220 perl_call_sv((SV*)cv, G_DISCARD);
2221 }
2222 }
2223
a0d0e21e 2224 /* compiled okay, so do it */
2225
4fdae800 2226 CvDEPTH(compcv) = 1;
2227
1ce6579f 2228 SP = stack_base + POPMARK; /* pop original mark */
a0d0e21e 2229 RETURNOP(eval_start);
2230}
2231
2232PP(pp_require)
2233{
2234 dSP;
2235 register CONTEXT *cx;
2236 SV *sv;
2237 char *name;
46fc3d4c 2238 char *tryname;
2239 SV *namesv = Nullsv;
a0d0e21e 2240 SV** svp;
2241 I32 gimme = G_SCALAR;
760ac839 2242 PerlIO *tryrsfp = 0;
a0d0e21e 2243
2244 sv = POPs;
4633a7c4 2245 if (SvNIOKp(sv) && !SvPOKp(sv)) {
36477c24 2246 SET_NUMERIC_STANDARD();
a5f75d66 2247 if (atof(patchlevel) + 0.00000999 < SvNV(sv))
2248 DIE("Perl %s required--this is only version %s, stopped",
2249 SvPV(sv,na),patchlevel);
a0d0e21e 2250 RETPUSHYES;
2251 }
2252 name = SvPV(sv, na);
2253 if (!*name)
2254 DIE("Null filename used");
4633a7c4 2255 TAINT_PROPER("require");
a0d0e21e 2256 if (op->op_type == OP_REQUIRE &&
2257 (svp = hv_fetch(GvHVn(incgv), name, SvCUR(sv), 0)) &&
2258 *svp != &sv_undef)
2259 RETPUSHYES;
2260
2261 /* prepare to compile file */
2262
46fc3d4c 2263 if (*name == '/' ||
2264 (*name == '.' &&
2265 (name[1] == '/' ||
2266 (name[1] == '.' && name[2] == '/')))
4633a7c4 2267#ifdef DOSISH
46fc3d4c 2268 || (name[0] && name[1] == ':')
4633a7c4 2269#endif
ba42ef2f 2270#ifdef WIN32
2271 || (name[0] == '\\' && name[1] == '\\') /* UNC path */
2272#endif
748a9306 2273#ifdef VMS
46fc3d4c 2274 || (strchr(name,':') || ((*name == '[' || *name == '<') &&
2275 (isALNUM(name[1]) || strchr("$-_]>",name[1]))))
748a9306 2276#endif
2277 )
a0d0e21e 2278 {
46fc3d4c 2279 tryname = name;
2280 tryrsfp = PerlIO_open(name,"r");
a0d0e21e 2281 }
2282 else {
2283 AV *ar = GvAVn(incgv);
2284 I32 i;
748a9306 2285#ifdef VMS
46fc3d4c 2286 char *unixname;
2287 if ((unixname = tounixspec(name, Nullch)) != Nullch)
2288#endif
2289 {
2290 namesv = NEWSV(806, 0);
2291 for (i = 0; i <= AvFILL(ar); i++) {
2292 char *dir = SvPVx(*av_fetch(ar, i, TRUE), na);
2293#ifdef VMS
2294 char *unixdir;
2295 if ((unixdir = tounixpath(dir, Nullch)) == Nullch)
2296 continue;
2297 sv_setpv(namesv, unixdir);
2298 sv_catpv(namesv, unixname);
748a9306 2299#else
46fc3d4c 2300 sv_setpvf(namesv, "%s/%s", dir, name);
748a9306 2301#endif
46fc3d4c 2302 tryname = SvPVX(namesv);
2303 tryrsfp = PerlIO_open(tryname, "r");
2304 if (tryrsfp) {
2305 if (tryname[0] == '.' && tryname[1] == '/')
2306 tryname += 2;
2307 break;
2308 }
a0d0e21e 2309 }
2310 }
2311 }
2312 SAVESPTR(compiling.cop_filegv);
46fc3d4c 2313 compiling.cop_filegv = gv_fetchfile(tryrsfp ? tryname : name);
2314 SvREFCNT_dec(namesv);
a0d0e21e 2315 if (!tryrsfp) {
2316 if (op->op_type == OP_REQUIRE) {
46fc3d4c 2317 SV *msg = sv_2mortal(newSVpvf("Can't locate %s in @INC", name));
2683423c 2318 SV *dirmsgsv = NEWSV(0, 0);
2319 AV *ar = GvAVn(incgv);
2320 I32 i;
46fc3d4c 2321 if (instr(SvPVX(msg), ".h "))
2322 sv_catpv(msg, " (change .h to .ph maybe?)");
2323 if (instr(SvPVX(msg), ".ph "))
2324 sv_catpv(msg, " (did you run h2ph?)");
3e3baf6d 2325 sv_catpv(msg, " (@INC contains:");
2683423c 2326 for (i = 0; i <= AvFILL(ar); i++) {
2327 char *dir = SvPVx(*av_fetch(ar, i, TRUE), na);
3e3baf6d 2328 sv_setpvf(dirmsgsv, " %s", dir);
2683423c 2329 sv_catsv(msg, dirmsgsv);
2330 }
3e3baf6d 2331 sv_catpvn(msg, ")", 1);
2683423c 2332 SvREFCNT_dec(dirmsgsv);
fc36a67e 2333 DIE("%_", msg);
a0d0e21e 2334 }
2335
2336 RETPUSHUNDEF;
2337 }
2338
2339 /* Assume success here to prevent recursive requirement. */
2340 (void)hv_store(GvHVn(incgv), name, strlen(name),
2341 newSVsv(GvSV(compiling.cop_filegv)), 0 );
2342
2343 ENTER;
2344 SAVETMPS;
2345 lex_start(sv_2mortal(newSVpv("",0)));
e50aee73 2346 if (rsfp_filters){
2347 save_aptr(&rsfp_filters);
2348 rsfp_filters = NULL;
2349 }
2350
a0d0e21e 2351 rsfp = tryrsfp;
2352 name = savepv(name);
2353 SAVEFREEPV(name);
2354 SAVEI32(hints);
2355 hints = 0;
2356
2357 /* switch to eval mode */
2358
2359 push_return(op->op_next);
2360 PUSHBLOCK(cx, CXt_EVAL, SP);
2361 PUSHEVAL(cx, name, compiling.cop_filegv);
2362
2363 compiling.cop_line = 0;
2364
2365 PUTBACK;
1e422769 2366 return DOCATCH(doeval(G_SCALAR));
a0d0e21e 2367}
2368
2369PP(pp_dofile)
2370{
2371 return pp_require(ARGS);
2372}
2373
2374PP(pp_entereval)
2375{
2376 dSP;
2377 register CONTEXT *cx;
2378 dPOPss;
54310121 2379 I32 gimme = GIMME_V, was = sub_generation;
fc36a67e 2380 char tmpbuf[TYPE_DIGITS(long) + 12];
2381 char *safestr;
a0d0e21e 2382 STRLEN len;
55497cff 2383 OP *ret;
a0d0e21e 2384
2385 if (!SvPV(sv,len) || !len)
2386 RETPUSHUNDEF;
748a9306 2387 TAINT_PROPER("eval");
a0d0e21e 2388
2389 ENTER;
a0d0e21e 2390 lex_start(sv);
748a9306 2391 SAVETMPS;
a0d0e21e 2392
2393 /* switch to eval mode */
2394
748a9306 2395 SAVESPTR(compiling.cop_filegv);
ff0cee69 2396 sprintf(tmpbuf, "_<(eval %lu)", (unsigned long)++evalseq);
a0d0e21e 2397 compiling.cop_filegv = gv_fetchfile(tmpbuf+2);
2398 compiling.cop_line = 1;
55497cff 2399 /* XXX For C<eval "...">s within BEGIN {} blocks, this ends up
2400 deleting the eval's FILEGV from the stash before gv_check() runs
2401 (i.e. before run-time proper). To work around the coredump that
2402 ensues, we always turn GvMULTI_on for any globals that were
2403 introduced within evals. See force_ident(). GSAR 96-10-12 */
2404 safestr = savepv(tmpbuf);
2405 SAVEDELETE(defstash, safestr, strlen(safestr));
a0d0e21e 2406 SAVEI32(hints);
2407 hints = op->op_targ;
2408
2409 push_return(op->op_next);
2410 PUSHBLOCK(cx, CXt_EVAL, SP);
2411 PUSHEVAL(cx, 0, compiling.cop_filegv);
2412
2413 /* prepare to compile string */
2414
08ea043f 2415 if (PERLDB_LINE && curstash != debstash)
a0d0e21e 2416 save_lines(GvAV(compiling.cop_filegv), linestr);
2417 PUTBACK;
55497cff 2418 ret = doeval(gimme);
08ea043f 2419 if (PERLDB_INTER && was != sub_generation /* Some subs defined here. */
e506e776 2420 && ret != op->op_next) { /* Successive compilation. */
55497cff 2421 strcpy(safestr, "_<(eval )"); /* Anything fake and short. */
2422 }
1e422769 2423 return DOCATCH(ret);
a0d0e21e 2424}
2425
2426PP(pp_leaveeval)
2427{
2428 dSP;
2429 register SV **mark;
2430 SV **newsp;
2431 PMOP *newpm;
2432 I32 gimme;
2433 register CONTEXT *cx;
2434 OP *retop;
760ac839 2435 U8 save_flags = op -> op_flags;
a0d0e21e 2436 I32 optype;
2437
2438 POPBLOCK(cx,newpm);
2439 POPEVAL(cx);
2440 retop = pop_return();
2441
a1f49e72 2442 TAINT_NOT;
54310121 2443 if (gimme == G_VOID)
2444 MARK = newsp;
2445 else if (gimme == G_SCALAR) {
2446 MARK = newsp + 1;
2447 if (MARK <= SP) {
2448 if (SvFLAGS(TOPs) & SVs_TEMP)
2449 *MARK = TOPs;
2450 else
2451 *MARK = sv_mortalcopy(TOPs);
2452 }
a0d0e21e 2453 else {
54310121 2454 MEXTEND(mark,0);
2455 *MARK = &sv_undef;
a0d0e21e 2456 }
a0d0e21e 2457 }
2458 else {
a1f49e72 2459 /* in case LEAVE wipes old return values */
2460 for (mark = newsp + 1; mark <= SP; mark++) {
2461 if (!(SvFLAGS(*mark) & SVs_TEMP)) {
a0d0e21e 2462 *mark = sv_mortalcopy(*mark);
a1f49e72 2463 TAINT_NOT; /* Each item is independent */
2464 }
2465 }
a0d0e21e 2466 }
2467 curpm = newpm; /* Don't pop $1 et al till now */
2468
84902520 2469 /*
2470 * Closures mentioned at top level of eval cannot be referenced
2471 * again, and their presence indirectly causes a memory leak.
2472 * (Note that the fact that compcv and friends are still set here
2473 * is, AFAIK, an accident.) --Chip
2474 */
2475 if (AvFILL(comppad_name) >= 0) {
2476 SV **svp = AvARRAY(comppad_name);
2477 I32 ix;
2478 for (ix = AvFILL(comppad_name); ix >= 0; ix--) {
2479 SV *sv = svp[ix];
2480 if (sv && sv != &sv_undef && *SvPVX(sv) == '&') {
2481 SvREFCNT_dec(sv);
2482 svp[ix] = &sv_undef;
2483
2484 sv = curpad[ix];
2485 if (CvCLONE(sv)) {
2486 SvREFCNT_dec(CvOUTSIDE(sv));
2487 CvOUTSIDE(sv) = Nullcv;
2488 }
2489 else {
2490 SvREFCNT_dec(sv);
2491 sv = NEWSV(0,0);
2492 SvPADTMP_on(sv);
2493 curpad[ix] = sv;
2494 }
2495 }
2496 }
2497 }
2498
4fdae800 2499#ifdef DEBUGGING
2500 assert(CvDEPTH(compcv) == 1);
2501#endif
2502 CvDEPTH(compcv) = 0;
2503
1ce6579f 2504 if (optype == OP_REQUIRE &&
54310121 2505 !(gimme == G_SCALAR ? SvTRUE(*sp) : sp > newsp))
2506 {
1ce6579f 2507 /* Unassume the success we assumed earlier. */
54310121 2508 char *name = cx->blk_eval.old_name;
1ce6579f 2509 (void)hv_delete(GvHVn(incgv), name, strlen(name), G_DISCARD);
2510 retop = die("%s did not return a true value", name);
a0d0e21e 2511 }
2512
2513 lex_end();
2514 LEAVE;
4fdae800 2515
760ac839 2516 if (!(save_flags & OPf_SPECIAL))
1ce6579f 2517 sv_setpv(GvSV(errgv),"");
a0d0e21e 2518
2519 RETURNOP(retop);
2520}
2521
a0d0e21e 2522PP(pp_entertry)
2523{
2524 dSP;
2525 register CONTEXT *cx;
54310121 2526 I32 gimme = GIMME_V;
a0d0e21e 2527
2528 ENTER;
2529 SAVETMPS;
2530
2531 push_return(cLOGOP->op_other->op_next);
2532 PUSHBLOCK(cx, CXt_EVAL, SP);
2533 PUSHEVAL(cx, 0, 0);
2534 eval_root = op; /* Only needed so that goto works right. */
2535
2536 in_eval = 1;
4633a7c4 2537 sv_setpv(GvSV(errgv),"");
1e422769 2538 PUTBACK;
2539 return DOCATCH(op->op_next);
a0d0e21e 2540}
2541
2542PP(pp_leavetry)
2543{
2544 dSP;
2545 register SV **mark;
2546 SV **newsp;
2547 PMOP *newpm;
2548 I32 gimme;
2549 register CONTEXT *cx;
2550 I32 optype;
2551
2552 POPBLOCK(cx,newpm);
2553 POPEVAL(cx);
2554 pop_return();
2555
a1f49e72 2556 TAINT_NOT;
54310121 2557 if (gimme == G_VOID)
2558 SP = newsp;
2559 else if (gimme == G_SCALAR) {
2560 MARK = newsp + 1;
2561 if (MARK <= SP) {
2562 if (SvFLAGS(TOPs) & (SVs_PADTMP|SVs_TEMP))
2563 *MARK = TOPs;
2564 else
2565 *MARK = sv_mortalcopy(TOPs);
2566 }
a0d0e21e 2567 else {
54310121 2568 MEXTEND(mark,0);
2569 *MARK = &sv_undef;
a0d0e21e 2570 }
2571 SP = MARK;
2572 }
2573 else {
a1f49e72 2574 /* in case LEAVE wipes old return values */
2575 for (mark = newsp + 1; mark <= SP; mark++) {
2576 if (!(SvFLAGS(*mark) & (SVs_PADTMP|SVs_TEMP))) {
a0d0e21e 2577 *mark = sv_mortalcopy(*mark);
a1f49e72 2578 TAINT_NOT; /* Each item is independent */
2579 }
2580 }
a0d0e21e 2581 }
2582 curpm = newpm; /* Don't pop $1 et al till now */
2583
2584 LEAVE;
4633a7c4 2585 sv_setpv(GvSV(errgv),"");
a0d0e21e 2586 RETURN;
2587}
2588
2589static void
2590doparseform(sv)
2591SV *sv;
2592{
2593 STRLEN len;
2594 register char *s = SvPV_force(sv, len);
2595 register char *send = s + len;
2596 register char *base;
2597 register I32 skipspaces = 0;
2598 bool noblank;
2599 bool repeat;
2600 bool postspace = FALSE;
2601 U16 *fops;
2602 register U16 *fpc;
2603 U16 *linepc;
2604 register I32 arg;
2605 bool ischop;
2606
55497cff 2607 if (len == 0)
bbce6d69 2608 croak("Null picture in formline");
55497cff 2609
2610 New(804, fops, (send - s)*3+10, U16); /* Almost certainly too long... */
a0d0e21e 2611 fpc = fops;
2612
2613 if (s < send) {
2614 linepc = fpc;
2615 *fpc++ = FF_LINEMARK;
2616 noblank = repeat = FALSE;
2617 base = s;
2618 }
2619
2620 while (s <= send) {
2621 switch (*s++) {
2622 default:
2623 skipspaces = 0;
2624 continue;
2625
2626 case '~':
2627 if (*s == '~') {
2628 repeat = TRUE;
2629 *s = ' ';
2630 }
2631 noblank = TRUE;
2632 s[-1] = ' ';
2633 /* FALL THROUGH */
2634 case ' ': case '\t':
2635 skipspaces++;
2636 continue;
2637
2638 case '\n': case 0:
2639 arg = s - base;
2640 skipspaces++;
2641 arg -= skipspaces;
2642 if (arg) {
5f05dabc 2643 if (postspace)
a0d0e21e 2644 *fpc++ = FF_SPACE;
a0d0e21e 2645 *fpc++ = FF_LITERAL;
2646 *fpc++ = arg;
2647 }
5f05dabc 2648 postspace = FALSE;
a0d0e21e 2649 if (s <= send)
2650 skipspaces--;
2651 if (skipspaces) {
2652 *fpc++ = FF_SKIP;
2653 *fpc++ = skipspaces;
2654 }
2655 skipspaces = 0;
2656 if (s <= send)
2657 *fpc++ = FF_NEWLINE;
2658 if (noblank) {
2659 *fpc++ = FF_BLANK;
2660 if (repeat)
2661 arg = fpc - linepc + 1;
2662 else
2663 arg = 0;
2664 *fpc++ = arg;
2665 }
2666 if (s < send) {
2667 linepc = fpc;
2668 *fpc++ = FF_LINEMARK;
2669 noblank = repeat = FALSE;
2670 base = s;
2671 }
2672 else
2673 s++;
2674 continue;
2675
2676 case '@':
2677 case '^':
2678 ischop = s[-1] == '^';
2679
2680 if (postspace) {
2681 *fpc++ = FF_SPACE;
2682 postspace = FALSE;
2683 }
2684 arg = (s - base) - 1;
2685 if (arg) {
2686 *fpc++ = FF_LITERAL;
2687 *fpc++ = arg;
2688 }
2689
2690 base = s - 1;
2691 *fpc++ = FF_FETCH;
2692 if (*s == '*') {
2693 s++;
2694 *fpc++ = 0;
2695 *fpc++ = FF_LINEGLOB;
2696 }
2697 else if (*s == '#' || (*s == '.' && s[1] == '#')) {
2698 arg = ischop ? 512 : 0;
2699 base = s - 1;
2700 while (*s == '#')
2701 s++;
2702 if (*s == '.') {
2703 char *f;
2704 s++;
2705 f = s;
2706 while (*s == '#')
2707 s++;
2708 arg |= 256 + (s - f);
2709 }
2710 *fpc++ = s - base; /* fieldsize for FETCH */
2711 *fpc++ = FF_DECIMAL;
2712 *fpc++ = arg;
2713 }
2714 else {
2715 I32 prespace = 0;
2716 bool ismore = FALSE;
2717
2718 if (*s == '>') {
2719 while (*++s == '>') ;
2720 prespace = FF_SPACE;
2721 }
2722 else if (*s == '|') {
2723 while (*++s == '|') ;
2724 prespace = FF_HALFSPACE;
2725 postspace = TRUE;
2726 }
2727 else {
2728 if (*s == '<')
2729 while (*++s == '<') ;
2730 postspace = TRUE;
2731 }
2732 if (*s == '.' && s[1] == '.' && s[2] == '.') {
2733 s += 3;
2734 ismore = TRUE;
2735 }
2736 *fpc++ = s - base; /* fieldsize for FETCH */
2737
2738 *fpc++ = ischop ? FF_CHECKCHOP : FF_CHECKNL;
2739
2740 if (prespace)
2741 *fpc++ = prespace;
2742 *fpc++ = FF_ITEM;
2743 if (ismore)
2744 *fpc++ = FF_MORE;
2745 if (ischop)
2746 *fpc++ = FF_CHOP;
2747 }
2748 base = s;
2749 skipspaces = 0;
2750 continue;
2751 }
2752 }
2753 *fpc++ = FF_END;
2754
2755 arg = fpc - fops;
2756 { /* need to jump to the next word */
2757 int z;
2758 z = WORD_ALIGN - SvCUR(sv) % WORD_ALIGN;
2759 SvGROW(sv, SvCUR(sv) + z + arg * sizeof(U16) + 4);
2760 s = SvPVX(sv) + SvCUR(sv) + z;
2761 }
2762 Copy(fops, s, arg, U16);
2763 Safefree(fops);
55497cff 2764 sv_magic(sv, Nullsv, 'f', Nullch, 0);
a0d0e21e 2765 SvCOMPILED_on(sv);
2766}