3 * Copyright (c) 1991-2000, 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 * Then he heard Merry change the note, and up went the Horn-cry of Buckland,
14 * Awake! Awake! Fear, Fire, Foes! Awake!
19 #define PERL_IN_PP_HOT_C
29 static void unset_cvowner(pTHXo_ void *cvarg);
30 #endif /* USE_THREADS */
41 PL_curcop = (COP*)PL_op;
42 TAINT_NOT; /* Each statement is presumed innocent */
43 PL_stack_sp = PL_stack_base + cxstack[cxstack_ix].blk_oldsp;
52 if (PL_op->op_private & OPpLVAL_INTRO)
53 PUSHs(save_scalar(cGVOP_gv));
55 PUSHs(GvSV(cGVOP_gv));
66 PL_curcop = (COP*)PL_op;
72 PUSHMARK(PL_stack_sp);
82 sv_setpvn(TARG,s,len);
83 if (SvUTF8(TOPs) && !IN_BYTE)
92 XPUSHs((SV*)cGVOP_gv);
103 RETURNOP(cLOGOP->op_other);
111 if (PL_op->op_private & OPpASSIGN_BACKWARDS) {
113 temp = left; left = right; right = temp;
115 if (PL_tainting && PL_tainted && !SvTAINTED(left))
117 SvSetMagicSV(right, left);
126 RETURNOP(cLOGOP->op_other);
128 RETURNOP(cLOGOP->op_next);
134 TAINT_NOT; /* Each statement is presumed innocent */
135 PL_stack_sp = PL_stack_base + cxstack[cxstack_ix].blk_oldsp;
137 oldsave = PL_scopestack[PL_scopestack_ix - 1];
138 LEAVE_SCOPE(oldsave);
144 djSP; dATARGET; tryAMAGICbin(concat,opASSIGN);
149 bool left_utf = DO_UTF8(left);
150 bool right_utf = DO_UTF8(right);
152 if (left_utf != right_utf) {
153 if (TARG == right && !right_utf) {
154 sv_utf8_upgrade(TARG); /* Now straight binary copy */
158 /* Set TARG to PV(left), then add right */
159 U8 *l, *c, *olds = NULL;
162 /* Need a safe copy elsewhere since we're just about to
164 olds = (U8*)SvPV(right,len);
165 s = (U8*)savepv((char*)olds);
168 s = (U8*)SvPV(right,len);
169 l = (U8*)SvPV(left, targlen);
171 sv_setpvn(TARG, (char*)l, targlen);
173 sv_utf8_upgrade(TARG);
174 /* Extend TARG to length of right (s) */
175 targlen = SvCUR(TARG) + len;
177 /* plus one for each hi-byte char if we have to upgrade */
178 for (c = s; *c; c++) {
183 SvGROW(TARG, targlen+1);
184 /* And now copy, maybe upgrading right to UTF8 on the fly */
185 for (c = (U8*)SvEND(TARG); *s; s++) {
186 if (*s & 0x80 && !right_utf)
187 c = uv_to_utf8(c, *s);
191 SvCUR_set(TARG, targlen);
201 s = (U8*)SvPV(left,len);
203 sv_insert(TARG, 0, 0, (char*)s, len);
207 sv_setpvn(TARG, (char *)s, len);
209 else if (SvGMAGICAL(TARG))
211 else if (!SvOK(TARG) && SvTYPE(TARG) <= SVt_PVMG)
212 sv_setpv(TARG, ""); /* Suppress warning. */
213 s = (U8*)SvPV(right,len);
215 #if defined(PERL_Y2KWARN)
216 if ((SvIOK(right) || SvNOK(right)) && ckWARN(WARN_Y2K)) {
218 char *s = SvPV(TARG,n);
219 if (n >= 2 && s[n-2] == '1' && s[n-1] == '9'
220 && (n == 2 || !isDIGIT(s[n-3])))
222 Perl_warner(aTHX_ WARN_Y2K, "Possible Y2K bug: %s",
223 "about to append an integer to '19'");
227 sv_catpvn(TARG, (char *)s, len);
230 sv_setpvn(TARG, (char *)s, len); /* suppress warning */
242 if (PL_op->op_flags & OPf_MOD) {
243 if (PL_op->op_private & OPpLVAL_INTRO)
244 SAVECLEARSV(PL_curpad[PL_op->op_targ]);
245 else if (PL_op->op_private & OPpDEREF) {
247 vivify_ref(PL_curpad[PL_op->op_targ], PL_op->op_private & OPpDEREF);
256 tryAMAGICunTARGET(iter, 0);
257 PL_last_in_gv = (GV*)(*PL_stack_sp--);
258 if (SvTYPE(PL_last_in_gv) != SVt_PVGV) {
259 if (SvROK(PL_last_in_gv) && SvTYPE(SvRV(PL_last_in_gv)) == SVt_PVGV)
260 PL_last_in_gv = (GV*)SvRV(PL_last_in_gv);
263 XPUSHs((SV*)PL_last_in_gv);
266 PL_last_in_gv = (GV*)(*PL_stack_sp--);
269 return do_readline();
274 djSP; tryAMAGICbinSET(eq,0);
277 SETs(boolSV(TOPn == value));
285 if (SvREADONLY(TOPs) || SvTYPE(TOPs) > SVt_PVLV)
286 DIE(aTHX_ PL_no_modify);
287 if (SvIOK_notUV(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs) &&
288 SvIVX(TOPs) != IV_MAX)
291 SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
306 RETURNOP(cLOGOP->op_other);
312 djSP; dATARGET; tryAMAGICbin(add,opASSIGN);
315 SETn( left + right );
323 AV *av = GvAV(cGVOP_gv);
324 U32 lval = PL_op->op_flags & OPf_MOD;
325 SV** svp = av_fetch(av, PL_op->op_private, lval);
326 SV *sv = (svp ? *svp : &PL_sv_undef);
328 if (!lval && SvGMAGICAL(sv)) /* see note in pp_helem() */
329 sv = sv_mortalcopy(sv);
336 djSP; dMARK; dTARGET;
338 do_join(TARG, *MARK, MARK, SP);
349 * We ass_u_me that LvTARGOFF() comes first, and that two STRLENs
350 * will be enough to hold an OP*.
352 SV* sv = sv_newmortal();
353 sv_upgrade(sv, SVt_PVLV);
355 Copy(&PL_op, &LvTARGOFF(sv), 1, OP*);
363 /* Oversized hot code. */
367 djSP; dMARK; dORIGMARK;
374 if (PL_op->op_flags & OPf_STACKED)
378 if ((mg = SvTIED_mg((SV*)gv, 'q'))) {
379 if (MARK == ORIGMARK) {
380 /* If using default handle then we need to make space to
381 * pass object as 1st arg, so move other args up ...
385 Move(MARK, MARK + 1, (SP - MARK) + 1, SV*);
389 *MARK = SvTIED_obj((SV*)gv, mg);
392 call_method("PRINT", G_SCALAR);
400 if (!(io = GvIO(gv))) {
401 if (ckWARN(WARN_UNOPENED)) {
402 SV* sv = sv_newmortal();
403 gv_efullname4(sv, gv, Nullch, FALSE);
404 Perl_warner(aTHX_ WARN_UNOPENED, "Filehandle %s never opened",
407 SETERRNO(EBADF,RMS$_IFI);
410 else if (!(fp = IoOFP(io))) {
411 if (ckWARN2(WARN_CLOSED, WARN_IO)) {
413 SV* sv = sv_newmortal();
414 gv_efullname4(sv, gv, Nullch, FALSE);
415 Perl_warner(aTHX_ WARN_IO,
416 "Filehandle %s opened only for input",
419 else if (ckWARN(WARN_CLOSED))
420 report_closed_fh(gv, io, "print", "filehandle");
422 SETERRNO(EBADF,IoIFP(io)?RMS$_FAC:RMS$_IFI);
429 if (!do_print(*MARK, fp))
433 if (PerlIO_write(fp, PL_ofs, PL_ofslen) == 0 || PerlIO_error(fp)) {
442 if (!do_print(*MARK, fp))
451 if (PerlIO_write(fp, PL_ors, PL_orslen) == 0 || PerlIO_error(fp))
454 if (IoFLAGS(io) & IOf_FLUSH)
455 if (PerlIO_flush(fp) == EOF)
476 tryAMAGICunDEREF(to_av);
479 if (SvTYPE(av) != SVt_PVAV)
480 DIE(aTHX_ "Not an ARRAY reference");
481 if (PL_op->op_flags & OPf_REF) {
487 if (SvTYPE(sv) == SVt_PVAV) {
489 if (PL_op->op_flags & OPf_REF) {
497 if (SvTYPE(sv) != SVt_PVGV) {
501 if (SvGMAGICAL(sv)) {
507 if (PL_op->op_flags & OPf_REF ||
508 PL_op->op_private & HINT_STRICT_REFS)
509 DIE(aTHX_ PL_no_usym, "an ARRAY");
510 if (ckWARN(WARN_UNINITIALIZED))
512 if (GIMME == G_ARRAY) {
519 if ((PL_op->op_flags & OPf_SPECIAL) &&
520 !(PL_op->op_flags & OPf_MOD))
522 gv = (GV*)gv_fetchpv(sym, FALSE, SVt_PVAV);
524 && (!is_gv_magical(sym,len,0)
525 || !(gv = (GV*)gv_fetchpv(sym, TRUE, SVt_PVAV))))
531 if (PL_op->op_private & HINT_STRICT_REFS)
532 DIE(aTHX_ PL_no_symref, sym, "an ARRAY");
533 gv = (GV*)gv_fetchpv(sym, TRUE, SVt_PVAV);
540 if (PL_op->op_private & OPpLVAL_INTRO)
542 if (PL_op->op_flags & OPf_REF) {
549 if (GIMME == G_ARRAY) {
550 I32 maxarg = AvFILL(av) + 1;
551 (void)POPs; /* XXXX May be optimized away? */
553 if (SvRMAGICAL(av)) {
555 for (i=0; i < maxarg; i++) {
556 SV **svp = av_fetch(av, i, FALSE);
557 SP[i+1] = (svp) ? *svp : &PL_sv_undef;
561 Copy(AvARRAY(av), SP+1, maxarg, SV*);
567 I32 maxarg = AvFILL(av) + 1;
580 tryAMAGICunDEREF(to_hv);
583 if (SvTYPE(hv) != SVt_PVHV && SvTYPE(hv) != SVt_PVAV)
584 DIE(aTHX_ "Not a HASH reference");
585 if (PL_op->op_flags & OPf_REF) {
591 if (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV) {
593 if (PL_op->op_flags & OPf_REF) {
601 if (SvTYPE(sv) != SVt_PVGV) {
605 if (SvGMAGICAL(sv)) {
611 if (PL_op->op_flags & OPf_REF ||
612 PL_op->op_private & HINT_STRICT_REFS)
613 DIE(aTHX_ PL_no_usym, "a HASH");
614 if (ckWARN(WARN_UNINITIALIZED))
616 if (GIMME == G_ARRAY) {
623 if ((PL_op->op_flags & OPf_SPECIAL) &&
624 !(PL_op->op_flags & OPf_MOD))
626 gv = (GV*)gv_fetchpv(sym, FALSE, SVt_PVHV);
628 && (!is_gv_magical(sym,len,0)
629 || !(gv = (GV*)gv_fetchpv(sym, TRUE, SVt_PVHV))))
635 if (PL_op->op_private & HINT_STRICT_REFS)
636 DIE(aTHX_ PL_no_symref, sym, "a HASH");
637 gv = (GV*)gv_fetchpv(sym, TRUE, SVt_PVHV);
644 if (PL_op->op_private & OPpLVAL_INTRO)
646 if (PL_op->op_flags & OPf_REF) {
653 if (GIMME == G_ARRAY) { /* array wanted */
654 *PL_stack_sp = (SV*)hv;
659 if (SvTYPE(hv) == SVt_PVAV)
660 hv = avhv_keys((AV*)hv);
662 Perl_sv_setpvf(aTHX_ TARG, "%"IVdf"/%"IVdf,
663 (IV)HvFILL(hv), (IV)HvMAX(hv) + 1);
673 S_do_maybe_phash(pTHX_ AV *ary, SV **lelem, SV **firstlelem, SV **relem,
679 leftop = ((BINOP*)PL_op)->op_last;
681 assert(leftop->op_type == OP_NULL && leftop->op_targ == OP_LIST);
682 leftop = ((LISTOP*)leftop)->op_first;
684 /* Skip PUSHMARK and each element already assigned to. */
685 for (i = lelem - firstlelem; i > 0; i--) {
686 leftop = leftop->op_sibling;
689 if (leftop->op_type != OP_RV2HV)
694 av_fill(ary, 0); /* clear all but the fields hash */
695 if (lastrelem >= relem) {
696 while (relem < lastrelem) { /* gobble up all the rest */
700 /* Avoid a memory leak when avhv_store_ent dies. */
701 tmpstr = sv_newmortal();
702 sv_setsv(tmpstr,relem[1]); /* value */
704 if (avhv_store_ent(ary,relem[0],tmpstr,0))
705 (void)SvREFCNT_inc(tmpstr);
706 if (SvMAGICAL(ary) != 0 && SvSMAGICAL(tmpstr))
712 if (relem == lastrelem)
718 S_do_oddball(pTHX_ HV *hash, SV **relem, SV **firstrelem)
722 if (ckWARN(WARN_MISC)) {
723 if (relem == firstrelem &&
725 (SvTYPE(SvRV(*relem)) == SVt_PVAV ||
726 SvTYPE(SvRV(*relem)) == SVt_PVHV))
728 Perl_warner(aTHX_ WARN_MISC,
729 "Reference found where even-sized list expected");
732 Perl_warner(aTHX_ WARN_MISC,
733 "Odd number of elements in hash assignment");
735 if (SvTYPE(hash) == SVt_PVAV) {
737 tmpstr = sv_newmortal();
738 if (avhv_store_ent((AV*)hash,*relem,tmpstr,0))
739 (void)SvREFCNT_inc(tmpstr);
740 if (SvMAGICAL(hash) && SvSMAGICAL(tmpstr))
745 tmpstr = NEWSV(29,0);
746 didstore = hv_store_ent(hash,*relem,tmpstr,0);
747 if (SvMAGICAL(hash)) {
748 if (SvSMAGICAL(tmpstr))
761 SV **lastlelem = PL_stack_sp;
762 SV **lastrelem = PL_stack_base + POPMARK;
763 SV **firstrelem = PL_stack_base + POPMARK + 1;
764 SV **firstlelem = lastrelem + 1;
777 PL_delaymagic = DM_DELAY; /* catch simultaneous items */
779 /* If there's a common identifier on both sides we have to take
780 * special care that assigning the identifier on the left doesn't
781 * clobber a value on the right that's used later in the list.
783 if (PL_op->op_private & (OPpASSIGN_COMMON)) {
784 EXTEND_MORTAL(lastrelem - firstrelem + 1);
785 for (relem = firstrelem; relem <= lastrelem; relem++) {
788 TAINT_NOT; /* Each item is independent */
789 *relem = sv_mortalcopy(sv);
799 while (lelem <= lastlelem) {
800 TAINT_NOT; /* Each item stands on its own, taintwise. */
802 switch (SvTYPE(sv)) {
805 magic = SvMAGICAL(ary) != 0;
806 if (PL_op->op_private & OPpASSIGN_HASH) {
807 switch (do_maybe_phash(ary, lelem, firstlelem, relem,
813 do_oddball((HV*)ary, relem, firstrelem);
815 relem = lastrelem + 1;
820 av_extend(ary, lastrelem - relem);
822 while (relem <= lastrelem) { /* gobble up all the rest */
828 didstore = av_store(ary,i++,sv);
838 case SVt_PVHV: { /* normal hash */
842 magic = SvMAGICAL(hash) != 0;
845 while (relem < lastrelem) { /* gobble up all the rest */
850 sv = &PL_sv_no, relem++;
851 tmpstr = NEWSV(29,0);
853 sv_setsv(tmpstr,*relem); /* value */
855 didstore = hv_store_ent(hash,sv,tmpstr,0);
857 if (SvSMAGICAL(tmpstr))
864 if (relem == lastrelem) {
865 do_oddball(hash, relem, firstrelem);
871 if (SvIMMORTAL(sv)) {
872 if (relem <= lastrelem)
876 if (relem <= lastrelem) {
877 sv_setsv(sv, *relem);
881 sv_setsv(sv, &PL_sv_undef);
886 if (PL_delaymagic & ~DM_DELAY) {
887 if (PL_delaymagic & DM_UID) {
889 (void)setresuid(PL_uid,PL_euid,(Uid_t)-1);
892 (void)setreuid(PL_uid,PL_euid);
895 if ((PL_delaymagic & DM_UID) == DM_RUID) {
896 (void)setruid(PL_uid);
897 PL_delaymagic &= ~DM_RUID;
899 # endif /* HAS_SETRUID */
901 if ((PL_delaymagic & DM_UID) == DM_EUID) {
902 (void)seteuid(PL_uid);
903 PL_delaymagic &= ~DM_EUID;
905 # endif /* HAS_SETEUID */
906 if (PL_delaymagic & DM_UID) {
907 if (PL_uid != PL_euid)
908 DIE(aTHX_ "No setreuid available");
909 (void)PerlProc_setuid(PL_uid);
911 # endif /* HAS_SETREUID */
912 #endif /* HAS_SETRESUID */
913 PL_uid = PerlProc_getuid();
914 PL_euid = PerlProc_geteuid();
916 if (PL_delaymagic & DM_GID) {
918 (void)setresgid(PL_gid,PL_egid,(Gid_t)-1);
921 (void)setregid(PL_gid,PL_egid);
924 if ((PL_delaymagic & DM_GID) == DM_RGID) {
925 (void)setrgid(PL_gid);
926 PL_delaymagic &= ~DM_RGID;
928 # endif /* HAS_SETRGID */
930 if ((PL_delaymagic & DM_GID) == DM_EGID) {
931 (void)setegid(PL_gid);
932 PL_delaymagic &= ~DM_EGID;
934 # endif /* HAS_SETEGID */
935 if (PL_delaymagic & DM_GID) {
936 if (PL_gid != PL_egid)
937 DIE(aTHX_ "No setregid available");
938 (void)PerlProc_setgid(PL_gid);
940 # endif /* HAS_SETREGID */
941 #endif /* HAS_SETRESGID */
942 PL_gid = PerlProc_getgid();
943 PL_egid = PerlProc_getegid();
945 PL_tainting |= (PL_uid && (PL_euid != PL_uid || PL_egid != PL_gid));
952 else if (gimme == G_SCALAR) {
955 SETi(lastrelem - firstrelem + 1);
961 SP = firstrelem + (lastlelem - firstlelem);
962 lelem = firstlelem + (relem - firstrelem);
964 *relem++ = (lelem <= lastlelem) ? *lelem++ : &PL_sv_undef;
972 register PMOP *pm = cPMOP;
973 SV *rv = sv_newmortal();
974 SV *sv = newSVrv(rv, "Regexp");
975 sv_magic(sv,(SV*)ReREFCNT_inc(pm->op_pmregexp),'r',0,0);
982 register PMOP *pm = cPMOP;
987 I32 r_flags = REXEC_CHECKED;
988 char *truebase; /* Start of string */
989 register REGEXP *rx = pm->op_pmregexp;
994 I32 oldsave = PL_savestack_ix;
995 I32 update_minmatch = 1;
998 if (PL_op->op_flags & OPf_STACKED)
1004 PUTBACK; /* EVAL blocks need stack_sp. */
1005 s = SvPV(TARG, len);
1008 DIE(aTHX_ "panic: do_match");
1009 rxtainted = ((pm->op_pmdynflags & PMdf_TAINTED) ||
1010 (PL_tainted && (pm->op_pmflags & PMf_RETAINT)));
1013 if (pm->op_pmdynflags & PMdf_USED) {
1015 if (gimme == G_ARRAY)
1020 if (!rx->prelen && PL_curpm) {
1022 rx = pm->op_pmregexp;
1024 if (rx->minlen > len) goto failure;
1028 /* XXXX What part of this is needed with true \G-support? */
1029 if ((global = pm->op_pmflags & PMf_GLOBAL)) {
1031 if (SvTYPE(TARG) >= SVt_PVMG && SvMAGIC(TARG)) {
1032 MAGIC* mg = mg_find(TARG, 'g');
1033 if (mg && mg->mg_len >= 0) {
1034 if (!(rx->reganch & ROPT_GPOS_SEEN))
1035 rx->endp[0] = rx->startp[0] = mg->mg_len;
1036 else if (rx->reganch & ROPT_ANCH_GPOS) {
1037 r_flags |= REXEC_IGNOREPOS;
1038 rx->endp[0] = rx->startp[0] = mg->mg_len;
1040 minmatch = (mg->mg_flags & MGf_MINMATCH);
1041 update_minmatch = 0;
1045 if ((gimme != G_ARRAY && !global && rx->nparens)
1046 || SvTEMP(TARG) || PL_sawampersand)
1047 r_flags |= REXEC_COPY_STR;
1049 r_flags |= REXEC_SCREAM;
1051 if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
1052 SAVEINT(PL_multiline);
1053 PL_multiline = pm->op_pmflags & PMf_MULTILINE;
1057 if (global && rx->startp[0] != -1) {
1058 t = s = rx->endp[0] + truebase;
1059 if ((s + rx->minlen) > strend)
1061 if (update_minmatch++)
1062 minmatch = had_zerolen;
1064 if (rx->reganch & RE_USE_INTUIT) {
1065 s = CALLREG_INTUIT_START(aTHX_ rx, TARG, s, strend, r_flags, NULL);
1069 if ( (rx->reganch & ROPT_CHECK_ALL)
1071 && ((rx->reganch & ROPT_NOSCAN)
1072 || !((rx->reganch & RE_INTUIT_TAIL)
1073 && (r_flags & REXEC_SCREAM)))
1074 && !SvROK(TARG)) /* Cannot trust since INTUIT cannot guess ^ */
1077 if (CALLREGEXEC(aTHX_ rx, s, strend, truebase, minmatch, TARG, NULL, r_flags))
1080 if (pm->op_pmflags & PMf_ONCE)
1081 pm->op_pmdynflags |= PMdf_USED;
1090 RX_MATCH_TAINTED_on(rx);
1091 TAINT_IF(RX_MATCH_TAINTED(rx));
1092 if (gimme == G_ARRAY) {
1095 iters = rx->nparens;
1096 if (global && !iters)
1100 SPAGAIN; /* EVAL blocks could move the stack. */
1101 EXTEND(SP, iters + i);
1102 EXTEND_MORTAL(iters + i);
1103 for (i = !i; i <= iters; i++) {
1104 PUSHs(sv_newmortal());
1106 if ((rx->startp[i] != -1) && rx->endp[i] != -1 ) {
1107 len = rx->endp[i] - rx->startp[i];
1108 s = rx->startp[i] + truebase;
1109 sv_setpvn(*SP, s, len);
1110 if ((pm->op_pmdynflags & PMdf_UTF8) && !IN_BYTE) {
1112 sv_utf8_downgrade(*SP, TRUE);
1117 had_zerolen = (rx->startp[0] != -1
1118 && rx->startp[0] == rx->endp[0]);
1119 PUTBACK; /* EVAL blocks may use stack */
1120 r_flags |= REXEC_IGNOREPOS | REXEC_NOT_FIRST;
1125 LEAVE_SCOPE(oldsave);
1131 if (SvTYPE(TARG) >= SVt_PVMG && SvMAGIC(TARG))
1132 mg = mg_find(TARG, 'g');
1134 sv_magic(TARG, (SV*)0, 'g', Nullch, 0);
1135 mg = mg_find(TARG, 'g');
1137 if (rx->startp[0] != -1) {
1138 mg->mg_len = rx->endp[0];
1139 if (rx->startp[0] == rx->endp[0])
1140 mg->mg_flags |= MGf_MINMATCH;
1142 mg->mg_flags &= ~MGf_MINMATCH;
1145 LEAVE_SCOPE(oldsave);
1149 yup: /* Confirmed by INTUIT */
1151 RX_MATCH_TAINTED_on(rx);
1152 TAINT_IF(RX_MATCH_TAINTED(rx));
1154 if (pm->op_pmflags & PMf_ONCE)
1155 pm->op_pmdynflags |= PMdf_USED;
1156 if (RX_MATCH_COPIED(rx))
1157 Safefree(rx->subbeg);
1158 RX_MATCH_COPIED_off(rx);
1159 rx->subbeg = Nullch;
1161 rx->subbeg = truebase;
1162 rx->startp[0] = s - truebase;
1163 rx->endp[0] = s - truebase + rx->minlen;
1164 rx->sublen = strend - truebase;
1167 if (PL_sawampersand) {
1170 rx->subbeg = savepvn(t, strend - t);
1171 rx->sublen = strend - t;
1172 RX_MATCH_COPIED_on(rx);
1173 off = rx->startp[0] = s - t;
1174 rx->endp[0] = off + rx->minlen;
1176 else { /* startp/endp are used by @- @+. */
1177 rx->startp[0] = s - truebase;
1178 rx->endp[0] = s - truebase + rx->minlen;
1180 rx->nparens = rx->lastparen = 0; /* used by @- and @+ */
1181 LEAVE_SCOPE(oldsave);
1186 if (global && !(pm->op_pmflags & PMf_CONTINUE)) {
1187 if (SvTYPE(TARG) >= SVt_PVMG && SvMAGIC(TARG)) {
1188 MAGIC* mg = mg_find(TARG, 'g');
1193 LEAVE_SCOPE(oldsave);
1194 if (gimme == G_ARRAY)
1200 Perl_do_readline(pTHX)
1202 dSP; dTARGETSTACKED;
1207 register IO *io = GvIO(PL_last_in_gv);
1208 register I32 type = PL_op->op_type;
1209 I32 gimme = GIMME_V;
1212 if ((mg = SvTIED_mg((SV*)PL_last_in_gv, 'q'))) {
1214 XPUSHs(SvTIED_obj((SV*)PL_last_in_gv, mg));
1217 call_method("READLINE", gimme);
1220 if (gimme == G_SCALAR)
1221 SvSetMagicSV_nosteal(TARG, TOPs);
1228 if (IoFLAGS(io) & IOf_ARGV) {
1229 if (IoFLAGS(io) & IOf_START) {
1231 if (av_len(GvAVn(PL_last_in_gv)) < 0) {
1232 IoFLAGS(io) &= ~IOf_START;
1233 do_open(PL_last_in_gv,"-",1,FALSE,O_RDONLY,0,Nullfp);
1234 sv_setpvn(GvSV(PL_last_in_gv), "-", 1);
1235 SvSETMAGIC(GvSV(PL_last_in_gv));
1240 fp = nextargv(PL_last_in_gv);
1241 if (!fp) { /* Note: fp != IoIFP(io) */
1242 (void)do_close(PL_last_in_gv, FALSE); /* now it does*/
1245 else if (type == OP_GLOB) {
1246 SV *tmpcmd = NEWSV(55, 0);
1250 #ifdef VMS /* expand the wildcards right here, rather than opening a pipe, */
1251 /* since spawning off a process is a real performance hit */
1253 #include <descrip.h>
1254 #include <lib$routines.h>
1257 char rslt[NAM$C_MAXRSS+1+sizeof(unsigned short int)] = {'\0','\0'};
1258 char vmsspec[NAM$C_MAXRSS+1];
1259 char *rstr = rslt + sizeof(unsigned short int), *begin, *end, *cp;
1260 char tmpfnam[L_tmpnam] = "SYS$SCRATCH:";
1261 $DESCRIPTOR(dfltdsc,"SYS$DISK:[]*.*;");
1264 struct dsc$descriptor_s wilddsc
1265 = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0};
1266 struct dsc$descriptor_vs rsdsc
1267 = {sizeof rslt, DSC$K_DTYPE_VT, DSC$K_CLASS_VS, rslt};
1268 unsigned long int cxt = 0, sts = 0, ok = 1, hasdir = 0, hasver = 0, isunix = 0;
1270 /* We could find out if there's an explicit dev/dir or version
1271 by peeking into lib$find_file's internal context at
1272 ((struct NAM *)((struct FAB *)cxt)->fab$l_nam)->nam$l_fnb
1273 but that's unsupported, so I don't want to do it now and
1274 have it bite someone in the future. */
1275 strcat(tmpfnam,PerlLIO_tmpnam(NULL));
1276 cp = SvPV(tmpglob,i);
1278 if (cp[i] == ';') hasver = 1;
1280 if (sts) hasver = 1;
1284 hasdir = isunix = 1;
1287 if (cp[i] == ']' || cp[i] == '>' || cp[i] == ':') {
1292 if ((tmpfp = PerlIO_open(tmpfnam,"w+","fop=dlt")) != NULL) {
1294 if (!PerlLIO_stat(SvPVX(tmpglob),&st) && S_ISDIR(st.st_mode))
1295 ok = ((wilddsc.dsc$a_pointer = tovmspath(SvPVX(tmpglob),vmsspec)) != NULL);
1296 else ok = ((wilddsc.dsc$a_pointer = tovmsspec(SvPVX(tmpglob),vmsspec)) != NULL);
1297 if (ok) wilddsc.dsc$w_length = (unsigned short int) strlen(wilddsc.dsc$a_pointer);
1298 while (ok && ((sts = lib$find_file(&wilddsc,&rsdsc,&cxt,
1299 &dfltdsc,NULL,NULL,NULL))&1)) {
1300 end = rstr + (unsigned long int) *rslt;
1301 if (!hasver) while (*end != ';') end--;
1302 *(end++) = '\n'; *end = '\0';
1303 for (cp = rstr; *cp; cp++) *cp = _tolower(*cp);
1305 if (isunix) trim_unixpath(rstr,SvPVX(tmpglob),1);
1310 while (*(--begin) != ']' && *begin != '>') ;
1313 ok = (PerlIO_puts(tmpfp,begin) != EOF);
1315 if (cxt) (void)lib$find_file_end(&cxt);
1316 if (ok && sts != RMS$_NMF &&
1317 sts != RMS$_DNF && sts != RMS$_FNF) ok = 0;
1320 SETERRNO((sts == RMS$_SYN ? EINVAL : EVMSERR),sts);
1322 PerlIO_close(tmpfp);
1326 PerlIO_rewind(tmpfp);
1328 IoIFP(io) = fp = tmpfp;
1329 IoFLAGS(io) &= ~IOf_UNTAINT; /* maybe redundant */
1334 #ifdef MACOS_TRADITIONAL
1335 sv_setpv(tmpcmd, "glob ");
1336 sv_catsv(tmpcmd, tmpglob);
1337 sv_catpv(tmpcmd, " |");
1341 sv_setpv(tmpcmd, "for a in ");
1342 sv_catsv(tmpcmd, tmpglob);
1343 sv_catpv(tmpcmd, "; do echo \"$a\\0\\c\"; done |");
1346 sv_setpv(tmpcmd, "/dev/dosglob/"); /* File System Extension */
1347 sv_catsv(tmpcmd, tmpglob);
1349 sv_setpv(tmpcmd, "perlglob ");
1350 sv_catsv(tmpcmd, tmpglob);
1351 sv_catpv(tmpcmd, " |");
1356 sv_setpvn(tmpcmd, PL_cshname, PL_cshlen);
1357 sv_catpv(tmpcmd, " -cf 'set nonomatch; glob ");
1358 sv_catsv(tmpcmd, tmpglob);
1359 sv_catpv(tmpcmd, "' 2>/dev/null |");
1361 sv_setpv(tmpcmd, "echo ");
1362 sv_catsv(tmpcmd, tmpglob);
1364 sv_catpv(tmpcmd, "|tr -s ' \t\f\r' '\\012\\012\\012\\012'|");
1366 sv_catpv(tmpcmd, "|tr -s ' \t\f\r' '\\n\\n\\n\\n'|");
1369 #endif /* !DOSISH */
1370 #endif /* MACOS_TRADITIONAL */
1371 (void)do_open(PL_last_in_gv, SvPVX(tmpcmd), SvCUR(tmpcmd),
1372 FALSE, O_RDONLY, 0, Nullfp);
1378 else if (type == OP_GLOB)
1380 else if (ckWARN(WARN_IO) /* stdout/stderr or other write fh */
1381 && (IoTYPE(io) == '>' || fp == PerlIO_stdout()
1382 || fp == PerlIO_stderr()))
1384 SV* sv = sv_newmortal();
1385 gv_efullname4(sv, PL_last_in_gv, Nullch, FALSE);
1386 Perl_warner(aTHX_ WARN_IO, "Filehandle %s opened only for output",
1391 if (ckWARN2(WARN_GLOB,WARN_CLOSED) && io && !(IoFLAGS(io) & IOf_START)) {
1392 if (type == OP_GLOB)
1393 Perl_warner(aTHX_ WARN_GLOB,
1394 "glob failed (can't start child: %s)",
1397 report_closed_fh(PL_last_in_gv, io, "readline", "filehandle");
1399 if (gimme == G_SCALAR) {
1400 (void)SvOK_off(TARG);
1406 if (gimme == G_SCALAR) {
1410 (void)SvUPGRADE(sv, SVt_PV);
1411 tmplen = SvLEN(sv); /* remember if already alloced */
1413 Sv_Grow(sv, 80); /* try short-buffering it */
1414 if (type == OP_RCATLINE)
1420 sv = sv_2mortal(NEWSV(57, 80));
1424 /* delay EOF state for a snarfed empty file */
1425 #define SNARF_EOF(gimme,rs,io,sv) \
1426 (gimme != G_SCALAR || SvCUR(sv) \
1427 || (IoFLAGS(io) & IOf_NOLINE) || !RsSNARF(rs))
1430 if (!sv_gets(sv, fp, offset)
1431 && (type == OP_GLOB || SNARF_EOF(gimme, PL_rs, io, sv)))
1433 PerlIO_clearerr(fp);
1434 if (IoFLAGS(io) & IOf_ARGV) {
1435 fp = nextargv(PL_last_in_gv);
1438 (void)do_close(PL_last_in_gv, FALSE);
1440 else if (type == OP_GLOB) {
1441 if (!do_close(PL_last_in_gv, FALSE) && ckWARN(WARN_GLOB)) {
1442 Perl_warner(aTHX_ WARN_GLOB,
1443 "glob failed (child exited with status %d%s)",
1444 (int)(STATUS_CURRENT >> 8),
1445 (STATUS_CURRENT & 0x80) ? ", core dumped" : "");
1448 if (gimme == G_SCALAR) {
1449 (void)SvOK_off(TARG);
1454 /* This should not be marked tainted if the fp is marked clean */
1455 if (!(IoFLAGS(io) & IOf_UNTAINT)) {
1460 IoFLAGS(io) |= IOf_NOLINE;
1463 if (type == OP_GLOB) {
1466 if (SvCUR(sv) > 0 && SvCUR(PL_rs) > 0) {
1467 tmps = SvEND(sv) - 1;
1468 if (*tmps == *SvPVX(PL_rs)) {
1473 for (tmps = SvPVX(sv); *tmps; tmps++)
1474 if (!isALPHA(*tmps) && !isDIGIT(*tmps) &&
1475 strchr("$&*(){}[]'\";\\|?<>~`", *tmps))
1477 if (*tmps && PerlLIO_lstat(SvPVX(sv), &PL_statbuf) < 0) {
1478 (void)POPs; /* Unmatched wildcard? Chuck it... */
1482 if (gimme == G_ARRAY) {
1483 if (SvLEN(sv) - SvCUR(sv) > 20) {
1484 SvLEN_set(sv, SvCUR(sv)+1);
1485 Renew(SvPVX(sv), SvLEN(sv), char);
1487 sv = sv_2mortal(NEWSV(58, 80));
1490 else if (gimme == G_SCALAR && !tmplen && SvLEN(sv) - SvCUR(sv) > 80) {
1491 /* try to reclaim a bit of scalar space (only on 1st alloc) */
1495 SvLEN_set(sv, SvCUR(sv)+40); /* allow some slop */
1496 Renew(SvPVX(sv), SvLEN(sv), char);
1505 register PERL_CONTEXT *cx;
1506 I32 gimme = OP_GIMME(PL_op, -1);
1509 if (cxstack_ix >= 0)
1510 gimme = cxstack[cxstack_ix].blk_gimme;
1518 PUSHBLOCK(cx, CXt_BLOCK, SP);
1530 U32 lval = PL_op->op_flags & OPf_MOD;
1531 U32 defer = PL_op->op_private & OPpLVAL_DEFER;
1534 if (SvTYPE(hv) == SVt_PVHV) {
1535 he = hv_fetch_ent(hv, keysv, lval && !defer, 0);
1536 svp = he ? &HeVAL(he) : 0;
1538 else if (SvTYPE(hv) == SVt_PVAV) {
1539 if (PL_op->op_private & OPpLVAL_INTRO)
1540 DIE(aTHX_ "Can't localize pseudo-hash element");
1541 svp = avhv_fetch_ent((AV*)hv, keysv, lval && !defer, 0);
1547 if (!svp || *svp == &PL_sv_undef) {
1552 DIE(aTHX_ PL_no_helem, SvPV(keysv, n_a));
1554 lv = sv_newmortal();
1555 sv_upgrade(lv, SVt_PVLV);
1557 sv_magic(lv, key2 = newSVsv(keysv), 'y', Nullch, 0);
1558 SvREFCNT_dec(key2); /* sv_magic() increments refcount */
1559 LvTARG(lv) = SvREFCNT_inc(hv);
1564 if (PL_op->op_private & OPpLVAL_INTRO) {
1565 if (HvNAME(hv) && isGV(*svp))
1566 save_gp((GV*)*svp, !(PL_op->op_flags & OPf_SPECIAL));
1568 save_helem(hv, keysv, svp);
1570 else if (PL_op->op_private & OPpDEREF)
1571 vivify_ref(*svp, PL_op->op_private & OPpDEREF);
1573 sv = (svp ? *svp : &PL_sv_undef);
1574 /* This makes C<local $tied{foo} = $tied{foo}> possible.
1575 * Pushing the magical RHS on to the stack is useless, since
1576 * that magic is soon destined to be misled by the local(),
1577 * and thus the later pp_sassign() will fail to mg_get() the
1578 * old value. This should also cure problems with delayed
1579 * mg_get()s. GSAR 98-07-03 */
1580 if (!lval && SvGMAGICAL(sv))
1581 sv = sv_mortalcopy(sv);
1589 register PERL_CONTEXT *cx;
1595 if (PL_op->op_flags & OPf_SPECIAL) {
1596 cx = &cxstack[cxstack_ix];
1597 cx->blk_oldpm = PL_curpm; /* fake block should preserve $1 et al */
1602 gimme = OP_GIMME(PL_op, -1);
1604 if (cxstack_ix >= 0)
1605 gimme = cxstack[cxstack_ix].blk_gimme;
1611 if (gimme == G_VOID)
1613 else if (gimme == G_SCALAR) {
1616 if (SvFLAGS(TOPs) & (SVs_PADTMP|SVs_TEMP))
1619 *MARK = sv_mortalcopy(TOPs);
1622 *MARK = &PL_sv_undef;
1626 else if (gimme == G_ARRAY) {
1627 /* in case LEAVE wipes old return values */
1628 for (mark = newsp + 1; mark <= SP; mark++) {
1629 if (!(SvFLAGS(*mark) & (SVs_PADTMP|SVs_TEMP))) {
1630 *mark = sv_mortalcopy(*mark);
1631 TAINT_NOT; /* Each item is independent */
1635 PL_curpm = newpm; /* Don't pop $1 et al till now */
1645 register PERL_CONTEXT *cx;
1651 cx = &cxstack[cxstack_ix];
1652 if (CxTYPE(cx) != CXt_LOOP)
1653 DIE(aTHX_ "panic: pp_iter");
1655 itersvp = CxITERVAR(cx);
1656 av = cx->blk_loop.iterary;
1657 if (SvTYPE(av) != SVt_PVAV) {
1658 /* iterate ($min .. $max) */
1659 if (cx->blk_loop.iterlval) {
1660 /* string increment */
1661 register SV* cur = cx->blk_loop.iterlval;
1663 char *max = SvPV((SV*)av, maxlen);
1664 if (!SvNIOK(cur) && SvCUR(cur) <= maxlen) {
1665 #ifndef USE_THREADS /* don't risk potential race */
1666 if (SvREFCNT(*itersvp) == 1 && !SvMAGICAL(*itersvp)) {
1667 /* safe to reuse old SV */
1668 sv_setsv(*itersvp, cur);
1673 /* we need a fresh SV every time so that loop body sees a
1674 * completely new SV for closures/references to work as
1676 SvREFCNT_dec(*itersvp);
1677 *itersvp = newSVsv(cur);
1679 if (strEQ(SvPVX(cur), max))
1680 sv_setiv(cur, 0); /* terminate next time */
1687 /* integer increment */
1688 if (cx->blk_loop.iterix > cx->blk_loop.itermax)
1691 #ifndef USE_THREADS /* don't risk potential race */
1692 if (SvREFCNT(*itersvp) == 1 && !SvMAGICAL(*itersvp)) {
1693 /* safe to reuse old SV */
1694 sv_setiv(*itersvp, cx->blk_loop.iterix++);
1699 /* we need a fresh SV every time so that loop body sees a
1700 * completely new SV for closures/references to work as they
1702 SvREFCNT_dec(*itersvp);
1703 *itersvp = newSViv(cx->blk_loop.iterix++);
1709 if (cx->blk_loop.iterix >= (av == PL_curstack ? cx->blk_oldsp : AvFILL(av)))
1712 SvREFCNT_dec(*itersvp);
1714 if ((sv = SvMAGICAL(av)
1715 ? *av_fetch(av, ++cx->blk_loop.iterix, FALSE)
1716 : AvARRAY(av)[++cx->blk_loop.iterix]))
1720 if (av != PL_curstack && SvIMMORTAL(sv)) {
1721 SV *lv = cx->blk_loop.iterlval;
1722 if (lv && SvREFCNT(lv) > 1) {
1727 SvREFCNT_dec(LvTARG(lv));
1729 lv = cx->blk_loop.iterlval = NEWSV(26, 0);
1730 sv_upgrade(lv, SVt_PVLV);
1732 sv_magic(lv, Nullsv, 'y', Nullch, 0);
1734 LvTARG(lv) = SvREFCNT_inc(av);
1735 LvTARGOFF(lv) = cx->blk_loop.iterix;
1736 LvTARGLEN(lv) = (STRLEN)UV_MAX;
1740 *itersvp = SvREFCNT_inc(sv);
1747 register PMOP *pm = cPMOP;
1763 register REGEXP *rx = pm->op_pmregexp;
1765 int force_on_match = 0;
1766 I32 oldsave = PL_savestack_ix;
1768 /* known replacement string? */
1769 dstr = (pm->op_pmflags & PMf_CONST) ? POPs : Nullsv;
1770 if (PL_op->op_flags & OPf_STACKED)
1776 if (SvREADONLY(TARG)
1777 || (SvTYPE(TARG) > SVt_PVLV
1778 && !(SvTYPE(TARG) == SVt_PVGV && SvFAKE(TARG))))
1779 DIE(aTHX_ PL_no_modify);
1782 s = SvPV(TARG, len);
1783 if (!SvPOKp(TARG) || SvTYPE(TARG) == SVt_PVGV)
1785 rxtainted = ((pm->op_pmdynflags & PMdf_TAINTED) ||
1786 (PL_tainted && (pm->op_pmflags & PMf_RETAINT)));
1793 DIE(aTHX_ "panic: do_subst");
1796 maxiters = 2*(strend - s) + 10; /* We can match twice at each
1797 position, once with zero-length,
1798 second time with non-zero. */
1800 if (!rx->prelen && PL_curpm) {
1802 rx = pm->op_pmregexp;
1804 r_flags = (rx->nparens || SvTEMP(TARG) || PL_sawampersand)
1805 ? REXEC_COPY_STR : 0;
1807 r_flags |= REXEC_SCREAM;
1808 if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
1809 SAVEINT(PL_multiline);
1810 PL_multiline = pm->op_pmflags & PMf_MULTILINE;
1813 if (rx->reganch & RE_USE_INTUIT) {
1814 s = CALLREG_INTUIT_START(aTHX_ rx, TARG, s, strend, r_flags, NULL);
1818 /* How to do it in subst? */
1819 /* if ( (rx->reganch & ROPT_CHECK_ALL)
1821 && ((rx->reganch & ROPT_NOSCAN)
1822 || !((rx->reganch & RE_INTUIT_TAIL)
1823 && (r_flags & REXEC_SCREAM))))
1828 /* only replace once? */
1829 once = !(rpm->op_pmflags & PMf_GLOBAL);
1831 /* known replacement string? */
1832 c = dstr ? SvPV(dstr, clen) : Nullch;
1834 /* can do inplace substitution? */
1835 if (c && clen <= rx->minlen && (once || !(r_flags & REXEC_COPY_STR))
1836 && !(rx->reganch & ROPT_LOOKBEHIND_SEEN)) {
1837 if (!CALLREGEXEC(aTHX_ rx, s, strend, orig, 0, TARG, NULL,
1838 r_flags | REXEC_CHECKED))
1842 LEAVE_SCOPE(oldsave);
1845 if (force_on_match) {
1847 s = SvPV_force(TARG, len);
1852 SvSCREAM_off(TARG); /* disable possible screamer */
1854 rxtainted |= RX_MATCH_TAINTED(rx);
1855 m = orig + rx->startp[0];
1856 d = orig + rx->endp[0];
1858 if (m - s > strend - d) { /* faster to shorten from end */
1860 Copy(c, m, clen, char);
1865 Move(d, m, i, char);
1869 SvCUR_set(TARG, m - s);
1872 else if ((i = m - s)) { /* faster from front */
1880 Copy(c, m, clen, char);
1885 Copy(c, d, clen, char);
1890 TAINT_IF(rxtainted & 1);
1896 if (iters++ > maxiters)
1897 DIE(aTHX_ "Substitution loop");
1898 rxtainted |= RX_MATCH_TAINTED(rx);
1899 m = rx->startp[0] + orig;
1903 Move(s, d, i, char);
1907 Copy(c, d, clen, char);
1910 s = rx->endp[0] + orig;
1911 } while (CALLREGEXEC(aTHX_ rx, s, strend, orig, s == m,
1913 /* don't match same null twice */
1914 REXEC_NOT_FIRST|REXEC_IGNOREPOS));
1917 SvCUR_set(TARG, d - SvPVX(TARG) + i);
1918 Move(s, d, i+1, char); /* include the NUL */
1920 TAINT_IF(rxtainted & 1);
1922 PUSHs(sv_2mortal(newSViv((I32)iters)));
1924 (void)SvPOK_only_UTF8(TARG);
1925 TAINT_IF(rxtainted);
1926 if (SvSMAGICAL(TARG)) {
1932 LEAVE_SCOPE(oldsave);
1936 if (CALLREGEXEC(aTHX_ rx, s, strend, orig, 0, TARG, NULL,
1937 r_flags | REXEC_CHECKED))
1939 if (force_on_match) {
1941 s = SvPV_force(TARG, len);
1944 rxtainted |= RX_MATCH_TAINTED(rx);
1945 dstr = NEWSV(25, len);
1946 sv_setpvn(dstr, m, s-m);
1949 register PERL_CONTEXT *cx;
1952 RETURNOP(cPMOP->op_pmreplroot);
1954 r_flags |= REXEC_IGNOREPOS | REXEC_NOT_FIRST;
1956 if (iters++ > maxiters)
1957 DIE(aTHX_ "Substitution loop");
1958 rxtainted |= RX_MATCH_TAINTED(rx);
1959 if (RX_MATCH_COPIED(rx) && rx->subbeg != orig) {
1964 strend = s + (strend - m);
1966 m = rx->startp[0] + orig;
1967 sv_catpvn(dstr, s, m-s);
1968 s = rx->endp[0] + orig;
1970 sv_catpvn(dstr, c, clen);
1973 } while (CALLREGEXEC(aTHX_ rx, s, strend, orig, s == m, TARG, NULL, r_flags));
1974 sv_catpvn(dstr, s, strend - s);
1976 (void)SvOOK_off(TARG);
1977 Safefree(SvPVX(TARG));
1978 SvPVX(TARG) = SvPVX(dstr);
1979 SvCUR_set(TARG, SvCUR(dstr));
1980 SvLEN_set(TARG, SvLEN(dstr));
1984 TAINT_IF(rxtainted & 1);
1986 PUSHs(sv_2mortal(newSViv((I32)iters)));
1988 (void)SvPOK_only(TARG);
1989 TAINT_IF(rxtainted);
1992 LEAVE_SCOPE(oldsave);
2001 LEAVE_SCOPE(oldsave);
2010 PL_stack_base[PL_markstack_ptr[-1]++] = PL_stack_base[*PL_markstack_ptr];
2011 ++*PL_markstack_ptr;
2012 LEAVE; /* exit inner scope */
2015 if (PL_stack_base + *PL_markstack_ptr > SP) {
2017 I32 gimme = GIMME_V;
2019 LEAVE; /* exit outer scope */
2020 (void)POPMARK; /* pop src */
2021 items = --*PL_markstack_ptr - PL_markstack_ptr[-1];
2022 (void)POPMARK; /* pop dst */
2023 SP = PL_stack_base + POPMARK; /* pop original mark */
2024 if (gimme == G_SCALAR) {
2028 else if (gimme == G_ARRAY)
2035 ENTER; /* enter inner scope */
2038 src = PL_stack_base[*PL_markstack_ptr];
2042 RETURNOP(cLOGOP->op_other);
2053 register PERL_CONTEXT *cx;
2059 if (gimme == G_SCALAR) {
2062 if (cx->blk_sub.cv && CvDEPTH(cx->blk_sub.cv) > 1) {
2064 *MARK = SvREFCNT_inc(TOPs);
2069 sv = SvREFCNT_inc(TOPs); /* FREETMPS could clobber it */
2071 *MARK = sv_mortalcopy(sv);
2076 *MARK = SvTEMP(TOPs) ? TOPs : sv_mortalcopy(TOPs);
2080 *MARK = &PL_sv_undef;
2084 else if (gimme == G_ARRAY) {
2085 for (MARK = newsp + 1; MARK <= SP; MARK++) {
2086 if (!SvTEMP(*MARK)) {
2087 *MARK = sv_mortalcopy(*MARK);
2088 TAINT_NOT; /* Each item is independent */
2094 POPSUB(cx,sv); /* Stack values are safe: release CV and @_ ... */
2095 PL_curpm = newpm; /* ... and pop $1 et al */
2099 return pop_return();
2102 /* This duplicates the above code because the above code must not
2103 * get any slower by more conditions */
2111 register PERL_CONTEXT *cx;
2118 if (cx->blk_sub.lval & OPpENTERSUB_INARGS) {
2119 /* We are an argument to a function or grep().
2120 * This kind of lvalueness was legal before lvalue
2121 * subroutines too, so be backward compatible:
2122 * cannot report errors. */
2124 /* Scalar context *is* possible, on the LHS of -> only,
2125 * as in f()->meth(). But this is not an lvalue. */
2126 if (gimme == G_SCALAR)
2128 if (gimme == G_ARRAY) {
2129 if (!CvLVALUE(cx->blk_sub.cv))
2130 goto temporise_array;
2131 EXTEND_MORTAL(SP - newsp);
2132 for (mark = newsp + 1; mark <= SP; mark++) {
2135 else if (SvFLAGS(*mark) & (SVs_PADTMP | SVf_READONLY))
2136 *mark = sv_mortalcopy(*mark);
2138 /* Can be a localized value subject to deletion. */
2139 PL_tmps_stack[++PL_tmps_ix] = *mark;
2140 (void)SvREFCNT_inc(*mark);
2145 else if (cx->blk_sub.lval) { /* Leave it as it is if we can. */
2146 /* Here we go for robustness, not for speed, so we change all
2147 * the refcounts so the caller gets a live guy. Cannot set
2148 * TEMP, so sv_2mortal is out of question. */
2149 if (!CvLVALUE(cx->blk_sub.cv)) {
2154 DIE(aTHX_ "Can't modify non-lvalue subroutine call");
2156 if (gimme == G_SCALAR) {
2160 if (SvFLAGS(TOPs) & (SVs_TEMP | SVs_PADTMP | SVf_READONLY)) {
2165 DIE(aTHX_ "Can't return a %s from lvalue subroutine",
2166 SvREADONLY(TOPs) ? "readonly value" : "temporary");
2168 else { /* Can be a localized value
2169 * subject to deletion. */
2170 PL_tmps_stack[++PL_tmps_ix] = *mark;
2171 (void)SvREFCNT_inc(*mark);
2174 else { /* Should not happen? */
2179 DIE(aTHX_ "%s returned from lvalue subroutine in scalar context",
2180 (MARK > SP ? "Empty array" : "Array"));
2184 else if (gimme == G_ARRAY) {
2185 EXTEND_MORTAL(SP - newsp);
2186 for (mark = newsp + 1; mark <= SP; mark++) {
2187 if (SvFLAGS(*mark) & (SVs_TEMP | SVs_PADTMP | SVf_READONLY)) {
2188 /* Might be flattened array after $#array = */
2194 DIE(aTHX_ "Can't return %s from lvalue subroutine",
2195 (*mark != &PL_sv_undef)
2197 ? "a readonly value" : "a temporary")
2198 : "an uninitialized value");
2201 /* Can be a localized value subject to deletion. */
2202 PL_tmps_stack[++PL_tmps_ix] = *mark;
2203 (void)SvREFCNT_inc(*mark);
2209 if (gimme == G_SCALAR) {
2213 if (cx->blk_sub.cv && CvDEPTH(cx->blk_sub.cv) > 1) {
2215 *MARK = SvREFCNT_inc(TOPs);
2220 sv = SvREFCNT_inc(TOPs); /* FREETMPS could clobber it */
2222 *MARK = sv_mortalcopy(sv);
2227 *MARK = SvTEMP(TOPs) ? TOPs : sv_mortalcopy(TOPs);
2231 *MARK = &PL_sv_undef;
2235 else if (gimme == G_ARRAY) {
2237 for (MARK = newsp + 1; MARK <= SP; MARK++) {
2238 if (!SvTEMP(*MARK)) {
2239 *MARK = sv_mortalcopy(*MARK);
2240 TAINT_NOT; /* Each item is independent */
2247 POPSUB(cx,sv); /* Stack values are safe: release CV and @_ ... */
2248 PL_curpm = newpm; /* ... and pop $1 et al */
2252 return pop_return();
2257 S_get_db_sub(pTHX_ SV **svp, CV *cv)
2260 SV *dbsv = GvSV(PL_DBsub);
2262 if (!PERLDB_SUB_NN) {
2266 if ( (CvFLAGS(cv) & (CVf_ANON | CVf_CLONED))
2267 || strEQ(GvNAME(gv), "END")
2268 || ((GvCV(gv) != cv) && /* Could be imported, and old sub redefined. */
2269 !( (SvTYPE(*svp) == SVt_PVGV) && (GvCV((GV*)*svp) == cv)
2270 && (gv = (GV*)*svp) ))) {
2271 /* Use GV from the stack as a fallback. */
2272 /* GV is potentially non-unique, or contain different CV. */
2273 SV *tmp = newRV((SV*)cv);
2274 sv_setsv(dbsv, tmp);
2278 gv_efullname3(dbsv, gv, Nullch);
2282 (void)SvUPGRADE(dbsv, SVt_PVIV);
2283 (void)SvIOK_on(dbsv);
2284 SAVEIV(SvIVX(dbsv));
2285 SvIVX(dbsv) = PTR2IV(cv); /* Do it the quickest way */
2289 PL_curcopdb = PL_curcop;
2290 cv = GvCV(PL_DBsub);
2300 register PERL_CONTEXT *cx;
2302 bool hasargs = (PL_op->op_flags & OPf_STACKED) != 0;
2305 DIE(aTHX_ "Not a CODE reference");
2306 switch (SvTYPE(sv)) {
2312 if (sv == &PL_sv_yes) { /* unfound import, ignore */
2314 SP = PL_stack_base + POPMARK;
2317 if (SvGMAGICAL(sv)) {
2319 sym = SvPOKp(sv) ? SvPVX(sv) : Nullch;
2322 sym = SvPV(sv, n_a);
2324 DIE(aTHX_ PL_no_usym, "a subroutine");
2325 if (PL_op->op_private & HINT_STRICT_REFS)
2326 DIE(aTHX_ PL_no_symref, sym, "a subroutine");
2327 cv = get_cv(sym, TRUE);
2331 SV **sp = &sv; /* Used in tryAMAGICunDEREF macro. */
2332 tryAMAGICunDEREF(to_cv);
2335 if (SvTYPE(cv) == SVt_PVCV)
2340 DIE(aTHX_ "Not a CODE reference");
2345 if (!(cv = GvCVu((GV*)sv)))
2346 cv = sv_2cv(sv, &stash, &gv, FALSE);
2359 if (!CvROOT(cv) && !CvXSUB(cv)) {
2363 /* anonymous or undef'd function leaves us no recourse */
2364 if (CvANON(cv) || !(gv = CvGV(cv)))
2365 DIE(aTHX_ "Undefined subroutine called");
2367 /* autoloaded stub? */
2368 if (cv != GvCV(gv)) {
2371 /* should call AUTOLOAD now? */
2374 if ((autogv = gv_autoload4(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv),
2381 sub_name = sv_newmortal();
2382 gv_efullname3(sub_name, gv, Nullch);
2383 DIE(aTHX_ "Undefined subroutine &%s called", SvPVX(sub_name));
2387 DIE(aTHX_ "Not a CODE reference");
2392 if ((PL_op->op_private & OPpENTERSUB_DB) && GvCV(PL_DBsub) && !CvNODEBUG(cv)) {
2393 cv = get_db_sub(&sv, cv);
2395 DIE(aTHX_ "No DBsub routine");
2400 * First we need to check if the sub or method requires locking.
2401 * If so, we gain a lock on the CV, the first argument or the
2402 * stash (for static methods), as appropriate. This has to be
2403 * inline because for FAKE_THREADS, COND_WAIT inlines code to
2404 * reschedule by returning a new op.
2406 MUTEX_LOCK(CvMUTEXP(cv));
2407 if (CvFLAGS(cv) & CVf_LOCKED) {
2409 if (CvFLAGS(cv) & CVf_METHOD) {
2410 if (SP > PL_stack_base + TOPMARK)
2411 sv = *(PL_stack_base + TOPMARK + 1);
2413 AV *av = (AV*)PL_curpad[0];
2414 if (hasargs || !av || AvFILLp(av) < 0
2415 || !(sv = AvARRAY(av)[0]))
2417 MUTEX_UNLOCK(CvMUTEXP(cv));
2418 DIE(aTHX_ "no argument for locked method call");
2425 char *stashname = SvPV(sv, len);
2426 sv = (SV*)gv_stashpvn(stashname, len, TRUE);
2432 MUTEX_UNLOCK(CvMUTEXP(cv));
2433 mg = condpair_magic(sv);
2434 MUTEX_LOCK(MgMUTEXP(mg));
2435 if (MgOWNER(mg) == thr)
2436 MUTEX_UNLOCK(MgMUTEXP(mg));
2439 COND_WAIT(MgOWNERCONDP(mg), MgMUTEXP(mg));
2441 DEBUG_S(PerlIO_printf(Perl_debug_log, "%p: pp_entersub lock %p\n",
2443 MUTEX_UNLOCK(MgMUTEXP(mg));
2444 SAVEDESTRUCTOR_X(Perl_unlock_condpair, sv);
2446 MUTEX_LOCK(CvMUTEXP(cv));
2449 * Now we have permission to enter the sub, we must distinguish
2450 * four cases. (0) It's an XSUB (in which case we don't care
2451 * about ownership); (1) it's ours already (and we're recursing);
2452 * (2) it's free (but we may already be using a cached clone);
2453 * (3) another thread owns it. Case (1) is easy: we just use it.
2454 * Case (2) means we look for a clone--if we have one, use it
2455 * otherwise grab ownership of cv. Case (3) means we look for a
2456 * clone (for non-XSUBs) and have to create one if we don't
2458 * Why look for a clone in case (2) when we could just grab
2459 * ownership of cv straight away? Well, we could be recursing,
2460 * i.e. we originally tried to enter cv while another thread
2461 * owned it (hence we used a clone) but it has been freed up
2462 * and we're now recursing into it. It may or may not be "better"
2463 * to use the clone but at least CvDEPTH can be trusted.
2465 if (CvOWNER(cv) == thr || CvXSUB(cv))
2466 MUTEX_UNLOCK(CvMUTEXP(cv));
2468 /* Case (2) or (3) */
2472 * XXX Might it be better to release CvMUTEXP(cv) while we
2473 * do the hv_fetch? We might find someone has pinched it
2474 * when we look again, in which case we would be in case
2475 * (3) instead of (2) so we'd have to clone. Would the fact
2476 * that we released the mutex more quickly make up for this?
2478 if ((svp = hv_fetch(thr->cvcache, (char *)cv, sizeof(cv), FALSE)))
2480 /* We already have a clone to use */
2481 MUTEX_UNLOCK(CvMUTEXP(cv));
2483 DEBUG_S(PerlIO_printf(Perl_debug_log,
2484 "entersub: %p already has clone %p:%s\n",
2485 thr, cv, SvPEEK((SV*)cv)));
2488 if (CvDEPTH(cv) == 0)
2489 SAVEDESTRUCTOR_X(unset_cvowner, (void*) cv);
2492 /* (2) => grab ownership of cv. (3) => make clone */
2496 MUTEX_UNLOCK(CvMUTEXP(cv));
2497 DEBUG_S(PerlIO_printf(Perl_debug_log,
2498 "entersub: %p grabbing %p:%s in stash %s\n",
2499 thr, cv, SvPEEK((SV*)cv), CvSTASH(cv) ?
2500 HvNAME(CvSTASH(cv)) : "(none)"));
2503 /* Make a new clone. */
2505 SvREFCNT_inc(cv); /* don't let it vanish from under us */
2506 MUTEX_UNLOCK(CvMUTEXP(cv));
2507 DEBUG_S((PerlIO_printf(Perl_debug_log,
2508 "entersub: %p cloning %p:%s\n",
2509 thr, cv, SvPEEK((SV*)cv))));
2511 * We're creating a new clone so there's no race
2512 * between the original MUTEX_UNLOCK and the
2513 * SvREFCNT_inc since no one will be trying to undef
2514 * it out from underneath us. At least, I don't think
2517 clonecv = cv_clone(cv);
2518 SvREFCNT_dec(cv); /* finished with this */
2519 hv_store(thr->cvcache, (char*)cv, sizeof(cv), (SV*)clonecv,0);
2520 CvOWNER(clonecv) = thr;
2524 DEBUG_S(if (CvDEPTH(cv) != 0)
2525 PerlIO_printf(Perl_debug_log, "depth %ld != 0\n",
2527 SAVEDESTRUCTOR_X(unset_cvowner, (void*) cv);
2530 #endif /* USE_THREADS */
2533 #ifdef PERL_XSUB_OLDSTYLE
2534 if (CvOLDSTYLE(cv)) {
2535 I32 (*fp3)(int,int,int);
2537 register I32 items = SP - MARK;
2538 /* We dont worry to copy from @_. */
2543 PL_stack_sp = mark + 1;
2544 fp3 = (I32(*)(int,int,int))CvXSUB(cv);
2545 items = (*fp3)(CvXSUBANY(cv).any_i32,
2546 MARK - PL_stack_base + 1,
2548 PL_stack_sp = PL_stack_base + items;
2551 #endif /* PERL_XSUB_OLDSTYLE */
2553 I32 markix = TOPMARK;
2558 /* Need to copy @_ to stack. Alternative may be to
2559 * switch stack to @_, and copy return values
2560 * back. This would allow popping @_ in XSUB, e.g.. XXXX */
2564 av = (AV*)PL_curpad[0];
2566 av = GvAV(PL_defgv);
2567 #endif /* USE_THREADS */
2568 items = AvFILLp(av) + 1; /* @_ is not tieable */
2571 /* Mark is at the end of the stack. */
2573 Copy(AvARRAY(av), SP + 1, items, SV*);
2578 /* We assume first XSUB in &DB::sub is the called one. */
2580 SAVEVPTR(PL_curcop);
2581 PL_curcop = PL_curcopdb;
2584 /* Do we need to open block here? XXXX */
2585 (void)(*CvXSUB(cv))(aTHXo_ cv);
2587 /* Enforce some sanity in scalar context. */
2588 if (gimme == G_SCALAR && ++markix != PL_stack_sp - PL_stack_base ) {
2589 if (markix > PL_stack_sp - PL_stack_base)
2590 *(PL_stack_base + markix) = &PL_sv_undef;
2592 *(PL_stack_base + markix) = *PL_stack_sp;
2593 PL_stack_sp = PL_stack_base + markix;
2601 register I32 items = SP - MARK;
2602 AV* padlist = CvPADLIST(cv);
2603 SV** svp = AvARRAY(padlist);
2604 push_return(PL_op->op_next);
2605 PUSHBLOCK(cx, CXt_SUB, MARK);
2608 /* XXX This would be a natural place to set C<PL_compcv = cv> so
2609 * that eval'' ops within this sub know the correct lexical space.
2610 * Owing the speed considerations, we choose to search for the cv
2611 * in doeval() instead.
2613 if (CvDEPTH(cv) < 2)
2614 (void)SvREFCNT_inc(cv);
2615 else { /* save temporaries on recursion? */
2616 PERL_STACK_OVERFLOW_CHECK();
2617 if (CvDEPTH(cv) > AvFILLp(padlist)) {
2619 AV *newpad = newAV();
2620 SV **oldpad = AvARRAY(svp[CvDEPTH(cv)-1]);
2621 I32 ix = AvFILLp((AV*)svp[1]);
2622 I32 names_fill = AvFILLp((AV*)svp[0]);
2623 svp = AvARRAY(svp[0]);
2624 for ( ;ix > 0; ix--) {
2625 if (names_fill >= ix && svp[ix] != &PL_sv_undef) {
2626 char *name = SvPVX(svp[ix]);
2627 if ((SvFLAGS(svp[ix]) & SVf_FAKE) /* outer lexical? */
2628 || *name == '&') /* anonymous code? */
2630 av_store(newpad, ix, SvREFCNT_inc(oldpad[ix]));
2632 else { /* our own lexical */
2634 av_store(newpad, ix, sv = (SV*)newAV());
2635 else if (*name == '%')
2636 av_store(newpad, ix, sv = (SV*)newHV());
2638 av_store(newpad, ix, sv = NEWSV(0,0));
2642 else if (IS_PADGV(oldpad[ix]) || IS_PADCONST(oldpad[ix])) {
2643 av_store(newpad, ix, sv = SvREFCNT_inc(oldpad[ix]));
2646 av_store(newpad, ix, sv = NEWSV(0,0));
2650 av = newAV(); /* will be @_ */
2652 av_store(newpad, 0, (SV*)av);
2653 AvFLAGS(av) = AVf_REIFY;
2654 av_store(padlist, CvDEPTH(cv), (SV*)newpad);
2655 AvFILLp(padlist) = CvDEPTH(cv);
2656 svp = AvARRAY(padlist);
2661 AV* av = (AV*)PL_curpad[0];
2663 items = AvFILLp(av) + 1;
2665 /* Mark is at the end of the stack. */
2667 Copy(AvARRAY(av), SP + 1, items, SV*);
2672 #endif /* USE_THREADS */
2673 SAVEVPTR(PL_curpad);
2674 PL_curpad = AvARRAY((AV*)svp[CvDEPTH(cv)]);
2677 #endif /* USE_THREADS */
2683 DEBUG_S(PerlIO_printf(Perl_debug_log,
2684 "%p entersub preparing @_\n", thr));
2686 av = (AV*)PL_curpad[0];
2688 /* @_ is normally not REAL--this should only ever
2689 * happen when DB::sub() calls things that modify @_ */
2695 cx->blk_sub.savearray = GvAV(PL_defgv);
2696 GvAV(PL_defgv) = (AV*)SvREFCNT_inc(av);
2697 #endif /* USE_THREADS */
2698 cx->blk_sub.oldcurpad = PL_curpad;
2699 cx->blk_sub.argarray = av;
2702 if (items > AvMAX(av) + 1) {
2704 if (AvARRAY(av) != ary) {
2705 AvMAX(av) += AvARRAY(av) - AvALLOC(av);
2706 SvPVX(av) = (char*)ary;
2708 if (items > AvMAX(av) + 1) {
2709 AvMAX(av) = items - 1;
2710 Renew(ary,items,SV*);
2712 SvPVX(av) = (char*)ary;
2715 Copy(MARK,AvARRAY(av),items,SV*);
2716 AvFILLp(av) = items - 1;
2724 /* warning must come *after* we fully set up the context
2725 * stuff so that __WARN__ handlers can safely dounwind()
2728 if (CvDEPTH(cv) == 100 && ckWARN(WARN_RECURSION)
2729 && !(PERLDB_SUB && cv == GvCV(PL_DBsub)))
2730 sub_crush_depth(cv);
2732 DEBUG_S(PerlIO_printf(Perl_debug_log,
2733 "%p entersub returning %p\n", thr, CvSTART(cv)));
2735 RETURNOP(CvSTART(cv));
2740 Perl_sub_crush_depth(pTHX_ CV *cv)
2743 Perl_warner(aTHX_ WARN_RECURSION, "Deep recursion on anonymous subroutine");
2745 SV* tmpstr = sv_newmortal();
2746 gv_efullname3(tmpstr, CvGV(cv), Nullch);
2747 Perl_warner(aTHX_ WARN_RECURSION, "Deep recursion on subroutine \"%s\"",
2758 U32 lval = PL_op->op_flags & OPf_MOD;
2759 U32 defer = (PL_op->op_private & OPpLVAL_DEFER) && (elem > AvFILL(av));
2763 elem -= PL_curcop->cop_arybase;
2764 if (SvTYPE(av) != SVt_PVAV)
2766 svp = av_fetch(av, elem, lval && !defer);
2768 if (!svp || *svp == &PL_sv_undef) {
2771 DIE(aTHX_ PL_no_aelem, elem);
2772 lv = sv_newmortal();
2773 sv_upgrade(lv, SVt_PVLV);
2775 sv_magic(lv, Nullsv, 'y', Nullch, 0);
2776 LvTARG(lv) = SvREFCNT_inc(av);
2777 LvTARGOFF(lv) = elem;
2782 if (PL_op->op_private & OPpLVAL_INTRO)
2783 save_aelem(av, elem, svp);
2784 else if (PL_op->op_private & OPpDEREF)
2785 vivify_ref(*svp, PL_op->op_private & OPpDEREF);
2787 sv = (svp ? *svp : &PL_sv_undef);
2788 if (!lval && SvGMAGICAL(sv)) /* see note in pp_helem() */
2789 sv = sv_mortalcopy(sv);
2795 Perl_vivify_ref(pTHX_ SV *sv, U32 to_what)
2801 Perl_croak(aTHX_ PL_no_modify);
2802 if (SvTYPE(sv) < SVt_RV)
2803 sv_upgrade(sv, SVt_RV);
2804 else if (SvTYPE(sv) >= SVt_PV) {
2805 (void)SvOOK_off(sv);
2806 Safefree(SvPVX(sv));
2807 SvLEN(sv) = SvCUR(sv) = 0;
2811 SvRV(sv) = NEWSV(355,0);
2814 SvRV(sv) = (SV*)newAV();
2817 SvRV(sv) = (SV*)newHV();
2832 if (SvTYPE(rsv) == SVt_PVCV) {
2838 SETs(method_common(sv, Null(U32*)));
2845 SV* sv = cSVOP->op_sv;
2846 U32 hash = SvUVX(sv);
2848 XPUSHs(method_common(sv, &hash));
2853 S_method_common(pTHX_ SV* meth, U32* hashp)
2864 name = SvPV(meth, namelen);
2865 sv = *(PL_stack_base + TOPMARK + 1);
2876 !(packname = SvPV(sv, packlen)) ||
2877 !(iogv = gv_fetchpv(packname, FALSE, SVt_PVIO)) ||
2878 !(ob=(SV*)GvIO(iogv)))
2881 ((*(U8*)packname >= 0xc0 && DO_UTF8(sv))
2882 ? !isIDFIRST_utf8((U8*)packname)
2883 : !isIDFIRST(*packname)
2886 Perl_croak(aTHX_ "Can't call method \"%s\" %s", name,
2887 SvOK(sv) ? "without a package or object reference"
2888 : "on an undefined value");
2890 stash = gv_stashpvn(packname, packlen, TRUE);
2893 *(PL_stack_base + TOPMARK + 1) = sv_2mortal(newRV((SV*)iogv));
2896 if (!ob || !(SvOBJECT(ob)
2897 || (SvTYPE(ob) == SVt_PVGV && (ob = (SV*)GvIO((GV*)ob))
2900 Perl_croak(aTHX_ "Can't call method \"%s\" on unblessed reference",
2904 stash = SvSTASH(ob);
2907 /* shortcut for simple names */
2909 HE* he = hv_fetch_ent(stash, meth, 0, *hashp);
2911 gv = (GV*)HeVAL(he);
2912 if (isGV(gv) && GvCV(gv) &&
2913 (!GvCVGEN(gv) || GvCVGEN(gv) == PL_sub_generation))
2914 return (SV*)GvCV(gv);
2918 gv = gv_fetchmethod(stash, name);
2925 for (p = name; *p; p++) {
2927 sep = p, leaf = p + 1;
2928 else if (*p == ':' && *(p + 1) == ':')
2929 sep = p, leaf = p + 2;
2931 if (!sep || ((sep - name) == 5 && strnEQ(name, "SUPER", 5))) {
2932 packname = sep ? CopSTASHPV(PL_curcop) : HvNAME(stash);
2933 packlen = strlen(packname);
2937 packlen = sep - name;
2939 gv = gv_fetchpv(packname, 0, SVt_PVHV);
2940 if (gv && isGV(gv)) {
2942 "Can't locate object method \"%s\" via package \"%s\"",
2947 "Can't locate object method \"%s\" via package \"%s\""
2948 " (perhaps you forgot to load \"%s\"?)",
2949 leaf, packname, packname);
2952 return isGV(gv) ? (SV*)GvCV(gv) : (SV*)gv;
2957 unset_cvowner(pTHXo_ void *cvarg)
2959 register CV* cv = (CV *) cvarg;
2962 #endif /* DEBUGGING */
2964 DEBUG_S((PerlIO_printf(Perl_debug_log, "%p unsetting CvOWNER of %p:%s\n",
2965 thr, cv, SvPEEK((SV*)cv))));
2966 MUTEX_LOCK(CvMUTEXP(cv));
2967 DEBUG_S(if (CvDEPTH(cv) != 0)
2968 PerlIO_printf(Perl_debug_log, "depth %ld != 0\n",
2970 assert(thr == CvOWNER(cv));
2972 MUTEX_UNLOCK(CvMUTEXP(cv));
2975 #endif /* USE_THREADS */