X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/e78862116af84a6ca22cd2ea66432fa8e52fde84..8005796e5264eb0df85cf3c0e4517ca3d769650f:/pp_ctl.c diff --git a/pp_ctl.c b/pp_ctl.c index e196022..2cde665 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -130,13 +130,6 @@ PP(pp_regcomp) sv_setsv(tmpstr, sv); continue; } - - if (SvROK(msv) && SvTYPE(SvRV(msv)) == SVt_REGEXP) { - msv = SvRV(msv); - PL_reginterp_cnt += - RX_SEEN_EVALS((REGEXP *)MUTABLE_PTR(msv)); - } - sv_catsv_nomg(tmpstr, msv); } SvSETMAGIC(tmpstr); @@ -212,7 +205,9 @@ PP(pp_regcomp) if (PL_op->op_flags & OPf_SPECIAL) PL_reginterp_cnt = I32_MAX; /* Mark as safe. */ - if (!DO_UTF8(tmpstr) && SvUTF8(tmpstr)) { + if (DO_UTF8(tmpstr)) { + assert (SvUTF8(tmpstr)); + } else if (SvUTF8(tmpstr)) { /* Not doing UTF-8, despite what the SV says. Is this only if we're trapped in use 'bytes'? */ /* Make a copy of the octet sequence, but without the flag on, @@ -221,11 +216,19 @@ PP(pp_regcomp) const char *const p = SvPV(tmpstr, len); tmpstr = newSVpvn_flags(p, len, SVs_TEMP); } - else if (SvAMAGIC(tmpstr) || SvGMAGICAL(tmpstr)) { + else if (SvAMAGIC(tmpstr)) { /* make a copy to avoid extra stringifies */ tmpstr = newSVpvn_flags(t, len, SVs_TEMP | SvUTF8(tmpstr)); } + /* If it is gmagical, create a mortal copy, but without calling + get-magic, as we have already done that. */ + if(SvGMAGICAL(tmpstr)) { + SV *mortalcopy = sv_newmortal(); + sv_setsv_flags(mortalcopy, tmpstr, 0); + tmpstr = mortalcopy; + } + if (eng) PM_SETRE(pm, CALLREGCOMP_ENG(eng, tmpstr, pm_flags)); else