This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[Merge] Fixes to reset("...")
[perl5.git] / pp_hot.c
index d7de38a..3adeb1e 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1332,6 +1332,7 @@ PP(pp_match)
     STRLEN len;
     const I32 oldsave = PL_savestack_ix;
     I32 had_zerolen = 0;
+    MAGIC *mg = NULL;
 
     if (PL_op->op_flags & OPf_STACKED)
        TARG = POPs;
@@ -1385,7 +1386,7 @@ PP(pp_match)
 
     /* get pos() if //g */
     if (global) {
-        MAGIC * const mg = mg_find_mglob(TARG);
+        mg = mg_find_mglob(TARG);
         if (mg && mg->mg_len >= 0) {
             curpos = mg->mg_len;
             /* last time pos() was set, it was zero-length match */
@@ -1419,22 +1420,20 @@ PP(pp_match)
     s = truebase;
 
   play_it_again:
-    if (global) {
+    if (global)
        s = truebase + curpos;
-    }
 
     if (!CALLREGEXEC(rx, (char*)s, (char *)strend, (char*)truebase,
                     had_zerolen, TARG, NULL, r_flags))
        goto nope;
 
     PL_curpm = pm;
-    if (dynpm->op_pmflags & PMf_ONCE) {
+    if (dynpm->op_pmflags & PMf_ONCE)
 #ifdef USE_ITHREADS
        SvREADONLY_on(PL_regex_pad[dynpm->op_pmoffset]);
 #else
        dynpm->op_pmflags |= PMf_USED;
 #endif
-    }
 
     if (rxtainted)
        RX_MATCH_TAINTED_on(rx);
@@ -1443,10 +1442,8 @@ PP(pp_match)
     /* update pos */
 
     if (global && (gimme != G_ARRAY || (dynpm->op_pmflags & PMf_CONTINUE))) {
-        MAGIC *mg = mg_find_mglob(TARG);
-        if (!mg) {
+        if (!mg)
             mg = sv_magicext_mglob(TARG);
-        }
         mg->mg_len = RX_OFFS(rx)[0].end;
         if (RX_ZERO_LEN(rx))
             mg->mg_flags |= MGf_MINMATCH;
@@ -1498,9 +1495,10 @@ PP(pp_match)
 
 nope:
     if (global && !(dynpm->op_pmflags & PMf_CONTINUE)) {
-           MAGIC* const mg = mg_find_mglob(TARG);
-           if (mg)
-               mg->mg_len = -1;
+        if (!mg)
+            mg = mg_find_mglob(TARG);
+        if (mg)
+            mg->mg_len = -1;
     }
     LEAVE_SCOPE(oldsave);
     if (gimme == G_ARRAY)
@@ -2060,9 +2058,6 @@ PP(pp_subst)
        sv_force_normal_flags(TARG,0);
 #endif
     if (!(rpm->op_pmflags & PMf_NONDESTRUCT)
-#ifdef PERL_ANY_COW
-       && !is_cow
-#endif
        && (SvREADONLY(TARG)
            || ( ((SvTYPE(TARG) == SVt_PVGV && isGV_with_GP(TARG))
                  || SvTYPE(TARG) > SVt_PVLV)