3 * Copyright (c) 1991-1997, Larry Wall
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.
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.
23 #define WORD_ALIGN sizeof(U16)
26 #define DOCATCH(o) ((CATCH_GET == TRUE) ? docatch(o) : (o))
28 static OP *docatch _((OP *o));
29 static OP *doeval _((int gimme));
30 static OP *dofindlabel _((OP *o, char *label, OP **opstack, OP **oplimit));
31 static void doparseform _((SV *sv));
32 static I32 dopoptoeval _((I32 startingblock));
33 static I32 dopoptolabel _((char *label));
34 static I32 dopoptoloop _((I32 startingblock));
35 static I32 dopoptosub _((I32 startingblock));
36 static void save_lines _((AV *array, SV *sv));
37 static int sortcv _((const void *, const void *));
38 static int sortcmp _((const void *, const void *));
39 static int sortcmp_locale _((const void *, const void *));
49 cxix = dopoptosub(cxstack_ix);
53 switch (cxstack[cxix].blk_gimme) {
70 register PMOP *pm = (PMOP*)cLOGOP->op_other;
76 t = SvPV(tmpstr, len);
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 */
87 pm->op_pmflags = pm->op_pmpermflags; /* reset case sensitivity */
88 pm->op_pmregexp = pregcomp(t, t + len, pm);
91 if (!pm->op_pmregexp->prelen && curpm)
93 else if (strEQ("\\s+", pm->op_pmregexp->precomp))
94 pm->op_pmflags |= PMf_WHITE;
96 if (pm->op_pmflags & PMf_KEEP) {
97 pm->op_private &= ~OPpRUNTIME; /* no point compiling again */
99 cLOGOP->op_first->op_next = op->op_next;
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;
113 register REGEXP *rx = cx->sb_rx;
115 rxres_restore(&cx->sb_rxres, rx);
117 if (cx->sb_iters++) {
118 if (cx->sb_iters > cx->sb_maxiters)
119 DIE("Substitution loop");
121 if (!cx->sb_rxtainted)
122 cx->sb_rxtainted = SvTAINTED(TOPs);
123 sv_catsv(dstr, POPs);
126 if (cx->sb_once || !pregexec(rx, s, cx->sb_strend, orig,
127 s == m, Nullsv, cx->sb_safebase))
129 SV *targ = cx->sb_targ;
130 sv_catpvn(dstr, s, cx->sb_strend - s);
132 TAINT_IF(cx->sb_rxtainted || rx->exec_tainted);
134 (void)SvOOK_off(targ);
135 Safefree(SvPVX(targ));
136 SvPVX(targ) = SvPVX(dstr);
137 SvCUR_set(targ, SvCUR(dstr));
138 SvLEN_set(targ, SvLEN(dstr));
141 (void)SvPOK_only(targ);
145 PUSHs(sv_2mortal(newSViv((I32)cx->sb_iters - 1)));
146 LEAVE_SCOPE(cx->sb_oldsave);
148 RETURNOP(pm->op_next);
151 if (rx->subbase && rx->subbase != orig) {
154 cx->sb_orig = orig = rx->subbase;
156 cx->sb_strend = s + (cx->sb_strend - m);
158 cx->sb_m = m = rx->startp[0];
159 sv_catpvn(dstr, s, m-s);
160 cx->sb_s = rx->endp[0];
161 cx->sb_rxtainted |= rx->exec_tainted;
162 rxres_save(&cx->sb_rxres, rx);
163 RETURNOP(pm->op_pmreplstart);
174 if (!p || p[1] < rx->nparens) {
175 i = 6 + rx->nparens * 2;
183 *p++ = (UV)rx->subbase;
184 rx->subbase = Nullch;
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];
197 rxres_restore(rsp, rx)
204 Safefree(rx->subbase);
205 rx->subbase = (char*)(*p);
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++);
225 Safefree((char*)(*p));
233 dSP; dMARK; dORIGMARK;
234 register SV *form = *++MARK;
246 bool chopspace = (strchr(chopset, ' ') != Nullch);
253 if (!SvMAGICAL(form) || !SvCOMPILED(form)) {
254 SvREADONLY_off(form);
258 SvPV_force(formtarget, len);
259 t = SvGROW(formtarget, len + SvCUR(form) + 1); /* XXX SvCUR bad */
262 /* need to jump to the next word */
263 s = f + len + WORD_ALIGN - SvCUR(form) % WORD_ALIGN;
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;
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;
291 PerlIO_printf(PerlIO_stderr(), "%-16s%ld\n", name, (long) arg);
293 PerlIO_printf(PerlIO_stderr(), "%-16s\n", name);
322 warn("Not enough format arguments");
327 item = s = SvPV(sv, len);
329 if (itemsize > fieldsize)
330 itemsize = fieldsize;
331 send = chophere = s + itemsize;
343 item = s = SvPV(sv, len);
345 if (itemsize <= fieldsize) {
346 send = chophere = s + itemsize;
357 itemsize = fieldsize;
358 send = chophere = s + itemsize;
359 while (s < send || (s == send && isSPACE(*s))) {
369 if (strchr(chopset, *s))
374 itemsize = chophere - item;
379 arg = fieldsize - itemsize;
388 arg = fieldsize - itemsize;
402 int ch = *t++ = *s++;
406 if ( !((*t++ = *s++) & ~31) )
416 while (*s && isSPACE(*s))
423 item = s = SvPV(sv, len);
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);
444 /* If the field is marked with ^ and the value is undefined,
447 if ((arg & 512) && !SvOK(sv)) {
455 /* Formats aren't yet marked for locales, so assume "yes". */
458 sprintf(t, "%#*.*f", (int) fieldsize, (int) arg & 255, value);
460 sprintf(t, "%*.0f", (int) fieldsize, value);
467 while (t-- > linemark && *t == ' ') ;
475 if (arg) { /* repeat until fields exhausted? */
477 SvCUR_set(formtarget, t - SvPVX(formtarget));
478 lines += FmLINES(formtarget);
481 if (strnEQ(linemark, linemark - arg, arg))
482 DIE("Runaway format");
484 FmLINES(formtarget) = lines;
486 RETURNOP(cLISTOP->op_first);
497 arg = fieldsize - itemsize;
504 if (strnEQ(s," ",3)) {
505 while (s > SvPVX(formtarget) && isSPACE(s[-1]))
516 SvCUR_set(formtarget, t - SvPVX(formtarget));
517 FmLINES(formtarget) += lines;
529 if (stack_base + *markstack_ptr == sp) {
531 if (GIMME_V == G_SCALAR)
533 RETURNOP(op->op_next->op_next);
535 stack_sp = stack_base + *markstack_ptr + 1;
536 pp_pushmark(ARGS); /* push dst */
537 pp_pushmark(ARGS); /* push src */
538 ENTER; /* enter outer scope */
541 SAVESPTR(GvSV(defgv));
543 ENTER; /* enter inner scope */
546 src = stack_base[*markstack_ptr];
551 if (op->op_type == OP_MAPSTART)
552 pp_pushmark(ARGS); /* push top */
553 return ((LOGOP*)op->op_next)->op_other;
558 DIE("panic: mapstart"); /* uses grepstart */
564 I32 diff = (sp - stack_base) - *markstack_ptr;
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;
579 markstack_ptr[-1] += shift;
580 *markstack_ptr += shift;
584 dst = stack_base + (markstack_ptr[-2] += diff) - 1;
587 *dst-- = SvTEMP(TOPs) ? POPs : sv_mortalcopy(POPs);
589 LEAVE; /* exit inner scope */
592 if (markstack_ptr[-1] > *markstack_ptr) {
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 */
602 if (gimme == G_SCALAR) {
606 else if (gimme == G_ARRAY)
613 ENTER; /* enter inner scope */
616 src = stack_base[markstack_ptr[-1]];
620 RETURNOP(cLOGOP->op_other);
627 dSP; dMARK; dORIGMARK;
629 SV **myorigmark = ORIGMARK;
635 OP* nextop = op->op_next;
637 if (gimme != G_ARRAY) {
642 if (op->op_flags & OPf_STACKED) {
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;
652 cv = sv_2cv(*++MARK, &stash, &gv, 0);
653 if (!(cv && CvROOT(cv))) {
655 SV *tmpstr = sv_newmortal();
656 gv_efullname3(tmpstr, gv, Nullch);
657 if (cv && CvXSUB(cv))
658 DIE("Xsub \"%s\" called in sort", SvPVX(tmpstr));
659 DIE("Undefined sort subroutine \"%s\" called",
664 DIE("Xsub called in sort");
665 DIE("Undefined subroutine in sort");
667 DIE("Not a CODE reference in sort");
669 sortcop = CvSTART(cv);
670 SAVESPTR(CvROOT(cv)->op_ppaddr);
671 CvROOT(cv)->op_ppaddr = ppaddr[OP_NULL];
674 curpad = AvARRAY((AV*)AvARRAY(CvPADLIST(cv))[1]);
679 stash = curcop->cop_stash;
683 while (MARK < SP) { /* This may or may not shift down one here. */
685 if (*up = *++MARK) { /* Weed out nulls. */
687 if (!sortcop && !SvPOK(*up))
688 (void)sv_2pv(*up, &na);
692 max = --up - myorigmark;
698 bool oldcatch = CATCH_GET;
706 AvREAL_off(sortstack);
707 av_extend(sortstack, 32);
710 SWITCHSTACK(curstack, sortstack);
711 if (sortstash != stash) {
712 firstgv = gv_fetchpv("a", TRUE, SVt_PV);
713 secondgv = gv_fetchpv("b", TRUE, SVt_PV);
717 SAVESPTR(GvSV(firstgv));
718 SAVESPTR(GvSV(secondgv));
720 PUSHBLOCK(cx, CXt_NULL, stack_base);
721 if (!(op->op_flags & OPf_SPECIAL)) {
722 bool hasargs = FALSE;
723 cx->cx_type = CXt_SUB;
724 cx->blk_gimme = G_SCALAR;
727 SvREFCNT_inc(cv); /* in preparation for POPSUB */
729 sortcxix = cxstack_ix;
731 qsort((char*)(myorigmark+1), max, sizeof(SV*), sortcv);
734 SWITCHSTACK(sortstack, oldstack);
741 MEXTEND(SP, 20); /* Can't afford stack realloc on signal. */
742 qsort((char*)(ORIGMARK+1), max, sizeof(SV*),
743 (op->op_private & OPpLOCALE) ? sortcmp_locale : sortcmp);
746 stack_sp = ORIGMARK + max;
754 if (GIMME == G_ARRAY)
755 return cCONDOP->op_true;
756 return SvTRUEx(PAD_SV(op->op_targ)) ? cCONDOP->op_false : cCONDOP->op_true;
763 if (GIMME == G_ARRAY) {
764 RETURNOP(((CONDOP*)cUNOP->op_first)->op_false);
768 SV *targ = PAD_SV(op->op_targ);
770 if ((op->op_private & OPpFLIP_LINENUM)
771 ? last_in_gv && SvIV(sv) == IoLINES(GvIOp(last_in_gv))
773 sv_setiv(PAD_SV(cUNOP->op_first->op_targ), 1);
774 if (op->op_flags & OPf_SPECIAL) {
781 RETURNOP(((CONDOP*)cUNOP->op_first)->op_false);
794 if (GIMME == G_ARRAY) {
800 if (SvNIOKp(left) || !SvPOKp(left) ||
801 (looks_like_number(left) && *SvPVX(left) != '0') )
806 EXTEND_MORTAL(max - i + 1);
807 EXTEND(SP, max - i + 1);
810 sv = sv_2mortal(newSViv(i++));
815 SV *final = sv_mortalcopy(right);
817 char *tmps = SvPV(final, len);
819 sv = sv_mortalcopy(left);
820 while (!SvNIOKp(sv) && SvCUR(sv) <= len &&
821 strNE(SvPVX(sv),tmps) ) {
823 sv = sv_2mortal(newSVsv(sv));
826 if (strEQ(SvPVX(sv),tmps))
832 SV *targ = PAD_SV(cUNOP->op_first->op_targ);
834 if ((op->op_private & OPpFLIP_LINENUM)
835 ? last_in_gv && SvIV(sv) == IoLINES(GvIOp(last_in_gv))
837 sv_setiv(PAD_SV(((UNOP*)cUNOP->op_first)->op_first->op_targ), 0);
838 sv_catpv(targ, "E0");
854 register CONTEXT *cx;
856 for (i = cxstack_ix; i >= 0; i--) {
858 switch (cx->cx_type) {
861 warn("Exiting substitution via %s", op_name[op->op_type]);
865 warn("Exiting subroutine via %s", op_name[op->op_type]);
869 warn("Exiting eval via %s", op_name[op->op_type]);
873 warn("Exiting pseudo-block via %s", op_name[op->op_type]);
876 if (!cx->blk_loop.label ||
877 strNE(label, cx->blk_loop.label) ) {
878 DEBUG_l(deb("(Skipping label #%ld %s)\n",
879 (long)i, cx->blk_loop.label));
882 DEBUG_l( deb("(Found label #%ld %s)\n", (long)i, label));
892 I32 gimme = block_gimme();
893 return (gimme == G_VOID) ? G_SCALAR : gimme;
902 cxix = dopoptosub(cxstack_ix);
906 switch (cxstack[cxix].blk_gimme) {
914 croak("panic: bad gimme: %d\n", cxstack[cxix].blk_gimme);
919 dopoptosub(startingblock)
924 register CONTEXT *cx;
925 for (i = startingblock; i >= 0; i--) {
927 switch (cx->cx_type) {
932 DEBUG_l( deb("(Found sub #%ld)\n", (long)i));
940 dopoptoeval(startingblock)
945 register CONTEXT *cx;
946 for (i = startingblock; i >= 0; i--) {
948 switch (cx->cx_type) {
952 DEBUG_l( deb("(Found eval #%ld)\n", (long)i));
960 dopoptoloop(startingblock)
965 register CONTEXT *cx;
966 for (i = startingblock; i >= 0; i--) {
968 switch (cx->cx_type) {
971 warn("Exiting substitution via %s", op_name[op->op_type]);
975 warn("Exiting subroutine via %s", op_name[op->op_type]);
979 warn("Exiting eval via %s", op_name[op->op_type]);
983 warn("Exiting pseudo-block via %s", op_name[op->op_type]);
986 DEBUG_l( deb("(Found loop #%ld)\n", (long)i));
998 register CONTEXT *cx;
1002 while (cxstack_ix > cxix) {
1003 cx = &cxstack[cxstack_ix];
1004 DEBUG_l(PerlIO_printf(Perl_debug_log, "Unwinding block %ld, type %s\n",
1005 (long) cxstack_ix+1, block_type[cx->cx_type]));
1006 /* Note: we don't need to restore the base context info till the end. */
1007 switch (cx->cx_type) {
1010 continue; /* not break */
1034 register CONTEXT *cx;
1040 STRLEN klen = strlen(message);
1042 svp = hv_fetch(GvHV(errgv), message, klen, TRUE);
1045 static char prefix[] = "\t(in cleanup) ";
1046 sv_upgrade(*svp, SVt_IV);
1047 (void)SvIOK_only(*svp);
1048 SvGROW(GvSV(errgv), SvCUR(GvSV(errgv))+sizeof(prefix)+klen);
1049 sv_catpvn(GvSV(errgv), prefix, sizeof(prefix)-1);
1050 sv_catpvn(GvSV(errgv), message, klen);
1056 sv_setpv(GvSV(errgv), message);
1058 cxix = dopoptoeval(cxstack_ix);
1062 if (cxix < cxstack_ix)
1066 if (cx->cx_type != CXt_EVAL) {
1067 PerlIO_printf(PerlIO_stderr(), "panic: die %s", message);
1072 if (gimme == G_SCALAR)
1073 *++newsp = &sv_undef;
1078 if (optype == OP_REQUIRE) {
1079 char* msg = SvPVx(GvSV(errgv), na);
1080 DIE("%s", *msg ? msg : "Compilation failed in require");
1082 return pop_return();
1085 PerlIO_printf(PerlIO_stderr(), "%s",message);
1086 PerlIO_flush(PerlIO_stderr());
1095 if (SvTRUE(left) != SvTRUE(right))
1107 RETURNOP(cLOGOP->op_other);
1116 RETURNOP(cLOGOP->op_other);
1123 SV** mark = (stack_base + *markstack_ptr + 1);
1125 while (mark < sp) { /* emulate old interface */
1130 return pp_entersub(ARGS);
1137 register I32 cxix = dopoptosub(cxstack_ix);
1138 register CONTEXT *cx;
1149 if (GIMME != G_ARRAY)
1153 if (DBsub && cxix >= 0 &&
1154 cxstack[cxix].blk_sub.cv == GvCV(DBsub))
1158 cxix = dopoptosub(cxix - 1);
1160 cx = &cxstack[cxix];
1161 if (cxstack[cxix].cx_type == CXt_SUB) {
1162 dbcxix = dopoptosub(cxix - 1);
1163 /* We expect that cxstack[dbcxix] is CXt_SUB, anyway, the
1164 field below is defined for any cx. */
1165 if (DBsub && dbcxix >= 0 && cxstack[dbcxix].blk_sub.cv == GvCV(DBsub))
1166 cx = &cxstack[dbcxix];
1169 if (GIMME != G_ARRAY) {
1172 sv_setpv(TARG, HvNAME(cx->blk_oldcop->cop_stash));
1177 PUSHs(sv_2mortal(newSVpv(HvNAME(cx->blk_oldcop->cop_stash), 0)));
1178 PUSHs(sv_2mortal(newSVpv(SvPVX(GvSV(cx->blk_oldcop->cop_filegv)), 0)));
1179 PUSHs(sv_2mortal(newSViv((I32)cx->blk_oldcop->cop_line)));
1182 if (cx->cx_type == CXt_SUB) { /* So is cxstack[dbcxix]. */
1184 gv_efullname3(sv, CvGV(cxstack[cxix].blk_sub.cv), Nullch);
1185 PUSHs(sv_2mortal(sv));
1186 PUSHs(sv_2mortal(newSViv((I32)cx->blk_sub.hasargs)));
1189 PUSHs(sv_2mortal(newSVpv("(eval)",0)));
1190 PUSHs(sv_2mortal(newSViv(0)));
1192 gimme = (I32)cx->blk_gimme;
1193 if (gimme == G_VOID)
1196 PUSHs(sv_2mortal(newSViv(gimme & G_ARRAY)));
1197 if (cx->cx_type == CXt_EVAL) {
1198 if (cx->blk_eval.old_op_type == OP_ENTEREVAL) {
1199 PUSHs(cx->blk_eval.cur_text);
1202 else if (cx->blk_eval.old_name) { /* Try blocks have old_name == 0. */
1203 /* Require, put the name. */
1204 PUSHs(sv_2mortal(newSVpv(cx->blk_eval.old_name, 0)));
1208 else if (cx->cx_type == CXt_SUB &&
1209 cx->blk_sub.hasargs &&
1210 curcop->cop_stash == debstash)
1212 AV *ary = cx->blk_sub.argarray;
1213 int off = AvARRAY(ary) - AvALLOC(ary);
1217 dbargs = GvAV(gv_AVadd(tmpgv = gv_fetchpv("DB::args", TRUE,
1220 AvREAL_off(dbargs); /* XXX Should be REIFY */
1223 if (AvMAX(dbargs) < AvFILL(ary) + off)
1224 av_extend(dbargs, AvFILL(ary) + off);
1225 Copy(AvALLOC(ary), AvARRAY(dbargs), AvFILL(ary) + 1 + off, SV*);
1226 AvFILL(dbargs) = AvFILL(ary) + off;
1237 SV * const *str1 = (SV * const *)a;
1238 SV * const *str2 = (SV * const *)b;
1239 I32 oldsaveix = savestack_ix;
1240 I32 oldscopeix = scopestack_ix;
1242 GvSV(firstgv) = *str1;
1243 GvSV(secondgv) = *str2;
1244 stack_sp = stack_base;
1247 if (stack_sp != stack_base + 1)
1248 croak("Sort subroutine didn't return single value");
1249 if (!SvNIOKp(*stack_sp))
1250 croak("Sort subroutine didn't return a numeric value");
1251 result = SvIV(*stack_sp);
1252 while (scopestack_ix > oldscopeix) {
1255 leave_scope(oldsaveix);
1264 return sv_cmp(*(SV * const *)a, *(SV * const *)b);
1268 sortcmp_locale(a, b)
1272 return sv_cmp_locale(*(SV * const *)a, *(SV * const *)b);
1277 unlock_condpair(svv)
1281 MAGIC *mg = mg_find((SV*)svv, 'm');
1284 croak("panic: unlock_condpair unlocking non-mutex");
1285 MUTEX_LOCK(MgMUTEXP(mg));
1286 if (MgOWNER(mg) != thr)
1287 croak("panic: unlock_condpair unlocking mutex that we don't own");
1289 COND_SIGNAL(MgOWNERCONDP(mg));
1290 MUTEX_UNLOCK(MgMUTEXP(mg));
1292 #endif /* USE_THREADS */
1302 croak("reset requires mutex argument with USE_THREADS");
1305 * Kludge to allow lock of real objects without requiring
1306 * to pass in every type of argument by explicit reference.
1310 mg = condpair_magic(sv);
1311 MUTEX_LOCK(MgMUTEXP(mg));
1312 if (MgOWNER(mg) == thr)
1313 MUTEX_UNLOCK(MgMUTEXP(mg));
1316 COND_WAIT(MgOWNERCONDP(mg), MgMUTEXP(mg));
1318 MUTEX_UNLOCK(MgMUTEXP(mg));
1319 save_destructor(unlock_condpair, sv);
1329 sv_reset(tmps, curcop->cop_stash);
1332 #endif /* USE_THREADS */
1343 TAINT_NOT; /* Each statement is presumed innocent */
1344 stack_sp = stack_base + cxstack[cxstack_ix].blk_oldsp;
1347 if (op->op_private || SvIV(DBsingle) || SvIV(DBsignal) || SvIV(DBtrace))
1351 register CONTEXT *cx;
1352 I32 gimme = G_ARRAY;
1359 DIE("No DB::DB routine defined");
1361 if (CvDEPTH(cv) >= 1 && !(debug & (1<<30))) /* don't do recursive DB::DB call */
1373 push_return(op->op_next);
1374 PUSHBLOCK(cx, CXt_SUB, sp);
1377 (void)SvREFCNT_inc(cv);
1379 curpad = AvARRAY((AV*)*av_fetch(CvPADLIST(cv),1,FALSE));
1380 RETURNOP(CvSTART(cv));
1394 register CONTEXT *cx;
1395 I32 gimme = GIMME_V;
1402 svp = &curpad[op->op_targ]; /* "my" variable */
1404 svp = &GvSV((GV*)POPs); /* symbol table variable */
1410 PUSHBLOCK(cx, CXt_LOOP, SP);
1411 PUSHLOOP(cx, svp, MARK);
1412 if (op->op_flags & OPf_STACKED)
1413 cx->blk_loop.iterary = (AV*)SvREFCNT_inc(POPs);
1415 cx->blk_loop.iterary = curstack;
1416 AvFILL(curstack) = sp - stack_base;
1417 cx->blk_loop.iterix = MARK - stack_base;
1426 register CONTEXT *cx;
1427 I32 gimme = GIMME_V;
1433 PUSHBLOCK(cx, CXt_LOOP, SP);
1434 PUSHLOOP(cx, 0, SP);
1442 register CONTEXT *cx;
1443 struct block_loop cxloop;
1451 POPLOOP1(cx); /* Delay POPLOOP2 until stack values are safe */
1454 if (gimme == G_VOID)
1456 else if (gimme == G_SCALAR) {
1458 *++newsp = sv_mortalcopy(*SP);
1460 *++newsp = &sv_undef;
1464 *++newsp = sv_mortalcopy(*++mark);
1465 TAINT_NOT; /* Each item is independent */
1471 POPLOOP2(); /* Stack values are safe: release loop vars ... */
1472 curpm = newpm; /* ... and pop $1 et al */
1484 register CONTEXT *cx;
1485 struct block_sub cxsub;
1486 bool popsub2 = FALSE;
1492 if (curstack == sortstack) {
1493 if (cxstack_ix == sortcxix || dopoptosub(cxstack_ix) <= sortcxix) {
1494 if (cxstack_ix > sortcxix)
1496 AvARRAY(curstack)[1] = *SP;
1497 stack_sp = stack_base + 1;
1502 cxix = dopoptosub(cxstack_ix);
1504 DIE("Can't return outside a subroutine");
1505 if (cxix < cxstack_ix)
1509 switch (cx->cx_type) {
1511 POPSUB1(cx); /* Delay POPSUB2 until stack values are safe */
1516 if (optype == OP_REQUIRE &&
1517 (MARK == SP || (gimme == G_SCALAR && !SvTRUE(*SP))) )
1519 /* Unassume the success we assumed earlier. */
1520 char *name = cx->blk_eval.old_name;
1521 (void)hv_delete(GvHVn(incgv), name, strlen(name), G_DISCARD);
1522 DIE("%s did not return a true value", name);
1526 DIE("panic: return");
1530 if (gimme == G_SCALAR) {
1532 *++newsp = (popsub2 && SvTEMP(*SP))
1533 ? *SP : sv_mortalcopy(*SP);
1535 *++newsp = &sv_undef;
1537 else if (gimme == G_ARRAY) {
1538 while (++MARK <= SP) {
1539 *++newsp = (popsub2 && SvTEMP(*MARK))
1540 ? *MARK : sv_mortalcopy(*MARK);
1541 TAINT_NOT; /* Each item is independent */
1546 /* Stack values are safe: */
1548 POPSUB2(); /* release CV and @_ ... */
1550 curpm = newpm; /* ... and pop $1 et al */
1553 return pop_return();
1560 register CONTEXT *cx;
1561 struct block_loop cxloop;
1562 struct block_sub cxsub;
1569 SV **mark = stack_base + cxstack[cxstack_ix].blk_oldsp;
1571 if (op->op_flags & OPf_SPECIAL) {
1572 cxix = dopoptoloop(cxstack_ix);
1574 DIE("Can't \"last\" outside a block");
1577 cxix = dopoptolabel(cPVOP->op_pv);
1579 DIE("Label not found for \"last %s\"", cPVOP->op_pv);
1581 if (cxix < cxstack_ix)
1585 switch (cx->cx_type) {
1587 POPLOOP1(cx); /* Delay POPLOOP2 until stack values are safe */
1589 nextop = cxloop.last_op->op_next;
1592 POPSUB1(cx); /* Delay POPSUB2 until stack values are safe */
1594 nextop = pop_return();
1598 nextop = pop_return();
1605 if (gimme == G_SCALAR) {
1607 *++newsp = ((pop2 == CXt_SUB) && SvTEMP(*SP))
1608 ? *SP : sv_mortalcopy(*SP);
1610 *++newsp = &sv_undef;
1612 else if (gimme == G_ARRAY) {
1613 while (++MARK <= SP) {
1614 *++newsp = ((pop2 == CXt_SUB) && SvTEMP(*MARK))
1615 ? *MARK : sv_mortalcopy(*MARK);
1616 TAINT_NOT; /* Each item is independent */
1622 /* Stack values are safe: */
1625 POPLOOP2(); /* release loop vars ... */
1629 POPSUB2(); /* release CV and @_ ... */
1632 curpm = newpm; /* ... and pop $1 et al */
1641 register CONTEXT *cx;
1644 if (op->op_flags & OPf_SPECIAL) {
1645 cxix = dopoptoloop(cxstack_ix);
1647 DIE("Can't \"next\" outside a block");
1650 cxix = dopoptolabel(cPVOP->op_pv);
1652 DIE("Label not found for \"next %s\"", cPVOP->op_pv);
1654 if (cxix < cxstack_ix)
1658 oldsave = scopestack[scopestack_ix - 1];
1659 LEAVE_SCOPE(oldsave);
1660 return cx->blk_loop.next_op;
1666 register CONTEXT *cx;
1669 if (op->op_flags & OPf_SPECIAL) {
1670 cxix = dopoptoloop(cxstack_ix);
1672 DIE("Can't \"redo\" outside a block");
1675 cxix = dopoptolabel(cPVOP->op_pv);
1677 DIE("Label not found for \"redo %s\"", cPVOP->op_pv);
1679 if (cxix < cxstack_ix)
1683 oldsave = scopestack[scopestack_ix - 1];
1684 LEAVE_SCOPE(oldsave);
1685 return cx->blk_loop.redo_op;
1688 static OP* lastgotoprobe;
1691 dofindlabel(o,label,opstack,oplimit)
1699 static char too_deep[] = "Target of goto is too deeply nested";
1703 if (o->op_type == OP_LEAVE ||
1704 o->op_type == OP_SCOPE ||
1705 o->op_type == OP_LEAVELOOP ||
1706 o->op_type == OP_LEAVETRY)
1708 *ops++ = cUNOPo->op_first;
1713 if (o->op_flags & OPf_KIDS) {
1714 /* First try all the kids at this level, since that's likeliest. */
1715 for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) {
1716 if ((kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) &&
1717 kCOP->cop_label && strEQ(kCOP->cop_label, label))
1720 for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) {
1721 if (kid == lastgotoprobe)
1723 if ((kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) &&
1725 (ops[-1]->op_type != OP_NEXTSTATE &&
1726 ops[-1]->op_type != OP_DBSTATE)))
1728 if (o = dofindlabel(kid, label, ops, oplimit))
1738 return pp_goto(ARGS);
1747 register CONTEXT *cx;
1748 #define GOTO_DEPTH 64
1749 OP *enterops[GOTO_DEPTH];
1751 int do_dump = (op->op_type == OP_DUMP);
1754 if (op->op_flags & OPf_STACKED) {
1757 /* This egregious kludge implements goto &subroutine */
1758 if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVCV) {
1760 register CONTEXT *cx;
1761 CV* cv = (CV*)SvRV(sv);
1766 if (!CvROOT(cv) && !CvXSUB(cv)) {
1768 SV *tmpstr = sv_newmortal();
1769 gv_efullname3(tmpstr, CvGV(cv), Nullch);
1770 DIE("Goto undefined subroutine &%s",SvPVX(tmpstr));
1772 DIE("Goto undefined subroutine");
1775 /* First do some returnish stuff. */
1776 cxix = dopoptosub(cxstack_ix);
1778 DIE("Can't goto subroutine outside a subroutine");
1779 if (cxix < cxstack_ix)
1783 if (cx->blk_sub.hasargs) { /* put @_ back onto stack */
1784 AV* av = cx->blk_sub.argarray;
1786 items = AvFILL(av) + 1;
1788 EXTEND(stack_sp, items); /* @_ could have been extended. */
1789 Copy(AvARRAY(av), stack_sp, items, SV*);
1791 SvREFCNT_dec(GvAV(defgv));
1792 GvAV(defgv) = cx->blk_sub.savearray;
1796 if (!(CvDEPTH(cx->blk_sub.cv) = cx->blk_sub.olddepth))
1797 SvREFCNT_dec(cx->blk_sub.cv);
1798 oldsave = scopestack[scopestack_ix - 1];
1799 LEAVE_SCOPE(oldsave);
1801 /* Now do some callish stuff. */
1804 if (CvOLDSTYLE(cv)) {
1805 I32 (*fp3)_((int,int,int));
1810 fp3 = (I32(*)_((int,int,int)))CvXSUB(cv);
1811 items = (*fp3)(CvXSUBANY(cv).any_i32,
1812 mark - stack_base + 1,
1814 sp = stack_base + items;
1817 stack_sp--; /* There is no cv arg. */
1818 (void)(*CvXSUB(cv))(cv);
1821 return pop_return();
1824 AV* padlist = CvPADLIST(cv);
1825 SV** svp = AvARRAY(padlist);
1826 cx->blk_sub.cv = cv;
1827 cx->blk_sub.olddepth = CvDEPTH(cv);
1829 if (CvDEPTH(cv) < 2)
1830 (void)SvREFCNT_inc(cv);
1831 else { /* save temporaries on recursion? */
1832 if (CvDEPTH(cv) == 100 && dowarn)
1833 sub_crush_depth(cv);
1834 if (CvDEPTH(cv) > AvFILL(padlist)) {
1835 AV *newpad = newAV();
1836 SV **oldpad = AvARRAY(svp[CvDEPTH(cv)-1]);
1837 I32 ix = AvFILL((AV*)svp[1]);
1838 svp = AvARRAY(svp[0]);
1839 for ( ;ix > 0; ix--) {
1840 if (svp[ix] != &sv_undef) {
1841 char *name = SvPVX(svp[ix]);
1842 if ((SvFLAGS(svp[ix]) & SVf_FAKE)
1845 /* outer lexical or anon code */
1846 av_store(newpad, ix,
1847 SvREFCNT_inc(oldpad[ix]) );
1849 else { /* our own lexical */
1851 av_store(newpad, ix, sv = (SV*)newAV());
1852 else if (*name == '%')
1853 av_store(newpad, ix, sv = (SV*)newHV());
1855 av_store(newpad, ix, sv = NEWSV(0,0));
1860 av_store(newpad, ix, sv = NEWSV(0,0));
1864 if (cx->blk_sub.hasargs) {
1867 av_store(newpad, 0, (SV*)av);
1868 AvFLAGS(av) = AVf_REIFY;
1870 av_store(padlist, CvDEPTH(cv), (SV*)newpad);
1871 AvFILL(padlist) = CvDEPTH(cv);
1872 svp = AvARRAY(padlist);
1876 curpad = AvARRAY((AV*)svp[CvDEPTH(cv)]);
1877 if (cx->blk_sub.hasargs) {
1878 AV* av = (AV*)curpad[0];
1881 cx->blk_sub.savearray = GvAV(defgv);
1882 cx->blk_sub.argarray = av;
1883 GvAV(defgv) = (AV*)SvREFCNT_inc(av);
1886 if (items >= AvMAX(av) + 1) {
1888 if (AvARRAY(av) != ary) {
1889 AvMAX(av) += AvARRAY(av) - AvALLOC(av);
1890 SvPVX(av) = (char*)ary;
1892 if (items >= AvMAX(av) + 1) {
1893 AvMAX(av) = items - 1;
1894 Renew(ary,items+1,SV*);
1896 SvPVX(av) = (char*)ary;
1899 Copy(mark,AvARRAY(av),items,SV*);
1900 AvFILL(av) = items - 1;
1908 if (perldb && curstash != debstash) {
1910 * We do not care about using sv to call CV;
1911 * it's for informational purposes only.
1913 SV *sv = GvSV(DBsub);
1915 gv_efullname3(sv, CvGV(cv), Nullch);
1917 RETURNOP(CvSTART(cv));
1921 label = SvPV(sv,na);
1923 else if (op->op_flags & OPf_SPECIAL) {
1925 DIE("goto must have label");
1928 label = cPVOP->op_pv;
1930 if (label && *label) {
1937 for (ix = cxstack_ix; ix >= 0; ix--) {
1939 switch (cx->cx_type) {
1941 gotoprobe = eval_root; /* XXX not good for nested eval */
1944 gotoprobe = cx->blk_oldcop->op_sibling;
1950 gotoprobe = cx->blk_oldcop->op_sibling;
1952 gotoprobe = main_root;
1955 if (CvDEPTH(cx->blk_sub.cv)) {
1956 gotoprobe = CvROOT(cx->blk_sub.cv);
1961 DIE("Can't \"goto\" outside a block");
1965 gotoprobe = main_root;
1968 retop = dofindlabel(gotoprobe, label,
1969 enterops, enterops + GOTO_DEPTH);
1972 lastgotoprobe = gotoprobe;
1975 DIE("Can't find label %s", label);
1977 /* pop unwanted frames */
1979 if (ix < cxstack_ix) {
1986 oldsave = scopestack[scopestack_ix];
1987 LEAVE_SCOPE(oldsave);
1990 /* push wanted frames */
1992 if (*enterops && enterops[1]) {
1994 for (ix = 1; enterops[ix]; ix++) {
1996 (*op->op_ppaddr)(ARGS);
2004 if (!retop) retop = main_start;
2011 restartop = 0; /* hmm, must be GNU unexec().. */
2015 if (curstack == signalstack) {
2033 if (anum == 1 && VMSISH_EXIT)
2046 double value = SvNVx(GvSV(cCOP->cop_gv));
2047 register I32 match = I_32(value);
2050 if (((double)match) > value)
2051 --match; /* was fractional--truncate other way */
2053 match -= cCOP->uop.scop.scop_offset;
2056 else if (match > cCOP->uop.scop.scop_max)
2057 match = cCOP->uop.scop.scop_max;
2058 op = cCOP->uop.scop.scop_next[match];
2068 op = op->op_next; /* can't assume anything */
2070 match = *(SvPVx(GvSV(cCOP->cop_gv), na)) & 255;
2071 match -= cCOP->uop.scop.scop_offset;
2074 else if (match > cCOP->uop.scop.scop_max)
2075 match = cCOP->uop.scop.scop_max;
2076 op = cCOP->uop.scop.scop_next[match];
2085 save_lines(array, sv)
2089 register char *s = SvPVX(sv);
2090 register char *send = SvPVX(sv) + SvCUR(sv);
2092 register I32 line = 1;
2094 while (s && s < send) {
2095 SV *tmpstr = NEWSV(85,0);
2097 sv_upgrade(tmpstr, SVt_PVMG);
2098 t = strchr(s, '\n');
2104 sv_setpvn(tmpstr, s, t - s);
2105 av_store(array, line++, tmpstr);
2115 I32 oldrunlevel = runlevel;
2121 assert(CATCH_GET == TRUE);
2122 DEBUG_l(deb("(Setting up local jumplevel, runlevel = %ld)\n", (long)runlevel+1));
2126 default: /* topmost level handles it */
2128 runlevel = oldrunlevel;
2134 PerlIO_printf(PerlIO_stderr(), "panic: restartop\n");
2145 runlevel = oldrunlevel;
2162 MUTEX_LOCK(&eval_mutex);
2163 if (eval_owner && eval_owner != thr)
2165 COND_WAIT(&eval_cond, &eval_mutex);
2167 MUTEX_UNLOCK(&eval_mutex);
2168 #endif /* USE_THREADS */
2173 /* set up a scratch pad */
2178 SAVESPTR(comppad_name);
2179 SAVEI32(comppad_name_fill);
2180 SAVEI32(min_intro_pending);
2181 SAVEI32(max_intro_pending);
2185 compcv = (CV*)NEWSV(1104,0);
2186 sv_upgrade((SV *)compcv, SVt_PVCV);
2187 CvUNIQUE_on(compcv);
2189 CvOWNER(compcv) = 0;
2190 New(666, CvMUTEXP(compcv), 1, pthread_mutex_t);
2191 MUTEX_INIT(CvMUTEXP(compcv));
2192 New(666, CvCONDP(compcv), 1, pthread_cond_t);
2193 COND_INIT(CvCONDP(compcv));
2194 #endif /* USE_THREADS */
2197 comppad_name = newAV();
2198 comppad_name_fill = 0;
2200 av_store(comppad_name, 0, newSVpv("@_", 2));
2201 #endif /* USE_THREADS */
2202 min_intro_pending = 0;
2203 av_push(comppad, Nullsv);
2204 curpad = AvARRAY(comppad);
2207 comppadlist = newAV();
2208 AvREAL_off(comppadlist);
2209 av_store(comppadlist, 0, (SV*)comppad_name);
2210 av_store(comppadlist, 1, (SV*)comppad);
2211 CvPADLIST(compcv) = comppadlist;
2213 if (saveop->op_type != OP_REQUIRE)
2214 CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc(caller);
2218 /* make sure we compile in the right package */
2220 newstash = curcop->cop_stash;
2221 if (curstash != newstash) {
2223 curstash = newstash;
2227 SAVEFREESV(beginav);
2229 /* try to compile it */
2233 curcop = &compiling;
2234 curcop->cop_arybase = 0;
2236 rs = newSVpv("\n", 1);
2237 if (saveop->op_flags & OPf_SPECIAL)
2240 sv_setpv(GvSV(errgv),"");
2241 if (yyparse() || error_count || !eval_root) {
2252 SP = stack_base + POPMARK; /* pop original mark */
2258 if (optype == OP_REQUIRE) {
2259 char* msg = SvPVx(GvSV(errgv), na);
2260 DIE("%s", *msg ? msg : "Compilation failed in require");
2263 rs = SvREFCNT_inc(nrs);
2267 rs = SvREFCNT_inc(nrs);
2268 compiling.cop_line = 0;
2269 SAVEFREEOP(eval_root);
2271 scalarvoid(eval_root);
2272 else if (gimme & G_ARRAY)
2277 DEBUG_x(dump_eval());
2279 /* Register with debugger: */
2280 if (perldb && saveop->op_type == OP_REQUIRE) {
2281 CV *cv = perl_get_cv("DB::postponed", FALSE);
2285 XPUSHs((SV*)compiling.cop_filegv);
2287 perl_call_sv((SV*)cv, G_DISCARD);
2291 /* compiled okay, so do it */
2293 CvDEPTH(compcv) = 1;
2294 SP = stack_base + POPMARK; /* pop original mark */
2296 MUTEX_LOCK(&eval_mutex);
2298 COND_SIGNAL(&eval_cond);
2299 MUTEX_UNLOCK(&eval_mutex);
2300 #endif /* USE_THREADS */
2302 RETURNOP(eval_start);
2308 register CONTEXT *cx;
2312 SV *namesv = Nullsv;
2314 I32 gimme = G_SCALAR;
2315 PerlIO *tryrsfp = 0;
2318 if (SvNIOKp(sv) && !SvPOKp(sv)) {
2319 SET_NUMERIC_STANDARD();
2320 if (atof(patchlevel) + 0.00000999 < SvNV(sv))
2321 DIE("Perl %s required--this is only version %s, stopped",
2322 SvPV(sv,na),patchlevel);
2325 name = SvPV(sv, na);
2327 DIE("Null filename used");
2328 TAINT_PROPER("require");
2329 if (op->op_type == OP_REQUIRE &&
2330 (svp = hv_fetch(GvHVn(incgv), name, SvCUR(sv), 0)) &&
2334 /* prepare to compile file */
2339 (name[1] == '.' && name[2] == '/')))
2341 || (name[0] && name[1] == ':')
2344 || (strchr(name,':') || ((*name == '[' || *name == '<') &&
2345 (isALNUM(name[1]) || strchr("$-_]>",name[1]))))
2350 tryrsfp = PerlIO_open(name,"r");
2353 AV *ar = GvAVn(incgv);
2357 if ((unixname = tounixspec(name, Nullch)) != Nullch)
2360 namesv = NEWSV(806, 0);
2361 for (i = 0; i <= AvFILL(ar); i++) {
2362 char *dir = SvPVx(*av_fetch(ar, i, TRUE), na);
2365 if ((unixdir = tounixpath(dir, Nullch)) == Nullch)
2367 sv_setpv(namesv, unixdir);
2368 sv_catpv(namesv, unixname);
2370 sv_setpvf(namesv, "%s/%s", dir, name);
2372 tryname = SvPVX(namesv);
2373 tryrsfp = PerlIO_open(tryname, "r");
2375 if (tryname[0] == '.' && tryname[1] == '/')
2382 SAVESPTR(compiling.cop_filegv);
2383 compiling.cop_filegv = gv_fetchfile(tryrsfp ? tryname : name);
2384 SvREFCNT_dec(namesv);
2386 if (op->op_type == OP_REQUIRE) {
2387 SV *msg = sv_2mortal(newSVpvf("Can't locate %s in @INC", name));
2388 if (instr(SvPVX(msg), ".h "))
2389 sv_catpv(msg, " (change .h to .ph maybe?)");
2390 if (instr(SvPVX(msg), ".ph "))
2391 sv_catpv(msg, " (did you run h2ph?)");
2398 /* Assume success here to prevent recursive requirement. */
2399 (void)hv_store(GvHVn(incgv), name, strlen(name),
2400 newSVsv(GvSV(compiling.cop_filegv)), 0 );
2404 lex_start(sv_2mortal(newSVpv("",0)));
2406 save_aptr(&rsfp_filters);
2407 rsfp_filters = NULL;
2411 name = savepv(name);
2416 /* switch to eval mode */
2418 push_return(op->op_next);
2419 PUSHBLOCK(cx, CXt_EVAL, SP);
2420 PUSHEVAL(cx, name, compiling.cop_filegv);
2422 compiling.cop_line = 0;
2425 return DOCATCH(doeval(G_SCALAR));
2430 return pp_require(ARGS);
2436 register CONTEXT *cx;
2438 I32 gimme = GIMME_V, was = sub_generation;
2439 char tmpbuf[TYPE_DIGITS(long) + 12];
2444 if (!SvPV(sv,len) || !len)
2446 TAINT_PROPER("eval");
2452 /* switch to eval mode */
2454 SAVESPTR(compiling.cop_filegv);
2455 sprintf(tmpbuf, "_<(eval %lu)", (unsigned long)++evalseq);
2456 compiling.cop_filegv = gv_fetchfile(tmpbuf+2);
2457 compiling.cop_line = 1;
2458 /* XXX For C<eval "...">s within BEGIN {} blocks, this ends up
2459 deleting the eval's FILEGV from the stash before gv_check() runs
2460 (i.e. before run-time proper). To work around the coredump that
2461 ensues, we always turn GvMULTI_on for any globals that were
2462 introduced within evals. See force_ident(). GSAR 96-10-12 */
2463 safestr = savepv(tmpbuf);
2464 SAVEDELETE(defstash, safestr, strlen(safestr));
2466 hints = op->op_targ;
2468 push_return(op->op_next);
2469 PUSHBLOCK(cx, CXt_EVAL, SP);
2470 PUSHEVAL(cx, 0, compiling.cop_filegv);
2472 /* prepare to compile string */
2474 if (perldb && curstash != debstash)
2475 save_lines(GvAV(compiling.cop_filegv), linestr);
2477 ret = doeval(gimme);
2478 if (perldb && was != sub_generation) { /* Some subs defined here. */
2479 strcpy(safestr, "_<(eval )"); /* Anything fake and short. */
2481 return DOCATCH(ret);
2491 register CONTEXT *cx;
2493 U8 save_flags = op -> op_flags;
2498 retop = pop_return();
2501 if (gimme == G_VOID)
2503 else if (gimme == G_SCALAR) {
2506 if (SvFLAGS(TOPs) & SVs_TEMP)
2509 *MARK = sv_mortalcopy(TOPs);
2517 /* in case LEAVE wipes old return values */
2518 for (mark = newsp + 1; mark <= SP; mark++) {
2519 if (!(SvFLAGS(*mark) & SVs_TEMP)) {
2520 *mark = sv_mortalcopy(*mark);
2521 TAINT_NOT; /* Each item is independent */
2525 curpm = newpm; /* Don't pop $1 et al till now */
2528 assert(CvDEPTH(compcv) == 1);
2530 CvDEPTH(compcv) = 0;
2532 if (optype == OP_REQUIRE &&
2533 !(gimme == G_SCALAR ? SvTRUE(*sp) : sp > newsp))
2535 /* Unassume the success we assumed earlier. */
2536 char *name = cx->blk_eval.old_name;
2537 (void)hv_delete(GvHVn(incgv), name, strlen(name), G_DISCARD);
2538 retop = die("%s did not return a true value", name);
2544 if (!(save_flags & OPf_SPECIAL))
2545 sv_setpv(GvSV(errgv),"");
2553 register CONTEXT *cx;
2554 I32 gimme = GIMME_V;
2559 push_return(cLOGOP->op_other->op_next);
2560 PUSHBLOCK(cx, CXt_EVAL, SP);
2562 eval_root = op; /* Only needed so that goto works right. */
2565 sv_setpv(GvSV(errgv),"");
2567 return DOCATCH(op->op_next);
2577 register CONTEXT *cx;
2585 if (gimme == G_VOID)
2587 else if (gimme == G_SCALAR) {
2590 if (SvFLAGS(TOPs) & (SVs_PADTMP|SVs_TEMP))
2593 *MARK = sv_mortalcopy(TOPs);
2602 /* in case LEAVE wipes old return values */
2603 for (mark = newsp + 1; mark <= SP; mark++) {
2604 if (!(SvFLAGS(*mark) & (SVs_PADTMP|SVs_TEMP))) {
2605 *mark = sv_mortalcopy(*mark);
2606 TAINT_NOT; /* Each item is independent */
2610 curpm = newpm; /* Don't pop $1 et al till now */
2613 sv_setpv(GvSV(errgv),"");
2622 register char *s = SvPV_force(sv, len);
2623 register char *send = s + len;
2624 register char *base;
2625 register I32 skipspaces = 0;
2628 bool postspace = FALSE;
2636 croak("Null picture in formline");
2638 New(804, fops, (send - s)*3+10, U16); /* Almost certainly too long... */
2643 *fpc++ = FF_LINEMARK;
2644 noblank = repeat = FALSE;
2662 case ' ': case '\t':
2673 *fpc++ = FF_LITERAL;
2681 *fpc++ = skipspaces;
2685 *fpc++ = FF_NEWLINE;
2689 arg = fpc - linepc + 1;
2696 *fpc++ = FF_LINEMARK;
2697 noblank = repeat = FALSE;
2706 ischop = s[-1] == '^';
2712 arg = (s - base) - 1;
2714 *fpc++ = FF_LITERAL;
2723 *fpc++ = FF_LINEGLOB;
2725 else if (*s == '#' || (*s == '.' && s[1] == '#')) {
2726 arg = ischop ? 512 : 0;
2736 arg |= 256 + (s - f);
2738 *fpc++ = s - base; /* fieldsize for FETCH */
2739 *fpc++ = FF_DECIMAL;
2744 bool ismore = FALSE;
2747 while (*++s == '>') ;
2748 prespace = FF_SPACE;
2750 else if (*s == '|') {
2751 while (*++s == '|') ;
2752 prespace = FF_HALFSPACE;
2757 while (*++s == '<') ;
2760 if (*s == '.' && s[1] == '.' && s[2] == '.') {
2764 *fpc++ = s - base; /* fieldsize for FETCH */
2766 *fpc++ = ischop ? FF_CHECKCHOP : FF_CHECKNL;
2784 { /* need to jump to the next word */
2786 z = WORD_ALIGN - SvCUR(sv) % WORD_ALIGN;
2787 SvGROW(sv, SvCUR(sv) + z + arg * sizeof(U16) + 4);
2788 s = SvPVX(sv) + SvCUR(sv) + z;
2790 Copy(fops, s, arg, U16);
2792 sv_magic(sv, Nullsv, 'f', Nullch, 0);