The old COW code needs to use SvPVX_mutable when doing copy-on-write.
[p5sagit/p5-mst-13.2.git] / doop.c
diff --git a/doop.c b/doop.c
index 22160af..b17da1a 100644 (file)
--- a/doop.c
+++ b/doop.c
@@ -97,8 +97,8 @@ S_do_trans_simple(pTHX_ SV *sv)
 STATIC I32
 S_do_trans_count(pTHX_ SV *sv)
 {
-    U8 *s;
-    U8 *send;
+    const U8 *s;
+    const U8 *send;
     I32 matches = 0;
     STRLEN len;
     const I32 complement = PL_op->op_private & OPpTRANS_COMPLEMENT;
@@ -107,7 +107,7 @@ S_do_trans_count(pTHX_ SV *sv)
     if (!tbl)
        Perl_croak(aTHX_ "panic: do_trans_count line %d",__LINE__);
 
-    s = (U8*)SvPV(sv, len);
+    s = (const U8*)SvPV_const(sv, len);
     send = s + len;
 
     if (!SvUTF8(sv))
@@ -605,7 +605,7 @@ Perl_do_trans(pTHX_ SV *sv)
         if (SvREADONLY(sv) && !(PL_op->op_private & OPpTRANS_IDENTICAL))
             Perl_croak(aTHX_ PL_no_modify);
     }
-    (void)SvPV(sv, len);
+    (void)SvPV_const(sv, len);
     if (!len)
        return 0;
     if (!(PL_op->op_private & OPpTRANS_IDENTICAL)) {
@@ -648,17 +648,17 @@ Perl_do_join(pTHX_ register SV *sv, SV *del, register SV **mark, register SV **s
     register STRLEN len;
     STRLEN delimlen;
 
-    (void) SvPV(del, delimlen); /* stringify and get the delimlen */
+    (void) SvPV_const(del, delimlen); /* stringify and get the delimlen */
     /* SvCUR assumes it's SvPOK() and woe betide you if it's not. */
 
     mark++;
     len = (items > 0 ? (delimlen * (items - 1) ) : 0);
-    (void)SvUPGRADE(sv, SVt_PV);
+    SvUPGRADE(sv, SVt_PV);
     if (SvLEN(sv) < len + items) {     /* current length is way too short */
        while (items-- > 0) {
            if (*mark && !SvGAMAGIC(*mark) && SvOK(*mark)) {
                STRLEN tmplen;
-               SvPV(*mark, tmplen);
+               SvPV_const(*mark, tmplen);
                len += tmplen;
            }
            mark++;
@@ -700,7 +700,7 @@ void
 Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg)
 {
     STRLEN patlen;
-    const char *pat = SvPV(*sarg, patlen);
+    const char *pat = SvPV_const(*sarg, patlen);
     bool do_taint = FALSE;
 
     SvUTF8_off(sv);
@@ -717,7 +717,7 @@ UV
 Perl_do_vecget(pTHX_ SV *sv, I32 offset, I32 size)
 {
     STRLEN srclen, len;
-    unsigned char *s = (unsigned char *) SvPV(sv, srclen);
+    const unsigned char *s = (const unsigned char *) SvPV_const(sv, srclen);
     UV retnum = 0;
 
     if (offset < 0)
@@ -1006,7 +1006,6 @@ Perl_do_chomp(pTHX_ register SV *sv)
 {
     register I32 count;
     STRLEN len;
-    STRLEN n_a;
     char *s;
     char *temp_buffer = NULL;
     SV* svrecode = Nullsv;
@@ -1123,7 +1122,7 @@ Perl_do_chomp(pTHX_ register SV *sv)
                count += rs_charlen;
            }
        }
-       s = SvPV_force(sv, n_a);
+       s = SvPV_force_nolen(sv);
        SvCUR_set(sv, len);
        *SvEND(sv) = '\0';
        SvNIOK_off(sv);
@@ -1149,12 +1148,12 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
     register char *dc;
     STRLEN leftlen;
     STRLEN rightlen;
-    register char *lc;
-    register char *rc;
+    register const char *lc;
+    register const char *rc;
     register I32 len;
     I32 lensave;
-    char *lsave;
-    char *rsave;
+    const char *lsave;
+    const char *rsave;
     const bool left_utf = DO_UTF8(left);
     const bool right_utf = DO_UTF8(right);
     I32 needlen = 0;
@@ -1166,8 +1165,8 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
 
     if (sv != left || (optype != OP_BIT_AND && !SvOK(sv) && !SvGMAGICAL(sv)))
        sv_setpvn(sv, "", 0);   /* avoid undef warning on |= and ^= */
-    lsave = lc = SvPV_nomg(left, leftlen);
-    rsave = rc = SvPV_nomg(right, rightlen);
+    lsave = lc = SvPV_nomg_const(left, leftlen);
+    rsave = rc = SvPV_nomg_const(right, rightlen);
     len = leftlen < rightlen ? leftlen : rightlen;
     lensave = len;
     if ((left_utf || right_utf) && (sv == left || sv == right)) {