summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Peters <steve@fisharerojo.org>2005-05-20 16:42:10 -0500
committerAbhijit Menon-Sen <ams@wiw.org>2005-05-21 02:58:49 +0000
commitb15aece354b2aec9d338e59acb2abc2deeebc3c0 (patch)
treecd9381dd13364c19fdc12c6a4d15a29d82e5314e
parent8d2f45362e368d7dd455b476c924dcbcc02d845b (diff)
downloadperl-b15aece354b2aec9d338e59acb2abc2deeebc3c0.tar.gz
SvPVX_const - patch #2
Message-Id: <20050521024210.GA29036@mccoy.peters.homeunix.org> p4raw-id: //depot/perl@24523
-rw-r--r--dump.c35
-rw-r--r--gv.c12
-rw-r--r--op.c30
-rw-r--r--pad.c32
-rw-r--r--perlio.c2
-rw-r--r--perly.c4
-rw-r--r--pp.c8
-rw-r--r--pp_ctl.c38
8 files changed, 81 insertions, 80 deletions
diff --git a/dump.c b/dump.c
index 627c5c0477..1b565b3daf 100644
--- a/dump.c
+++ b/dump.c
@@ -83,7 +83,7 @@ Perl_dump_sub(pTHX_ const GV *gv)
SV *sv = sv_newmortal();
gv_fullname3(sv, gv, Nullch);
- Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nSUB %s = ", SvPVX(sv));
+ Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nSUB %s = ", SvPVX_const(sv));
if (CvXSUB(GvCV(gv)))
Perl_dump_indent(aTHX_ 0, Perl_debug_log, "(xsub 0x%"UVxf" %d)\n",
PTR2UV(CvXSUB(GvCV(gv))),
@@ -100,7 +100,7 @@ Perl_dump_form(pTHX_ const GV *gv)
SV *sv = sv_newmortal();
gv_fullname3(sv, gv, Nullch);
- Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nFORMAT %s = ", SvPVX(sv));
+ Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nFORMAT %s = ", SvPVX_const(sv));
if (CvROOT(GvFORM(gv)))
op_dump(CvROOT(GvFORM(gv)));
else
@@ -193,7 +193,7 @@ Perl_sv_peek(pTHX_ SV *sv)
!(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
SVp_POK|SVp_NOK)) &&
SvCUR(sv) == 1 &&
- SvPVX(sv) && *SvPVX(sv) == '1' &&
+ SvPVX_const(sv) && *SvPVX_const(sv) == '1' &&
SvNVX(sv) == 1.0)
goto finish;
}
@@ -297,14 +297,14 @@ Perl_sv_peek(pTHX_ SV *sv)
}
if (SvPOKp(sv)) {
- if (!SvPVX(sv))
+ if (!SvPVX_const(sv))
sv_catpv(t, "(null)");
else {
SV *tmp = newSVpvn("", 0);
sv_catpv(t, "(");
if (SvOOK(sv))
- Perl_sv_catpvf(aTHX_ t, "[%s]", pv_display(tmp, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, 127));
- Perl_sv_catpvf(aTHX_ t, "%s)", pv_display(tmp, SvPVX(sv), SvCUR(sv), SvLEN(sv), 127));
+ Perl_sv_catpvf(aTHX_ t, "[%s]", pv_display(tmp, SvPVX_const(sv)-SvIVX(sv), SvIVX(sv), 0, 127));
+ Perl_sv_catpvf(aTHX_ t, "%s)", pv_display(tmp, SvPVX_const(sv), SvCUR(sv), SvLEN(sv), 127));
if (SvUTF8(sv))
Perl_sv_catpvf(aTHX_ t, " [UTF8 \"%s\"]",
sv_uni_display(tmp, sv, 8 * sv_len_utf8(sv),
@@ -387,7 +387,7 @@ Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, const PMOP *pm)
sv_catpv(tmpsv, ",RETAINT");
if (pm->op_pmflags & PMf_EVAL)
sv_catpv(tmpsv, ",EVAL");
- Perl_dump_indent(aTHX_ level, file, "PMFLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : "");
+ Perl_dump_indent(aTHX_ level, file, "PMFLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX_const(tmpsv) + 1 : "");
SvREFCNT_dec(tmpsv);
}
@@ -583,7 +583,7 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o)
sv_catpv(tmpsv, ",MOD");
if (o->op_flags & OPf_SPECIAL)
sv_catpv(tmpsv, ",SPECIAL");
- Perl_dump_indent(aTHX_ level, file, "FLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX(tmpsv) + 1 : "");
+ Perl_dump_indent(aTHX_ level, file, "FLAGS = (%s)\n", SvCUR(tmpsv) ? SvPVX_const(tmpsv) + 1 : "");
SvREFCNT_dec(tmpsv);
}
if (o->op_private) {
@@ -753,7 +753,7 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o)
if (o->op_flags & OPf_MOD && o->op_private & OPpLVAL_INTRO)
sv_catpv(tmpsv, ",INTRO");
if (SvCUR(tmpsv))
- Perl_dump_indent(aTHX_ level, file, "PRIVATE = (%s)\n", SvPVX(tmpsv) + 1);
+ Perl_dump_indent(aTHX_ level, file, "PRIVATE = (%s)\n", SvPVX_const(tmpsv) + 1);
SvREFCNT_dec(tmpsv);
}
@@ -873,10 +873,10 @@ Perl_gv_dump(pTHX_ GV *gv)
sv = sv_newmortal();
PerlIO_printf(Perl_debug_log, "{\n");
gv_fullname3(sv, gv, Nullch);
- Perl_dump_indent(aTHX_ 1, Perl_debug_log, "GV_NAME = %s", SvPVX(sv));
+ Perl_dump_indent(aTHX_ 1, Perl_debug_log, "GV_NAME = %s", SvPVX_const(sv));
if (gv != GvEGV(gv)) {
gv_efullname3(sv, GvEGV(gv), Nullch);
- Perl_dump_indent(aTHX_ 1, Perl_debug_log, "-> %s", SvPVX(sv));
+ Perl_dump_indent(aTHX_ 1, Perl_debug_log, "-> %s", SvPVX_const(sv));
}
PerlIO_putc(Perl_debug_log, '\n');
Perl_dump_indent(aTHX_ 0, Perl_debug_log, "}\n");
@@ -1208,7 +1208,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
SvPVX(d)[SvCUR(d)] = '\0';
}
sv_catpv(d, ")");
- s = SvPVX(d);
+ s = SvPVX_const(d);
#ifdef DEBUG_LEAKING_SCALARS
Perl_dump_indent(aTHX_ level, file, "ALLOCATED at %s:%d %s %s%s\n",
@@ -1313,11 +1313,11 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
return;
}
if (type <= SVt_PVLV && type != SVt_PVGV) {
- if (SvPVX(sv)) {
- Perl_dump_indent(aTHX_ level, file," PV = 0x%"UVxf" ", PTR2UV(SvPVX(sv)));
+ if (SvPVX_const(sv)) {
+ Perl_dump_indent(aTHX_ level, file," PV = 0x%"UVxf" ", PTR2UV(SvPVX_const(sv)));
if (SvOOK(sv))
- PerlIO_printf(file, "( %s . ) ", pv_display(d, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, pvlim));
- PerlIO_printf(file, "%s", pv_display(d, SvPVX(sv), SvCUR(sv), SvLEN(sv), pvlim));
+ PerlIO_printf(file, "( %s . ) ", pv_display(d, SvPVX_const(sv)-SvIVX(sv), SvIVX(sv), 0, pvlim));
+ PerlIO_printf(file, "%s", pv_display(d, SvPVX_const(sv), SvCUR(sv), SvLEN(sv), pvlim));
if (SvUTF8(sv)) /* the 8? \x{....} */
PerlIO_printf(file, " [UTF8 \"%s\"]", sv_uni_display(d, sv, 8 * sv_len_utf8(sv), UNI_DISPLAY_QQ));
PerlIO_printf(file, "\n");
@@ -1348,7 +1348,8 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
sv_setpvn(d, "", 0);
if (AvREAL(sv)) sv_catpv(d, ",REAL");
if (AvREIFY(sv)) sv_catpv(d, ",REIFY");
- Perl_dump_indent(aTHX_ level, file, " FLAGS = (%s)\n", SvCUR(d) ? SvPVX(d) + 1 : "");
+ Perl_dump_indent(aTHX_ level, file, " FLAGS = (%s)\n",
+ SvCUR(d) ? SvPVX_const(d) + 1 : "");
if (nest < maxnest && av_len((AV*)sv) >= 0) {
int count;
for (count = 0; count <= av_len((AV*)sv) && count < maxnest; count++) {
diff --git a/gv.c b/gv.c
index 0b31ae999e..5d533f0110 100644
--- a/gv.c
+++ b/gv.c
@@ -111,7 +111,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
dVAR;
register GP *gp;
const bool doproto = SvTYPE(gv) > SVt_NULL;
- const char * const proto = (doproto && SvPOK(gv)) ? SvPVX(gv) : NULL;
+ const char * const proto = (doproto && SvPOK(gv)) ? SvPVX_const(gv) : NULL;
sv_upgrade((SV*)gv, SVt_PVGV);
if (SvLEN(gv)) {
@@ -120,7 +120,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
SvLEN_set(gv, 0);
SvPOK_off(gv);
} else
- Safefree(SvPVX(gv));
+ Safefree(SvPVX_const(gv));
}
Newz(602, gp, 1, GP);
GvGP(gv) = gp_ref(gp);
@@ -433,7 +433,7 @@ Perl_gv_fetchmethod_autoload(pTHX_ HV *stash, const char *name, I32 autoload)
SV *tmpstr = sv_2mortal(Perl_newSVpvf(aTHX_ "%s::SUPER",
CopSTASHPV(PL_curcop)));
/* __PACKAGE__::SUPER stash should be autovivified */
- stash = gv_stashpvn(SvPVX(tmpstr), SvCUR(tmpstr), TRUE);
+ stash = gv_stashpvn(SvPVX_const(tmpstr), SvCUR(tmpstr), TRUE);
DEBUG_o( Perl_deb(aTHX_ "Treating %s as %s::%s\n",
origname, HvNAME(stash), name) );
}
@@ -1415,12 +1415,12 @@ Perl_Gv_AMupdate(pTHX_ HV *stash)
"' for overloaded `%s' in package `%.256s'\n",
GvSV(gv), cp, HvNAME(stash)) );
if (!SvPOK(GvSV(gv))
- || !(ngv = gv_fetchmethod_autoload(stash, SvPVX(GvSV(gv)),
+ || !(ngv = gv_fetchmethod_autoload(stash, SvPVX_const(GvSV(gv)),
FALSE)))
{
/* Can be an import stub (created by `can'). */
SV *gvsv = GvSV(gv);
- const char *name = SvPOK(gvsv) ? SvPVX(gvsv) : "???";
+ const char *name = SvPOK(gvsv) ? SvPVX_const(gvsv) : "???";
Perl_croak(aTHX_ "%s method `%.256s' overloading `%s' "\
"in package `%.256s'",
(GvCVGEN(gv) ? "Stub found while resolving"
@@ -1707,7 +1707,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags)
HvNAME(SvSTASH(SvRV(right))):
""));
if (amtp && amtp->fallback >= AMGfallYES) {
- DEBUG_o( Perl_deb(aTHX_ "%s", SvPVX(msg)) );
+ DEBUG_o( Perl_deb(aTHX_ "%s", SvPVX_const(msg)) );
} else {
Perl_croak(aTHX_ "%"SVf, msg);
}
diff --git a/op.c b/op.c
index c8eff92b3b..17522bf753 100644
--- a/op.c
+++ b/op.c
@@ -785,9 +785,9 @@ Perl_scalarvoid(pTHX_ OP *o)
built upon these three nroff macros being used in
void context. The pink camel has the details in
the script wrapman near page 319. */
- if (strnEQ(SvPVX(sv), "di", 2) ||
- strnEQ(SvPVX(sv), "ds", 2) ||
- strnEQ(SvPVX(sv), "ig", 2))
+ if (strnEQ(SvPVX_const(sv), "di", 2) ||
+ strnEQ(SvPVX_const(sv), "ds", 2) ||
+ strnEQ(SvPVX_const(sv), "ig", 2))
useless = 0;
}
}
@@ -1607,7 +1607,7 @@ S_apply_attrs_my(pTHX_ HV *stash, OP *target, OP *attrs, OP **imopsp)
(void)SvIOK_on(meth);
{
U32 hash;
- PERL_HASH(hash, SvPVX(meth), SvCUR(meth));
+ PERL_HASH(hash, SvPVX_const(meth), SvCUR(meth));
SvUV_set(meth, hash);
}
imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL|OPf_WANT_VOID,
@@ -3046,7 +3046,7 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *idop, OP *arg)
(void)SvIOK_on(meth);
{
U32 hash;
- PERL_HASH(hash, SvPVX(meth), SvCUR(meth));
+ PERL_HASH(hash, SvPVX_const(meth), SvCUR(meth));
SvUV_set(meth, hash);
}
veop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
@@ -3074,7 +3074,7 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *idop, OP *arg)
(void)SvIOK_on(meth);
{
U32 hash;
- PERL_HASH(hash, SvPVX(meth), SvCUR(meth));
+ PERL_HASH(hash, SvPVX_const(meth), SvCUR(meth));
SvUV_set(meth, hash);
}
imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
@@ -4090,7 +4090,7 @@ Perl_cv_undef(pTHX_ CV *cv)
void
Perl_cv_ckproto(pTHX_ const CV *cv, const GV *gv, const char *p)
{
- if (((!p != !SvPOK(cv)) || (p && strNE(p, SvPVX(cv)))) && ckWARN_d(WARN_PROTOTYPE)) {
+ if (((!p != !SvPOK(cv)) || (p && strNE(p, SvPVX_const(cv)))) && ckWARN_d(WARN_PROTOTYPE)) {
SV* msg = sv_newmortal();
SV* name = Nullsv;
@@ -4259,7 +4259,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
Perl_sv_setpvf(aTHX_ sv, "%s[%s:%"IVdf"]",
PL_curstash ? "__ANON__" : "__ANON__::__ANON__",
CopFILE(PL_curcop), (IV)CopLINE(PL_curcop));
- aname = SvPVX(sv);
+ aname = SvPVX_const(sv);
}
else
aname = Nullch;
@@ -4509,9 +4509,9 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
CopFILE(PL_curcop),
(long)PL_subline, (long)CopLINE(PL_curcop));
gv_efullname3(tmpstr, gv, Nullch);
- hv_store(GvHV(PL_DBsub), SvPVX(tmpstr), SvCUR(tmpstr), sv, 0);
+ hv_store(GvHV(PL_DBsub), SvPVX_const(tmpstr), SvCUR(tmpstr), sv, 0);
hv = GvHVn(db_postponed);
- if (HvFILL(hv) > 0 && hv_exists(hv, SvPVX(tmpstr), SvCUR(tmpstr))
+ if (HvFILL(hv) > 0 && hv_exists(hv, SvPVX_const(tmpstr), SvCUR(tmpstr))
&& (pcv = GvCV(db_postponed)))
{
dSP;
@@ -5841,10 +5841,10 @@ Perl_ck_method(pTHX_ OP *o)
OP *kid = cUNOPo->op_first;
if (kid->op_type == OP_CONST) {
SV* sv = kSVOP->op_sv;
- if (!(strchr(SvPVX(sv), ':') || strchr(SvPVX(sv), '\''))) {
+ if (!(strchr(SvPVX_const(sv), ':') || strchr(SvPVX_const(sv), '\''))) {
OP *cmop;
if (!SvREADONLY(sv) || !SvFAKE(sv)) {
- sv = newSVpvn_share(SvPVX(sv), SvCUR(sv), 0);
+ sv = newSVpvn_share(SvPVX_const(sv), SvCUR(sv), 0);
}
else {
kSVOP->op_sv = Nullsv;
@@ -5896,7 +5896,7 @@ Perl_ck_open(pTHX_ OP *o)
OP *first = cLISTOPx(o)->op_first; /* The pushmark. */
OP *last = cLISTOPx(o)->op_last; /* The bareword. */
OP *oa;
- char *mode;
+ const char *mode;
if ((last->op_type == OP_CONST) && /* The bareword. */
(last->op_private & OPpCONST_BARE) &&
@@ -5904,7 +5904,7 @@ Perl_ck_open(pTHX_ OP *o)
(oa = first->op_sibling) && /* The fh. */
(oa = oa->op_sibling) && /* The mode. */
SvPOK(((SVOP*)oa)->op_sv) &&
- (mode = SvPVX(((SVOP*)oa)->op_sv)) &&
+ (mode = SvPVX_const(((SVOP*)oa)->op_sv)) &&
mode[0] == '>' && mode[1] == '&' && /* A dup open. */
(last == oa->op_sibling)) /* The bareword. */
last->op_private &= ~OPpCONST_STRICT;
@@ -6679,7 +6679,7 @@ Perl_peep(pTHX_ register OP *o)
}
else if ((o->op_private & OPpEARLY_CV) && ckWARN(WARN_PROTOTYPE)) {
GV *gv = cGVOPo_gv;
- if (SvTYPE(gv) == SVt_PVGV && GvCV(gv) && SvPVX(GvCV(gv))) {
+ if (SvTYPE(gv) == SVt_PVGV && GvCV(gv) && SvPVX_const(GvCV(gv))) {
/* XXX could check prototype here instead of just carping */
SV *sv = sv_newmortal();
gv_efullname3(sv, gv, Nullch);
diff --git a/pad.c b/pad.c
index e8dd681409..2cff24dc95 100644
--- a/pad.c
+++ b/pad.c
@@ -257,7 +257,7 @@ Perl_pad_undef(pTHX_ CV* cv)
for (ix = AvFILLp(comppad_name); ix > 0; ix--) {
SV *namesv = namepad[ix];
if (namesv && namesv != &PL_sv_undef
- && *SvPVX(namesv) == '&')
+ && *SvPVX_const(namesv) == '&')
{
CV * const innercv = (CV*)curpad[ix];
U32 inner_rc = SvREFCNT(innercv);
@@ -517,7 +517,7 @@ Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash)
&& (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0)
&& (!is_our
|| ((SvFLAGS(sv) & SVpad_OUR) && GvSTASH(sv) == ourstash))
- && strEQ(name, SvPVX(sv)))
+ && strEQ(name, SvPVX_const(sv)))
{
Perl_warner(aTHX_ packWARN(WARN_MISC),
"\"%s\" variable %s masks earlier declaration in same %s",
@@ -536,7 +536,7 @@ Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash)
&& !SvFAKE(sv)
&& (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0)
&& ((SvFLAGS(sv) & SVpad_OUR) && GvSTASH(sv) == ourstash)
- && strEQ(name, SvPVX(sv)))
+ && strEQ(name, SvPVX_const(sv)))
{
Perl_warner(aTHX_ packWARN(WARN_MISC),
"\"our\" variable %s redeclared", name);
@@ -586,7 +586,7 @@ Perl_pad_findmy(pTHX_ const char *name)
if (namesv && namesv != &PL_sv_undef
&& !SvFAKE(namesv)
&& (SvFLAGS(namesv) & SVpad_OUR)
- && strEQ(SvPVX(namesv), name)
+ && strEQ(SvPVX_const(namesv), name)
&& U_32(SvNVX(namesv)) == PAD_MAX /* min */
)
return offset;
@@ -669,7 +669,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
for (offset = AvFILLp(nameav); offset > 0; offset--) {
const SV *namesv = name_svp[offset];
if (namesv && namesv != &PL_sv_undef
- && strEQ(SvPVX(namesv), name))
+ && strEQ(SvPVX_const(namesv), name))
{
if (SvFAKE(namesv))
fake_offset = offset; /* in case we don't find a real one */
@@ -816,7 +816,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
PL_curpad = AvARRAY(PL_comppad);
new_offset = pad_add_name(
- SvPVX(*out_name_sv),
+ SvPVX_const(*out_name_sv),
(SvFLAGS(*out_name_sv) & SVpad_TYPED)
? SvSTASH(*out_name_sv) : Nullhv,
(SvFLAGS(*out_name_sv) & SVpad_OUR)
@@ -966,7 +966,7 @@ Perl_intro_my(pTHX)
SvNV_set(sv, (NV)PL_cop_seqmax);
DEBUG_Xv(PerlIO_printf(Perl_debug_log,
"Pad intromy: %ld \"%s\", (%ld,%ld)\n",
- (long)i, SvPVX(sv),
+ (long)i, SvPVX_const(sv),
(long)U_32(SvNVX(sv)), (long)SvIVX(sv))
);
}
@@ -1015,7 +1015,7 @@ Perl_pad_leavemy(pTHX)
SvIV_set(sv, PL_cop_seqmax);
DEBUG_Xv(PerlIO_printf(Perl_debug_log,
"Pad leavemy: %ld \"%s\", (%ld,%ld)\n",
- (long)off, SvPVX(sv),
+ (long)off, SvPVX_const(sv),
(long)U_32(SvNVX(sv)), (long)SvIVX(sv))
);
}
@@ -1168,7 +1168,7 @@ Perl_pad_tidy(pTHX_ padtidy_type type)
*/
if (!((namesv = namep[ix]) != Nullsv &&
namesv != &PL_sv_undef &&
- *SvPVX(namesv) == '&'))
+ *SvPVX_const(namesv) == '&'))
{
SvREFCNT_dec(PL_curpad[ix]);
PL_curpad[ix] = Nullsv;
@@ -1289,7 +1289,7 @@ Perl_do_dump_pad(pTHX_ I32 level, PerlIO *file, PADLIST *padlist, int full)
(int) ix,
PTR2UV(ppad[ix]),
(unsigned long) (ppad[ix] ? SvREFCNT(ppad[ix]) : 0),
- SvPVX(namesv),
+ SvPVX_const(namesv),
(unsigned long)SvIVX(namesv),
(unsigned long)SvNVX(namesv)
@@ -1302,7 +1302,7 @@ Perl_do_dump_pad(pTHX_ I32 level, PerlIO *file, PADLIST *padlist, int full)
(unsigned long) (ppad[ix] ? SvREFCNT(ppad[ix]) : 0),
(long)U_32(SvNVX(namesv)),
(long)SvIVX(namesv),
- SvPVX(namesv)
+ SvPVX_const(namesv)
);
}
else if (full) {
@@ -1425,7 +1425,7 @@ Perl_cv_clone(pTHX_ CV *proto)
CvOUTSIDE_SEQ(cv) = CvOUTSIDE_SEQ(proto);
if (SvPOK(proto))
- sv_setpvn((SV*)cv, SvPVX(proto), SvCUR(proto));
+ sv_setpvn((SV*)cv, SvPVX_const(proto), SvCUR(proto));
CvPADLIST(cv) = pad_new(padnew_CLONE|padnew_SAVE);
@@ -1448,7 +1448,7 @@ Perl_cv_clone(pTHX_ CV *proto)
if (SvTYPE(proto) == SVt_PVFM && SvPADSTALE(sv)) {
if (ckWARN(WARN_CLOSURE))
Perl_warner(aTHX_ packWARN(WARN_CLOSURE),
- "Variable \"%s\" is not available", SvPVX(namesv));
+ "Variable \"%s\" is not available", SvPVX_const(namesv));
sv = Nullsv;
}
else {
@@ -1457,7 +1457,7 @@ Perl_cv_clone(pTHX_ CV *proto)
}
}
if (!sv) {
- const char sigil = SvPVX(namesv)[0];
+ const char sigil = SvPVX_const(namesv)[0];
if (sigil == '&')
sv = SvREFCNT_inc(ppad[ix]);
else if (sigil == '@')
@@ -1529,7 +1529,7 @@ Perl_pad_fixup_inner_anons(pTHX_ PADLIST *padlist, CV *old_cv, CV *new_cv)
for (ix = AvFILLp(comppad_name); ix > 0; ix--) {
const SV *namesv = namepad[ix];
if (namesv && namesv != &PL_sv_undef
- && *SvPVX(namesv) == '&')
+ && *SvPVX_const(namesv) == '&')
{
CV *innercv = (CV*)curpad[ix];
assert(CvWEAKOUTSIDE(innercv));
@@ -1567,7 +1567,7 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth)
for ( ;ix > 0; ix--) {
if (names_fill >= ix && names[ix] != &PL_sv_undef) {
- const char sigil = SvPVX(names[ix])[0];
+ const char sigil = SvPVX_const(names[ix])[0];
if ((SvFLAGS(names[ix]) & SVf_FAKE) || sigil == '&') {
/* outer lexical or anon code */
av_store(newpad, ix, SvREFCNT_inc(oldpad[ix]));
diff --git a/perlio.c b/perlio.c
index 69186cee04..b4ebc7bab7 100644
--- a/perlio.c
+++ b/perlio.c
@@ -4892,7 +4892,7 @@ PerlIO_tmpfile(void)
f = PerlIO_fdopen(fd, "w+");
if (f)
PerlIOBase(f)->flags |= PERLIO_F_TEMP;
- PerlLIO_unlink(SvPVX(sv));
+ PerlLIO_unlink(SvPVX_const(sv));
SvREFCNT_dec(sv);
}
# else /* !HAS_MKSTEMP, fallback to stdio tmpfile(). */
diff --git a/perly.c b/perly.c
index 6b9e376625..91f3bb9636 100644
--- a/perly.c
+++ b/perly.c
@@ -322,7 +322,7 @@ Perl_yyparse (pTHX)
#ifdef DEBUGGING
yyns_sv = NEWSV(73, YYINITDEPTH * sizeof(char *));
SAVEFREESV(yyns_sv);
- yyns = (const char **) SvPVX(yyns_sv);
+ yyns = SvPVX_const(yyns_sv);
yynsp = yyns;
#endif
@@ -366,7 +366,7 @@ Perl_yyparse (pTHX)
yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
#ifdef DEBUGGING
SvGROW(yyns_sv, yystacksize * sizeof(char *));
- yyns = (const char **) SvPVX(yyns_sv);
+ yyns = SvPVX_const(yyns_sv);
if (! yyns)
goto yyoverflowlab;
yynsp = yyns + yysize - 1;
diff --git a/pp.c b/pp.c
index 60301fc2c9..19e740bd05 100644
--- a/pp.c
+++ b/pp.c
@@ -181,7 +181,7 @@ PP(pp_rv2gv)
}
if (SvTYPE(sv) < SVt_RV)
sv_upgrade(sv, SVt_RV);
- if (SvPVX(sv)) {
+ if (SvPVX_const(sv)) {
SvPV_free(sv);
SvLEN_set(sv, 0);
SvCUR_set(sv, 0);
@@ -376,7 +376,7 @@ PP(pp_prototype)
ret = &PL_sv_undef;
if (SvPOK(TOPs) && SvCUR(TOPs) >= 7) {
- const char *s = SvPVX(TOPs);
+ const char *s = SvPVX_const(TOPs);
if (strnEQ(s, "CORE::", 6)) {
const int code = keyword(s + 6, SvCUR(TOPs) - 6);
if (code < 0) { /* Overridable. */
@@ -427,7 +427,7 @@ PP(pp_prototype)
}
cv = sv_2cv(TOPs, &stash, &gv, FALSE);
if (cv && SvPOK(cv))
- ret = sv_2mortal(newSVpvn(SvPVX(cv), SvCUR(cv)));
+ ret = sv_2mortal(newSVpvn(SvPVX_const(cv), SvCUR(cv)));
set:
SETs(ret);
RETURN;
@@ -826,7 +826,7 @@ PP(pp_undef)
}
break;
default:
- if (SvTYPE(sv) >= SVt_PV && SvPVX(sv) && SvLEN(sv)) {
+ if (SvTYPE(sv) >= SVt_PV && SvPVX_const(sv) && SvLEN(sv)) {
SvPV_free(sv);
SvPV_set(sv, Nullch);
SvLEN_set(sv, 0);
diff --git a/pp_ctl.c b/pp_ctl.c
index 9b4c2ff1c5..ae25cc60f0 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -475,14 +475,14 @@ PP(pp_formline)
case FF_LITERAL:
arg = *fpc++;
if (targ_is_utf8 && !SvUTF8(tmpForm)) {
- SvCUR_set(PL_formtarget, t - SvPVX(PL_formtarget));
+ SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
*t = '\0';
sv_catpvn_utf8_upgrade(PL_formtarget, f, arg, nsv);
t = SvEND(PL_formtarget);
break;
}
if (!targ_is_utf8 && DO_UTF8(tmpForm)) {
- SvCUR_set(PL_formtarget, t - SvPVX(PL_formtarget));
+ SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
*t = '\0';
sv_utf8_upgrade(PL_formtarget);
SvGROW(PL_formtarget, SvCUR(PL_formtarget) + fudge + 1);
@@ -658,7 +658,7 @@ PP(pp_formline)
s = item;
if (item_is_utf8) {
if (!targ_is_utf8) {
- SvCUR_set(PL_formtarget, t - SvPVX(PL_formtarget));
+ SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
*t = '\0';
sv_utf8_upgrade(PL_formtarget);
SvGROW(PL_formtarget, SvCUR(PL_formtarget) + fudge + 1);
@@ -691,7 +691,7 @@ PP(pp_formline)
break;
}
if (targ_is_utf8 && !item_is_utf8) {
- SvCUR_set(PL_formtarget, t - SvPVX(PL_formtarget));
+ SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
*t = '\0';
sv_catpvn_utf8_upgrade(PL_formtarget, s, arg, nsv);
for (; t < SvEND(PL_formtarget); t++) {
@@ -757,7 +757,7 @@ PP(pp_formline)
}
}
}
- SvCUR_set(PL_formtarget, t - SvPVX(PL_formtarget));
+ SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
if (targ_is_utf8)
SvUTF8_on(PL_formtarget);
if (oneline) {
@@ -829,7 +829,7 @@ PP(pp_formline)
if (gotsome) {
if (arg) { /* repeat until fields exhausted? */
*t = '\0';
- SvCUR_set(PL_formtarget, t - SvPVX(PL_formtarget));
+ SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
lines += FmLINES(PL_formtarget);
if (lines == 200) {
arg = t - linemark;
@@ -865,7 +865,7 @@ PP(pp_formline)
}
s = t - 3;
if (strnEQ(s," ",3)) {
- while (s > SvPVX(PL_formtarget) && isSPACE(s[-1]))
+ while (s > SvPVX_const(PL_formtarget) && isSPACE(s[-1]))
s--;
}
*s++ = '.';
@@ -876,7 +876,7 @@ PP(pp_formline)
case FF_END:
*t = '\0';
- SvCUR_set(PL_formtarget, t - SvPVX(PL_formtarget));
+ SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
if (targ_is_utf8)
SvUTF8_on(PL_formtarget);
FmLINES(PL_formtarget) += lines;
@@ -1099,7 +1099,7 @@ PP(pp_flip)
SvNIOKp(left) || (SvOK(left) && !SvPOKp(left)) || \
SvNIOKp(right) || (SvOK(right) && !SvPOKp(right)) || \
(((!SvOK(left) && SvOK(right)) || ((!SvOK(left) || \
- looks_like_number(left)) && SvPOKp(left) && *SvPVX(left) != '0')) \
+ looks_like_number(left)) && SvPOKp(left) && *SvPVX_const(left) != '0')) \
&& (!SvOK(right) || looks_like_number(right))))
PP(pp_flop)
@@ -1144,7 +1144,7 @@ PP(pp_flop)
SvPV_force(sv,n_a);
while (!SvNIOKp(sv) && SvCUR(sv) <= len) {
XPUSHs(sv);
- if (strEQ(SvPVX(sv),tmps))
+ if (strEQ(SvPVX_const(sv),tmps))
break;
sv = sv_2mortal(newSVsv(sv));
sv_inc(sv);
@@ -1410,7 +1410,7 @@ Perl_die_where(pTHX_ const char *message, STRLEN msglen)
sv_catpvn(err, message, msglen);
if (ckWARN(WARN_MISC)) {
STRLEN start = SvCUR(err)-msglen-sizeof(prefix)+1;
- Perl_warner(aTHX_ packWARN(WARN_MISC), SvPVX(err)+start);
+ Perl_warner(aTHX_ packWARN(WARN_MISC), SvPVX_const(err)+start);
}
}
}
@@ -1458,7 +1458,7 @@ Perl_die_where(pTHX_ const char *message, STRLEN msglen)
if (optype == OP_REQUIRE) {
const char* msg = SvPVx(ERRSV, n_a);
SV *nsv = cx->blk_eval.old_namesv;
- (void)hv_store(GvHVn(PL_incgv), SvPVX(nsv), SvCUR(nsv),
+ (void)hv_store(GvHVn(PL_incgv), SvPVX_const(nsv), SvCUR(nsv),
&PL_sv_undef, 0);
DIE(aTHX_ "%sCompilation failed in require",
*msg ? msg : "Unknown error\n");
@@ -1971,7 +1971,7 @@ PP(pp_return)
{
/* Unassume the success we assumed earlier. */
SV *nsv = cx->blk_eval.old_namesv;
- (void)hv_delete(GvHVn(PL_incgv), SvPVX(nsv), SvCUR(nsv), G_DISCARD);
+ (void)hv_delete(GvHVn(PL_incgv), SvPVX_const(nsv), SvCUR(nsv), G_DISCARD);
DIE(aTHX_ "%"SVf" did not return a true value", nsv);
}
break;
@@ -2658,8 +2658,8 @@ PP(pp_cswitch)
STATIC void
S_save_lines(pTHX_ AV *array, SV *sv)
{
- register const char *s = SvPVX(sv);
- register const char *send = SvPVX(sv) + SvCUR(sv);
+ register const char *s = SvPVX_const(sv);
+ register const char *send = SvPVX_const(sv) + SvCUR(sv);
register I32 line = 1;
while (s && s < send) {
@@ -2942,7 +2942,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
if (optype == OP_REQUIRE) {
const char* msg = SvPVx(ERRSV, n_a);
SV *nsv = cx->blk_eval.old_namesv;
- (void)hv_store(GvHVn(PL_incgv), SvPVX(nsv), SvCUR(nsv),
+ (void)hv_store(GvHVn(PL_incgv), SvPVX_const(nsv), SvCUR(nsv),
&PL_sv_undef, 0);
DIE(aTHX_ "%sCompilation failed in require",
*msg ? msg : "Unknown error\n");
@@ -3298,9 +3298,9 @@ PP(pp_require)
AV *ar = GvAVn(PL_incgv);
I32 i;
sv_catpvn(msg, " in @INC", 8);
- if (instr(SvPVX(msg), ".h "))
+ if (instr(SvPVX_const(msg), ".h "))
sv_catpv(msg, " (change .h to .ph maybe?)");
- if (instr(SvPVX(msg), ".ph "))
+ if (instr(SvPVX_const(msg), ".ph "))
sv_catpv(msg, " (did you run h2ph?)");
sv_catpv(msg, " (@INC contains:");
for (i = 0; i <= AvFILL(ar); i++) {
@@ -3526,7 +3526,7 @@ PP(pp_leaveeval)
{
/* Unassume the success we assumed earlier. */
SV *nsv = cx->blk_eval.old_namesv;
- (void)hv_delete(GvHVn(PL_incgv), SvPVX(nsv), SvCUR(nsv), G_DISCARD);
+ (void)hv_delete(GvHVn(PL_incgv), SvPVX_const(nsv), SvCUR(nsv), G_DISCARD);
retop = Perl_die(aTHX_ "%"SVf" did not return a true value", nsv);
/* die_where() did LEAVE, or we won't be here */
}