This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use pvs macros instead of pvn where possible.
[perl5.git] / doop.c
diff --git a/doop.c b/doop.c
index 1a5c829..039d9ad 100644 (file)
--- a/doop.c
+++ b/doop.c
@@ -1,7 +1,7 @@
 /*    doop.c
  *
- *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- *    2000, 2001, 2002, 2004, 2005, 2006, 2007, by Larry Wall and others
+ *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+ *    2001, 2002, 2004, 2005, 2006, 2007, 2008, by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -318,7 +318,7 @@ S_do_trans_simple_utf8(pTHX_ SV * const sv)
 #else
                    (SV*)cSVOP->op_sv;
 #endif
-    HV* const  hv = (HV*)SvRV(rv);
+    HV* const  hv = MUTABLE_HV(SvRV(rv));
     SV* const * svp = hv_fetchs(hv, "NONE", FALSE);
     const UV none = svp ? SvUV(*svp) : 0x7fffffff;
     const UV extra = none + 1;
@@ -420,7 +420,7 @@ S_do_trans_count_utf8(pTHX_ SV * const sv)
 #else
                    (SV*)cSVOP->op_sv;
 #endif
-    HV* const hv = (HV*)SvRV(rv);
+    HV* const hv = MUTABLE_HV(SvRV(rv));
     SV* const * const svp = hv_fetchs(hv, "NONE", FALSE);
     const UV none = svp ? SvUV(*svp) : 0x7fffffff;
     const UV extra = none + 1;
@@ -471,7 +471,7 @@ S_do_trans_complex_utf8(pTHX_ SV * const sv)
 #else
                    (SV*)cSVOP->op_sv;
 #endif
-    HV * const hv = (HV*)SvRV(rv);
+    HV * const hv = MUTABLE_HV(SvRV(rv));
     SV * const *svp = hv_fetchs(hv, "NONE", FALSE);
     const UV none = svp ? SvUV(*svp) : 0x7fffffff;
     const UV extra = none + 1;
@@ -633,10 +633,10 @@ Perl_do_trans(pTHX_ SV *sv)
 
     PERL_ARGS_ASSERT_DO_TRANS;
 
-    if (SvREADONLY(sv)) {
+    if (SvREADONLY(sv) && !(PL_op->op_private & OPpTRANS_IDENTICAL)) {
         if (SvIsCOW(sv))
             sv_force_normal_flags(sv, 0);
-        if (SvREADONLY(sv) && !(PL_op->op_private & OPpTRANS_IDENTICAL))
+        if (SvREADONLY(sv))
             Perl_croak(aTHX_ PL_no_modify);
     }
     (void)SvPV_const(sv, len);
@@ -707,7 +707,7 @@ Perl_do_join(pTHX_ register SV *sv, SV *delim, register SV **mark, register SV *
        ++mark;
     }
 
-    sv_setpvn(sv, "", 0);
+    sv_setpvs(sv, "");
     /* sv_setpv retains old UTF8ness [perl #24846] */
     SvUTF8_off(sv);
 
@@ -998,7 +998,7 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv)
 
     if (SvTYPE(sv) == SVt_PVAV) {
        register I32 i;
-       AV* const av = (AV*)sv;
+       AV *const av = MUTABLE_AV(sv);
        const I32 max = AvFILL(av);
 
        for (i = 0; i <= max; i++) {
@@ -1009,7 +1009,7 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv)
         return;
     }
     else if (SvTYPE(sv) == SVt_PVHV) {
-       HV* const hv = (HV*)sv;
+       HV* const hv = MUTABLE_HV(sv);
        HE* entry;
         (void)hv_iterinit(hv);
         while ((entry = hv_iternext(hv)))
@@ -1033,7 +1033,7 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv)
 
     s = SvPV(sv, len);
     if (len && !SvPOK(sv))
-       s = SvPV_force(sv, len);
+       s = SvPV_force_nomg(sv, len);
     if (DO_UTF8(sv)) {
        if (s && len) {
            char * const send = s + len;
@@ -1050,7 +1050,7 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv)
            }
        }
        else
-           sv_setpvn(astr, "", 0);
+           sv_setpvs(astr, "");
     }
     else if (s && len) {
        s += --len;
@@ -1061,7 +1061,7 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv)
        SvNIOK_off(sv);
     }
     else
-       sv_setpvn(astr, "", 0);
+       sv_setpvs(astr, "");
     SvSETMAGIC(sv);
 }
 
@@ -1084,7 +1084,7 @@ Perl_do_chomp(pTHX_ register SV *sv)
     count = 0;
     if (SvTYPE(sv) == SVt_PVAV) {
        register I32 i;
-       AV* const av = (AV*)sv;
+       AV *const av = MUTABLE_AV(sv);
        const I32 max = AvFILL(av);
 
        for (i = 0; i <= max; i++) {
@@ -1095,7 +1095,7 @@ Perl_do_chomp(pTHX_ register SV *sv)
         return count;
     }
     else if (SvTYPE(sv) == SVt_PVHV) {
-       HV* const hv = (HV*)sv;
+       HV* const hv = MUTABLE_HV(sv);
        HE* entry;
         (void)hv_iterinit(hv);
         while ((entry = hv_iternext(hv)))
@@ -1228,7 +1228,7 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
     PERL_ARGS_ASSERT_DO_VOP;
 
     if (sv != left || (optype != OP_BIT_AND && !SvOK(sv) && !SvGMAGICAL(sv)))
-       sv_setpvn(sv, "", 0);   /* avoid undef warning on |= and ^= */
+       sv_setpvs(sv, "");      /* avoid undef warning on |= and ^= */
     lsave = lc = SvPV_nomg_const(left, leftlen);
     rsave = rc = SvPV_nomg_const(right, rightlen);
 
@@ -1431,7 +1431,7 @@ Perl_do_kv(pTHX)
 {
     dVAR;
     dSP;
-    HV * const hv = (HV*)POPs;
+    HV * const hv = MUTABLE_HV(POPs);
     HV *keys;
     register HE *entry;
     const I32 gimme = GIMME_V;