X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pp_hot.c;h=75bdb4fa98abc18d0033344ebca8b4d684bc0229;hb=9f6ab4074f86da83f9650997df3135d1f2daf062;hp=99e45d180e4e175060b11576d1f55aae7fc38af8;hpb=3280af22f58e7b37514ed104858e2c2fc55ceeeb;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pp_hot.c b/pp_hot.c index 99e45d1..75bdb4f 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -21,6 +21,14 @@ #ifdef I_UNISTD #include #endif +#ifdef I_FCNTL +#include +#endif +#ifdef I_SYS_FILE +#include +#endif + +#define HOP(pos,off) (IN_UTF8 ? utf8_hop(pos, off) : (pos + off)) /* Hot code. */ @@ -33,10 +41,10 @@ unset_cvowner(void *cvarg) dTHR; #endif /* DEBUGGING */ - DEBUG_L((PerlIO_printf(PerlIO_stderr(), "%p unsetting CvOWNER of %p:%s\n", + DEBUG_S((PerlIO_printf(PerlIO_stderr(), "%p unsetting CvOWNER of %p:%s\n", thr, cv, SvPEEK((SV*)cv)))); MUTEX_LOCK(CvMUTEXP(cv)); - DEBUG_L(if (CvDEPTH(cv) != 0) + DEBUG_S(if (CvDEPTH(cv) != 0) PerlIO_printf(PerlIO_stderr(), "depth %ld != 0\n", CvDEPTH(cv));); assert(thr == CvOWNER(cv)); @@ -55,7 +63,7 @@ PP(pp_const) PP(pp_nextstate) { - PL_curcop = (COP*)op; + PL_curcop = (COP*)PL_op; TAINT_NOT; /* Each statement is presumed innocent */ PL_stack_sp = PL_stack_base + cxstack[cxstack_ix].blk_oldsp; FREETMPS; @@ -66,7 +74,7 @@ PP(pp_gvsv) { djSP; EXTEND(SP,1); - if (op->op_private & OPpLVAL_INTRO) + if (PL_op->op_private & OPpLVAL_INTRO) PUSHs(save_scalar(cGVOP->op_gv)); else PUSHs(GvSV(cGVOP->op_gv)); @@ -118,7 +126,7 @@ PP(pp_sassign) djSP; dPOPTOPssrl; MAGIC *mg; - if (op->op_private & OPpASSIGN_BACKWARDS) { + if (PL_op->op_private & OPpASSIGN_BACKWARDS) { SV *temp; temp = left; left = right; right = temp; } @@ -180,12 +188,12 @@ PP(pp_padsv) { djSP; dTARGET; XPUSHs(TARG); - if (op->op_flags & OPf_MOD) { - if (op->op_private & OPpLVAL_INTRO) - SAVECLEARSV(PL_curpad[op->op_targ]); - else if (op->op_private & OPpDEREF) { + if (PL_op->op_flags & OPf_MOD) { + if (PL_op->op_private & OPpLVAL_INTRO) + SAVECLEARSV(PL_curpad[PL_op->op_targ]); + else if (PL_op->op_private & OPpDEREF) { PUTBACK; - vivify_ref(PL_curpad[op->op_targ], op->op_private & OPpDEREF); + vivify_ref(PL_curpad[PL_op->op_targ], PL_op->op_private & OPpDEREF); SPAGAIN; } } @@ -250,8 +258,8 @@ PP(pp_aelemfast) { djSP; AV *av = GvAV((GV*)cSVOP->op_sv); - U32 lval = op->op_flags & OPf_MOD; - SV** svp = av_fetch(av, op->op_private, lval); + U32 lval = PL_op->op_flags & OPf_MOD; + SV** svp = av_fetch(av, PL_op->op_private, lval); SV *sv = (svp ? *svp : &PL_sv_undef); EXTEND(SP, 1); if (!lval && SvGMAGICAL(sv)) /* see note in pp_helem() */ @@ -281,10 +289,10 @@ PP(pp_pushre) SV* sv = sv_newmortal(); sv_upgrade(sv, SVt_PVLV); LvTYPE(sv) = '/'; - Copy(&op, &LvTARGOFF(sv), 1, OP*); + Copy(&PL_op, &LvTARGOFF(sv), 1, OP*); XPUSHs(sv); #else - XPUSHs((SV*)op); + XPUSHs((SV*)PL_op); #endif RETURN; } @@ -299,7 +307,7 @@ PP(pp_print) register PerlIO *fp; MAGIC *mg; - if (op->op_flags & OPf_STACKED) + if (PL_op->op_flags & OPf_STACKED) gv = (GV*)*++MARK; else gv = PL_defoutgv; @@ -326,23 +334,25 @@ PP(pp_print) RETURN; } if (!(io = GvIO(gv))) { - if (PL_dowarn) { + if (ckWARN(WARN_UNOPENED)) { SV* sv = sv_newmortal(); gv_fullname3(sv, gv, Nullch); - warn("Filehandle %s never opened", SvPV(sv,PL_na)); + warner(WARN_UNOPENED, "Filehandle %s never opened", SvPV(sv,PL_na)); } SETERRNO(EBADF,RMS$_IFI); goto just_say_no; } else if (!(fp = IoOFP(io))) { - if (PL_dowarn) { + if (ckWARN2(WARN_CLOSED, WARN_IO)) { SV* sv = sv_newmortal(); gv_fullname3(sv, gv, Nullch); if (IoIFP(io)) - warn("Filehandle %s opened only for input", SvPV(sv,PL_na)); - else - warn("print on closed filehandle %s", SvPV(sv,PL_na)); + warner(WARN_IO, "Filehandle %s opened only for input", + SvPV(sv,PL_na)); + else if (ckWARN(WARN_CLOSED)) + warner(WARN_CLOSED, "print on closed filehandle %s", + SvPV(sv,PL_na)); } SETERRNO(EBADF,IoIFP(io)?RMS$_FAC:RMS$_IFI); goto just_say_no; @@ -401,7 +411,7 @@ PP(pp_rv2av) av = (AV*)SvRV(sv); if (SvTYPE(av) != SVt_PVAV) DIE("Not an ARRAY reference"); - if (op->op_flags & OPf_REF) { + if (PL_op->op_flags & OPf_REF) { PUSHs((SV*)av); RETURN; } @@ -409,7 +419,7 @@ PP(pp_rv2av) else { if (SvTYPE(sv) == SVt_PVAV) { av = (AV*)sv; - if (op->op_flags & OPf_REF) { + if (PL_op->op_flags & OPf_REF) { PUSHs((SV*)av); RETURN; } @@ -426,26 +436,26 @@ PP(pp_rv2av) goto wasref; } if (!SvOK(sv)) { - if (op->op_flags & OPf_REF || - op->op_private & HINT_STRICT_REFS) + if (PL_op->op_flags & OPf_REF || + PL_op->op_private & HINT_STRICT_REFS) DIE(no_usym, "an ARRAY"); - if (PL_dowarn) - warn(warn_uninit); + if (ckWARN(WARN_UNINITIALIZED)) + warner(WARN_UNINITIALIZED, warn_uninit); if (GIMME == G_ARRAY) RETURN; RETPUSHUNDEF; } sym = SvPV(sv,PL_na); - if (op->op_private & HINT_STRICT_REFS) + if (PL_op->op_private & HINT_STRICT_REFS) DIE(no_symref, sym, "an ARRAY"); gv = (GV*)gv_fetchpv(sym, TRUE, SVt_PVAV); } else { gv = (GV*)sv; } av = GvAVn(gv); - if (op->op_private & OPpLVAL_INTRO) + if (PL_op->op_private & OPpLVAL_INTRO) av = save_ary(gv); - if (op->op_flags & OPf_REF) { + if (PL_op->op_flags & OPf_REF) { PUSHs((SV*)av); RETURN; } @@ -485,7 +495,7 @@ PP(pp_rv2hv) hv = (HV*)SvRV(sv); if (SvTYPE(hv) != SVt_PVHV && SvTYPE(hv) != SVt_PVAV) DIE("Not a HASH reference"); - if (op->op_flags & OPf_REF) { + if (PL_op->op_flags & OPf_REF) { SETs((SV*)hv); RETURN; } @@ -493,7 +503,7 @@ PP(pp_rv2hv) else { if (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV) { hv = (HV*)sv; - if (op->op_flags & OPf_REF) { + if (PL_op->op_flags & OPf_REF) { SETs((SV*)hv); RETURN; } @@ -510,11 +520,11 @@ PP(pp_rv2hv) goto wasref; } if (!SvOK(sv)) { - if (op->op_flags & OPf_REF || - op->op_private & HINT_STRICT_REFS) + if (PL_op->op_flags & OPf_REF || + PL_op->op_private & HINT_STRICT_REFS) DIE(no_usym, "a HASH"); - if (PL_dowarn) - warn(warn_uninit); + if (ckWARN(WARN_UNINITIALIZED)) + warner(WARN_UNINITIALIZED, warn_uninit); if (GIMME == G_ARRAY) { SP--; RETURN; @@ -522,16 +532,16 @@ PP(pp_rv2hv) RETSETUNDEF; } sym = SvPV(sv,PL_na); - if (op->op_private & HINT_STRICT_REFS) + if (PL_op->op_private & HINT_STRICT_REFS) DIE(no_symref, sym, "a HASH"); gv = (GV*)gv_fetchpv(sym, TRUE, SVt_PVHV); } else { gv = (GV*)sv; } hv = GvHVn(gv); - if (op->op_private & OPpLVAL_INTRO) + if (PL_op->op_private & OPpLVAL_INTRO) hv = save_hash(gv); - if (op->op_flags & OPf_REF) { + if (PL_op->op_flags & OPf_REF) { SETs((SV*)hv); RETURN; } @@ -582,7 +592,7 @@ PP(pp_aassign) * special care that assigning the identifier on the left doesn't * clobber a value on the right that's used later in the list. */ - if (op->op_private & OPpASSIGN_COMMON) { + if (PL_op->op_private & OPpASSIGN_COMMON) { for (relem = firstrelem; relem <= lastrelem; relem++) { /*SUPPRESS 560*/ if (sv = *relem) { @@ -652,14 +662,14 @@ PP(pp_aassign) if (relem == lastrelem) { if (*relem) { HE *didstore; - if (PL_dowarn) { + if (ckWARN(WARN_UNSAFE)) { if (relem == firstrelem && SvROK(*relem) && ( SvTYPE(SvRV(*relem)) == SVt_PVAV || SvTYPE(SvRV(*relem)) == SVt_PVHV ) ) - warn("Reference found where even-sized list expected"); + warner(WARN_UNSAFE, "Reference found where even-sized list expected"); else - warn("Odd number of elements in hash assignment"); + warner(WARN_UNSAFE, "Odd number of elements in hash assignment"); } tmpstr = NEWSV(29,0); didstore = hv_store_ent(hash,*relem,tmpstr,0); @@ -700,27 +710,27 @@ PP(pp_aassign) if (PL_delaymagic & ~DM_DELAY) { if (PL_delaymagic & DM_UID) { #ifdef HAS_SETRESUID - (void)setresuid(uid,euid,(Uid_t)-1); + (void)setresuid(PL_uid,PL_euid,(Uid_t)-1); #else # ifdef HAS_SETREUID (void)setreuid(PL_uid,PL_euid); # else # ifdef HAS_SETRUID - if ((delaymagic & DM_UID) == DM_RUID) { - (void)setruid(uid); - delaymagic &= ~DM_RUID; + if ((PL_delaymagic & DM_UID) == DM_RUID) { + (void)setruid(PL_uid); + PL_delaymagic &= ~DM_RUID; } # endif /* HAS_SETRUID */ # ifdef HAS_SETEUID - if ((delaymagic & DM_UID) == DM_EUID) { - (void)seteuid(uid); - delaymagic &= ~DM_EUID; + if ((PL_delaymagic & DM_UID) == DM_EUID) { + (void)seteuid(PL_uid); + PL_delaymagic &= ~DM_EUID; } # endif /* HAS_SETEUID */ - if (delaymagic & DM_UID) { - if (uid != euid) + if (PL_delaymagic & DM_UID) { + if (PL_uid != PL_euid) DIE("No setreuid available"); - (void)PerlProc_setuid(uid); + (void)PerlProc_setuid(PL_uid); } # endif /* HAS_SETREUID */ #endif /* HAS_SETRESUID */ @@ -729,27 +739,27 @@ PP(pp_aassign) } if (PL_delaymagic & DM_GID) { #ifdef HAS_SETRESGID - (void)setresgid(gid,egid,(Gid_t)-1); + (void)setresgid(PL_gid,PL_egid,(Gid_t)-1); #else # ifdef HAS_SETREGID (void)setregid(PL_gid,PL_egid); # else # ifdef HAS_SETRGID - if ((delaymagic & DM_GID) == DM_RGID) { - (void)setrgid(gid); - delaymagic &= ~DM_RGID; + if ((PL_delaymagic & DM_GID) == DM_RGID) { + (void)setrgid(PL_gid); + PL_delaymagic &= ~DM_RGID; } # endif /* HAS_SETRGID */ # ifdef HAS_SETEGID - if ((delaymagic & DM_GID) == DM_EGID) { - (void)setegid(gid); - delaymagic &= ~DM_EGID; + if ((PL_delaymagic & DM_GID) == DM_EGID) { + (void)setegid(PL_gid); + PL_delaymagic &= ~DM_EGID; } # endif /* HAS_SETEGID */ - if (delaymagic & DM_GID) { - if (gid != egid) + if (PL_delaymagic & DM_GID) { + if (PL_gid != PL_egid) DIE("No setregid available"); - (void)PerlProc_setgid(gid); + (void)PerlProc_setgid(PL_gid); } # endif /* HAS_SETREGID */ #endif /* HAS_SETRESGID */ @@ -809,7 +819,7 @@ PP(pp_match) I32 update_minmatch = 1; SV *screamer; - if (op->op_flags & OPf_STACKED) + if (PL_op->op_flags & OPf_STACKED) TARG = POPs; else { TARG = DEFSV; @@ -853,8 +863,6 @@ PP(pp_match) } } } - if (!rx->nparens && !global) - gimme = G_SCALAR; /* accidental array context? */ safebase = (((gimme == G_ARRAY) || global || !rx->nparens) && !PL_sawampersand); safebase = safebase ? 0 : REXEC_COPY_STR ; @@ -875,17 +883,20 @@ play_it_again: if (!(rx->reganch & ROPT_NOSCAN)) { /* Floating checkstring. */ if ( screamer ) { I32 p = -1; + char *b; if (PL_screamfirst[BmRARE(rx->check_substr)] < 0) goto nope; - else if (!(s = screaminstr(TARG, rx->check_substr, - rx->check_offset_min, 0, &p, 0))) + + b = (char*)HOP((U8*)s, rx->check_offset_min); + if (!(s = screaminstr(TARG, rx->check_substr, b - s, 0, &p, 0))) goto nope; - else if ((rx->reganch & ROPT_CHECK_ALL) + + if ((rx->reganch & ROPT_CHECK_ALL) && !PL_sawampersand && !SvTAIL(rx->check_substr)) goto yup; } - else if (!(s = fbm_instr((unsigned char*)s + rx->check_offset_min, + else if (!(s = fbm_instr((unsigned char*)HOP((U8*)s, rx->check_offset_min), (unsigned char*)strend, rx->check_substr, 0))) goto nope; @@ -893,7 +904,7 @@ play_it_again: goto yup; if (s && rx->check_offset_max < s - t) { ++BmUSEFUL(rx->check_substr); - s -= rx->check_offset_max; + s = (char*)HOP((U8*)s, -rx->check_offset_max); } else s = t; @@ -902,13 +913,13 @@ play_it_again: beginning of match, and the match is anchored at s. */ else if (!PL_multiline) { /* Anchored near beginning of string. */ I32 slen; - if (*SvPVX(rx->check_substr) != s[rx->check_offset_min] + char *b = (char*)HOP((U8*)s, rx->check_offset_min); + if (*SvPVX(rx->check_substr) != *b || ((slen = SvCUR(rx->check_substr)) > 1 - && memNE(SvPVX(rx->check_substr), - s + rx->check_offset_min, slen))) + && memNE(SvPVX(rx->check_substr), b, slen))) goto nope; } - if (!rx->naughty && --BmUSEFUL(rx->check_substr) < 0 + if (!(rx->reganch & ROPT_NAUGHTY) && --BmUSEFUL(rx->check_substr) < 0 && rx->check_substr == rx->float_substr) { SvREFCNT_dec(rx->check_substr); rx->check_substr = Nullsv; /* opt is being useless */ @@ -958,6 +969,8 @@ play_it_again: PUTBACK; /* EVAL blocks may use stack */ goto play_it_again; } + else if (!iters) + XPUSHs(&PL_sv_yes); LEAVE_SCOPE(oldsave); RETURN; } @@ -1038,7 +1051,7 @@ do_readline(void) STRLEN offset; PerlIO *fp; register IO *io = GvIO(PL_last_in_gv); - register I32 type = op->op_type; + register I32 type = PL_op->op_type; I32 gimme = GIMME_V; MAGIC *mg; @@ -1063,7 +1076,7 @@ do_readline(void) IoFLAGS(io) &= ~IOf_START; IoLINES(io) = 0; if (av_len(GvAVn(PL_last_in_gv)) < 0) { - do_open(PL_last_in_gv,"-",1,FALSE,0,0,Nullfp); + do_open(PL_last_in_gv,"-",1,FALSE,O_RDONLY,0,Nullfp); sv_setpvn(GvSV(PL_last_in_gv), "-", 1); SvSETMAGIC(GvSV(PL_last_in_gv)); fp = IoIFP(io); @@ -1197,7 +1210,7 @@ do_readline(void) #endif /* !CSH */ #endif /* !DOSISH */ (void)do_open(PL_last_in_gv, SvPVX(tmpcmd), SvCUR(tmpcmd), - FALSE, 0, 0, Nullfp); + FALSE, O_RDONLY, 0, Nullfp); fp = IoIFP(io); #endif /* !VMS */ LEAVE; @@ -1207,8 +1220,9 @@ do_readline(void) SP--; } if (!fp) { - if (PL_dowarn && io && !(IoFLAGS(io) & IOf_START)) - warn("Read on closed filehandle <%s>", GvENAME(PL_last_in_gv)); + if (ckWARN(WARN_CLOSED) && io && !(IoFLAGS(io) & IOf_START)) + warner(WARN_CLOSED, + "Read on closed filehandle <%s>", GvENAME(PL_last_in_gv)); if (gimme == G_SCALAR) { (void)SvOK_off(TARG); PUSHTARG; @@ -1244,8 +1258,12 @@ do_readline(void) IoFLAGS(io) |= IOf_START; } else if (type == OP_GLOB) { - if (do_close(PL_last_in_gv, FALSE) & ~0xFF) - warn("internal error: glob failed"); + if (!do_close(PL_last_in_gv, FALSE) && ckWARN(WARN_CLOSED)) { + warner(WARN_CLOSED, + "glob failed (child exited with status %d%s)", + STATUS_CURRENT >> 8, + (STATUS_CURRENT & 0xFF) ? ", core dumped" : ""); + } } if (gimme == G_SCALAR) { (void)SvOK_off(TARG); @@ -1304,7 +1322,7 @@ PP(pp_enter) { djSP; register PERL_CONTEXT *cx; - I32 gimme = OP_GIMME(op, -1); + I32 gimme = OP_GIMME(PL_op, -1); if (gimme == -1) { if (cxstack_ix >= 0) @@ -1328,8 +1346,8 @@ PP(pp_helem) SV **svp; SV *keysv = POPs; HV *hv = (HV*)POPs; - U32 lval = op->op_flags & OPf_MOD; - U32 defer = op->op_private & OPpLVAL_DEFER; + U32 lval = PL_op->op_flags & OPf_MOD; + U32 defer = PL_op->op_private & OPpLVAL_DEFER; SV *sv; if (SvTYPE(hv) == SVt_PVHV) { @@ -1337,6 +1355,8 @@ PP(pp_helem) svp = he ? &HeVAL(he) : 0; } else if (SvTYPE(hv) == SVt_PVAV) { + if (PL_op->op_private & OPpLVAL_INTRO) + DIE("Can't localize pseudo-hash element"); svp = avhv_fetch_ent((AV*)hv, keysv, lval && !defer, 0); } else { @@ -1358,14 +1378,14 @@ PP(pp_helem) PUSHs(lv); RETURN; } - if (op->op_private & OPpLVAL_INTRO) { + if (PL_op->op_private & OPpLVAL_INTRO) { if (HvNAME(hv) && isGV(*svp)) - save_gp((GV*)*svp, !(op->op_flags & OPf_SPECIAL)); + save_gp((GV*)*svp, !(PL_op->op_flags & OPf_SPECIAL)); else save_helem(hv, keysv, svp); } - else if (op->op_private & OPpDEREF) - vivify_ref(*svp, op->op_private & OPpDEREF); + else if (PL_op->op_private & OPpDEREF) + vivify_ref(*svp, PL_op->op_private & OPpDEREF); } sv = (svp ? *svp : &PL_sv_undef); /* This makes C possible. @@ -1389,14 +1409,14 @@ PP(pp_leave) PMOP *newpm; I32 gimme; - if (op->op_flags & OPf_SPECIAL) { + if (PL_op->op_flags & OPf_SPECIAL) { cx = &cxstack[cxstack_ix]; cx->blk_oldpm = PL_curpm; /* fake block should preserve $1 et al */ } POPBLOCK(cx,newpm); - gimme = OP_GIMME(op, -1); + gimme = OP_GIMME(PL_op, -1); if (gimme == -1) { if (cxstack_ix >= 0) gimme = cxstack[cxstack_ix].blk_gimme; @@ -1458,7 +1478,9 @@ PP(pp_iter) char *max = SvPV((SV*)av, maxlen); if (!SvNIOK(cur) && SvCUR(cur) <= maxlen) { #ifndef USE_THREADS /* don't risk potential race */ - if (SvREFCNT(*cx->blk_loop.itervar) == 1) { + if (SvREFCNT(*cx->blk_loop.itervar) == 1 + && !SvMAGICAL(*cx->blk_loop.itervar)) + { /* safe to reuse old SV */ sv_setsv(*cx->blk_loop.itervar, cur); } @@ -1484,7 +1506,9 @@ PP(pp_iter) RETPUSHNO; #ifndef USE_THREADS /* don't risk potential race */ - if (SvREFCNT(*cx->blk_loop.itervar) == 1) { + if (SvREFCNT(*cx->blk_loop.itervar) == 1 + && !SvMAGICAL(*cx->blk_loop.itervar)) + { /* safe to reuse old SV */ sv_setiv(*cx->blk_loop.itervar, cx->blk_loop.iterix++); } @@ -1564,7 +1588,7 @@ PP(pp_subst) /* known replacement string? */ dstr = (pm->op_pmflags & PMf_CONST) ? POPs : Nullsv; - if (op->op_flags & OPf_STACKED) + if (PL_op->op_flags & OPf_STACKED) TARG = POPs; else { TARG = DEFSV; @@ -1590,7 +1614,9 @@ PP(pp_subst) DIE("panic: do_subst"); strend = s + len; - maxiters = (strend - s) + 10; + maxiters = 2*(strend - s) + 10; /* We can match twice at each + position, once with zero-length, + second time with non-zero. */ if (!rx->prelen && PL_curpm) { pm = PL_curpm; @@ -1610,19 +1636,22 @@ PP(pp_subst) if (!(rx->reganch & ROPT_NOSCAN)) { /* It floats. */ if (screamer) { I32 p = -1; + char *b; if (PL_screamfirst[BmRARE(rx->check_substr)] < 0) goto nope; - else if (!(s = screaminstr(TARG, rx->check_substr, rx->check_offset_min, 0, &p, 0))) + + b = (char*)HOP((U8*)s, rx->check_offset_min); + if (!(s = screaminstr(TARG, rx->check_substr, b - s, 0, &p, 0))) goto nope; } - else if (!(s = fbm_instr((unsigned char*)s + rx->check_offset_min, + else if (!(s = fbm_instr((unsigned char*)HOP((U8*)s, rx->check_offset_min), (unsigned char*)strend, rx->check_substr, 0))) goto nope; if (s && rx->check_offset_max < s - m) { ++BmUSEFUL(rx->check_substr); - s -= rx->check_offset_max; + s = (char*)HOP((U8*)s, -rx->check_offset_max); } else s = m; @@ -1631,13 +1660,13 @@ PP(pp_subst) beginning of match, and the match is anchored at s. */ else if (!PL_multiline) { /* Anchored at beginning of string. */ I32 slen; - if (*SvPVX(rx->check_substr) != s[rx->check_offset_min] + char *b = (char*)HOP((U8*)s, rx->check_offset_min); + if (*SvPVX(rx->check_substr) != *b || ((slen = SvCUR(rx->check_substr)) > 1 - && memNE(SvPVX(rx->check_substr), - s + rx->check_offset_min, slen))) + && memNE(SvPVX(rx->check_substr), b, slen))) goto nope; } - if (!rx->naughty && --BmUSEFUL(rx->check_substr) < 0 + if (!(rx->reganch & ROPT_NAUGHTY) && --BmUSEFUL(rx->check_substr) < 0 && rx->check_substr == rx->float_substr) { SvREFCNT_dec(rx->check_substr); rx->check_substr = Nullsv; /* opt is being useless */ @@ -1958,7 +1987,7 @@ PP(pp_entersub) register CV *cv; register PERL_CONTEXT *cx; I32 gimme; - bool hasargs = (op->op_flags & OPf_STACKED) != 0; + bool hasargs = (PL_op->op_flags & OPf_STACKED) != 0; if (!sv) DIE("Not a CODE reference"); @@ -1980,7 +2009,7 @@ PP(pp_entersub) sym = SvPV(sv, PL_na); if (!sym) DIE(no_usym, "a subroutine"); - if (op->op_private & HINT_STRICT_REFS) + if (PL_op->op_private & HINT_STRICT_REFS) DIE(no_symref, sym, "a subroutine"); cv = perl_get_cv(sym, TRUE); break; @@ -2034,7 +2063,7 @@ PP(pp_entersub) } gimme = GIMME_V; - if ((op->op_private & OPpENTERSUB_DB) && GvCV(PL_DBsub) && !CvNODEBUG(cv)) + if ((PL_op->op_private & OPpENTERSUB_DB) && GvCV(PL_DBsub) && !CvNODEBUG(cv)) cv = get_db_sub(&sv, cv); if (!cv) DIE("No DBsub routine"); @@ -2051,8 +2080,8 @@ PP(pp_entersub) if (CvFLAGS(cv) & CVf_LOCKED) { MAGIC *mg; if (CvFLAGS(cv) & CVf_METHOD) { - if (SP > stack_base + TOPMARK) - sv = *(stack_base + TOPMARK + 1); + if (SP > PL_stack_base + TOPMARK) + sv = *(PL_stack_base + TOPMARK + 1); else { MUTEX_UNLOCK(CvMUTEXP(cv)); croak("no argument for locked method call"); @@ -2077,7 +2106,7 @@ PP(pp_entersub) while (MgOWNER(mg)) COND_WAIT(MgOWNERCONDP(mg), MgMUTEXP(mg)); MgOWNER(mg) = thr; - DEBUG_L(PerlIO_printf(PerlIO_stderr(), "%p: pp_entersub lock %p\n", + DEBUG_S(PerlIO_printf(PerlIO_stderr(), "%p: pp_entersub lock %p\n", thr, sv);) MUTEX_UNLOCK(MgMUTEXP(mg)); SvREFCNT_inc(sv); /* Keep alive until magic_mutexfree */ @@ -2115,13 +2144,13 @@ PP(pp_entersub) * (3) instead of (2) so we'd have to clone. Would the fact * that we released the mutex more quickly make up for this? */ - if (threadnum && + if (PL_threadnum && (svp = hv_fetch(thr->cvcache, (char *)cv, sizeof(cv), FALSE))) { /* We already have a clone to use */ MUTEX_UNLOCK(CvMUTEXP(cv)); cv = *(CV**)svp; - DEBUG_L(PerlIO_printf(PerlIO_stderr(), + DEBUG_S(PerlIO_printf(PerlIO_stderr(), "entersub: %p already has clone %p:%s\n", thr, cv, SvPEEK((SV*)cv))); CvOWNER(cv) = thr; @@ -2135,7 +2164,7 @@ PP(pp_entersub) CvOWNER(cv) = thr; SvREFCNT_inc(cv); MUTEX_UNLOCK(CvMUTEXP(cv)); - DEBUG_L(PerlIO_printf(PerlIO_stderr(), + DEBUG_S(PerlIO_printf(PerlIO_stderr(), "entersub: %p grabbing %p:%s in stash %s\n", thr, cv, SvPEEK((SV*)cv), CvSTASH(cv) ? HvNAME(CvSTASH(cv)) : "(none)")); @@ -2144,7 +2173,7 @@ PP(pp_entersub) CV *clonecv; SvREFCNT_inc(cv); /* don't let it vanish from under us */ MUTEX_UNLOCK(CvMUTEXP(cv)); - DEBUG_L((PerlIO_printf(PerlIO_stderr(), + DEBUG_S((PerlIO_printf(PerlIO_stderr(), "entersub: %p cloning %p:%s\n", thr, cv, SvPEEK((SV*)cv)))); /* @@ -2161,7 +2190,7 @@ PP(pp_entersub) cv = clonecv; SvREFCNT_inc(cv); } - DEBUG_L(if (CvDEPTH(cv) != 0) + DEBUG_S(if (CvDEPTH(cv) != 0) PerlIO_printf(PerlIO_stderr(), "depth %ld != 0\n", CvDEPTH(cv));); SAVEDESTRUCTOR(unset_cvowner, (void*) cv); @@ -2198,7 +2227,7 @@ PP(pp_entersub) AV* av; I32 items; #ifdef USE_THREADS - av = (AV*)curpad[0]; + av = (AV*)PL_curpad[0]; #else av = GvAV(PL_defgv); #endif /* USE_THREADS */ @@ -2239,14 +2268,14 @@ PP(pp_entersub) register I32 items = SP - MARK; AV* padlist = CvPADLIST(cv); SV** svp = AvARRAY(padlist); - push_return(op->op_next); + push_return(PL_op->op_next); PUSHBLOCK(cx, CXt_SUB, MARK); PUSHSUB(cx); CvDEPTH(cv)++; if (CvDEPTH(cv) < 2) (void)SvREFCNT_inc(cv); else { /* save temporaries on recursion? */ - if (CvDEPTH(cv) == 100 && PL_dowarn + if (CvDEPTH(cv) == 100 && ckWARN(WARN_RECURSION) && !(PERLDB_SUB && cv == GvCV(PL_DBsub))) sub_crush_depth(cv); if (CvDEPTH(cv) > AvFILLp(padlist)) { @@ -2289,7 +2318,7 @@ PP(pp_entersub) } #ifdef USE_THREADS if (!hasargs) { - AV* av = (AV*)curpad[0]; + AV* av = (AV*)PL_curpad[0]; items = AvFILLp(av) + 1; if (items) { @@ -2311,7 +2340,7 @@ PP(pp_entersub) SV** ary; #if 0 - DEBUG_L(PerlIO_printf(PerlIO_stderr(), + DEBUG_S(PerlIO_printf(PerlIO_stderr(), "%p entersub preparing @_\n", thr)); #endif av = (AV*)PL_curpad[0]; @@ -2349,7 +2378,7 @@ PP(pp_entersub) } } #if 0 - DEBUG_L(PerlIO_printf(PerlIO_stderr(), + DEBUG_S(PerlIO_printf(PerlIO_stderr(), "%p entersub returning %p\n", thr, CvSTART(cv))); #endif RETURNOP(CvSTART(cv)); @@ -2360,11 +2389,12 @@ void sub_crush_depth(CV *cv) { if (CvANON(cv)) - warn("Deep recursion on anonymous subroutine"); + warner(WARN_RECURSION, "Deep recursion on anonymous subroutine"); else { SV* tmpstr = sv_newmortal(); gv_efullname3(tmpstr, CvGV(cv), Nullch); - warn("Deep recursion on subroutine \"%s\"", SvPVX(tmpstr)); + warner(WARN_RECURSION, "Deep recursion on subroutine \"%s\"", + SvPVX(tmpstr)); } } @@ -2374,8 +2404,8 @@ PP(pp_aelem) SV** svp; I32 elem = POPi; AV* av = (AV*)POPs; - U32 lval = op->op_flags & OPf_MOD; - U32 defer = (op->op_private & OPpLVAL_DEFER) && (elem > AvFILL(av)); + U32 lval = PL_op->op_flags & OPf_MOD; + U32 defer = (PL_op->op_private & OPpLVAL_DEFER) && (elem > AvFILL(av)); SV *sv; if (elem > 0) @@ -2398,10 +2428,10 @@ PP(pp_aelem) PUSHs(lv); RETURN; } - if (op->op_private & OPpLVAL_INTRO) + if (PL_op->op_private & OPpLVAL_INTRO) save_aelem(av, elem, svp); - else if (op->op_private & OPpDEREF) - vivify_ref(*svp, op->op_private & OPpDEREF); + else if (PL_op->op_private & OPpDEREF) + vivify_ref(*svp, PL_op->op_private & OPpDEREF); } sv = (svp ? *svp : &PL_sv_undef); if (!lval && SvGMAGICAL(sv)) /* see note in pp_helem() */