This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In struct regexp replace the two arrays of I32s accessed via startp
[perl5.git] / pp.c
diff --git a/pp.c b/pp.c
index 6f54dc6..173f81d 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -251,17 +251,17 @@ Perl_softref2xv(pTHX_ SV *const sv, const char *const what, const U32 type,
     if ((PL_op->op_flags & OPf_SPECIAL) &&
        !(PL_op->op_flags & OPf_MOD))
        {
-           gv = (GV*)gv_fetchsv(sv, 0, type);
+           gv = gv_fetchsv(sv, 0, type);
            if (!gv
                && (!is_gv_magical_sv(sv,0)
-                   || !(gv = (GV*)gv_fetchsv(sv, GV_ADD, type))))
+                   || !(gv = gv_fetchsv(sv, GV_ADD, type))))
                {
                    **spp = &PL_sv_undef;
                    return NULL;
                }
        }
     else {
-       gv = (GV*)gv_fetchsv(sv, GV_ADD, type);
+       gv = gv_fetchsv(sv, GV_ADD, type);
     }
     return gv;
 }
@@ -323,8 +323,7 @@ PP(pp_av2arylen)
     AV * const av = (AV*)TOPs;
     SV ** const sv = Perl_av_arylen_p(aTHX_ (AV*)av);
     if (!*sv) {
-       *sv = newSV(0);
-       sv_upgrade(*sv, SVt_PVMG);
+       *sv = newSV_type(SVt_PVMG);
        sv_magic(*sv, (SV*)av, PERL_MAGIC_arylen, NULL, 0);
     }
     SETs(*sv);
@@ -578,7 +577,7 @@ PP(pp_bless)
        if (len == 0 && ckWARN(WARN_MISC))
            Perl_warner(aTHX_ packWARN(WARN_MISC),
                   "Explicit blessing to '' (assuming package main)");
-       stash = gv_stashpvn(ptr, len, TRUE);
+       stash = gv_stashpvn(ptr, len, GV_ADD);
     }
 
     (void)sv_bless(TOPs, stash);
@@ -3015,13 +3014,13 @@ PP(pp_substr)
     I32 pos;
     I32 rem;
     I32 fail;
-    const I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET;
+    const int num_args = PL_op->op_private & 7;
+    const I32 lvalue = num_args <= 3 && ( PL_op->op_flags & OPf_MOD || LVRET );
     const char *tmps;
     const I32 arybase = CopARYBASE_get(PL_curcop);
     SV *repl_sv = NULL;
     const char *repl = NULL;
     STRLEN repl_len;
-    const int num_args = PL_op->op_private & 7;
     bool repl_need_utf8_upgrade = FALSE;
     bool repl_is_utf8 = FALSE;
 
@@ -3116,7 +3115,8 @@ PP(pp_substr)
            }
        }
 
-       sv_setpvn(TARG, tmps, rem);
+       if (GIMME_V != G_VOID && !lvalue)
+           sv_setpvn(TARG, tmps, rem);
 #ifdef USE_LOCALE_COLLATE
        sv_unmagic(TARG, PERL_MAGIC_collxfrm);
 #endif
@@ -4762,7 +4762,7 @@ PP(pp_split)
                s = orig + (m - s);
                strend = s + (strend - m);
            }
-           m = rx->startp[0] + orig;
+           m = rx->offs[0].start + orig;
            dstr = newSVpvn(s, m-s);
            if (make_mortal)
                sv_2mortal(dstr);
@@ -4772,8 +4772,8 @@ PP(pp_split)
            if (rx->nparens) {
                I32 i;
                for (i = 1; i <= (I32)rx->nparens; i++) {
-                   s = rx->startp[i] + orig;
-                   m = rx->endp[i] + orig;
+                   s = rx->offs[i].start + orig;
+                   m = rx->offs[i].end + orig;
 
                    /* japhy (07/27/01) -- the (m && s) test doesn't catch
                       parens that didn't match -- they should be set to
@@ -4790,7 +4790,7 @@ PP(pp_split)
                    XPUSHs(dstr);
                }
            }
-           s = rx->endp[0] + orig;
+           s = rx->offs[0].end + orig;
        }
     }