This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
SvPVX_const() - part 3 ... and const'ing Storable
authorSteve Peters <steve@fisharerojo.org>
Tue, 31 May 2005 09:55:43 +0000 (04:55 -0500)
committerAbhijit Menon-Sen <ams@wiw.org>
Thu, 2 Jun 2005 08:44:41 +0000 (08:44 +0000)
Message-Id: <20050531145543.GA8051@mccoy.peters.homeunix.org>

p4raw-id: //depot/perl@24670

12 files changed:
ext/B/B.xs
ext/Data/Dumper/Dumper.xs
ext/Devel/DProf/DProf.xs
ext/Opcode/Opcode.xs
ext/POSIX/POSIX.xs
ext/PerlIO/encoding/encoding.xs
ext/PerlIO/via/via.xs
ext/Storable/Storable.xs
pp_hot.c
pp_pack.c
pp_sys.c
scope.c

index c49e4d7..cedaf08 100644 (file)
@@ -1215,7 +1215,7 @@ SvPV(sv)
     CODE:
         ST(0) = sv_newmortal();
         if( SvPOK(sv) ) { 
-            sv_setpvn(ST(0), SvPVX(sv), SvCUR(sv));
+            sv_setpvn(ST(0), SvPVX_const(sv), SvCUR(sv));
             SvFLAGS(ST(0)) |= SvUTF8(sv);
         }
         else {
@@ -1229,7 +1229,7 @@ SvPVBM(sv)
        B::PV   sv
     CODE:
         ST(0) = sv_newmortal();
-       sv_setpvn(ST(0), SvPVX(sv),
+       sv_setpvn(ST(0), SvPVX_const(sv),
            SvCUR(sv) + (SvTYPE(sv) == SVt_PVBM ? 257 : 0));
 
 
index 3f06b7b..9fec64d 100644 (file)
@@ -6,8 +6,8 @@
 static I32 num_q (char *s, STRLEN slen);
 static I32 esc_q (char *dest, char *src, STRLEN slen);
 static I32 esc_q_utf8 (pTHX_ SV *sv, char *src, STRLEN slen);
-static SV *sv_x (pTHX_ SV *sv, char *str, STRLEN len, I32 n);
-static I32 DD_dump (pTHX_ SV *val, char *name, STRLEN namelen, SV *retval,
+static SV *sv_x (pTHX_ SV *sv, const char *str, STRLEN len, I32 n);
+static I32 DD_dump (pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval,
                    HV *seenhv, AV *postav, I32 *levelp, I32 indent,
                    SV *pad, SV *xpad, SV *apad, SV *sep, SV *pair,
                    SV *freezer, SV *toaster,
@@ -208,7 +208,7 @@ esc_q_utf8(pTHX_ SV* sv, register char *src, register STRLEN slen)
 
 /* append a repeated string to an SV */
 static SV *
-sv_x(pTHX_ SV *sv, register char *str, STRLEN len, I32 n)
+sv_x(pTHX_ SV *sv, const char *str, STRLEN len, I32 n)
 {
     if (sv == Nullsv)
        sv = newSVpvn("", 0);
@@ -239,7 +239,7 @@ sv_x(pTHX_ SV *sv, register char *str, STRLEN len, I32 n)
  * efficiency raisins.)  Ugggh!
  */
 static I32
-DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
+DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
        AV *postav, I32 *levelp, I32 indent, SV *pad, SV *xpad,
        SV *apad, SV *sep, SV *pair, SV *freezer, SV *toaster, I32 purity,
        I32 deepcopy, I32 quotekeys, SV *bless, I32 maxdepth, SV *sortkeys)
@@ -268,12 +268,12 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
            it.  Warn on errors. */
        if (SvOBJECT(SvRV(val)) && freezer &&
            SvPOK(freezer) && SvCUR(freezer) &&
-            gv_fetchmeth(SvSTASH(SvRV(val)), SvPVX(freezer), 
+            gv_fetchmeth(SvSTASH(SvRV(val)), SvPVX_const(freezer), 
                          SvCUR(freezer), -1) != NULL)
        {
            dSP; ENTER; SAVETMPS; PUSHMARK(sp);
            XPUSHs(val); PUTBACK;
-           i = perl_call_method(SvPVX(freezer), G_EVAL|G_VOID);
+           i = perl_call_method(SvPVX_const(freezer), G_EVAL|G_VOID);
            SPAGAIN;
            if (SvTRUE(ERRSV))
                warn("WARNING(Freezer method call failed): %"SVf"", ERRSV);
@@ -316,9 +316,9 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                    }
                    else {
                        if (name[0] == '@' || name[0] == '%') {
-                           if ((SvPVX(othername))[0] == '\\' &&
-                               (SvPVX(othername))[1] == name[0]) {
-                               sv_catpvn(retval, SvPVX(othername)+1,
+                           if ((SvPVX_const(othername))[0] == '\\' &&
+                               (SvPVX_const(othername))[1] == name[0]) {
+                               sv_catpvn(retval, SvPVX_const(othername)+1,
                                          SvCUR(othername)-1);
                            }
                            else {
@@ -405,7 +405,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
        }
 
        (*levelp)++;
-       ipad = sv_x(aTHX_ Nullsv, SvPVX(xpad), SvCUR(xpad), *levelp);
+       ipad = sv_x(aTHX_ Nullsv, SvPVX_const(xpad), SvCUR(xpad), *levelp);
 
        if (realtype <= SVt_PVBM) {                          /* scalar ref */
            SV *namesv = newSVpvn("${", 2);
@@ -413,7 +413,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
            sv_catpvn(namesv, "}", 1);
            if (realpack) {                                  /* blessed */
                sv_catpvn(retval, "do{\\(my $o = ", 13);
-               DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
+               DD_dump(aTHX_ ival, SvPVX_const(namesv), SvCUR(namesv), retval, seenhv,
                        postav, levelp, indent, pad, xpad, apad, sep, pair,
                        freezer, toaster, purity, deepcopy, quotekeys, bless,
                        maxdepth, sortkeys);
@@ -421,7 +421,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
            }                                                /* plain */
            else {
                sv_catpvn(retval, "\\", 1);
-               DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
+               DD_dump(aTHX_ ival, SvPVX_const(namesv), SvCUR(namesv), retval, seenhv,
                        postav, levelp, indent, pad, xpad, apad, sep, pair,
                        freezer, toaster, purity, deepcopy, quotekeys, bless,
                        maxdepth, sortkeys);
@@ -433,7 +433,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
            sv_catpvn(namesv, name, namelen);
            sv_catpvn(namesv, "}", 1);
            sv_catpvn(retval, "\\", 1);
-           DD_dump(aTHX_ ival, SvPVX(namesv), SvCUR(namesv), retval, seenhv,
+           DD_dump(aTHX_ ival, SvPVX_const(namesv), SvCUR(namesv), retval, seenhv,
                    postav, levelp,     indent, pad, xpad, apad, sep, pair,
                    freezer, toaster, purity, deepcopy, quotekeys, bless,
                    maxdepth, sortkeys);
@@ -510,7 +510,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                    sv_catpvn(retval, ",", 1);
            }
            if (ixmax >= 0) {
-               SV *opad = sv_x(aTHX_ Nullsv, SvPVX(xpad), SvCUR(xpad), (*levelp)-1);
+               SV *opad = sv_x(aTHX_ Nullsv, SvPVX_const(xpad), SvCUR(xpad), (*levelp)-1);
                sv_catsv(retval, totpad);
                sv_catsv(retval, opad);
                SvREFCNT_dec(opad);
@@ -707,7 +707,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                else
                    newapad = apad;
 
-               DD_dump(aTHX_ hval, SvPVX(sname), SvCUR(sname), retval, seenhv,
+               DD_dump(aTHX_ hval, SvPVX_const(sname), SvCUR(sname), retval, seenhv,
                        postav, levelp, indent, pad, xpad, newapad, sep, pair,
                        freezer, toaster, purity, deepcopy, quotekeys, bless,
                        maxdepth, sortkeys);
@@ -717,7 +717,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                    SvREFCNT_dec(newapad);
            }
            if (i) {
-               SV *opad = sv_x(aTHX_ Nullsv, SvPVX(xpad), SvCUR(xpad), *levelp-1);
+               SV *opad = sv_x(aTHX_ Nullsv, SvPVX_const(xpad), SvCUR(xpad), *levelp-1);
                sv_catsv(retval, totpad);
                sv_catsv(retval, opad);
                SvREFCNT_dec(opad);
@@ -863,7 +863,7 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv,
                        if (indent >= 2)
                            (void)sv_x(aTHX_ newapad, " ", 1, SvCUR(postentry));
                        
-                       DD_dump(aTHX_ e, SvPVX(nname), SvCUR(nname), postentry,
+                       DD_dump(aTHX_ e, SvPVX_const(nname), SvCUR(nname), postentry,
                                seenhv, postav, &nlevel, indent, pad, xpad,
                                newapad, sep, pair, freezer, toaster, purity,
                                deepcopy, quotekeys, bless, maxdepth, 
@@ -1047,7 +1047,7 @@ Data_Dumper_Dumpxs(href, ...)
                        (void)SvOK_off(name);
                
                    if (SvOK(name)) {
-                       if ((SvPVX(name))[0] == '*') {
+                       if ((SvPVX_const(name))[0] == '*') {
                            if (SvROK(val)) {
                                switch (SvTYPE(SvRV(val))) {
                                case SVt_PVAV:
@@ -1067,7 +1067,7 @@ Data_Dumper_Dumpxs(href, ...)
                            else
                                (SvPVX(name))[0] = '$';
                        }
-                       else if ((SvPVX(name))[0] != '$')
+                       else if ((SvPVX_const(name))[0] != '$')
                            sv_insert(name, 0, 0, "$", 1);
                    }
                    else {
@@ -1088,7 +1088,7 @@ Data_Dumper_Dumpxs(href, ...)
                    else
                        newapad = apad;
                
-                   DD_dump(aTHX_ val, SvPVX(name), SvCUR(name), valstr, seenhv,
+                   DD_dump(aTHX_ val, SvPVX_const(name), SvCUR(name), valstr, seenhv,
                            postav, &level, indent, pad, xpad, newapad, sep, pair,
                            freezer, toaster, purity, deepcopy, quotekeys,
                            bless, maxdepth, sortkeys);
@@ -1099,7 +1099,7 @@ Data_Dumper_Dumpxs(href, ...)
                    postlen = av_len(postav);
                    if (postlen >= 0 || !terse) {
                        sv_insert(valstr, 0, 0, " = ", 3);
-                       sv_insert(valstr, 0, 0, SvPVX(name), SvCUR(name));
+                       sv_insert(valstr, 0, 0, SvPVX_const(name), SvCUR(name));
                        sv_catpvn(valstr, ";", 1);
                    }
                    sv_catsv(retval, pad);
index c840b24..39a604d 100644 (file)
@@ -24,7 +24,7 @@ db_get_cv(pTHX_ SV *sv)
            cv = INT2PTR(CV*,SvIVX(sv));
        } else {
            if (SvPOK(sv)) {
-               cv = get_cv(SvPVX(sv), TRUE);
+               cv = get_cv(SvPVX_const(sv), TRUE);
            } else if (SvROK(sv)) {
                cv = (CV*)SvRV(sv);
            } else {
@@ -376,7 +376,7 @@ prof_mark(pTHX_ opcode ptype)
        gname = GvNAME(gv);
 
        set_cv_key(aTHX_ cv, pname, gname);
-       svp = hv_fetch(g_cv_hash, SvPVX(g_key_hash), SvCUR(g_key_hash), TRUE);
+       svp = hv_fetch(g_cv_hash, SvPVX_const(g_key_hash), SvCUR(g_key_hash), TRUE);
        if (!SvOK(*svp)) {
            sv_setiv(*svp, id = ++g_lastid);
            if (CvXSUB(cv) == XS_Devel__DProf_END)
index 62b4d05..50c0a4f 100644 (file)
@@ -133,7 +133,7 @@ new_opset(pTHX_ SV *old_opset)
     }
     else {
        opset = NEWSV(1156, opset_len);
-       Zero(SvPVX(opset), opset_len + 1, char);
+       Zero(SvPVX_const(opset), opset_len + 1, char);
        SvCUR_set(opset, opset_len);
        (void)SvPOK_only(opset);
     }
index bdb41f9..7447666 100644 (file)
@@ -1261,7 +1261,7 @@ sigaction(sig, optaction, oldaction = 0)
            SV** svp;
            SV** sigsvp;
            if (sig == 0 && SvPOK(ST(0))) {
-               char *s = SvPVX(ST(0));
+               const char *s = SvPVX_const(ST(0));
                int i = whichsig(s);
 
                if (i < 0 && memEQ(s, "SIG", 3))
@@ -1366,7 +1366,7 @@ sigaction(sig, optaction, oldaction = 0)
 
                /* And here again we duplicate -- DEFAULT/IGNORE checking. */
                if(SvPOK(*svp)) {
-                       char *s=SvPVX(*svp);
+                       const char *s=SvPVX_const(*svp);
                        if(strEQ(s,"IGNORE")) {
                                act.sa_handler = SIG_IGN;
                        }
index e743f3f..125978b 100644 (file)
@@ -308,8 +308,8 @@ PerlIOEncode_fill(pTHX_ PerlIO * f)
        }
        else {
            /* Create a "dummy" SV to represent the available data from layer below */
-           if (SvLEN(e->dataSV) && SvPVX(e->dataSV)) {
-               Safefree(SvPVX(e->dataSV));
+           if (SvLEN(e->dataSV) && SvPVX_const(e->dataSV)) {
+               Safefree(SvPVX_const(e->dataSV));
            }
            if (use > (SSize_t)e->base.bufsiz) {
                if (e->flags & NEEDS_LINES) {
index 028a298..733ffd6 100644 (file)
@@ -141,7 +141,7 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
                    newSVpvn(Perl_form(aTHX_ "PerlIO::via::%s", pkg),
                             pkglen + 13);
                SvREFCNT_dec(arg);
-               s->stash = gv_stashpvn(SvPVX(s->obj), pkglen + 13, FALSE);
+               s->stash = gv_stashpvn(SvPVX_const(s->obj), pkglen + 13, FALSE);
            }
            if (s->stash) {
                char lmode[8];
index d746c55..d9484c6 100644 (file)
@@ -379,7 +379,7 @@ typedef struct stcxt {
        PerlIO *fio;            /* where I/O are performed, NULL for memory */
        int ver_major;          /* major of version for retrieved object */
        int ver_minor;          /* minor of version for retrieved object */
-       SV *(**retrieve_vtbl)(pTHX_ struct stcxt *, char *);    /* retrieve dispatch table */
+       SV *(**retrieve_vtbl)(pTHX_ struct stcxt *, const char *);      /* retrieve dispatch table */
        SV *prev;               /* contexts chained backwards in real recursion */
        SV *my_sv;              /* the blessed scalar who's SvPVX() I am */
 } stcxt_t;
@@ -1064,7 +1064,7 @@ static const char byteorderstr_56[] = {BYTEORDER_BYTES_56, 0};
 #endif /* PATCHLEVEL <= 6 */
 
 static int store(pTHX_ stcxt_t *cxt, SV *sv);
-static SV *retrieve(pTHX_ stcxt_t *cxt, char *cname);
+static SV *retrieve(pTHX_ stcxt_t *cxt, const char *cname);
 
 /*
  * Dynamic dispatching table for SV store.
@@ -1099,24 +1099,24 @@ static sv_store_t sv_store[] = {
  * Dynamic dispatching tables for SV retrieval.
  */
 
-static SV *retrieve_lscalar(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_lutf8str(pTHX_ stcxt_t *cxt, char *cname);
-static SV *old_retrieve_array(pTHX_ stcxt_t *cxt, char *cname);
-static SV *old_retrieve_hash(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_ref(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_undef(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_integer(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_double(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_byte(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_netint(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_scalar(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_utf8str(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_tied_array(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_tied_hash(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_tied_scalar(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_other(pTHX_ stcxt_t *cxt, char *cname);
-
-typedef SV* (*sv_retrieve_t)(pTHX_ stcxt_t *cxt, char *name);
+static SV *retrieve_lscalar(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_lutf8str(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *old_retrieve_array(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *old_retrieve_hash(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_ref(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_undef(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_integer(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_double(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_byte(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_netint(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_scalar(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_utf8str(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_tied_array(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_tied_hash(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_tied_scalar(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_other(pTHX_ stcxt_t *cxt, const char *cname);
+
+typedef SV* (*sv_retrieve_t)(pTHX_ stcxt_t *cxt, const char *name);
 
 static const sv_retrieve_t sv_old_retrieve[] = {
        0,                      /* SX_OBJECT -- entry unused dynamically */
@@ -1151,21 +1151,21 @@ static const sv_retrieve_t sv_old_retrieve[] = {
        (sv_retrieve_t)retrieve_other,  /* SX_ERROR */
 };
 
-static SV *retrieve_array(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_hash(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_sv_undef(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_sv_yes(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_sv_no(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_blessed(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_idx_blessed(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_overloaded(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_tied_key(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_tied_idx(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_flag_hash(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_code(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_weakref(pTHX_ stcxt_t *cxt, char *cname);
-static SV *retrieve_weakoverloaded(pTHX_ stcxt_t *cxt, char *cname);
+static SV *retrieve_array(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_hash(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_sv_undef(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_sv_yes(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_sv_no(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_blessed(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_idx_blessed(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_hook(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_overloaded(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_tied_key(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_tied_idx(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_flag_hash(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_code(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_weakref(pTHX_ stcxt_t *cxt, const char *cname);
+static SV *retrieve_weakoverloaded(pTHX_ stcxt_t *cxt, const char *cname);
 
 static const sv_retrieve_t sv_retrieve[] = {
        0,                      /* SX_OBJECT -- entry unused dynamically */
@@ -3887,7 +3887,7 @@ SV *net_mstore(pTHX_ SV *sv)
  * Return an error via croak, since it is not possible that we get here
  * under normal conditions, when facing a file produced via pstore().
  */
-static SV *retrieve_other(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_other(pTHX_ stcxt_t *cxt, const char *cname)
 {
        if (
                cxt->ver_major != STORABLE_BIN_MAJOR &&
@@ -3912,10 +3912,10 @@ static SV *retrieve_other(pTHX_ stcxt_t *cxt, char *cname)
  * Layout is SX_IX_BLESS <index> <object> with SX_IX_BLESS already read.
  * <index> can be coded on either 1 or 5 bytes.
  */
-static SV *retrieve_idx_blessed(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_idx_blessed(pTHX_ stcxt_t *cxt, const char *cname)
 {
        I32 idx;
-       char *classname;
+       const char *classname;
        SV **sva;
        SV *sv;
 
@@ -3953,7 +3953,7 @@ static SV *retrieve_idx_blessed(pTHX_ stcxt_t *cxt, char *cname)
  * Layout is SX_BLESS <len> <classname> <object> with SX_BLESS already read.
  * <len> can be coded on either 1 or 5 bytes.
  */
-static SV *retrieve_blessed(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_blessed(pTHX_ stcxt_t *cxt, const char *cname)
 {
        I32 len;
        SV *sv;
@@ -4019,7 +4019,7 @@ static SV *retrieve_blessed(pTHX_ stcxt_t *cxt, char *cname)
  * processing (since we won't have seen the magic object by the time the hook
  * is called).  See comments below for why it was done that way.
  */
-static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_hook(pTHX_ stcxt_t *cxt, const char *cname)
 {
        I32 len;
        char buf[LG_BLESS + 1];         /* Avoid malloc() if possible */
@@ -4419,7 +4419,7 @@ static SV *retrieve_hook(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve reference to some other scalar.
  * Layout is SX_REF <object>, with SX_REF already read.
  */
-static SV *retrieve_ref(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_ref(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *rv;
        SV *sv;
@@ -4479,7 +4479,7 @@ static SV *retrieve_ref(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve weak reference to some other scalar.
  * Layout is SX_WEAKREF <object>, with SX_WEAKREF already read.
  */
-static SV *retrieve_weakref(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_weakref(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *sv;
 
@@ -4502,7 +4502,7 @@ static SV *retrieve_weakref(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve reference to some other scalar with overloading.
  * Layout is SX_OVERLOAD <object>, with SX_OVERLOAD already read.
  */
-static SV *retrieve_overloaded(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_overloaded(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *rv;
        SV *sv;
@@ -4571,7 +4571,7 @@ static SV *retrieve_overloaded(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve weak overloaded reference to some other scalar.
  * Layout is SX_WEAKOVERLOADED <object>, with SX_WEAKOVERLOADED already read.
  */
-static SV *retrieve_weakoverloaded(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_weakoverloaded(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *sv;
 
@@ -4594,7 +4594,7 @@ static SV *retrieve_weakoverloaded(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve tied array
  * Layout is SX_TIED_ARRAY <object>, with SX_TIED_ARRAY already read.
  */
-static SV *retrieve_tied_array(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_tied_array(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *tv;
        SV *sv;
@@ -4623,7 +4623,7 @@ static SV *retrieve_tied_array(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve tied hash
  * Layout is SX_TIED_HASH <object>, with SX_TIED_HASH already read.
  */
-static SV *retrieve_tied_hash(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_tied_hash(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *tv;
        SV *sv;
@@ -4651,7 +4651,7 @@ static SV *retrieve_tied_hash(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve tied scalar
  * Layout is SX_TIED_SCALAR <object>, with SX_TIED_SCALAR already read.
  */
-static SV *retrieve_tied_scalar(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_tied_scalar(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *tv;
        SV *sv, *obj = NULL;
@@ -4687,7 +4687,7 @@ static SV *retrieve_tied_scalar(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve reference to value in a tied hash.
  * Layout is SX_TIED_KEY <object> <key>, with SX_TIED_KEY already read.
  */
-static SV *retrieve_tied_key(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_tied_key(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *tv;
        SV *sv;
@@ -4719,7 +4719,7 @@ static SV *retrieve_tied_key(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve reference to value in a tied array.
  * Layout is SX_TIED_IDX <object> <idx>, with SX_TIED_IDX already read.
  */
-static SV *retrieve_tied_idx(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_tied_idx(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *tv;
        SV *sv;
@@ -4752,7 +4752,7 @@ static SV *retrieve_tied_idx(pTHX_ stcxt_t *cxt, char *cname)
  * The scalar is "long" in that <length> is larger than LG_SCALAR so it
  * was not stored on a single byte.
  */
-static SV *retrieve_lscalar(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_lscalar(pTHX_ stcxt_t *cxt, const char *cname)
 {
        I32 len;
        SV *sv;
@@ -4798,7 +4798,7 @@ static SV *retrieve_lscalar(pTHX_ stcxt_t *cxt, char *cname)
  * The scalar is "short" so <length> is single byte. If it is 0, there
  * is no <data> section.
  */
-static SV *retrieve_scalar(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_scalar(pTHX_ stcxt_t *cxt, const char *cname)
 {
        int len;
        SV *sv;
@@ -4857,7 +4857,7 @@ static SV *retrieve_scalar(pTHX_ stcxt_t *cxt, char *cname)
  * Like retrieve_scalar(), but tag result as utf8.
  * If we're retrieving UTF8 data in a non-UTF8 perl, croaks.
  */
-static SV *retrieve_utf8str(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_utf8str(pTHX_ stcxt_t *cxt, const char *cname)
 {
     SV *sv;
 
@@ -4886,7 +4886,7 @@ static SV *retrieve_utf8str(pTHX_ stcxt_t *cxt, char *cname)
  * Like retrieve_lscalar(), but tag result as utf8.
  * If we're retrieving UTF8 data in a non-UTF8 perl, croaks.
  */
-static SV *retrieve_lutf8str(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_lutf8str(pTHX_ stcxt_t *cxt, const char *cname)
 {
     SV *sv;
 
@@ -4914,7 +4914,7 @@ static SV *retrieve_lutf8str(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve defined integer.
  * Layout is SX_INTEGER <data>, whith SX_INTEGER already read.
  */
-static SV *retrieve_integer(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_integer(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *sv;
        IV iv;
@@ -4937,7 +4937,7 @@ static SV *retrieve_integer(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve defined integer in network order.
  * Layout is SX_NETINT <data>, whith SX_NETINT already read.
  */
-static SV *retrieve_netint(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_netint(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *sv;
        I32 iv;
@@ -4965,7 +4965,7 @@ static SV *retrieve_netint(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve defined double.
  * Layout is SX_DOUBLE <data>, whith SX_DOUBLE already read.
  */
-static SV *retrieve_double(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_double(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *sv;
        NV nv;
@@ -4988,7 +4988,7 @@ static SV *retrieve_double(pTHX_ stcxt_t *cxt, char *cname)
  * Retrieve defined byte (small integer within the [-128, +127] range).
  * Layout is SX_BYTE <data>, whith SX_BYTE already read.
  */
-static SV *retrieve_byte(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_byte(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *sv;
        int siv;
@@ -5013,7 +5013,7 @@ static SV *retrieve_byte(pTHX_ stcxt_t *cxt, char *cname)
  *
  * Return the undefined value.
  */
-static SV *retrieve_undef(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_undef(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV* sv;
 
@@ -5030,7 +5030,7 @@ static SV *retrieve_undef(pTHX_ stcxt_t *cxt, char *cname)
  *
  * Return the immortal undefined value.
  */
-static SV *retrieve_sv_undef(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_sv_undef(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *sv = &PL_sv_undef;
 
@@ -5051,7 +5051,7 @@ static SV *retrieve_sv_undef(pTHX_ stcxt_t *cxt, char *cname)
  *
  * Return the immortal yes value.
  */
-static SV *retrieve_sv_yes(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_sv_yes(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *sv = &PL_sv_yes;
 
@@ -5066,7 +5066,7 @@ static SV *retrieve_sv_yes(pTHX_ stcxt_t *cxt, char *cname)
  *
  * Return the immortal no value.
  */
-static SV *retrieve_sv_no(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_sv_no(pTHX_ stcxt_t *cxt, const char *cname)
 {
        SV *sv = &PL_sv_no;
 
@@ -5085,7 +5085,7 @@ static SV *retrieve_sv_no(pTHX_ stcxt_t *cxt, char *cname)
  *
  * When we come here, SX_ARRAY has been read already.
  */
-static SV *retrieve_array(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_array(pTHX_ stcxt_t *cxt, const char *cname)
 {
        I32 len;
        I32 i;
@@ -5136,7 +5136,7 @@ static SV *retrieve_array(pTHX_ stcxt_t *cxt, char *cname)
  *
  * When we come here, SX_HASH has been read already.
  */
-static SV *retrieve_hash(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_hash(pTHX_ stcxt_t *cxt, const char *cname)
 {
        I32 len;
        I32 size;
@@ -5210,7 +5210,7 @@ static SV *retrieve_hash(pTHX_ stcxt_t *cxt, char *cname)
  *
  * When we come here, SX_HASH has been read already.
  */
-static SV *retrieve_flag_hash(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_flag_hash(pTHX_ stcxt_t *cxt, const char *cname)
 {
     dVAR;
     I32 len;
@@ -5347,7 +5347,7 @@ static SV *retrieve_flag_hash(pTHX_ stcxt_t *cxt, char *cname)
  *
  * Return a code reference.
  */
-static SV *retrieve_code(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve_code(pTHX_ stcxt_t *cxt, const char *cname)
 {
 #if PERL_VERSION < 6
     CROAK(("retrieve_code does not work with perl 5.005 or less\n"));
@@ -5468,7 +5468,7 @@ static SV *retrieve_code(pTHX_ stcxt_t *cxt, char *cname)
  *
  * When we come here, SX_ARRAY has been read already.
  */
-static SV *old_retrieve_array(pTHX_ stcxt_t *cxt, char *cname)
+static SV *old_retrieve_array(pTHX_ stcxt_t *cxt, const char *cname)
 {
        I32 len;
        I32 i;
@@ -5528,7 +5528,7 @@ static SV *old_retrieve_array(pTHX_ stcxt_t *cxt, char *cname)
  *
  * When we come here, SX_HASH has been read already.
  */
-static SV *old_retrieve_hash(pTHX_ stcxt_t *cxt, char *cname)
+static SV *old_retrieve_hash(pTHX_ stcxt_t *cxt, const char *cname)
 {
        I32 len;
        I32 size;
@@ -5687,7 +5687,7 @@ static SV *magic_check(pTHX_ stcxt_t *cxt)
      */
 
     version_major = use_network_order >> 1;
-    cxt->retrieve_vtbl = (SV*(**)(pTHX_ stcxt_t *cxt, char *cname)) (version_major ? sv_retrieve : sv_old_retrieve);
+    cxt->retrieve_vtbl = (SV*(**)(pTHX_ stcxt_t *cxt, const char *cname)) (version_major ? sv_retrieve : sv_old_retrieve);
 
     TRACEME(("magic_check: netorder = 0x%x", use_network_order));
 
@@ -5800,7 +5800,7 @@ static SV *magic_check(pTHX_ stcxt_t *cxt)
  * root SV (which may be an AV or an HV for what we care).
  * Returns null if there is a problem.
  */
-static SV *retrieve(pTHX_ stcxt_t *cxt, char *cname)
+static SV *retrieve(pTHX_ stcxt_t *cxt, const char *cname)
 {
        int type;
        SV **svh;
index f829f49..c9bfc46 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1397,7 +1397,7 @@ yup:                                      /* Confirmed by INTUIT */
                              (int)(t-truebase));
            }
            rx->saved_copy = sv_setsv_cow(rx->saved_copy, TARG);
-           rx->subbeg = SvPVX(rx->saved_copy) + (t - truebase);
+           rx->subbeg = SvPVX_const(rx->saved_copy) + (t - truebase);
            assert (SvPOKp(rx->saved_copy));
        } else
 #endif
@@ -1593,7 +1593,7 @@ Perl_do_readline(pTHX)
 
            if (SvCUR(sv) > 0 && SvCUR(PL_rs) > 0) {
                tmps = SvEND(sv) - 1;
-               if (*tmps == *SvPVX(PL_rs)) {
+               if (*tmps == *SvPVX_const(PL_rs)) {
                    *tmps = '\0';
                    SvCUR_set(sv, SvCUR(sv) - 1);
                }
@@ -1602,7 +1602,7 @@ Perl_do_readline(pTHX)
                if (!isALPHA(*tmps) && !isDIGIT(*tmps) &&
                    strchr("$&*(){}[]'\";\\|?<>~`", *tmps))
                        break;
-           if (*tmps && PerlLIO_lstat(SvPVX(sv), &PL_statbuf) < 0) {
+           if (*tmps && PerlLIO_lstat(SvPVX_const(sv), &PL_statbuf) < 0) {
                (void)POPs;             /* Unmatched wildcard?  Chuck it... */
                continue;
            }
@@ -1837,7 +1837,7 @@ PP(pp_iter)
                    *itersvp = newSVsv(cur);
                    SvREFCNT_dec(oldsv);
                }
-               if (strEQ(SvPVX(cur), max))
+               if (strEQ(SvPVX_const(cur), max))
                    sv_setiv(cur, 0); /* terminate next time */
                else
                    sv_inc(cur);
@@ -2162,7 +2162,7 @@ PP(pp_subst)
                                 REXEC_NOT_FIRST|REXEC_IGNOREPOS));
            if (s != d) {
                i = strend - s;
-               SvCUR_set(TARG, d - SvPVX(TARG) + i);
+               SvCUR_set(TARG, d - SvPVX_const(TARG) + i);
                Move(s, d, i+1, char);          /* include the NUL */
            }
            TAINT_IF(rxtainted & 1);
@@ -2619,7 +2619,7 @@ PP(pp_entersub)
                mg_get(sv);
                if (SvROK(sv))
                    goto got_rv;
-               sym = SvPOKp(sv) ? SvPVX(sv) : Nullch;
+               sym = SvPOKp(sv) ? SvPVX_const(sv) : Nullch;
            }
            else {
                 STRLEN n_a;
index d4731a2..9987a7b 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -1558,7 +1558,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
                }
            }
            *str = '\0';
-           SvCUR_set(sv, str - SvPVX(sv));
+           SvCUR_set(sv, str - SvPVX_const(sv));
            XPUSHs(sv);
            break;
        }
@@ -1595,7 +1595,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
                }
            }
            *str = '\0';
-           SvCUR_set(sv, str - SvPVX(sv));
+           SvCUR_set(sv, str - SvPVX_const(sv));
            XPUSHs(sv);
            break;
        }
@@ -2445,7 +2445,7 @@ marked_upgrade(pTHX_ SV *sv, tempsym_t *sym_ptr) {
 
     if (SvUTF8(sv)) return;
 
-    from_start = SvPVX(sv);
+    from_start = SvPVX_const(sv);
     from_end = from_start + SvCUR(sv);
     for (from_ptr = from_start; from_ptr < from_end; from_ptr++)
        if (!NATIVE_IS_INVARIANT(*from_ptr)) break;
index dbf483c..98b99e4 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1236,7 +1236,7 @@ PP(pp_getc)
     *SvPVX(TARG) = PerlIO_getc(IoIFP(GvIOp(gv))); /* should never be EOF */
     if (PerlIO_isutf8(IoIFP(GvIOp(gv)))) {
        /* Find out how many bytes the char needs */
-       Size_t len = UTF8SKIP(SvPVX(TARG));
+       Size_t len = UTF8SKIP(SvPVX_const(TARG));
        if (len > 1) {
            SvGROW(TARG,len+1);
            len = PerlIO_read(IoIFP(GvIOp(gv)),SvPVX(TARG)+1,len-1);
@@ -1371,7 +1371,7 @@ PP(pp_leavewrite)
            }
            if (s) {
                const STRLEN save = SvCUR(PL_formtarget);
-               SvCUR_set(PL_formtarget, s - SvPVX(PL_formtarget));
+               SvCUR_set(PL_formtarget, s - SvPVX_const(PL_formtarget));
                do_print(PL_formtarget, ofp);
                SvCUR_set(PL_formtarget, save);
                sv_chop(PL_formtarget, s);
@@ -1740,7 +1740,7 @@ PP(pp_sysread)
                report_evil_fh(gv, io, OP_phoney_OUTPUT_ONLY);
        goto say_undef;
     }
-    SvCUR_set(read_target, count+(buffer - SvPVX(read_target)));
+    SvCUR_set(read_target, count+(buffer - SvPVX_const(read_target)));
     *SvEND(read_target) = '\0';
     (void)SvPOK_only(read_target);
     if (fp_utf8 && !IN_BYTES) {
@@ -1754,7 +1754,7 @@ PP(pp_sysread)
            if (buffer - charskip + skip > bend) {
                /* partial character - try for rest of it */
                length = skip - (bend-buffer);
-               offset = bend - SvPVX(bufsv);
+               offset = bend - SvPVX_const(bufsv);
                charstart = FALSE;
                charskip += count;
                goto more_bytes;
@@ -1771,7 +1771,7 @@ PP(pp_sysread)
         */
        if (got < wanted && count == length) {
            length = wanted - got;
-           offset = bend - SvPVX(bufsv);
+           offset = bend - SvPVX_const(bufsv);
            goto more_bytes;
        }
        /* return value is character count */
@@ -3461,7 +3461,7 @@ PP(pp_fttext)
        PL_statgv = Nullgv;
        PL_laststype = OP_STAT;
        sv_setpv(PL_statname, SvPV(sv, n_a));
-       if (!(fp = PerlIO_open(SvPVX(PL_statname), "r"))) {
+       if (!(fp = PerlIO_open(SvPVX_const(PL_statname), "r"))) {
            if (ckWARN(WARN_NEWLINE) && strchr(SvPV(PL_statname, n_a), '\n'))
                Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "open");
            RETPUSHUNDEF;
diff --git a/scope.c b/scope.c
index 5fce68a..494fe0b 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -267,7 +267,7 @@ Perl_save_gp(pTHX_ GV *gv, I32 empty)
     SSPUSHIV((IV)SvLEN(gv));
     SvLEN_set(gv, 0); /* forget that anything was allocated here */
     SSPUSHIV((IV)SvCUR(gv));
-    SSPUSHPTR(SvPVX(gv));
+    SSPUSHPTR(SvPVX_const(gv));
     SvPOK_off(gv);
     SSPUSHPTR(SvREFCNT_inc(gv));
     SSPUSHPTR(GvGP(gv));
@@ -838,8 +838,8 @@ Perl_leave_scope(pTHX_ I32 base)
        case SAVEt_GP:                          /* scalar reference */
            ptr = SSPOPPTR;
            gv = (GV*)SSPOPPTR;
-           if (SvPVX(gv) && SvLEN(gv) > 0) {
-               Safefree(SvPVX(gv));
+           if (SvPVX_const(gv) && SvLEN(gv) > 0) {
+               Safefree(SvPVX_const(gv));
            }
            SvPV_set(gv, (char *)SSPOPPTR);
            SvCUR_set(gv, (STRLEN)SSPOPIV);
@@ -1091,7 +1091,7 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
                PL_op_desc[cx->blk_eval.old_op_type]);
        if (cx->blk_eval.old_namesv)
            PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n",
-                         SvPVX(cx->blk_eval.old_namesv));
+                         SvPVX_const(cx->blk_eval.old_namesv));
        PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_EVAL_ROOT = 0x%"UVxf"\n",
                PTR2UV(cx->blk_eval.old_eval_root));
        PerlIO_printf(Perl_debug_log, "BLK_EVAL.RETOP = 0x%"UVxf"\n",