summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--av.c2
-rw-r--r--doop.c4
-rw-r--r--dump.c8
-rw-r--r--mathoms.c4
-rw-r--r--mg.c14
-rw-r--r--mro.c12
-rw-r--r--pad.c36
-rw-r--r--pp.c34
-rw-r--r--pp_ctl.c30
-rw-r--r--pp_hot.c14
-rw-r--r--pp_sort.c6
-rw-r--r--regcomp.c12
-rw-r--r--regexec.c6
-rw-r--r--scope.c16
-rw-r--r--sv.c58
-rw-r--r--toke.c2
-rw-r--r--universal.c2
-rw-r--r--util.c12
18 files changed, 137 insertions, 135 deletions
diff --git a/av.c b/av.c
index 722b62b0fe..dee4823285 100644
--- a/av.c
+++ b/av.c
@@ -387,7 +387,7 @@ will have a reference count of 1.
AV *
Perl_av_make(pTHX_ register I32 size, register SV **strp)
{
- register AV * const av = (AV*)newSV_type(SVt_PVAV);
+ register AV * const av = MUTABLE_AV(newSV_type(SVt_PVAV));
/* sv_upgrade does AvREAL_only() */
PERL_ARGS_ASSERT_AV_MAKE;
assert(SvTYPE(av) == SVt_PVAV);
diff --git a/doop.c b/doop.c
index ef40257751..910e177550 100644
--- a/doop.c
+++ b/doop.c
@@ -1000,7 +1000,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++) {
@@ -1086,7 +1086,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++) {
diff --git a/dump.c b/dump.c
index 1ad5687a1f..0ef4940bc8 100644
--- a/dump.c
+++ b/dump.c
@@ -1650,10 +1650,10 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
if (AvREIFY(sv)) sv_catpv(d, ",REIFY");
Perl_dump_indent(aTHX_ level, file, " FLAGS = (%s)\n",
SvCUR(d) ? SvPVX_const(d) + 1 : "");
- if (nest < maxnest && av_len((AV*)sv) >= 0) {
+ if (nest < maxnest && av_len(MUTABLE_AV(sv)) >= 0) {
int count;
- for (count = 0; count <= av_len((AV*)sv) && count < maxnest; count++) {
- SV** const elt = av_fetch((AV*)sv,count,0);
+ for (count = 0; count <= av_len(MUTABLE_AV(sv)) && count < maxnest; count++) {
+ SV** const elt = av_fetch(MUTABLE_AV(sv),count,0);
Perl_dump_indent(aTHX_ level + 1, file, "Elt No. %"IVdf"\n", (IV)count);
if (elt)
@@ -2018,7 +2018,7 @@ Perl_debop(pTHX_ const OP *o)
SV *sv;
if (cv) {
AV * const padlist = CvPADLIST(cv);
- AV * const comppad = (AV*)(*av_fetch(padlist, 0, FALSE));
+ AV * const comppad = MUTABLE_AV(*av_fetch(padlist, 0, FALSE));
sv = *av_fetch(comppad, o->op_targ, FALSE);
} else
sv = NULL;
diff --git a/mathoms.c b/mathoms.c
index 8c748823a5..eb0df68205 100644
--- a/mathoms.c
+++ b/mathoms.c
@@ -617,7 +617,7 @@ AV *
Perl_av_fake(pTHX_ register I32 size, register SV **strp)
{
register SV** ary;
- register AV * const av = (AV*)newSV_type(SVt_PVAV);
+ register AV * const av = MUTABLE_AV(newSV_type(SVt_PVAV));
PERL_ARGS_ASSERT_AV_FAKE;
@@ -1463,7 +1463,7 @@ Perl_magic_setglob(pTHX_ SV *sv, MAGIC *mg)
AV *
Perl_newAV(pTHX)
{
- return (AV*)newSV_type(SVt_PVAV);
+ return MUTABLE_AV(newSV_type(SVt_PVAV));
/* sv_upgrade does AvREAL_only():
AvALLOC(av) = 0;
AvARRAY(av) = NULL;
diff --git a/mg.c b/mg.c
index 04bfb60d64..67321061be 100644
--- a/mg.c
+++ b/mg.c
@@ -360,7 +360,7 @@ Perl_mg_size(pTHX_ SV *sv)
switch(SvTYPE(sv)) {
case SVt_PVAV:
- return AvFILLp((AV *) sv); /* Fallback to non-tied array */
+ return AvFILLp((const AV *) sv); /* Fallback to non-tied array */
case SVt_PVHV:
/* FIXME */
default:
@@ -1605,7 +1605,7 @@ Perl_magic_clearisa(pTHX_ SV *sv, MAGIC *mg)
/* Bail out if destruction is going on */
if(PL_dirty) return 0;
- av_clear((AV*)sv);
+ av_clear(MUTABLE_AV(sv));
/* XXX see comments in magic_setisa */
stash = GvSTASH(
@@ -1897,7 +1897,7 @@ int
Perl_magic_getarylen(pTHX_ SV *sv, const MAGIC *mg)
{
dVAR;
- const AV * const obj = (AV*)mg->mg_obj;
+ const AV * const obj = MUTABLE_AV(mg->mg_obj);
PERL_ARGS_ASSERT_MAGIC_GETARYLEN;
@@ -1913,7 +1913,7 @@ int
Perl_magic_setarylen(pTHX_ SV *sv, MAGIC *mg)
{
dVAR;
- AV * const obj = (AV*)mg->mg_obj;
+ AV * const obj = MUTABLE_AV(mg->mg_obj);
PERL_ARGS_ASSERT_MAGIC_SETARYLEN;
@@ -2166,7 +2166,7 @@ Perl_magic_getdefelem(pTHX_ SV *sv, MAGIC *mg)
targ = HeVAL(he);
}
else {
- AV* const av = (AV*)LvTARG(sv);
+ AV *const av = MUTABLE_AV(LvTARG(sv));
if ((I32)LvTARGOFF(sv) <= AvFILL(av))
targ = AvARRAY(av)[LvTARGOFF(sv)];
}
@@ -2220,7 +2220,7 @@ Perl_vivify_defelem(pTHX_ SV *sv)
Perl_croak(aTHX_ PL_no_helem_sv, SVfARG(mg->mg_obj));
}
else {
- AV* const av = (AV*)LvTARG(sv);
+ AV *const av = MUTABLE_AV(LvTARG(sv));
if ((I32)LvTARGLEN(sv) < 0 && (I32)LvTARGOFF(sv) > AvFILL(av))
LvTARG(sv) = NULL; /* array can't be extended */
else {
@@ -2242,7 +2242,7 @@ int
Perl_magic_killbackrefs(pTHX_ SV *sv, MAGIC *mg)
{
PERL_ARGS_ASSERT_MAGIC_KILLBACKREFS;
- return Perl_sv_kill_backrefs(aTHX_ sv, (AV*)mg->mg_obj);
+ return Perl_sv_kill_backrefs(aTHX_ sv, MUTABLE_AV(mg->mg_obj));
}
int
diff --git a/mro.c b/mro.c
index 304eb2d668..72e0f9bc33 100644
--- a/mro.c
+++ b/mro.c
@@ -84,10 +84,10 @@ Perl_mro_meta_dup(pTHX_ struct mro_meta* smeta, CLONE_PARAMS* param)
if (newmeta->mro_linear_dfs)
newmeta->mro_linear_dfs
- = (AV*) SvREFCNT_inc(sv_dup((SV*)newmeta->mro_linear_dfs, param));
+ = MUTABLE_AV(SvREFCNT_inc(sv_dup((SV*)newmeta->mro_linear_dfs, param)));
if (newmeta->mro_linear_c3)
newmeta->mro_linear_c3
- = (AV*) SvREFCNT_inc(sv_dup((SV*)newmeta->mro_linear_c3, param));
+ = MUTABLE_AV(SvREFCNT_inc(sv_dup((SV*)newmeta->mro_linear_c3, param)));
if (newmeta->mro_nextmethod)
newmeta->mro_nextmethod
= MUTABLE_HV(SvREFCNT_inc(sv_dup((SV*)newmeta->mro_nextmethod, param)));
@@ -183,7 +183,7 @@ S_mro_get_linear_isa_dfs(pTHX_ HV *stash, I32 level)
/* not in cache, make a new one */
- retval = (AV*)sv_2mortal((SV *)newAV());
+ retval = MUTABLE_AV(sv_2mortal((SV *)newAV()));
/* We use this later in this function, but don't need a reference to it
beyond the end of this function, so reference count is fine. */
our_name = newSVhek(stashhek);
@@ -347,7 +347,7 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, I32 level)
SV** seqs_ptr;
I32 seqs_items;
HV* const tails = MUTABLE_HV(sv_2mortal((SV*)newHV()));
- AV* const seqs = (AV*)sv_2mortal((SV*)newAV());
+ AV *const seqs = MUTABLE_AV(sv_2mortal((SV*)newAV()));
I32* heads;
/* This builds @seqs, which is an array of arrays.
@@ -387,7 +387,7 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, I32 level)
seqs_ptr = AvARRAY(seqs);
seqs_items = AvFILLp(seqs) + 1;
while(seqs_items--) {
- AV* const seq = (AV*)*seqs_ptr++;
+ AV *const seq = MUTABLE_AV(*seqs_ptr++);
I32 seq_items = AvFILLp(seq);
if(seq_items > 0) {
SV** seq_ptr = AvARRAY(seq) + 1;
@@ -421,7 +421,7 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, I32 level)
SV** const avptr = AvARRAY(seqs);
for(s = 0; s <= AvFILLp(seqs); s++) {
SV** svp;
- AV * const seq = (AV*)(avptr[s]);
+ AV * const seq = MUTABLE_AV(avptr[s]);
SV* seqhead;
if(!seq) continue; /* skip empty seqs */
svp = av_fetch(seq, heads[s], 0);
diff --git a/pad.c b/pad.c
index 33a19e3e39..b4ec2e19a0 100644
--- a/pad.c
+++ b/pad.c
@@ -214,8 +214,8 @@ Perl_pad_new(pTHX_ int flags)
/* ... then update state variables */
- PL_comppad_name = (AV*)(*av_fetch(padlist, 0, FALSE));
- PL_comppad = (AV*)(*av_fetch(padlist, 1, FALSE));
+ PL_comppad_name = MUTABLE_AV((*av_fetch(padlist, 0, FALSE)));
+ PL_comppad = MUTABLE_AV((*av_fetch(padlist, 1, FALSE)));
PL_curpad = AvARRAY(PL_comppad);
if (! (flags & padnew_CLONE)) {
@@ -280,9 +280,9 @@ Perl_pad_undef(pTHX_ CV* cv)
if (!PL_dirty) { /* don't bother during global destruction */
CV * const outercv = CvOUTSIDE(cv);
const U32 seq = CvOUTSIDE_SEQ(cv);
- AV * const comppad_name = (AV*)AvARRAY(padlist)[0];
+ AV * const comppad_name = MUTABLE_AV(AvARRAY(padlist)[0]);
SV ** const namepad = AvARRAY(comppad_name);
- AV * const comppad = (AV*)AvARRAY(padlist)[1];
+ AV * const comppad = MUTABLE_AV(AvARRAY(padlist)[1]);
SV ** const curpad = AvARRAY(comppad);
for (ix = AvFILLp(comppad_name); ix > 0; ix--) {
SV * const namesv = namepad[ix];
@@ -633,7 +633,7 @@ Perl_pad_findmy(pTHX_ const char *name)
* our $foo = 0 unless defined $foo;
* to not give a warning. (Yes, this is a hack) */
- nameav = (AV*)AvARRAY(CvPADLIST(PL_compcv))[0];
+ nameav = MUTABLE_AV(AvARRAY(CvPADLIST(PL_compcv))[0]);
name_svp = AvARRAY(nameav);
for (offset = AvFILLp(nameav); offset > 0; offset--) {
const SV * const namesv = name_svp[offset];
@@ -716,7 +716,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
if (padlist) { /* not an undef CV */
I32 fake_offset = 0;
- const AV * const nameav = (AV*)AvARRAY(padlist)[0];
+ const AV * const nameav = MUTABLE_AV(AvARRAY(padlist)[0]);
SV * const * const name_svp = AvARRAY(nameav);
for (offset = AvFILLp(nameav); offset > 0; offset--) {
@@ -814,8 +814,8 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
return offset;
}
- *out_capture = AvARRAY((AV*)AvARRAY(padlist)[
- CvDEPTH(cv) ? CvDEPTH(cv) : 1])[offset];
+ *out_capture = AvARRAY(MUTABLE_AV(AvARRAY(padlist)[
+ CvDEPTH(cv) ? CvDEPTH(cv) : 1]))[offset];
DEBUG_Xv(PerlIO_printf(Perl_debug_log,
"Pad findlex cv=0x%"UVxf" found lex=0x%"UVxf"\n",
PTR2UV(cv), PTR2UV(*out_capture)));
@@ -869,8 +869,8 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
SV *new_namesv;
AV * const ocomppad_name = PL_comppad_name;
PAD * const ocomppad = PL_comppad;
- PL_comppad_name = (AV*)AvARRAY(padlist)[0];
- PL_comppad = (AV*)AvARRAY(padlist)[1];
+ PL_comppad_name = MUTABLE_AV(AvARRAY(padlist)[0]);
+ PL_comppad = MUTABLE_AV(AvARRAY(padlist)[1]);
PL_curpad = AvARRAY(PL_comppad);
new_offset = pad_add_name(
@@ -1349,8 +1349,8 @@ Perl_do_dump_pad(pTHX_ I32 level, PerlIO *file, PADLIST *padlist, int full)
if (!padlist) {
return;
}
- pad_name = (AV*)*av_fetch((AV*)padlist, 0, FALSE);
- pad = (AV*)*av_fetch((AV*)padlist, 1, FALSE);
+ pad_name = MUTABLE_AV(*av_fetch(MUTABLE_AV(padlist), 0, FALSE));
+ pad = MUTABLE_AV(*av_fetch(MUTABLE_AV(padlist), 1, FALSE));
pname = AvARRAY(pad_name);
ppad = AvARRAY(pad);
Perl_dump_indent(aTHX_ level, file,
@@ -1459,8 +1459,8 @@ Perl_cv_clone(pTHX_ CV *proto)
dVAR;
I32 ix;
AV* const protopadlist = CvPADLIST(proto);
- const AV* const protopad_name = (AV*)*av_fetch(protopadlist, 0, FALSE);
- const AV* const protopad = (AV*)*av_fetch(protopadlist, 1, FALSE);
+ const AV *const protopad_name = (const AV *)*av_fetch(protopadlist, 0, FALSE);
+ const AV *const protopad = (const AV *)*av_fetch(protopadlist, 1, FALSE);
SV** const pname = AvARRAY(protopad_name);
SV** const ppad = AvARRAY(protopad);
const I32 fname = AvFILLp(protopad_name);
@@ -1611,8 +1611,8 @@ Perl_pad_fixup_inner_anons(pTHX_ PADLIST *padlist, CV *old_cv, CV *new_cv)
{
dVAR;
I32 ix;
- AV * const comppad_name = (AV*)AvARRAY(padlist)[0];
- AV * const comppad = (AV*)AvARRAY(padlist)[1];
+ AV * const comppad_name = MUTABLE_AV(AvARRAY(padlist)[0]);
+ AV * const comppad = MUTABLE_AV(AvARRAY(padlist)[1]);
SV ** const namepad = AvARRAY(comppad_name);
SV ** const curpad = AvARRAY(comppad);
@@ -1654,8 +1654,8 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth)
SV** const svp = AvARRAY(padlist);
AV* const newpad = newAV();
SV** const oldpad = AvARRAY(svp[depth-1]);
- I32 ix = AvFILLp((AV*)svp[1]);
- const I32 names_fill = AvFILLp((AV*)svp[0]);
+ I32 ix = AvFILLp((const AV *)svp[1]);
+ const I32 names_fill = AvFILLp((const AV *)svp[0]);
SV** const names = AvARRAY(svp[0]);
AV *av;
diff --git a/pp.c b/pp.c
index c4552e6b27..7fb2ef39c5 100644
--- a/pp.c
+++ b/pp.c
@@ -78,23 +78,23 @@ PP(pp_padav)
}
gimme = GIMME_V;
if (gimme == G_ARRAY) {
- const I32 maxarg = AvFILL((AV*)TARG) + 1;
+ const I32 maxarg = AvFILL(MUTABLE_AV(TARG)) + 1;
EXTEND(SP, maxarg);
if (SvMAGICAL(TARG)) {
U32 i;
for (i=0; i < (U32)maxarg; i++) {
- SV * const * const svp = av_fetch((AV*)TARG, i, FALSE);
+ SV * const * const svp = av_fetch(MUTABLE_AV(TARG), i, FALSE);
SP[i+1] = (svp) ? *svp : &PL_sv_undef;
}
}
else {
- Copy(AvARRAY((AV*)TARG), SP+1, maxarg, SV*);
+ Copy(AvARRAY((const AV *)TARG), SP+1, maxarg, SV*);
}
SP += maxarg;
}
else if (gimme == G_SCALAR) {
SV* const sv = sv_newmortal();
- const I32 maxarg = AvFILL((AV*)TARG) + 1;
+ const I32 maxarg = AvFILL(MUTABLE_AV(TARG)) + 1;
sv_setiv(sv, maxarg);
PUSHs(sv);
}
@@ -319,8 +319,8 @@ PP(pp_rv2sv)
PP(pp_av2arylen)
{
dVAR; dSP;
- AV * const av = (AV*)TOPs;
- SV ** const sv = Perl_av_arylen_p(aTHX_ (AV*)av);
+ AV * const av = MUTABLE_AV(TOPs);
+ SV ** const sv = Perl_av_arylen_p(aTHX_ MUTABLE_AV(av));
if (!*sv) {
*sv = newSV_type(SVt_PVMG);
sv_magic(*sv, (SV*)av, PERL_MAGIC_arylen, NULL, 0);
@@ -525,8 +525,8 @@ S_refto(pTHX_ SV *sv)
SvREFCNT_inc_void_NN(sv);
}
else if (SvTYPE(sv) == SVt_PVAV) {
- if (!AvREAL((AV*)sv) && AvREIFY((AV*)sv))
- av_reify((AV*)sv);
+ if (!AvREAL((const AV *)sv) && AvREIFY((const AV *)sv))
+ av_reify(MUTABLE_AV(sv));
SvTEMP_off(sv);
SvREFCNT_inc_void_NN(sv);
}
@@ -806,7 +806,7 @@ PP(pp_undef)
case SVt_NULL:
break;
case SVt_PVAV:
- av_undef((AV*)sv);
+ av_undef(MUTABLE_AV(sv));
break;
case SVt_PVHV:
hv_undef(MUTABLE_HV(sv));
@@ -3891,7 +3891,7 @@ PP(pp_quotemeta)
PP(pp_aslice)
{
dVAR; dSP; dMARK; dORIGMARK;
- register AV* const av = (AV*)POPs;
+ register AV *const av = MUTABLE_AV(POPs);
register const I32 lval = (PL_op->op_flags & OPf_MOD || LVRET);
if (SvTYPE(av) == SVt_PVAV) {
@@ -3985,7 +3985,7 @@ PP(pp_delete)
else if (hvtype == SVt_PVAV) { /* array element */
if (PL_op->op_flags & OPf_SPECIAL) {
while (++MARK <= SP) {
- SV * const sv = av_delete((AV*)hv, SvIV(*MARK), discard);
+ SV * const sv = av_delete(MUTABLE_AV(hv), SvIV(*MARK), discard);
*MARK = sv ? sv : &PL_sv_undef;
}
}
@@ -4011,7 +4011,7 @@ PP(pp_delete)
sv = hv_delete_ent(hv, keysv, discard, 0);
else if (SvTYPE(hv) == SVt_PVAV) {
if (PL_op->op_flags & OPf_SPECIAL)
- sv = av_delete((AV*)hv, SvIV(keysv), discard);
+ sv = av_delete(MUTABLE_AV(hv), SvIV(keysv), discard);
else
DIE(aTHX_ "panic: avhv_delete no longer supported");
}
@@ -4050,7 +4050,7 @@ PP(pp_exists)
}
else if (SvTYPE(hv) == SVt_PVAV) {
if (PL_op->op_flags & OPf_SPECIAL) { /* array element */
- if (av_exists((AV*)hv, SvIV(tmpsv)))
+ if (av_exists(MUTABLE_AV(hv), SvIV(tmpsv)))
RETPUSHYES;
}
}
@@ -4228,7 +4228,7 @@ PP(pp_anonhash)
PP(pp_splice)
{
dVAR; dSP; dMARK; dORIGMARK;
- register AV *ary = (AV*)*++MARK;
+ register AV *ary = MUTABLE_AV(*++MARK);
register SV **src;
register SV **dst;
register I32 i;
@@ -4433,7 +4433,7 @@ PP(pp_splice)
PP(pp_push)
{
dVAR; dSP; dMARK; dORIGMARK; dTARGET;
- register AV * const ary = (AV*)*++MARK;
+ register AV * const ary = MUTABLE_AV(*++MARK);
const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied);
if (mg) {
@@ -4469,7 +4469,7 @@ PP(pp_shift)
{
dVAR;
dSP;
- AV * const av = (AV*)POPs;
+ AV * const av = MUTABLE_AV(POPs);
SV * const sv = PL_op->op_type == OP_SHIFT ? av_shift(av) : av_pop(av);
EXTEND(SP, 1);
assert (sv);
@@ -4482,7 +4482,7 @@ PP(pp_shift)
PP(pp_unshift)
{
dVAR; dSP; dMARK; dORIGMARK; dTARGET;
- register AV *ary = (AV*)*++MARK;
+ register AV *ary = MUTABLE_AV(*++MARK);
const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied);
if (mg) {
diff --git a/pp_ctl.c b/pp_ctl.c
index 6ba9f4418a..23aaf047cb 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2490,10 +2490,10 @@ PP(pp_goto)
PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));
if (CxHASARGS(cx))
{
- AV* const av = (AV*)PAD_SVl(0);
+ AV *const av = MUTABLE_AV(PAD_SVl(0));
cx->blk_sub.savearray = GvAV(PL_defgv);
- GvAV(PL_defgv) = (AV*)SvREFCNT_inc_simple(av);
+ GvAV(PL_defgv) = MUTABLE_AV(SvREFCNT_inc_simple(av));
CX_CURPAD_SAVE(cx->blk_sub);
cx->blk_sub.argarray = av;
@@ -2858,7 +2858,7 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
(*startop)->op_ppaddr = PL_ppaddr[OP_NULL];
lex_end();
/* XXX DAPM do this properly one year */
- *padp = (AV*)SvREFCNT_inc_simple(PL_comppad);
+ *padp = MUTABLE_AV(SvREFCNT_inc_simple(PL_comppad));
LEAVE;
if (IN_PERL_COMPILETIME)
CopHINTS_set(&PL_compiling, PL_hints);
@@ -3163,7 +3163,7 @@ PP(pp_require)
SV * const pv = *hv_fetchs(MUTABLE_HV(req), "original", FALSE);
/* get the left hand term */
- lav = (AV *)SvRV(*hv_fetchs(MUTABLE_HV(req), "version", FALSE));
+ lav = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(req), "version", FALSE)));
first = SvIV(*av_fetch(lav,0,0));
if ( first > (int)PERL_REVISION /* probably 'use 6.0' */
@@ -3286,7 +3286,7 @@ PP(pp_require)
if (SvTYPE(SvRV(loader)) == SVt_PVAV
&& !sv_isobject(loader))
{
- loader = *av_fetch((AV *)SvRV(loader), 0, TRUE);
+ loader = *av_fetch(MUTABLE_AV(SvRV(loader)), 0, TRUE);
}
Perl_sv_setpvf(aTHX_ namesv, "/loader/0x%"UVxf"/%s",
@@ -4114,7 +4114,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
RETPUSHYES;
}
else if (SM_OTHER_REF(PVAV)) {
- AV * const other_av = (AV *) SvRV(Other);
+ AV * const other_av = MUTABLE_AV(SvRV(Other));
const I32 other_len = av_len(other_av) + 1;
I32 i;
@@ -4155,8 +4155,8 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
}
else if (SM_REF(PVAV)) {
if (SM_OTHER_REF(PVAV)) {
- AV *other_av = (AV *) SvRV(Other);
- if (av_len((AV *) This) != av_len(other_av))
+ AV *other_av = MUTABLE_AV(SvRV(Other));
+ if (av_len(MUTABLE_AV(This)) != av_len(other_av))
RETPUSHNO;
else {
I32 i;
@@ -4171,7 +4171,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
(void) sv_2mortal((SV *) seen_other);
}
for(i = 0; i <= other_len; ++i) {
- SV * const * const this_elem = av_fetch((AV *)This, i, FALSE);
+ SV * const * const this_elem = av_fetch(MUTABLE_AV(This), i, FALSE);
SV * const * const other_elem = av_fetch(other_av, i, FALSE);
if (!this_elem || !other_elem) {
@@ -4207,11 +4207,11 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
}
else if (SM_OTHER_REGEX) {
PMOP * const matcher = make_matcher(other_regex);
- const I32 this_len = av_len((AV *) This);
+ const I32 this_len = av_len(MUTABLE_AV(This));
I32 i;
for(i = 0; i <= this_len; ++i) {
- SV * const * const svp = av_fetch((AV *)This, i, FALSE);
+ SV * const * const svp = av_fetch(MUTABLE_AV(This), i, FALSE);
if (svp && matcher_matches_sv(matcher, *svp)) {
destroy_matcher(matcher);
RETPUSHYES;
@@ -4223,8 +4223,8 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
else if (SvIOK(Other) || SvNOK(Other)) {
I32 i;
- for(i = 0; i <= AvFILL((AV *) This); ++i) {
- SV * const * const svp = av_fetch((AV *)This, i, FALSE);
+ for(i = 0; i <= AvFILL(MUTABLE_AV(This)); ++i) {
+ SV * const * const svp = av_fetch(MUTABLE_AV(This), i, FALSE);
if (!svp)
continue;
@@ -4242,11 +4242,11 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
RETPUSHNO;
}
else if (SvPOK(Other)) {
- const I32 this_len = av_len((AV *) This);
+ const I32 this_len = av_len(MUTABLE_AV(This));
I32 i;
for(i = 0; i <= this_len; ++i) {
- SV * const * const svp = av_fetch((AV *)This, i, FALSE);
+ SV * const * const svp = av_fetch(MUTABLE_AV(This), i, FALSE);
if (!svp)
continue;
diff --git a/pp_hot.c b/pp_hot.c
index 4c842b62ae..de9009006b 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -665,8 +665,8 @@ PP(pp_add)
PP(pp_aelemfast)
{
dVAR; dSP;
- AV * const av = PL_op->op_flags & OPf_SPECIAL ?
- (AV*)PAD_SV(PL_op->op_targ) : GvAV(cGVOP_gv);
+ AV * const av = PL_op->op_flags & OPf_SPECIAL
+ ? MUTABLE_AV(PAD_SV(PL_op->op_targ)) : GvAV(cGVOP_gv);
const U32 lval = PL_op->op_flags & OPf_MOD;
SV** const svp = av_fetch(av, PL_op->op_private, lval);
SV *sv = (svp ? *svp : &PL_sv_undef);
@@ -890,7 +890,7 @@ PP(pp_rv2av)
}
if (is_pp_rv2av) {
- AV *const av = (AV*)sv;
+ AV *const av = MUTABLE_AV(sv);
/* The guts of pp_rv2av, with no intenting change to preserve history
(until such time as we get tools that can do blame annotation across
whitespace changes. */
@@ -1024,7 +1024,7 @@ PP(pp_aassign)
sv = *lelem++;
switch (SvTYPE(sv)) {
case SVt_PVAV:
- ary = (AV*)sv;
+ ary = MUTABLE_AV(sv);
magic = SvMAGICAL(ary) != 0;
av_clear(ary);
av_extend(ary, lastrelem - relem);
@@ -2807,7 +2807,7 @@ try_autoload:
SAVECOMPPAD();
PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));
if (hasargs) {
- AV* const av = (AV*)PAD_SVl(0);
+ AV *const av = MUTABLE_AV(PAD_SVl(0));
if (AvREAL(av)) {
/* @_ is normally not REAL--this should only ever
* happen when DB::sub() calls things that modify @_ */
@@ -2816,7 +2816,7 @@ try_autoload:
AvREIFY_on(av);
}
cx->blk_sub.savearray = GvAV(PL_defgv);
- GvAV(PL_defgv) = (AV*)SvREFCNT_inc_simple(av);
+ GvAV(PL_defgv) = MUTABLE_AV(SvREFCNT_inc_simple(av));
CX_CURPAD_SAVE(cx->blk_sub);
cx->blk_sub.argarray = av;
++MARK;
@@ -2920,7 +2920,7 @@ PP(pp_aelem)
SV** svp;
SV* const elemsv = POPs;
IV elem = SvIV(elemsv);
- AV* const av = (AV*)POPs;
+ AV *const av = MUTABLE_AV(POPs);
const U32 lval = PL_op->op_flags & OPf_MOD || LVRET;
const U32 defer = (PL_op->op_private & OPpLVAL_DEFER) && (elem > av_len(av));
SV *sv;
diff --git a/pp_sort.c b/pp_sort.c
index f945921dae..79c64663df 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1555,7 +1555,7 @@ PP(pp_sort)
if (priv & OPpSORT_INPLACE) {
assert( MARK+1 == SP && *SP && SvTYPE(*SP) == SVt_PVAV);
(void)POPMARK; /* remove mark associated with ex-OP_AASSIGN */
- av = (AV*)(*SP);
+ av = MUTABLE_AV((*SP));
max = AvFILL(av) + 1;
if (SvMAGICAL(av)) {
MEXTEND(SP, max);
@@ -1665,10 +1665,10 @@ PP(pp_sort)
if (hasargs) {
/* This is mostly copied from pp_entersub */
- AV * const av = (AV*)PAD_SVl(0);
+ AV * const av = MUTABLE_AV(PAD_SVl(0));
cx->blk_sub.savearray = GvAV(PL_defgv);
- GvAV(PL_defgv) = (AV*)SvREFCNT_inc_simple(av);
+ GvAV(PL_defgv) = MUTABLE_AV(SvREFCNT_inc_simple(av));
CX_CURPAD_SAVE(cx->blk_sub);
cx->blk_sub.argarray = av;
}
diff --git a/regcomp.c b/regcomp.c
index 4f562522b8..1d069b1627 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5075,7 +5075,7 @@ Perl_reg_named_buff_scalar(pTHX_ REGEXP * const rx, const U32 flags)
return newSViv(HvTOTALKEYS(RXp_PAREN_NAMES(rx)));
} else if (flags & RXapif_ONE) {
ret = CALLREG_NAMED_BUFF_ALL(rx, (flags | RXapif_REGNAMES));
- av = (AV*)SvRV(ret);
+ av = MUTABLE_AV(SvRV(ret));
length = av_len(av);
SvREFCNT_dec(ret);
return newSViv(length + 1);
@@ -9080,13 +9080,13 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o)
Perl_sv_catpvf(aTHX_ sv, "%d", (int)ARG(o)); /* Parenth number */
if ( RXp_PAREN_NAMES(prog) ) {
if ( k != REF || OP(o) < NREF) {
- AV *list= (AV *)progi->data->data[progi->name_list_idx];
+ AV *list= MUTABLE_AV(progi->data->data[progi->name_list_idx]);
SV **name= av_fetch(list, ARG(o), 0 );
if (name)
Perl_sv_catpvf(aTHX_ sv, " '%"SVf"'", SVfARG(*name));
}
else {
- AV *list= (AV *)progi->data->data[ progi->name_list_idx ];
+ AV *list= MUTABLE_AV(progi->data->data[ progi->name_list_idx ]);
SV *sv_dat=(SV*)progi->data->data[ ARG( o ) ];
I32 *nums=(I32*)SvPVX(sv_dat);
SV **name= av_fetch(list, nums[0], 0 );
@@ -9455,7 +9455,7 @@ Perl_regfree_internal(pTHX_ REGEXP * const r)
Safefree(ri->data->data[n]);
break;
case 'p':
- new_comppad = (AV*)ri->data->data[n];
+ new_comppad = MUTABLE_AV(ri->data->data[n]);
break;
case 'o':
if (new_comppad == NULL)
@@ -9530,7 +9530,7 @@ Perl_regfree_internal(pTHX_ REGEXP * const r)
}
#define sv_dup_inc(s,t) SvREFCNT_inc(sv_dup(s,t))
-#define av_dup_inc(s,t) (AV*)SvREFCNT_inc(sv_dup((const SV *)s,t))
+#define av_dup_inc(s,t) MUTABLE_AV(SvREFCNT_inc(sv_dup((const SV *)s,t)))
#define hv_dup_inc(s,t) MUTABLE_HV(SvREFCNT_inc(sv_dup((const SV *)s,t)))
#define SAVEPVN(p,n) ((p) ? savepvn(p,n) : NULL)
@@ -10021,7 +10021,7 @@ S_dumpuntil(pTHX_ const regexp *r, const regnode *start, const regnode *node,
const reg_trie_data * const trie =
(reg_trie_data*)ri->data->data[op<AHOCORASICK ? n : ac->trie];
#ifdef DEBUGGING
- AV *const trie_words = (AV *) ri->data->data[n + TRIE_WORDS_OFFSET];
+ AV *const trie_words = MUTABLE_AV(ri->data->data[n + TRIE_WORDS_OFFSET]);
#endif
const regnode *nextbranch= NULL;
I32 word_idx;
diff --git a/regexec.c b/regexec.c
index 07889e500f..e92e3754b4 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3099,7 +3099,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
/* only one choice left - just continue */
DEBUG_EXECUTE_r({
AV *const trie_words
- = (AV *) rexi->data->data[ARG(ST.me)+TRIE_WORDS_OFFSET];
+ = MUTABLE_AV(rexi->data->data[ARG(ST.me)+TRIE_WORDS_OFFSET]);
SV ** const tmp = av_fetch( trie_words,
ST.accept_buff[ 0 ].wordnum-1, 0 );
SV *sv= tmp ? sv_newmortal() : NULL;
@@ -3181,7 +3181,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
DEBUG_EXECUTE_r({
AV *const trie_words
- = (AV *) rexi->data->data[ARG(ST.me)+TRIE_WORDS_OFFSET];
+ = MUTABLE_AV(rexi->data->data[ARG(ST.me)+TRIE_WORDS_OFFSET]);
SV ** const tmp = av_fetch( trie_words,
ST.accept_buff[ best ].wordnum - 1, 0 );
regnode *nextop=(!ST.jump || !ST.jump[ST.accept_buff[best].wordnum]) ?
@@ -5646,7 +5646,7 @@ Perl_regclass_swash(pTHX_ const regexp *prog, register const regnode* node, bool
if (data->what[n] == 's') {
SV * const rv = (SV*)data->data[n];
- AV * const av = (AV*)SvRV((SV*)rv);
+ AV * const av = MUTABLE_AV(SvRV((SV*)rv));
SV **const ary = AvARRAY(av);
SV **a, **b;
diff --git a/scope.c b/scope.c
index eaa32660ca..3cf2071dcf 100644
--- a/scope.c
+++ b/scope.c
@@ -718,7 +718,7 @@ Perl_leave_scope(pTHX_ I32 base)
value = (SV*)SSPOPPTR;
gv = (GV*)SSPOPPTR;
ptr = &GvSV(gv);
- av = (AV*)gv; /* what to refcnt_dec */
+ av = MUTABLE_AV(gv); /* what to refcnt_dec */
restore_sv:
sv = *(SV**)ptr;
DEBUG_S(PerlIO_printf(Perl_debug_log,
@@ -763,7 +763,7 @@ Perl_leave_scope(pTHX_ I32 base)
SvREFCNT_dec(value);
break;
case SAVEt_AV: /* array reference */
- av = (AV*)SSPOPPTR;
+ av = MUTABLE_AV(SSPOPPTR);
gv = (GV*)SSPOPPTR;
if (GvAV(gv)) {
SvREFCNT_dec(GvAV(gv));
@@ -823,7 +823,7 @@ Perl_leave_scope(pTHX_ I32 base)
break;
case SAVEt_APTR: /* AV* reference */
ptr = SSPOPPTR;
- *(AV**)ptr = (AV*)SSPOPPTR;
+ *(AV**)ptr = MUTABLE_AV(SSPOPPTR);
break;
case SAVEt_GP: /* scalar reference */
ptr = SSPOPPTR;
@@ -882,7 +882,7 @@ Perl_leave_scope(pTHX_ I32 base)
case SVt_NULL:
break;
case SVt_PVAV:
- av_clear((AV*)sv);
+ av_clear(MUTABLE_AV(sv));
break;
case SVt_PVHV:
hv_clear(MUTABLE_HV(sv));
@@ -936,7 +936,7 @@ Perl_leave_scope(pTHX_ I32 base)
case SAVEt_AELEM: /* array element */
value = (SV*)SSPOPPTR;
i = SSPOPINT;
- av = (AV*)SSPOPPTR;
+ av = MUTABLE_AV(SSPOPPTR);
ptr = av_fetch(av,i,1);
if (!AvREAL(av) && AvREIFY(av)) /* undo reify guard */
SvREFCNT_dec(value);
@@ -963,7 +963,7 @@ Perl_leave_scope(pTHX_ I32 base)
ptr = &HeVAL((HE*)ptr);
if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied))
SvREFCNT_inc_void(*(SV**)ptr);
- av = (AV*)hv; /* what to refcnt_dec */
+ av = MUTABLE_AV(hv); /* what to refcnt_dec */
goto restore_sv;
}
}
@@ -1031,8 +1031,8 @@ Perl_leave_scope(pTHX_ I32 base)
case SAVEt_SAVESWITCHSTACK:
{
dSP;
- AV* const t = (AV*)SSPOPPTR;
- AV* const f = (AV*)SSPOPPTR;
+ AV *const t = MUTABLE_AV(SSPOPPTR);
+ AV *const f = MUTABLE_AV(SSPOPPTR);
SWITCHSTACK(t,f);
PL_curstackinfo->si_stack = f;
}
diff --git a/sv.c b/sv.c
index 5b6b1b039f..fad9a30985 100644
--- a/sv.c
+++ b/sv.c
@@ -5074,7 +5074,7 @@ Perl_sv_add_backref(pTHX_ SV *tsv, SV *sv)
if (mg) {
/* Aha. They've got it stowed in magic. Bring it back. */
- av = (AV*)mg->mg_obj;
+ av = MUTABLE_AV(mg->mg_obj);
/* Stop mg_free decreasing the refernce count. */
mg->mg_obj = NULL;
/* Stop mg_free even calling the destructor, given that
@@ -5092,7 +5092,7 @@ Perl_sv_add_backref(pTHX_ SV *tsv, SV *sv)
const MAGIC *const mg
= SvMAGICAL(tsv) ? mg_find(tsv, PERL_MAGIC_backref) : NULL;
if (mg)
- av = (AV*)mg->mg_obj;
+ av = MUTABLE_AV(mg->mg_obj);
else {
av = newAV();
AvREAL_off(av);
@@ -5131,7 +5131,7 @@ S_sv_del_backref(pTHX_ SV *tsv, SV *sv)
const MAGIC *const mg
= SvMAGICAL(tsv) ? mg_find(tsv, PERL_MAGIC_backref) : NULL;
if (mg)
- av = (AV *)mg->mg_obj;
+ av = MUTABLE_AV(mg->mg_obj);
}
if (!av)
@@ -5506,11 +5506,11 @@ Perl_sv_clear(pTHX_ register SV *sv)
hv_undef(MUTABLE_HV(sv));
break;
case SVt_PVAV:
- if (PL_comppad == (AV*)sv) {
+ if (PL_comppad == MUTABLE_AV(sv)) {
PL_comppad = NULL;
PL_curpad = NULL;
}
- av_undef((AV*)sv);
+ av_undef(MUTABLE_AV(sv));
break;
case SVt_PVLV:
if (LvTYPE(sv) == 'T') { /* for tie: return HE to pool */
@@ -10048,8 +10048,8 @@ ptr_table_* functions.
If this changes, please unmerge ss_dup. */
#define sv_dup_inc(s,t) SvREFCNT_inc(sv_dup(s,t))
#define sv_dup_inc_NN(s,t) SvREFCNT_inc_NN(sv_dup(s,t))
-#define av_dup(s,t) (AV*)sv_dup((const SV *)s,t)
-#define av_dup_inc(s,t) (AV*)SvREFCNT_inc(sv_dup((const SV *)s,t))
+#define av_dup(s,t) MUTABLE_AV(sv_dup((const SV *)s,t))
+#define av_dup_inc(s,t) MUTABLE_AV(SvREFCNT_inc(sv_dup((const SV *)s,t)))
#define hv_dup(s,t) MUTABLE_HV(sv_dup((const SV *)s,t))
#define hv_dup_inc(s,t) MUTABLE_HV(SvREFCNT_inc(sv_dup((const SV *)s,t)))
#define cv_dup(s,t) MUTABLE_CV(sv_dup((SV*)s,t))
@@ -10285,7 +10285,8 @@ Perl_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS* param)
else if(mg->mg_type == PERL_MAGIC_backref) {
/* The backref AV has its reference count deliberately bumped by
1. */
- nmg->mg_obj = SvREFCNT_inc(av_dup_inc((AV*) mg->mg_obj, param));
+ nmg->mg_obj
+ = SvREFCNT_inc(av_dup_inc((const AV *) mg->mg_obj, param));
}
else {
nmg->mg_obj = (mg->mg_flags & MGf_REFCOUNTED)
@@ -10737,16 +10738,16 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param)
break;
case SVt_PVAV:
/* avoid cloning an empty array */
- if (AvARRAY((AV *)sstr) && AvFILLp((AV *)sstr) >= 0) {
+ if (AvARRAY((const AV *)sstr) && AvFILLp((const AV *)sstr) >= 0) {
SV **dst_ary, **src_ary;
- SSize_t items = AvFILLp((AV*)sstr) + 1;
+ SSize_t items = AvFILLp((const AV *)sstr) + 1;
- src_ary = AvARRAY((AV*)sstr);
- Newxz(dst_ary, AvMAX((AV*)sstr)+1, SV*);
+ src_ary = AvARRAY((const AV *)sstr);
+ Newxz(dst_ary, AvMAX((const AV *)sstr)+1, SV*);
ptr_table_store(PL_ptr_table, src_ary, dst_ary);
- AvARRAY((AV*)dstr) = dst_ary;
- AvALLOC((AV*)dstr) = dst_ary;
- if (AvREAL((AV*)sstr)) {
+ AvARRAY(MUTABLE_AV(dstr)) = dst_ary;
+ AvALLOC((const AV *)dstr) = dst_ary;
+ if (AvREAL((const AV *)sstr)) {
while (items-- > 0)
*dst_ary++ = sv_dup_inc(*src_ary++, param);
}
@@ -10754,16 +10755,16 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param)
while (items-- > 0)
*dst_ary++ = sv_dup(*src_ary++, param);
}
- items = AvMAX((AV*)sstr) - AvFILLp((AV*)sstr);
+ items = AvMAX((const AV *)sstr) - AvFILLp((const AV *)sstr);
while (items-- > 0) {
*dst_ary++ = &PL_sv_undef;
}
}
else {
- AvARRAY((AV*)dstr) = NULL;
- AvALLOC((AV*)dstr) = (SV**)NULL;
- AvMAX( (AV *)dstr) = -1;
- AvFILLp((AV *)dstr) = -1;
+ AvARRAY(MUTABLE_AV(dstr)) = NULL;
+ AvALLOC(MUTABLE_AV(dstr)) = (SV**)NULL;
+ AvMAX( MUTABLE_AV(dstr)) = -1;
+ AvFILLp(MUTABLE_AV(dstr)) = -1;
}
break;
case SVt_PVHV:
@@ -10801,8 +10802,8 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param)
/* backref array needs refcnt=2; see sv_add_backref */
daux->xhv_backreferences =
saux->xhv_backreferences
- ? (AV*) SvREFCNT_inc(
- sv_dup_inc((SV*)saux->xhv_backreferences, param))
+ ? MUTABLE_AV(SvREFCNT_inc(
+ sv_dup_inc((SV*)saux->xhv_backreferences, param)))
: 0;
daux->xhv_mro_meta = saux->xhv_mro_meta
@@ -11206,7 +11207,7 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param)
TOPPTR(nss,ix) = sv_dup_inc(sv, param);
i = POPINT(ss,ix);
TOPINT(nss,ix) = i;
- av = (AV*)POPPTR(ss,ix);
+ av = (const AV *)POPPTR(ss,ix);
TOPPTR(nss,ix) = av_dup_inc(av, param);
break;
case SAVEt_OP:
@@ -12371,7 +12372,7 @@ S_varname(pTHX_ GV *gv, const char gvtype, PADOFFSET targ,
if (!cv || !CvPADLIST(cv))
return NULL;
- av = (AV*)(*av_fetch(CvPADLIST(cv), 0, FALSE));
+ av = MUTABLE_AV((*av_fetch(CvPADLIST(cv), 0, FALSE)));
sv = *av_fetch(av, targ, FALSE);
sv_setpvn(name, SvPV_nolen_const(sv), SvCUR(sv));
}
@@ -12466,7 +12467,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match)
subscript_type = FUV_SUBSCRIPT_HASH;
}
else {
- index = find_array_subscript((AV*)sv, uninit_sv);
+ index = find_array_subscript((const AV *)sv, uninit_sv);
if (index >= 0)
subscript_type = FUV_SUBSCRIPT_ARRAY;
}
@@ -12494,7 +12495,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match)
if (obase->op_flags & OPf_SPECIAL) { /* lexical array */
if (match) {
SV **svp;
- av = (AV*)PAD_SV(obase->op_targ);
+ av = MUTABLE_AV(PAD_SV(obase->op_targ));
if (!av || SvRMAGICAL(av))
break;
svp = av_fetch(av, (I32)obase->op_private, FALSE);
@@ -12566,7 +12567,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match)
break;
}
else {
- SV * const * const svp = av_fetch((AV*)sv, SvIV(cSVOPx_sv(kid)), FALSE);
+ SV * const * const svp = av_fetch(MUTABLE_AV(sv), SvIV(cSVOPx_sv(kid)), FALSE);
if (!svp || *svp != uninit_sv)
break;
}
@@ -12588,7 +12589,8 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match)
keysv, 0, FUV_SUBSCRIPT_HASH);
}
else {
- const I32 index = find_array_subscript((AV*)sv, uninit_sv);
+ const I32 index
+ = find_array_subscript((const AV *)sv, uninit_sv);
if (index >= 0)
return varname(gv, '@', o->op_targ,
NULL, index, FUV_SUBSCRIPT_ARRAY);
diff --git a/toke.c b/toke.c
index 7ab13da686..bec6369aca 100644
--- a/toke.c
+++ b/toke.c
@@ -712,7 +712,7 @@ Perl_lex_start(pTHX_ SV *line, PerlIO *rsfp, bool new_filter)
parser->expect = XSTATE;
parser->rsfp = rsfp;
parser->rsfp_filters = (new_filter || !oparser) ? newAV()
- : (AV*)SvREFCNT_inc(oparser->rsfp_filters);
+ : MUTABLE_AV(SvREFCNT_inc(oparser->rsfp_filters));
Newx(parser->lex_brackstack, 120, char);
Newx(parser->lex_casestack, 12, char);
diff --git a/universal.c b/universal.c
index 1122f5e877..2044e880df 100644
--- a/universal.c
+++ b/universal.c
@@ -1176,7 +1176,7 @@ XS(XS_re_regnames)
if (!ret)
XSRETURN_UNDEF;
- av = (AV*)SvRV(ret);
+ av = MUTABLE_AV(SvRV(ret));
length = av_len(av);
for (i = 0; i <= length; i++) {
diff --git a/util.c b/util.c
index b04d0ebe45..773c2a6398 100644
--- a/util.c
+++ b/util.c
@@ -4408,7 +4408,7 @@ Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv)
Compiler in question is:
gcc version 3.3 20030304 (Apple Computer, Inc. build 1640)
for ( len = 2 - len; len > 0; len-- )
- av_push((AV *)sv, newSViv(0));
+ av_push(MUTABLE_AV(sv), newSViv(0));
*/
len = 2 - len;
while (len-- > 0)
@@ -4495,7 +4495,7 @@ Perl_new_version(pTHX_ SV *ver)
(void)hv_stores(MUTABLE_HV(hv), "original", newSVsv(pv));
}
- sav = (AV *)SvRV(*hv_fetchs(MUTABLE_HV(ver), "version", FALSE));
+ sav = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(ver), "version", FALSE)));
/* This will get reblessed later if a derived class*/
for ( key = 0; key <= av_len(sav); key++ )
{
@@ -4700,7 +4700,7 @@ Perl_vnumify(pTHX_ SV *vs)
/* attempt to retrieve the version array */
- if ( !(av = (AV *)SvRV(*hv_fetchs(MUTABLE_HV(vs), "version", FALSE)) ) ) {
+ if ( !(av = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(vs), "version", FALSE))) ) ) {
sv_catpvs(sv,"0");
return sv;
}
@@ -4773,7 +4773,7 @@ Perl_vnormal(pTHX_ SV *vs)
if ( hv_exists(MUTABLE_HV(vs), "alpha", 5 ) )
alpha = TRUE;
- av = (AV *)SvRV(*hv_fetchs(MUTABLE_HV(vs), "version", FALSE));
+ av = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(vs), "version", FALSE)));
len = av_len(av);
if ( len == -1 )
@@ -4877,12 +4877,12 @@ Perl_vcmp(pTHX_ SV *lhv, SV *rhv)
Perl_croak(aTHX_ "Invalid version object");
/* get the left hand term */
- lav = (AV *)SvRV(*hv_fetchs(MUTABLE_HV(lhv), "version", FALSE));
+ lav = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(lhv), "version", FALSE)));
if ( hv_exists(MUTABLE_HV(lhv), "alpha", 5 ) )
lalpha = TRUE;
/* and the right hand term */
- rav = (AV *)SvRV(*hv_fetchs(MUTABLE_HV(rhv), "version", FALSE));
+ rav = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(rhv), "version", FALSE)));
if ( hv_exists(MUTABLE_HV(rhv), "alpha", 5 ) )
ralpha = TRUE;