X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pp_hot.c;h=0422017d74c4c44f48c03a05eb87201e7d5a22a3;hb=5cd24f17b72b10f8506d70fba1ec4dd25224c257;hp=2f735a3bf633ab41b540d7d5e54ad2cbc4913edd;hpb=daff0e373f3630eaa9dbded0adcc04185f454487;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pp_hot.c b/pp_hot.c index 2f735a3..0422017 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1171,7 +1171,8 @@ do_readline() IoFLAGS(io) |= IOf_START; } else if (type == OP_GLOB) { - (void)do_close(last_in_gv, FALSE); + if (do_close(last_in_gv, FALSE) & ~0xFF) + warn("internal error: glob failed"); } if (gimme == G_SCALAR) { (void)SvOK_off(TARG); @@ -1386,6 +1387,13 @@ PP(pp_iter) RETPUSHYES; } +static void +leave_subst(p) +void *p; +{ + ((PMOP*)p)->op_private &= ~OPpLVAL_INTRO; +} + PP(pp_subst) { dSP; dTARG; @@ -1410,8 +1418,8 @@ PP(pp_subst) int force_on_match = 0; I32 oldsave = savestack_ix; - if (pm->op_pmflags & PMf_CONST) /* known replacement string? */ - dstr = POPs; + /* known replacement string? */ + dstr = (pm->op_pmflags & PMf_CONST) ? POPs : Nullsv; if (op->op_flags & OPf_STACKED) TARG = POPs; else { @@ -1427,6 +1435,13 @@ PP(pp_subst) force_on_match = 1; TAINT_NOT; + if (pm->op_private & OPpLVAL_INTRO) + croak("Recursive substitution detected"); + if (!dstr) { + SAVEDESTRUCTOR(leave_subst, pm); + pm->op_private |= OPpLVAL_INTRO; + } + force_it: if (!pm || !s) DIE("panic: do_subst"); @@ -1480,7 +1495,7 @@ PP(pp_subst) once = !(rpm->op_pmflags & PMf_GLOBAL); /* known replacement string? */ - c = (rpm->op_pmflags & PMf_CONST) ? SvPV(dstr, clen) : Nullch; + c = dstr ? SvPV(dstr, clen) : Nullch; /* can do inplace substitution? */ if (c && clen <= rx->minlen) { @@ -1630,13 +1645,12 @@ PP(pp_subst) LEAVE_SCOPE(oldsave); RETURN; } - - PUSHs(&sv_no); - LEAVE_SCOPE(oldsave); - RETURN; + goto ret_no; nope: ++BmUSEFUL(pm->op_pmshort); + +ret_no: PUSHs(&sv_no); LEAVE_SCOPE(oldsave); RETURN;