This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #96230] Stop s/$qr// from reusing last pattern
[perl5.git] / pp.c
diff --git a/pp.c b/pp.c
index 171cb87..28a774e 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -980,11 +980,9 @@ PP(pp_undef)
        }
        break;
     case SVt_PVGV:
-       if (SvFAKE(sv)) {
-           SvSetMagicSV(sv, &PL_sv_undef);
-           break;
-       }
-       else if (isGV_with_GP(sv)) {
+       assert(isGV_with_GP(sv));
+       assert(!SvFAKE(sv));
+       {
            GP *gp;
             HV *stash;
 
@@ -1022,7 +1020,6 @@ PP(pp_undef)
 
            break;
        }
-       /* FALL THROUGH */
     default:
        if (SvTYPE(sv) >= SVt_PV && SvPVX_const(sv) && SvLEN(sv)) {
            SvPV_free(sv);
@@ -3066,7 +3063,7 @@ PP(pp_substr)
        tmps = SvPV_force_nomg(sv, curlen);
        if (DO_UTF8(repl_sv) && repl_len) {
            if (!DO_UTF8(sv)) {
-               sv_utf8_upgrade(sv);
+               sv_utf8_upgrade_nomg(sv);
                curlen = SvCUR(sv);
            }
        }
@@ -3075,7 +3072,7 @@ PP(pp_substr)
     }
     else tmps = SvPV_const(sv, curlen);
     if (DO_UTF8(sv)) {
-        utf8_curlen = sv_len_utf8_nomg(sv);
+        utf8_curlen = sv_or_pv_len_utf8(sv, tmps, curlen);
        if (utf8_curlen == curlen)
            utf8_curlen = 0;
        else
@@ -3093,7 +3090,7 @@ PP(pp_substr)
 
        byte_len = len;
        byte_pos = utf8_curlen
-           ? sv_pos_u2b_flags(sv, pos, &byte_len, SV_CONST_RETURN) : pos;
+           ? sv_or_pv_pos_u2b(sv, tmps, pos, &byte_len) : pos;
 
        tmps += byte_pos;