From: Nicholas Clark Date: Thu, 30 Oct 2008 23:22:31 +0000 (+0000) Subject: Eliminate (SV *) casts from the rest of *.c, picking up one (further) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ad64d0ecd555e97c5a216efca1ec5a96b7fd0b34;p=p5sagit%2Fp5-mst-13.2.git Eliminate (SV *) casts from the rest of *.c, picking up one (further) erroneous const in dump.c. p4raw-id: //depot/perl@34675 --- diff --git a/av.c b/av.c index 0f06ce0..7bd19ee 100644 --- a/av.c +++ b/av.c @@ -33,7 +33,7 @@ Perl_av_reify(pTHX_ AV *av) if (AvREAL(av)) return; #ifdef DEBUGGING - if (SvTIED_mg((SV*)av, PERL_MAGIC_tied) && ckWARN_d(WARN_DEBUGGING)) + if (SvTIED_mg((const SV *)av, PERL_MAGIC_tied) && ckWARN_d(WARN_DEBUGGING)) Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), "av_reify called on tied array"); #endif key = AvMAX(av) + 1; @@ -70,7 +70,7 @@ Perl_av_extend(pTHX_ AV *av, I32 key) PERL_ARGS_ASSERT_AV_EXTEND; assert(SvTYPE(av) == SVt_PVAV); - mg = SvTIED_mg((SV*)av, PERL_MAGIC_tied); + mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied); if (mg) { dSP; ENTER; @@ -78,7 +78,7 @@ Perl_av_extend(pTHX_ AV *av, I32 key) PUSHSTACKi(PERLSI_MAGIC); PUSHMARK(SP); EXTEND(SP,2); - PUSHs(SvTIED_obj((SV*)av, mg)); + PUSHs(SvTIED_obj(MUTABLE_SV(av), mg)); mPUSHi(key + 1); PUTBACK; call_method("EXTEND", G_SCALAR|G_DISCARD); @@ -215,15 +215,17 @@ Perl_av_fetch(pTHX_ register AV *av, I32 key, I32 lval) assert(SvTYPE(av) == SVt_PVAV); if (SvRMAGICAL(av)) { - const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied); - if (tied_magic || mg_find((SV*)av, PERL_MAGIC_regdata)) { + const MAGIC * const tied_magic + = mg_find((const SV *)av, PERL_MAGIC_tied); + if (tied_magic || mg_find((const SV *)av, PERL_MAGIC_regdata)) { SV *sv; if (key < 0) { I32 adjust_index = 1; if (tied_magic) { /* Handle negative array indices 20020222 MJD */ SV * const * const negative_indices_glob = - hv_fetch(SvSTASH(SvRV(SvTIED_obj((SV *)av, tied_magic))), + hv_fetch(SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(av), + tied_magic))), NEGATIVE_INDICES_VAR, 16, 0); if (negative_indices_glob && SvTRUE(GvSV(*negative_indices_glob))) @@ -239,7 +241,7 @@ Perl_av_fetch(pTHX_ register AV *av, I32 key, I32 lval) sv = sv_newmortal(); sv_upgrade(sv, SVt_PVLV); - mg_copy((SV*)av, sv, 0, key); + mg_copy(MUTABLE_SV(av), sv, 0, key); LvTYPE(sv) = 't'; LvTARG(sv) = sv; /* fake (SV**) */ return &(LvTARG(sv)); @@ -306,13 +308,13 @@ Perl_av_store(pTHX_ register AV *av, I32 key, SV *val) val = &PL_sv_undef; if (SvRMAGICAL(av)) { - const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied); + const MAGIC * const tied_magic = mg_find((const SV *)av, PERL_MAGIC_tied); if (tied_magic) { /* Handle negative array indices 20020222 MJD */ if (key < 0) { bool adjust_index = 1; SV * const * const negative_indices_glob = - hv_fetch(SvSTASH(SvRV(SvTIED_obj((SV *)av, + hv_fetch(SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(av), tied_magic))), NEGATIVE_INDICES_VAR, 16, 0); if (negative_indices_glob @@ -325,7 +327,7 @@ Perl_av_store(pTHX_ register AV *av, I32 key, SV *val) } } if (val != &PL_sv_undef) { - mg_copy((SV*)av, val, 0, key); + mg_copy(MUTABLE_SV(av), val, 0, key); } return NULL; } @@ -362,12 +364,12 @@ Perl_av_store(pTHX_ register AV *av, I32 key, SV *val) if (SvSMAGICAL(av)) { const MAGIC* const mg = SvMAGIC(av); if (val != &PL_sv_undef) { - sv_magic(val, (SV*)av, toLOWER(mg->mg_type), 0, key); + sv_magic(val, MUTABLE_SV(av), toLOWER(mg->mg_type), 0, key); } if (PL_delaymagic && mg->mg_type == PERL_MAGIC_isa) PL_delaymagic |= DM_ARRAY; else - mg_set((SV*)av); + mg_set(MUTABLE_SV(av)); } return &ary[key]; } @@ -440,7 +442,7 @@ Perl_av_clear(pTHX_ register AV *av) if (PL_delaymagic && mg && mg->mg_type == PERL_MAGIC_isa) PL_delaymagic |= DM_ARRAY; else - mg_clear((SV*)av); + mg_clear(MUTABLE_SV(av)); } if (AvMAX(av) < 0) @@ -481,7 +483,7 @@ Perl_av_undef(pTHX_ register AV *av) assert(SvTYPE(av) == SVt_PVAV); /* Give any tie a chance to cleanup first */ - if (SvTIED_mg((SV*)av, PERL_MAGIC_tied)) + if (SvTIED_mg((const SV *)av, PERL_MAGIC_tied)) av_fill(av, -1); if (AvREAL(av)) { @@ -495,7 +497,7 @@ Perl_av_undef(pTHX_ register AV *av) AvARRAY(av) = NULL; AvMAX(av) = AvFILLp(av) = -1; - if(SvRMAGICAL(av)) mg_clear((SV*)av); + if(SvRMAGICAL(av)) mg_clear(MUTABLE_SV(av)); } /* @@ -539,12 +541,12 @@ Perl_av_push(pTHX_ register AV *av, SV *val) if (SvREADONLY(av)) Perl_croak(aTHX_ PL_no_modify); - if ((mg = SvTIED_mg((SV*)av, PERL_MAGIC_tied))) { + if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) { dSP; PUSHSTACKi(PERLSI_MAGIC); PUSHMARK(SP); EXTEND(SP,2); - PUSHs(SvTIED_obj((SV*)av, mg)); + PUSHs(SvTIED_obj(MUTABLE_SV(av), mg)); PUSHs(val); PUTBACK; ENTER; @@ -577,11 +579,11 @@ Perl_av_pop(pTHX_ register AV *av) if (SvREADONLY(av)) Perl_croak(aTHX_ PL_no_modify); - if ((mg = SvTIED_mg((SV*)av, PERL_MAGIC_tied))) { + if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) { dSP; PUSHSTACKi(PERLSI_MAGIC); PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)av, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(av), mg)); PUTBACK; ENTER; if (call_method("POP", G_SCALAR)) { @@ -598,7 +600,7 @@ Perl_av_pop(pTHX_ register AV *av) retval = AvARRAY(av)[AvFILLp(av)]; AvARRAY(av)[AvFILLp(av)--] = &PL_sv_undef; if (SvSMAGICAL(av)) - mg_set((SV*)av); + mg_set(MUTABLE_SV(av)); return retval; } @@ -647,12 +649,12 @@ Perl_av_unshift(pTHX_ register AV *av, register I32 num) if (SvREADONLY(av)) Perl_croak(aTHX_ PL_no_modify); - if ((mg = SvTIED_mg((SV*)av, PERL_MAGIC_tied))) { + if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) { dSP; PUSHSTACKi(PERLSI_MAGIC); PUSHMARK(SP); EXTEND(SP,1+num); - PUSHs(SvTIED_obj((SV*)av, mg)); + PUSHs(SvTIED_obj(MUTABLE_SV(av), mg)); while (num-- > 0) { PUSHs(&PL_sv_undef); } @@ -719,11 +721,11 @@ Perl_av_shift(pTHX_ register AV *av) if (SvREADONLY(av)) Perl_croak(aTHX_ PL_no_modify); - if ((mg = SvTIED_mg((SV*)av, PERL_MAGIC_tied))) { + if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) { dSP; PUSHSTACKi(PERLSI_MAGIC); PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)av, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(av), mg)); PUTBACK; ENTER; if (call_method("SHIFT", G_SCALAR)) { @@ -744,7 +746,7 @@ Perl_av_shift(pTHX_ register AV *av) AvMAX(av)--; AvFILLp(av)--; if (SvSMAGICAL(av)) - mg_set((SV*)av); + mg_set(MUTABLE_SV(av)); return retval; } @@ -791,14 +793,14 @@ Perl_av_fill(pTHX_ register AV *av, I32 fill) if (fill < 0) fill = -1; - if ((mg = SvTIED_mg((SV*)av, PERL_MAGIC_tied))) { + if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) { dSP; ENTER; SAVETMPS; PUSHSTACKi(PERLSI_MAGIC); PUSHMARK(SP); EXTEND(SP,2); - PUSHs(SvTIED_obj((SV*)av, mg)); + PUSHs(SvTIED_obj(MUTABLE_SV(av), mg)); mPUSHi(fill + 1); PUTBACK; call_method("STORESIZE", G_SCALAR|G_DISCARD); @@ -824,7 +826,7 @@ Perl_av_fill(pTHX_ register AV *av, I32 fill) AvFILLp(av) = fill; if (SvSMAGICAL(av)) - mg_set((SV*)av); + mg_set(MUTABLE_SV(av)); } else (void)av_store(av,fill,&PL_sv_undef); @@ -852,15 +854,16 @@ Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags) Perl_croak(aTHX_ PL_no_modify); if (SvRMAGICAL(av)) { - const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied); - if ((tied_magic || mg_find((SV*)av, PERL_MAGIC_regdata))) { + const MAGIC * const tied_magic + = mg_find((const SV *)av, PERL_MAGIC_tied); + if ((tied_magic || mg_find((const SV *)av, PERL_MAGIC_regdata))) { /* Handle negative array indices 20020222 MJD */ SV **svp; if (key < 0) { unsigned adjust_index = 1; if (tied_magic) { SV * const * const negative_indices_glob = - hv_fetch(SvSTASH(SvRV(SvTIED_obj((SV *)av, + hv_fetch(SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(av), tied_magic))), NEGATIVE_INDICES_VAR, 16, 0); if (negative_indices_glob @@ -907,7 +910,7 @@ Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags) else AvARRAY(av)[key] = &PL_sv_undef; if (SvSMAGICAL(av)) - mg_set((SV*)av); + mg_set(MUTABLE_SV(av)); } if (flags & G_DISCARD) { SvREFCNT_dec(sv); @@ -936,8 +939,9 @@ Perl_av_exists(pTHX_ AV *av, I32 key) assert(SvTYPE(av) == SVt_PVAV); if (SvRMAGICAL(av)) { - const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied); - if (tied_magic || mg_find((SV*)av, PERL_MAGIC_regdata)) { + const MAGIC * const tied_magic + = mg_find((const SV *)av, PERL_MAGIC_tied); + if (tied_magic || mg_find((const SV *)av, PERL_MAGIC_regdata)) { SV * const sv = sv_newmortal(); MAGIC *mg; /* Handle negative array indices 20020222 MJD */ @@ -945,7 +949,7 @@ Perl_av_exists(pTHX_ AV *av, I32 key) unsigned adjust_index = 1; if (tied_magic) { SV * const * const negative_indices_glob = - hv_fetch(SvSTASH(SvRV(SvTIED_obj((SV *)av, + hv_fetch(SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(av), tied_magic))), NEGATIVE_INDICES_VAR, 16, 0); if (negative_indices_glob @@ -959,7 +963,7 @@ Perl_av_exists(pTHX_ AV *av, I32 key) } } - mg_copy((SV*)av, sv, 0, key); + mg_copy(MUTABLE_SV(av), sv, 0, key); mg = mg_find(sv, PERL_MAGIC_tiedelem); if (mg) { magic_existspack(sv, mg); @@ -992,11 +996,11 @@ S_get_aux_mg(pTHX_ AV *av) { PERL_ARGS_ASSERT_GET_AUX_MG; assert(SvTYPE(av) == SVt_PVAV); - mg = mg_find((SV*)av, PERL_MAGIC_arylen_p); + mg = mg_find((const SV *)av, PERL_MAGIC_arylen_p); if (!mg) { - mg = sv_magicext((SV*)av, 0, PERL_MAGIC_arylen_p, &PL_vtbl_arylen_p, - 0, 0); + mg = sv_magicext(MUTABLE_SV(av), 0, PERL_MAGIC_arylen_p, + &PL_vtbl_arylen_p, 0, 0); assert(mg); /* sv_magicext won't set this for us because we pass in a NULL obj */ mg->mg_flags |= MGf_REFCOUNTED; diff --git a/doop.c b/doop.c index 039d9ad..b9c6fdc 100644 --- a/doop.c +++ b/doop.c @@ -316,7 +316,7 @@ S_do_trans_simple_utf8(pTHX_ SV * const sv) #ifdef USE_ITHREADS PAD_SVl(cPADOP->op_padix); #else - (SV*)cSVOP->op_sv; + MUTABLE_SV(cSVOP->op_sv); #endif HV* const hv = MUTABLE_HV(SvRV(rv)); SV* const * svp = hv_fetchs(hv, "NONE", FALSE); @@ -418,7 +418,7 @@ S_do_trans_count_utf8(pTHX_ SV * const sv) #ifdef USE_ITHREADS PAD_SVl(cPADOP->op_padix); #else - (SV*)cSVOP->op_sv; + MUTABLE_SV(cSVOP->op_sv); #endif HV* const hv = MUTABLE_HV(SvRV(rv)); SV* const * const svp = hv_fetchs(hv, "NONE", FALSE); @@ -469,7 +469,7 @@ S_do_trans_complex_utf8(pTHX_ SV * const sv) #ifdef USE_ITHREADS PAD_SVl(cPADOP->op_padix); #else - (SV*)cSVOP->op_sv; + MUTABLE_SV(cSVOP->op_sv); #endif HV * const hv = MUTABLE_HV(SvRV(rv)); SV * const *svp = hv_fetchs(hv, "NONE", FALSE); @@ -1002,7 +1002,7 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv) const I32 max = AvFILL(av); for (i = 0; i <= max; i++) { - sv = (SV*)av_fetch(av, i, FALSE); + sv = MUTABLE_SV(av_fetch(av, i, FALSE)); if (sv && ((sv = *(SV**)sv), sv != &PL_sv_undef)) do_chop(astr, sv); } @@ -1088,7 +1088,7 @@ Perl_do_chomp(pTHX_ register SV *sv) const I32 max = AvFILL(av); for (i = 0; i <= max; i++) { - sv = (SV*)av_fetch(av, i, FALSE); + sv = MUTABLE_SV(av_fetch(av, i, FALSE)); if (sv && ((sv = *(SV**)sv), sv != &PL_sv_undef)) count += do_chomp(sv); } @@ -1465,7 +1465,7 @@ Perl_do_kv(pTHX) sv_magic(TARG, NULL, PERL_MAGIC_nkeys, NULL, 0); } LvTYPE(TARG) = 'k'; - if (LvTARG(TARG) != (SV*)keys) { + if (LvTARG(TARG) != (const SV *)keys) { if (LvTARG(TARG)) SvREFCNT_dec(LvTARG(TARG)); LvTARG(TARG) = SvREFCNT_inc_simple(keys); @@ -1474,7 +1474,7 @@ Perl_do_kv(pTHX) RETURN; } - if (! SvTIED_mg((SV*)keys, PERL_MAGIC_tied) ) + if (! SvTIED_mg((const SV *)keys, PERL_MAGIC_tied) ) { i = HvKEYS(keys); } diff --git a/dump.c b/dump.c index 7f55558..1d2dd2b 100644 --- a/dump.c +++ b/dump.c @@ -409,7 +409,7 @@ Perl_sv_peek(pTHX_ SV *sv) sv_catpv(t, "VOID"); goto finish; } - else if (sv == (SV*)0x55555555 || SvTYPE(sv) == 'U') { + else if (sv == (const SV *)0x55555555 || SvTYPE(sv) == 'U') { sv_catpv(t, "WILD"); goto finish; } @@ -480,7 +480,7 @@ Perl_sv_peek(pTHX_ SV *sv) sv_catpv(t, "..."); goto finish; } - sv = (SV*)SvRV(sv); + sv = SvRV(sv); goto retry; } type = SvTYPE(sv); @@ -1328,7 +1328,8 @@ Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, const MAGIC *mg, I32 nest, I32 } else if (mg->mg_len == HEf_SVKEY) { PerlIO_puts(file, " => HEf_SVKEY\n"); - do_sv_dump(level+2, file, (SV*)((mg)->mg_ptr), nest+1, maxnest, dumpops, pvlim); /* MG is already +1 */ + do_sv_dump(level+2, file, MUTABLE_SV(((mg)->mg_ptr)), nest+1, + maxnest, dumpops, pvlim); /* MG is already +1 */ continue; } else @@ -1745,12 +1746,12 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo Perl_dump_indent(aTHX_ level, file, " NAME = \"%s\"\n", hvname); } if (SvOOK(sv)) { - const AV * const backrefs + AV * const backrefs = *Perl_hv_backreferences_p(aTHX_ MUTABLE_HV(sv)); if (backrefs) { Perl_dump_indent(aTHX_ level, file, " BACKREFS = 0x%"UVxf"\n", PTR2UV(backrefs)); - do_sv_dump(level+1, file, (SV*)backrefs, nest+1, maxnest, + do_sv_dump(level+1, file, MUTABLE_SV(backrefs), nest+1, maxnest, dumpops, pvlim); } } @@ -1840,7 +1841,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo : CvGV(outside) ? GvNAME(CvGV(outside)) : "UNDEFINED")); } if (nest < maxnest && (CvCLONE(sv) || CvCLONED(sv))) - do_sv_dump(level+1, file, (SV*)CvOUTSIDE(sv), nest+1, maxnest, dumpops, pvlim); + do_sv_dump(level+1, file, MUTABLE_SV(CvOUTSIDE(sv)), nest+1, maxnest, dumpops, pvlim); break; case SVt_PVGV: case SVt_PVLV: @@ -1895,8 +1896,8 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo else { Perl_dump_indent(aTHX_ level, file, " TOP_GV = 0x%"UVxf"\n", PTR2UV(IoTOP_GV(sv))); - do_sv_dump (level+1, file, (SV *) IoTOP_GV(sv), nest+1, maxnest, - dumpops, pvlim); + do_sv_dump (level+1, file, MUTABLE_SV(IoTOP_GV(sv)), nest+1, + maxnest, dumpops, pvlim); } /* Source filters hide things that are not GVs in these three, so let's be careful out there. */ @@ -1907,8 +1908,8 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo else { Perl_dump_indent(aTHX_ level, file, " FMT_GV = 0x%"UVxf"\n", PTR2UV(IoFMT_GV(sv))); - do_sv_dump (level+1, file, (SV *) IoFMT_GV(sv), nest+1, maxnest, - dumpops, pvlim); + do_sv_dump (level+1, file, MUTABLE_SV(IoFMT_GV(sv)), nest+1, + maxnest, dumpops, pvlim); } if (IoBOTTOM_NAME(sv)) Perl_dump_indent(aTHX_ level, file, " BOTTOM_NAME = \"%s\"\n", IoBOTTOM_NAME(sv)); @@ -1917,8 +1918,8 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo else { Perl_dump_indent(aTHX_ level, file, " BOTTOM_GV = 0x%"UVxf"\n", PTR2UV(IoBOTTOM_GV(sv))); - do_sv_dump (level+1, file, (SV *) IoBOTTOM_GV(sv), nest+1, maxnest, - dumpops, pvlim); + do_sv_dump (level+1, file, MUTABLE_SV(IoBOTTOM_GV(sv)), nest+1, + maxnest, dumpops, pvlim); } if (isPRINT(IoTYPE(sv))) Perl_dump_indent(aTHX_ level, file, " TYPE = '%c'\n", IoTYPE(sv)); @@ -2372,7 +2373,7 @@ Perl_sv_xmlpeek(pTHX_ SV *sv) sv_catpv(t, "VOID=\"\""); goto finish; } - else if (sv == (SV*)0x55555555 || SvTYPE(sv) == 'U') { + else if (sv == (const SV *)0x55555555 || SvTYPE(sv) == 'U') { sv_catpv(t, "WILD=\"\""); goto finish; } @@ -2536,7 +2537,7 @@ Perl_do_pmop_xmldump(pTHX_ I32 level, PerlIO *file, const PMOP *pm) if (PM_GETRE(pm)) { REGEXP *const r = PM_GETRE(pm); SV * const tmpsv = newSVpvn_utf8("", 0, TRUE); - sv_catxmlsv(tmpsv, (SV*)r); + sv_catxmlsv(tmpsv, MUTABLE_SV(r)); Perl_xmldump_indent(aTHX_ level, file, "pre=\"%s\"\n", SvPVX(tmpsv)); SvREFCNT_dec(tmpsv); @@ -2945,7 +2946,7 @@ Perl_do_op_xmldump(pTHX_ I32 level, PerlIO *file, const OP *o) break; case MAD_SV: sv_catpv(tmpsv, " val=\""); - sv_catxmlsv(tmpsv, (SV*)mp->mad_val); + sv_catxmlsv(tmpsv, MUTABLE_SV(mp->mad_val)); sv_catpv(tmpsv, "\""); Perl_xmldump_indent(aTHX_ level, file, "\n", SvPVX(tmpsv)); break; diff --git a/gv.c b/gv.c index aa27f4a..4a1617c 100644 --- a/gv.c +++ b/gv.c @@ -45,7 +45,7 @@ Perl_gv_SVadd(pTHX_ GV *gv) { PERL_ARGS_ASSERT_GV_SVADD; - if (!gv || SvTYPE((SV*)gv) != SVt_PVGV) + if (!gv || SvTYPE((const SV *)gv) != SVt_PVGV) Perl_croak(aTHX_ "Bad symbol for scalar"); if (!GvSV(gv)) GvSV(gv) = newSV(0); @@ -58,7 +58,7 @@ Perl_gv_AVadd(pTHX_ register GV *gv) { PERL_ARGS_ASSERT_GV_AVADD; - if (!gv || SvTYPE((SV*)gv) != SVt_PVGV) + if (!gv || SvTYPE((const SV *)gv) != SVt_PVGV) Perl_croak(aTHX_ "Bad symbol for array"); if (!GvAV(gv)) GvAV(gv) = newAV(); @@ -70,7 +70,7 @@ Perl_gv_HVadd(pTHX_ register GV *gv) { PERL_ARGS_ASSERT_GV_HVADD; - if (!gv || SvTYPE((SV*)gv) != SVt_PVGV) + if (!gv || SvTYPE((const SV *)gv) != SVt_PVGV) Perl_croak(aTHX_ "Bad symbol for hash"); if (!GvHV(gv)) GvHV(gv) = newHV(); @@ -84,7 +84,7 @@ Perl_gv_IOadd(pTHX_ register GV *gv) PERL_ARGS_ASSERT_GV_IOADD; - if (!gv || SvTYPE((SV*)gv) != SVt_PVGV) { + if (!gv || SvTYPE((const SV *)gv) != SVt_PVGV) { /* * if it walks like a dirhandle, then let's assume that @@ -256,7 +256,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi) if (old_type < SVt_PVGV) { if (old_type >= SVt_PV) SvCUR_set(gv, 0); - sv_upgrade((SV*)gv, SVt_PVGV); + sv_upgrade(MUTABLE_SV(gv), SVt_PVGV); } if (SvLEN(gv)) { if (proto) { @@ -272,7 +272,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi) GvGP(gv) = Perl_newGP(aTHX_ gv); GvSTASH(gv) = stash; if (stash) - Perl_sv_add_backref(aTHX_ (SV*)stash, (SV*)gv); + Perl_sv_add_backref(aTHX_ MUTABLE_SV(stash), MUTABLE_SV(gv)); gv_name_set(gv, name, len, GV_ADD); if (multi || doproto) /* doproto means it _was_ mentioned */ GvMULTI_on(gv); @@ -297,7 +297,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi) CvFILE_set_from_cop(GvCV(gv), PL_curcop); CvSTASH(GvCV(gv)) = PL_curstash; if (proto) { - sv_usepvn_flags((SV*)GvCV(gv), proto, protolen, + sv_usepvn_flags(MUTABLE_SV(GvCV(gv)), proto, protolen, SV_HAS_TRAILING_NUL); } } @@ -588,7 +588,7 @@ S_gv_get_super_pkg(pTHX_ const char* name, I32 namelen) gv_init(gv, stash, "ISA", 3, TRUE); superisa = GvAVn(gv); GvMULTI_on(gv); - sv_magic((SV*)superisa, (SV*)gv, PERL_MAGIC_isa, NULL, 0); + sv_magic(MUTABLE_SV(superisa), MUTABLE_SV(gv), PERL_MAGIC_isa, NULL, 0); #ifdef USE_ITHREADS av_push(superisa, newSVpv(CopSTASHPV(PL_curcop), 0)); #else @@ -618,7 +618,7 @@ Perl_gv_fetchmethod_flags(pTHX_ HV *stash, const char *name, U32 flags) GV* gv; HV* ostash = stash; const char * const origname = name; - SV *const error_report = (SV *)stash; + SV *const error_report = MUTABLE_SV(stash); const U32 autoload = flags & GV_AUTOLOAD; const U32 do_croak = flags & GV_CROAK; @@ -739,7 +739,7 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method) return NULL; if (stash) { if (SvTYPE(stash) < SVt_PVHV) { - packname = SvPV_const((SV*)stash, packname_len); + packname = SvPV_const(MUTABLE_SV(stash), packname_len); stash = NULL; } else { @@ -1204,7 +1204,8 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, if (strEQ(name2, "SA")) { AV* const av = GvAVn(gv); GvMULTI_on(gv); - sv_magic((SV*)av, (SV*)gv, PERL_MAGIC_isa, NULL, 0); + sv_magic(MUTABLE_SV(av), MUTABLE_SV(gv), PERL_MAGIC_isa, + NULL, 0); /* NOTE: No support for tied ISA */ if ((add & GV_ADDMULTI) && strEQ(nambeg,"AnyDBM_File::ISA") && AvFILLp(av) == -1) @@ -1342,7 +1343,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, GvMULTI_on(gv); /* If %! has been used, automatically load Errno.pm. */ - sv_magic(GvSVn(gv), (SV*)gv, PERL_MAGIC_sv, name, len); + sv_magic(GvSVn(gv), MUTABLE_SV(gv), PERL_MAGIC_sv, name, len); /* magicalization must be done before require_tie_mod is called */ if (sv_type == SVt_PVHV || sv_type == SVt_PVGV) @@ -1354,10 +1355,10 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, GvMULTI_on(gv); /* no used once warnings here */ { AV* const av = GvAVn(gv); - SV* const avc = (*name == '+') ? (SV*)av : NULL; + SV* const avc = (*name == '+') ? MUTABLE_SV(av) : NULL; - sv_magic((SV*)av, avc, PERL_MAGIC_regdata, NULL, 0); - sv_magic(GvSVn(gv), (SV*)gv, PERL_MAGIC_sv, name, len); + sv_magic(MUTABLE_SV(av), avc, PERL_MAGIC_regdata, NULL, 0); + sv_magic(GvSVn(gv), MUTABLE_SV(gv), PERL_MAGIC_sv, name, len); if (avc) SvREADONLY_on(GvSVn(gv)); SvREADONLY_on(av); @@ -1421,7 +1422,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, case '\024': /* $^T */ case '\027': /* $^W */ magicalize: - sv_magic(GvSVn(gv), (SV*)gv, PERL_MAGIC_sv, name, len); + sv_magic(GvSVn(gv), MUTABLE_SV(gv), PERL_MAGIC_sv, name, len); break; case '\014': /* $^L */ @@ -1646,7 +1647,7 @@ Perl_magic_freeovrld(pTHX_ SV *sv, MAGIC *mg) for (i = 1; i < NofAMmeth; i++) { CV * const cv = amtp->table[i]; if (cv) { - SvREFCNT_dec((SV *) cv); + SvREFCNT_dec(MUTABLE_SV(cv)); amtp->table[i] = NULL; } } @@ -1660,7 +1661,7 @@ bool Perl_Gv_AMupdate(pTHX_ HV *stash) { dVAR; - MAGIC* const mg = mg_find((SV*)stash, PERL_MAGIC_overload_table); + MAGIC* const mg = mg_find((const SV *)stash, PERL_MAGIC_overload_table); AMT amt; const struct mro_meta* stash_meta = HvMROMETA(stash); U32 newgen; @@ -1674,7 +1675,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash) && amtp->was_ok_sub == newgen) { return (bool)AMT_OVERLOADED(amtp); } - sv_unmagic((SV*)stash, PERL_MAGIC_overload_table); + sv_unmagic(MUTABLE_SV(stash), PERL_MAGIC_overload_table); } DEBUG_o( Perl_deb(aTHX_ "Recalcing overload magic in package %s\n",HvNAME_get(stash)) ); @@ -1773,7 +1774,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash) AMT_AMAGIC_on(&amt); if (have_ovl) AMT_OVERLOADED_on(&amt); - sv_magic((SV*)stash, 0, PERL_MAGIC_overload_table, + sv_magic(MUTABLE_SV(stash), 0, PERL_MAGIC_overload_table, (char*)&amt, sizeof(AMT)); return have_ovl; } @@ -1781,7 +1782,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash) /* Here we have no table: */ /* no_table: */ AMT_AMAGIC_off(&amt); - sv_magic((SV*)stash, 0, PERL_MAGIC_overload_table, + sv_magic(MUTABLE_SV(stash), 0, PERL_MAGIC_overload_table, (char*)&amt, sizeof(AMTS)); return FALSE; } @@ -1802,11 +1803,11 @@ Perl_gv_handler(pTHX_ HV *stash, I32 id) stash_meta = HvMROMETA(stash); newgen = PL_sub_generation + stash_meta->pkg_gen + stash_meta->cache_gen; - mg = mg_find((SV*)stash, PERL_MAGIC_overload_table); + mg = mg_find((const SV *)stash, PERL_MAGIC_overload_table); if (!mg) { do_update: Gv_AMupdate(stash); - mg = mg_find((SV*)stash, PERL_MAGIC_overload_table); + mg = mg_find((const SV *)stash, PERL_MAGIC_overload_table); } assert(mg); amtp = (AMT*)mg->mg_ptr; @@ -1853,7 +1854,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) if (!(AMGf_noleft & flags) && SvAMAGIC(left) && (stash = SvSTASH(SvRV(left))) - && (mg = mg_find((SV*)stash, PERL_MAGIC_overload_table)) + && (mg = mg_find((const SV *)stash, PERL_MAGIC_overload_table)) && (ocvp = cvp = (AMT_AMAGIC((AMT*)mg->mg_ptr) ? (oamtp = amtp = (AMT*)mg->mg_ptr)->table : NULL)) @@ -1977,7 +1978,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) if (!cv) goto not_found; } else if (!(AMGf_noright & flags) && SvAMAGIC(right) && (stash = SvSTASH(SvRV(right))) - && (mg = mg_find((SV*)stash, PERL_MAGIC_overload_table)) + && (mg = mg_find((const SV *)stash, PERL_MAGIC_overload_table)) && (cvp = (AMT_AMAGIC((AMT*)mg->mg_ptr) ? (amtp = (AMT*)mg->mg_ptr)->table : NULL)) @@ -2151,7 +2152,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) PUSHs(newSVpvn_flags(AMG_id2name(method + assignshift), AMG_id2namelen(method + assignshift), SVs_TEMP)); } - PUSHs((SV*)cv); + PUSHs(MUTABLE_SV(cv)); PUTBACK; if ((PL_op = Perl_pp_entersub(aTHX))) diff --git a/hv.c b/hv.c index 746e829..d840696 100644 --- a/hv.c +++ b/hv.c @@ -169,7 +169,7 @@ Perl_he_dup(pTHX_ const HE *e, bool shared, CLONE_PARAMS* param) HeNEXT(ret) = he_dup(HeNEXT(e),shared, param); if (HeKLEN(e) == HEf_SVKEY) { char *k; - Newx(k, HEK_BASESIZE + sizeof(SV*), char); + Newx(k, HEK_BASESIZE + sizeof(const SV *), char); HeKEY_hek(ret) = (HEK*)k; HeKEY_sv(ret) = SvREFCNT_inc(sv_dup(HeKEY_sv(e), param)); } @@ -357,7 +357,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, if (SvSMAGICAL(hv) && SvGMAGICAL(hv) && !(action & HV_DISABLE_UVAR_XKEY)) { MAGIC* mg; - if ((mg = mg_find((SV*)hv, PERL_MAGIC_uvar))) { + if ((mg = mg_find((const SV *)hv, PERL_MAGIC_uvar))) { struct ufuncs * const uf = (struct ufuncs *)mg->mg_ptr; if (uf->uf_set == NULL) { SV* obj = mg->mg_obj; @@ -370,7 +370,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, mg->mg_obj = keysv; /* pass key */ uf->uf_index = action; /* pass action */ - magic_getuvar((SV*)hv, mg); + magic_getuvar(MUTABLE_SV(hv), mg); keysv = mg->mg_obj; /* may have changed */ mg->mg_obj = obj; @@ -399,7 +399,8 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, xhv = (XPVHV*)SvANY(hv); if (SvMAGICAL(hv)) { if (SvRMAGICAL(hv) && !(action & (HV_FETCH_ISSTORE|HV_FETCH_ISEXISTS))) { - if ( mg_find((SV*)hv, PERL_MAGIC_tied) || SvGMAGICAL((SV*)hv)) + if (mg_find((const SV *)hv, PERL_MAGIC_tied) + || SvGMAGICAL((const SV *)hv)) { /* FIXME should be able to skimp on the HE/HEK here when HV_FETCH_JUST_SV is true. */ @@ -409,7 +410,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, keysv = newSVsv(keysv); } sv = sv_newmortal(); - mg_copy((SV*)hv, sv, (char *)keysv, HEf_SVKEY); + mg_copy(MUTABLE_SV(hv), sv, (char *)keysv, HEf_SVKEY); /* grab a fake HE/HEK pair from the pool or make a new one */ entry = PL_hv_fetch_ent_mh; @@ -418,7 +419,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, else { char *k; entry = new_HE(); - Newx(k, HEK_BASESIZE + sizeof(SV*), char); + Newx(k, HEK_BASESIZE + sizeof(const SV *), char); HeKEY_hek(entry) = (HEK*)k; } HeNEXT(entry) = NULL; @@ -427,7 +428,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, sv_upgrade(sv, SVt_PVLV); LvTYPE(sv) = 'T'; /* so we can free entry when freeing sv */ - LvTARG(sv) = (SV*)entry; + LvTARG(sv) = MUTABLE_SV(entry); /* XXX remove at some point? */ if (flags & HVhek_FREEKEY) @@ -439,7 +440,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, return (void *) entry; } #ifdef ENV_IS_CASELESS - else if (mg_find((SV*)hv, PERL_MAGIC_env)) { + else if (mg_find((const SV *)hv, PERL_MAGIC_env)) { U32 i; for (i = 0; i < klen; ++i) if (isLOWER(key[i])) { @@ -474,7 +475,8 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, #endif } /* ISFETCH */ else if (SvRMAGICAL(hv) && (action & HV_FETCH_ISEXISTS)) { - if (mg_find((SV*)hv, PERL_MAGIC_tied) || SvGMAGICAL((SV*)hv)) { + if (mg_find((const SV *)hv, PERL_MAGIC_tied) + || SvGMAGICAL((const SV *)hv)) { /* I don't understand why hv_exists_ent has svret and sv, whereas hv_exists only had one. */ SV * const svret = sv_newmortal(); @@ -486,9 +488,9 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, } else { keysv = newSVsv(keysv); } - mg_copy((SV*)hv, sv, (char *)sv_2mortal(keysv), HEf_SVKEY); + mg_copy(MUTABLE_SV(hv), sv, (char *)sv_2mortal(keysv), HEf_SVKEY); } else { - mg_copy((SV*)hv, sv, key, klen); + mg_copy(MUTABLE_SV(hv), sv, key, klen); } if (flags & HVhek_FREEKEY) Safefree(key); @@ -499,7 +501,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, return SvTRUE(svret) ? (void *)hv : NULL; } #ifdef ENV_IS_CASELESS - else if (mg_find((SV*)hv, PERL_MAGIC_env)) { + else if (mg_find((const SV *)hv, PERL_MAGIC_env)) { /* XXX This code isn't UTF8 clean. */ char * const keysave = (char * const)key; /* Will need to free this, so set FREEKEY flag. */ @@ -529,9 +531,9 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, if (PL_tainting) PL_tainted = SvTAINTED(keysv); keysv = sv_2mortal(newSVsv(keysv)); - mg_copy((SV*)hv, val, (char*)keysv, HEf_SVKEY); + mg_copy(MUTABLE_SV(hv), val, (char*)keysv, HEf_SVKEY); } else { - mg_copy((SV*)hv, val, key, klen); + mg_copy(MUTABLE_SV(hv), val, key, klen); } TAINT_IF(save_taint); @@ -541,7 +543,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, return NULL; } #ifdef ENV_IS_CASELESS - else if (mg_find((SV*)hv, PERL_MAGIC_env)) { + else if (mg_find((const SV *)hv, PERL_MAGIC_env)) { /* XXX This code isn't UTF8 clean. */ const char *keysave = key; /* Will need to free this, so set FREEKEY flag. */ @@ -564,7 +566,8 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, if (!HvARRAY(hv)) { if ((action & (HV_FETCH_LVALUE | HV_FETCH_ISSTORE)) #ifdef DYNAMIC_ENV_FETCH /* if it's an %ENV lookup, we may get it on the fly */ - || (SvRMAGICAL((SV*)hv) && mg_find((SV*)hv, PERL_MAGIC_env)) + || (SvRMAGICAL((const SV *)hv) + && mg_find((const SV *)hv, PERL_MAGIC_env)) #endif ) { char *array; @@ -707,7 +710,8 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, } #ifdef DYNAMIC_ENV_FETCH /* %ENV lookup? If so, try to fetch the value now */ if (!(action & HV_FETCH_ISSTORE) - && SvRMAGICAL((SV*)hv) && mg_find((SV*)hv, PERL_MAGIC_env)) { + && SvRMAGICAL((const SV *)hv) + && mg_find((const SV *)hv, PERL_MAGIC_env)) { unsigned long len; const char * const env = PerlEnv_ENVgetenv_len(key,&len); if (env) { @@ -860,7 +864,7 @@ Perl_hv_scalar(pTHX_ HV *hv) PERL_ARGS_ASSERT_HV_SCALAR; if (SvRMAGICAL(hv)) { - MAGIC * const mg = mg_find((SV*)hv, PERL_MAGIC_tied); + MAGIC * const mg = mg_find((const SV *)hv, PERL_MAGIC_tied); if (mg) return magic_scalarpack(hv, mg); } @@ -930,7 +934,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, return NULL; /* element cannot be deleted */ } #ifdef ENV_IS_CASELESS - else if (mg_find((SV*)hv, PERL_MAGIC_env)) { + else if (mg_find((const SV *)hv, PERL_MAGIC_env)) { /* XXX This code isn't UTF8 clean. */ keysv = newSVpvn_flags(key, klen, SVs_TEMP); if (k_flags & HVhek_FREEKEY) { @@ -965,7 +969,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, } k_flags |= HVhek_WASUTF8 | HVhek_FREEKEY; } - HvHASKFLAGS_on((SV*)hv); + HvHASKFLAGS_on(MUTABLE_SV(hv)); } if (HvREHASH(hv)) { @@ -1332,7 +1336,7 @@ Perl_newHVhv(pTHX_ HV *ohv) return hv; hv_max = HvMAX(ohv); - if (!SvMAGICAL((SV *)ohv)) { + if (!SvMAGICAL((const SV *)ohv)) { /* It's an ordinary hash, so copy it fast. AMS 20010804 */ STRLEN i; const bool shared = !!HvSHAREKEYS(ohv); @@ -1525,7 +1529,7 @@ Perl_hv_clear(pTHX_ HV *hv) Zero(HvARRAY(hv), xhv->xhv_max+1 /* HvMAX(hv)+1 */, HE*); if (SvRMAGICAL(hv)) - mg_clear((SV*)hv); + mg_clear(MUTABLE_SV(hv)); HvHASKFLAGS_off(hv); HvREHASH_off(hv); @@ -1670,7 +1674,8 @@ S_hfreeentries(pTHX_ HV *hv) SvREFCNT_dec(iter->xhv_backreferences); } else { - sv_magic((SV*)hv, (SV*)iter->xhv_backreferences, + sv_magic(MUTABLE_SV(hv), + MUTABLE_SV(iter->xhv_backreferences), PERL_MAGIC_backref, NULL, 0); } iter->xhv_backreferences = NULL; @@ -1793,7 +1798,7 @@ Perl_hv_undef(pTHX_ HV *hv) HvPLACEHOLDERS_set(hv, 0); if (SvRMAGICAL(hv)) - mg_clear((SV*)hv); + mg_clear(MUTABLE_SV(hv)); } static struct xpvhv_aux* @@ -1985,7 +1990,7 @@ Perl_hv_kill_backrefs(pTHX_ HV *hv) { if (av) { HvAUX(hv)->xhv_backreferences = 0; - Perl_sv_kill_backrefs(aTHX_ (SV*) hv, av); + Perl_sv_kill_backrefs(aTHX_ MUTABLE_SV(hv), av); SvREFCNT_dec(av); } } @@ -2046,7 +2051,7 @@ Perl_hv_iternext_flags(pTHX_ HV *hv, I32 flags) oldentry = entry = iter->xhv_eiter; /* HvEITER(hv) */ if (SvMAGICAL(hv) && SvRMAGICAL(hv)) { - if ( ( mg = mg_find((SV*)hv, PERL_MAGIC_tied) ) ) { + if ( ( mg = mg_find((const SV *)hv, PERL_MAGIC_tied) ) ) { SV * const key = sv_newmortal(); if (entry) { sv_setsv(key, HeSVKEY_force(entry)); @@ -2059,12 +2064,12 @@ Perl_hv_iternext_flags(pTHX_ HV *hv, I32 flags) /* one HE per MAGICAL hash */ iter->xhv_eiter = entry = new_HE(); /* HvEITER(hv) = new_HE() */ Zero(entry, 1, HE); - Newxz(k, HEK_BASESIZE + sizeof(SV*), char); + Newxz(k, HEK_BASESIZE + sizeof(const SV *), char); hek = (HEK*)k; HeKEY_hek(entry) = hek; HeKLEN(entry) = HEf_SVKEY; } - magic_nextpack((SV*) hv,mg,key); + magic_nextpack(MUTABLE_SV(hv),mg,key); if (SvOK(key)) { /* force key to stay around until next time */ HeSVKEY_set(entry, SvREFCNT_inc_simple_NN(key)); @@ -2079,7 +2084,8 @@ Perl_hv_iternext_flags(pTHX_ HV *hv, I32 flags) } } #if defined(DYNAMIC_ENV_FETCH) && !defined(__riscos__) /* set up %ENV for iteration */ - if (!entry && SvRMAGICAL((SV*)hv) && mg_find((SV*)hv, PERL_MAGIC_env)) { + if (!entry && SvRMAGICAL((const SV *)hv) + && mg_find((const SV *)hv, PERL_MAGIC_env)) { prime_env_iter(); #ifdef VMS /* The prime_env_iter() on VMS just loaded up new hash values @@ -2203,12 +2209,12 @@ Perl_hv_iterval(pTHX_ HV *hv, register HE *entry) PERL_ARGS_ASSERT_HV_ITERVAL; if (SvRMAGICAL(hv)) { - if (mg_find((SV*)hv, PERL_MAGIC_tied)) { + if (mg_find((const SV *)hv, PERL_MAGIC_tied)) { SV* const sv = sv_newmortal(); if (HeKLEN(entry) == HEf_SVKEY) - mg_copy((SV*)hv, sv, (char*)HeKEY_sv(entry), HEf_SVKEY); + mg_copy(MUTABLE_SV(hv), sv, (char*)HeKEY_sv(entry), HEf_SVKEY); else - mg_copy((SV*)hv, sv, HeKEY(entry), HeKLEN(entry)); + mg_copy(MUTABLE_SV(hv), sv, HeKEY(entry), HeKLEN(entry)); return sv; } } @@ -2490,12 +2496,12 @@ I32 * Perl_hv_placeholders_p(pTHX_ HV *hv) { dVAR; - MAGIC *mg = mg_find((SV*)hv, PERL_MAGIC_rhash); + MAGIC *mg = mg_find((const SV *)hv, PERL_MAGIC_rhash); PERL_ARGS_ASSERT_HV_PLACEHOLDERS_P; if (!mg) { - mg = sv_magicext((SV*)hv, 0, PERL_MAGIC_rhash, 0, 0, 0); + mg = sv_magicext(MUTABLE_SV(hv), 0, PERL_MAGIC_rhash, 0, 0, 0); if (!mg) { Perl_die(aTHX_ "panic: hv_placeholders_p"); @@ -2520,14 +2526,14 @@ void Perl_hv_placeholders_set(pTHX_ HV *hv, I32 ph) { dVAR; - MAGIC * const mg = mg_find((SV*)hv, PERL_MAGIC_rhash); + MAGIC * const mg = mg_find((const SV *)hv, PERL_MAGIC_rhash); PERL_ARGS_ASSERT_HV_PLACEHOLDERS_SET; if (mg) { mg->mg_len = ph; } else if (ph) { - if (!sv_magicext((SV*)hv, 0, PERL_MAGIC_rhash, 0, 0, ph)) + if (!sv_magicext(MUTABLE_SV(hv), 0, PERL_MAGIC_rhash, 0, 0, ph)) Perl_die(aTHX_ "panic: hv_placeholders_set"); } /* else we don't need to add magic to record 0 placeholders. */ @@ -2768,7 +2774,7 @@ Perl_refcounted_he_new(pTHX_ struct refcounted_he *const parent, if (SvPOK(value)) { value_type = HVrhek_PV; } else if (SvIOK(value)) { - value_type = SvUOK((SV*)value) ? HVrhek_UV : HVrhek_IV; + value_type = SvUOK((const SV *)value) ? HVrhek_UV : HVrhek_IV; } else if (value == &PL_sv_placeholder) { value_type = HVrhek_delete; } else if (!SvOK(value)) { @@ -2831,9 +2837,9 @@ S_refcounted_he_new_common(pTHX_ struct refcounted_he *const parent, Copy((char *)value, he->refcounted_he_data + 1, value_len + 1, char); he->refcounted_he_val.refcounted_he_u_len = value_len; } else if (value_type == HVrhek_IV) { - he->refcounted_he_val.refcounted_he_u_iv = SvIVX((SV *)value); + he->refcounted_he_val.refcounted_he_u_iv = SvIVX((const SV *)value); } else if (value_type == HVrhek_UV) { - he->refcounted_he_val.refcounted_he_u_uv = SvUVX((SV *)value); + he->refcounted_he_val.refcounted_he_u_uv = SvUVX((const SV *)value); } PERL_HASH(hash, key_p, key_len); @@ -2983,7 +2989,7 @@ Perl_hv_assert(pTHX_ HV *hv) } else if (HeKWASUTF8(entry)) withflags++; } - if (!SvTIED_mg((SV*)hv, PERL_MAGIC_tied)) { + if (!SvTIED_mg((const SV *)hv, PERL_MAGIC_tied)) { static const char bad_count[] = "Count %d %s(s), but hash reports %d\n"; const int nhashkeys = HvUSEDKEYS(hv); const int nhashplaceholders = HvPLACEHOLDERS_get(hv); @@ -3004,7 +3010,7 @@ Perl_hv_assert(pTHX_ HV *hv) bad = 1; } if (bad) { - sv_dump((SV *)hv); + sv_dump(MUTABLE_SV(hv)); } HvRITER_set(hv, riter); /* Restore hash iterator state */ HvEITER_set(hv, eiter); diff --git a/mathoms.c b/mathoms.c index 7cd5e2e..44e1a0d 100644 --- a/mathoms.c +++ b/mathoms.c @@ -602,7 +602,7 @@ Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how) { PERL_ARGS_ASSERT_HV_MAGIC; - sv_magic((SV*)hv, (SV*)gv, how, NULL, 0); + sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0); } AV * @@ -1353,8 +1353,8 @@ Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash) { PERL_ARGS_ASSERT_HV_DELETE_ENT; - return (SV *) hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL, - hash); + return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL, + hash)); } SV** @@ -1436,8 +1436,8 @@ Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags) klen = klen_i32; k_flags = 0; } - return (SV *) hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE, - NULL, 0); + return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE, + NULL, 0)); } /* Functions after here were made mathoms post 5.10.0 but pre 5.8.9 */ diff --git a/mg.c b/mg.c index 1ae5ad3..39313aa 100644 --- a/mg.c +++ b/mg.c @@ -524,7 +524,7 @@ Perl_mg_free(pTHX_ SV *sv) if (mg->mg_len > 0 || mg->mg_type == PERL_MAGIC_utf8) Safefree(mg->mg_ptr); else if (mg->mg_len == HEf_SVKEY) - SvREFCNT_dec((SV*)mg->mg_ptr); + SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr)); } if (mg->mg_flags & MGf_REFCOUNTED) SvREFCNT_dec(mg->mg_obj); @@ -1641,7 +1641,7 @@ Perl_magic_getnkeys(pTHX_ SV *sv, MAGIC *mg) if (hv) { (void) hv_iterinit(hv); - if (! SvTIED_mg((SV*)hv, PERL_MAGIC_tied)) + if (! SvTIED_mg((const SV *)hv, PERL_MAGIC_tied)) i = HvKEYS(hv); else { while (hv_iternext(hv)) @@ -1681,7 +1681,7 @@ S_magic_methcall(pTHX_ SV *sv, const MAGIC *mg, const char *meth, I32 flags, int if (mg->mg_len >= 0) mPUSHp(mg->mg_ptr, mg->mg_len); else if (mg->mg_len == HEf_SVKEY) - PUSHs((SV*)mg->mg_ptr); + PUSHs(MUTABLE_SV(mg->mg_ptr)); } else if (mg->mg_type == PERL_MAGIC_tiedelem) { mPUSHi(mg->mg_len); @@ -1833,8 +1833,8 @@ Perl_magic_scalarpack(pTHX_ HV *hv, MAGIC *mg) { dVAR; dSP; SV *retval; - SV * const tied = SvTIED_obj((SV*)hv, mg); - HV * const pkg = SvSTASH((SV*)SvRV(tied)); + SV * const tied = SvTIED_obj(MUTABLE_SV(hv), mg); + HV * const pkg = SvSTASH((const SV *)SvRV(tied)); PERL_ARGS_ASSERT_MAGIC_SCALARPACK; @@ -1845,7 +1845,7 @@ Perl_magic_scalarpack(pTHX_ HV *hv, MAGIC *mg) return &PL_sv_yes; /* no xhv_eiter so now use FIRSTKEY */ key = sv_newmortal(); - magic_nextpack((SV*)hv, mg, key); + magic_nextpack(MUTABLE_SV(hv), mg, key); HvEITER_set(hv, NULL); /* need to reset iterator */ return SvOK(key) ? &PL_sv_yes : &PL_sv_no; } @@ -2953,7 +2953,7 @@ Perl_sighandler(int sig) if (sigaction(sig, 0, &oact) == 0 && oact.sa_flags & SA_SIGINFO) { if (sip) { HV *sih = newHV(); - SV *rv = newRV_noinc((SV*)sih); + SV *rv = newRV_noinc(MUTABLE_SV(sih)); /* The siginfo fields signo, code, errno, pid, uid, * addr, status, and band are defined by POSIX/SUSv3. */ (void)hv_stores(sih, "signo", newSViv(sip->si_signo)); @@ -2967,7 +2967,7 @@ Perl_sighandler(int sig) hv_stores(sih, "band", newSViv(sip->si_band)); #endif EXTEND(SP, 2); - PUSHs((SV*)rv); + PUSHs(rv); mPUSHp((char *)sip, sizeof(*sip)); } @@ -2976,7 +2976,7 @@ Perl_sighandler(int sig) #endif PUTBACK; - call_sv((SV*)cv, G_DISCARD|G_EVAL); + call_sv(MUTABLE_SV(cv), G_DISCARD|G_EVAL); POPSTACK; if (SvTRUE(ERRSV)) { @@ -3102,7 +3102,7 @@ int Perl_magic_sethint(pTHX_ SV *sv, MAGIC *mg) { dVAR; - SV *key = (mg->mg_len == HEf_SVKEY) ? (SV *)mg->mg_ptr + SV *key = (mg->mg_len == HEf_SVKEY) ? MUTABLE_SV(mg->mg_ptr) : newSVpvn_flags(mg->mg_ptr, mg->mg_len, SVs_TEMP); PERL_ARGS_ASSERT_MAGIC_SETHINT; @@ -3144,7 +3144,7 @@ Perl_magic_clearhint(pTHX_ SV *sv, MAGIC *mg) PL_hints |= HINT_LOCALIZE_HH; PL_compiling.cop_hints_hash = Perl_refcounted_he_new(aTHX_ PL_compiling.cop_hints_hash, - (SV *)mg->mg_ptr, &PL_sv_placeholder); + MUTABLE_SV(mg->mg_ptr), &PL_sv_placeholder); return 0; } diff --git a/mro.c b/mro.c index d5b9231..43214c2 100644 --- a/mro.c +++ b/mro.c @@ -82,16 +82,16 @@ Perl_mro_meta_dup(pTHX_ struct mro_meta* smeta, CLONE_PARAMS* param) if (newmeta->mro_linear_dfs) newmeta->mro_linear_dfs - = MUTABLE_AV(SvREFCNT_inc(sv_dup((SV*)newmeta->mro_linear_dfs, param))); + = MUTABLE_AV(SvREFCNT_inc(sv_dup((const SV *)newmeta->mro_linear_dfs, param))); if (newmeta->mro_linear_c3) newmeta->mro_linear_c3 - = MUTABLE_AV(SvREFCNT_inc(sv_dup((SV*)newmeta->mro_linear_c3, param))); + = MUTABLE_AV(SvREFCNT_inc(sv_dup((const SV *)newmeta->mro_linear_c3, param))); if (newmeta->mro_nextmethod) newmeta->mro_nextmethod - = MUTABLE_HV(SvREFCNT_inc(sv_dup((SV*)newmeta->mro_nextmethod, param))); + = MUTABLE_HV(SvREFCNT_inc(sv_dup((const SV *)newmeta->mro_nextmethod, param))); if (newmeta->isa) newmeta->isa - = MUTABLE_HV(SvREFCNT_inc(sv_dup((SV*)newmeta->isa, param))); + = MUTABLE_HV(SvREFCNT_inc(sv_dup((const SV *)newmeta->isa, param))); return newmeta; } @@ -181,7 +181,7 @@ S_mro_get_linear_isa_dfs(pTHX_ HV *stash, I32 level) /* not in cache, make a new one */ - retval = MUTABLE_AV(sv_2mortal((SV *)newAV())); + retval = MUTABLE_AV(sv_2mortal(MUTABLE_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); @@ -197,7 +197,7 @@ S_mro_get_linear_isa_dfs(pTHX_ HV *stash, I32 level) It's then retained to be re-used as a fast lookup for ->isa(), by adding our own name and "UNIVERSAL" to it. */ - stored = MUTABLE_HV(sv_2mortal((SV*)newHV())); + stored = MUTABLE_HV(sv_2mortal(MUTABLE_SV(newHV()))); if(av && AvFILLp(av) >= 0) { @@ -344,8 +344,8 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, I32 level) if(isa && AvFILLp(isa) >= 0) { SV** seqs_ptr; I32 seqs_items; - HV* const tails = MUTABLE_HV(sv_2mortal((SV*)newHV())); - AV *const seqs = MUTABLE_AV(sv_2mortal((SV*)newAV())); + HV* const tails = MUTABLE_HV(sv_2mortal(MUTABLE_SV(newHV()))); + AV *const seqs = MUTABLE_AV(sv_2mortal(MUTABLE_SV(newAV()))); I32* heads; /* This builds @seqs, which is an array of arrays. @@ -362,15 +362,15 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, I32 level) containing just itself */ AV* const isa_lin = newAV(); av_push(isa_lin, newSVsv(isa_item)); - av_push(seqs, (SV*)isa_lin); + av_push(seqs, MUTABLE_SV(isa_lin)); } else { /* recursion */ AV* const isa_lin = mro_get_linear_isa_c3(isa_item_stash, level + 1); - av_push(seqs, SvREFCNT_inc_simple_NN((SV*)isa_lin)); + av_push(seqs, SvREFCNT_inc_simple_NN(MUTABLE_SV(isa_lin))); } } - av_push(seqs, SvREFCNT_inc_simple_NN((SV*)isa)); + av_push(seqs, SvREFCNT_inc_simple_NN(MUTABLE_SV(isa))); /* This builds "heads", which as an array of integer array indices, one per seq, which point at the virtual "head" @@ -566,8 +566,8 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash) /* wipe out the cached linearizations for this stash */ meta = HvMROMETA(stash); - SvREFCNT_dec((SV*)meta->mro_linear_dfs); - SvREFCNT_dec((SV*)meta->mro_linear_c3); + SvREFCNT_dec(MUTABLE_SV(meta->mro_linear_dfs)); + SvREFCNT_dec(MUTABLE_SV(meta->mro_linear_c3)); meta->mro_linear_dfs = NULL; meta->mro_linear_c3 = NULL; if (meta->isa) { @@ -609,8 +609,8 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash) if(!revstash) continue; revmeta = HvMROMETA(revstash); - SvREFCNT_dec((SV*)revmeta->mro_linear_dfs); - SvREFCNT_dec((SV*)revmeta->mro_linear_c3); + SvREFCNT_dec(MUTABLE_SV(revmeta->mro_linear_dfs)); + SvREFCNT_dec(MUTABLE_SV(revmeta->mro_linear_c3)); revmeta->mro_linear_dfs = NULL; revmeta->mro_linear_c3 = NULL; if(!is_universal) @@ -643,7 +643,7 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash) mroisarev = MUTABLE_HV(HeVAL(he)); - SvUPGRADE((SV*)mroisarev, SVt_PVHV); + SvUPGRADE(MUTABLE_SV(mroisarev), SVt_PVHV); /* This hash only ever contains PL_sv_yes. Storing it over itself is almost as cheap as calling hv_exists, so on aggregate we expect to @@ -799,7 +799,7 @@ XS(XS_mro_get_linear_isa) { /* No stash exists yet, give them just the classname */ AV* isalin = newAV(); av_push(isalin, newSVsv(classname)); - ST(0) = sv_2mortal(newRV_noinc((SV*)isalin)); + ST(0) = sv_2mortal(newRV_noinc(MUTABLE_SV(isalin))); XSRETURN(1); } else if(items > 1) { @@ -813,7 +813,7 @@ XS(XS_mro_get_linear_isa) { RETVAL = mro_get_linear_isa(class_stash); } - ST(0) = newRV_inc((SV*)RETVAL); + ST(0) = newRV_inc(MUTABLE_SV(RETVAL)); sv_2mortal(ST(0)); XSRETURN(1); } @@ -900,7 +900,7 @@ XS(XS_mro_get_isarev) while((iter = hv_iternext(isarev))) av_push(ret_array, newSVsv(hv_iterkeysv(iter))); } - mXPUSHs(newRV_noinc((SV*)ret_array)); + mXPUSHs(newRV_noinc(MUTABLE_SV(ret_array))); PUTBACK; return; @@ -1168,9 +1168,9 @@ XS(XS_mro_nextcan) entries, because in C3 the method cache of a parent is not valid for the child */ if (SvTYPE(candidate) == SVt_PVGV && (cand_cv = GvCV(candidate)) && !GvCVGEN(candidate)) { - SvREFCNT_inc_simple_void_NN((SV*)cand_cv); - (void)hv_store_ent(nmcache, newSVsv(sv), (SV*)cand_cv, 0); - mXPUSHs(newRV_inc((SV*)cand_cv)); + SvREFCNT_inc_simple_void_NN(MUTABLE_SV(cand_cv)); + (void)hv_store_ent(nmcache, newSVsv(sv), MUTABLE_SV(cand_cv), 0); + mXPUSHs(newRV_inc(MUTABLE_SV(cand_cv))); XSRETURN(1); } } diff --git a/op.c b/op.c index 6406b3d..b70d502 100644 --- a/op.c +++ b/op.c @@ -635,7 +635,7 @@ Perl_op_clear(pTHX_ OP *o) pad_swipe(cPMOPo->op_pmreplrootu.op_pmtargetoff, TRUE); } #else - SvREFCNT_dec((SV*)cPMOPo->op_pmreplrootu.op_pmtargetgv); + SvREFCNT_dec(MUTABLE_SV(cPMOPo->op_pmreplrootu.op_pmtargetgv)); #endif /* FALL THROUGH */ case OP_MATCH: @@ -695,7 +695,7 @@ S_forget_pmop(pTHX_ PMOP *const o PERL_ARGS_ASSERT_FORGET_PMOP; if (pmstash && !SvIS_FREED(pmstash)) { - MAGIC * const mg = mg_find((SV*)pmstash, PERL_MAGIC_symtab); + MAGIC * const mg = mg_find((const SV *)pmstash, PERL_MAGIC_symtab); if (mg) { PMOP **const array = (PMOP**) mg->mg_ptr; U32 count = mg->mg_len / sizeof(PMOP**); @@ -2029,7 +2029,7 @@ Perl_apply_attrs_string(pTHX_ const char *stashpv, CV *cv, newSVOP(OP_CONST, 0, newSVpv(stashpv,0)), prepend_elem(OP_LIST, newSVOP(OP_CONST, 0, - newRV((SV*)cv)), + newRV(MUTABLE_SV(cv))), attrs))); } @@ -2075,8 +2075,8 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp) PL_parser->in_my_stash = NULL; apply_attrs(GvSTASH(gv), (type == OP_RV2SV ? GvSV(gv) : - type == OP_RV2AV ? (SV*)GvAV(gv) : - type == OP_RV2HV ? (SV*)GvHV(gv) : (SV*)gv), + type == OP_RV2AV ? MUTABLE_SV(GvAV(gv)) : + type == OP_RV2HV ? MUTABLE_SV(GvHV(gv)) : MUTABLE_SV(gv)), attrs, FALSE); } o->op_private |= OPpOUR_INTRO; @@ -2349,9 +2349,9 @@ Perl_newPROG(pTHX_ OP *o) if (cv) { dSP; PUSHMARK(SP); - XPUSHs((SV*)CopFILEGV(&PL_compiling)); + XPUSHs(MUTABLE_SV(CopFILEGV(&PL_compiling))); PUTBACK; - call_sv((SV*)cv, G_DISCARD); + call_sv(MUTABLE_SV(cv), G_DISCARD); } } } @@ -2565,7 +2565,7 @@ Perl_fold_constants(pTHX_ register OP *o) if (type == OP_RV2GV) newop = newGVOP(OP_GV, 0, (GV*)sv); else - newop = newSVOP(OP_CONST, 0, (SV*)sv); + newop = newSVOP(OP_CONST, 0, MUTABLE_SV(sv)); op_getmad(o,newop,'f'); return newop; @@ -2779,7 +2779,7 @@ Perl_token_getmad(pTHX_ TOKEN* tk, OP* o, char slot) /* faked up qw list? */ if (slot == '(' && tm->mad_type == MAD_SV && - SvPVX((SV*)tm->mad_val)[0] == 'q') + SvPVX((const SV *)tm->mad_val)[0] == 'q') slot = 'x'; if (o) { @@ -2970,7 +2970,7 @@ Perl_mad_free(pTHX_ MADPROP* mp) op_free((OP*)mp->mad_val); break; case MAD_SV: - sv_free((SV*)mp->mad_val); + sv_free(MUTABLE_SV(mp->mad_val)); break; default: PerlIO_printf(PerlIO_stderr(), "Unrecognized mad\n"); @@ -3348,7 +3348,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl) PerlMemShared_free(cPVOPo->op_pv); cPVOPo->op_pv = NULL; - swash = (SV*)swash_init("utf8", "", listsv, bits, none); + swash = MUTABLE_SV(swash_init("utf8", "", listsv, bits, none)); #ifdef USE_ITHREADS cPADOPo->op_padix = pad_alloc(OP_TRANS, SVs_PADTMP); SvREFCNT_dec(PAD_SVl(cPADOPo->op_padix)); @@ -5313,7 +5313,7 @@ Perl_cv_undef(pTHX_ CV *cv) CvSTART(cv) = NULL; LEAVE; } - SvPOK_off((SV*)cv); /* forget prototype */ + SvPOK_off(MUTABLE_SV(cv)); /* forget prototype */ CvGV(cv) = NULL; pad_undef(cv); @@ -5325,7 +5325,7 @@ Perl_cv_undef(pTHX_ CV *cv) CvOUTSIDE(cv) = NULL; } if (CvCONST(cv)) { - SvREFCNT_dec((SV*)CvXSUBANY(cv).any_ptr); + SvREFCNT_dec(MUTABLE_SV(CvXSUBANY(cv).any_ptr)); CvCONST_off(cv); } if (CvISXSUB(cv) && CvXSUB(cv)) { @@ -5392,7 +5392,7 @@ Perl_cv_const_sv(pTHX_ const CV *const cv) return NULL; if (!(SvTYPE(cv) == SVt_PVCV || SvTYPE(cv) == SVt_PVFM)) return NULL; - return CvCONST(cv) ? (SV*)CvXSUBANY(cv).any_ptr : NULL; + return CvCONST(cv) ? MUTABLE_SV(CvXSUBANY(cv).any_ptr) : NULL; } /* op_const_sv: examine an optree to determine whether it's in-lineable. @@ -5564,7 +5564,8 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) if (SvTYPE(gv) != SVt_PVGV) { /* Maybe prototype now, and had at maximum a prototype before. */ if (SvTYPE(gv) > SVt_NULL) { - if (!SvPOK((SV*)gv) && !(SvIOK((SV*)gv) && SvIVX((SV*)gv) == -1) + if (!SvPOK((const SV *)gv) + && !(SvIOK((const SV *)gv) && SvIVX((const SV *)gv) == -1) && ckWARN_d(WARN_PROTOTYPE)) { Perl_warner(aTHX_ packWARN(WARN_PROTOTYPE), "Runaway prototype"); @@ -5572,9 +5573,9 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) cv_ckproto_len((const CV *)gv, NULL, ps, ps_len); } if (ps) - sv_setpvn((SV*)gv, ps, ps_len); + sv_setpvn(MUTABLE_SV(gv), ps, ps_len); else - sv_setiv((SV*)gv, -1); + sv_setiv(MUTABLE_SV(gv), -1); SvREFCNT_dec(PL_compcv); cv = PL_compcv = NULL; @@ -5661,7 +5662,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) SvREFCNT_inc_simple_void_NN(const_sv); if (cv) { assert(!CvROOT(cv) && !CvCONST(cv)); - sv_setpvs((SV*)cv, ""); /* prototype is "" */ + sv_setpvs(MUTABLE_SV(cv), ""); /* prototype is "" */ CvXSUBANY(cv).any_ptr = const_sv; CvXSUB(cv) = const_sv_xsub; CvCONST_on(cv); @@ -5697,7 +5698,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) || block->op_type == OP_NULL #endif )) { - rcv = (SV*)cv; + rcv = MUTABLE_SV(cv); /* Might have had built-in attributes applied -- propagate them. */ CvFLAGS(cv) |= (CvFLAGS(PL_compcv) & CVf_BUILTIN_ATTRS); if (CvGV(cv) && GvSTASH(CvGV(cv))) @@ -5709,7 +5710,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) } else { /* possibly about to re-define existing subr -- ignore old cv */ - rcv = (SV*)PL_compcv; + rcv = MUTABLE_SV(PL_compcv); if (name && GvSTASH(gv)) stash = GvSTASH(gv); else @@ -5755,7 +5756,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) GvCV(gv) = cv; if (PL_madskills) { if (strEQ(name, "import")) { - PL_formfeed = (SV*)cv; + PL_formfeed = MUTABLE_SV(cv); Perl_warner(aTHX_ packWARN(WARN_VOID), "%lx\n", (long)cv); } } @@ -5768,7 +5769,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) CvSTASH(cv) = PL_curstash; if (ps) - sv_setpvn((SV*)cv, ps, ps_len); + sv_setpvn(MUTABLE_SV(cv), ps, ps_len); if (PL_parser && PL_parser->error_count) { op_free(block); @@ -5851,7 +5852,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) PUSHMARK(SP); XPUSHs(tmpstr); PUTBACK; - call_sv((SV*)pcv, G_DISCARD); + call_sv(MUTABLE_SV(pcv), G_DISCARD); } } } @@ -5884,7 +5885,7 @@ S_process_special_blocks(pTHX_ const char *const fullname, GV *const gv, SAVECOPLINE(&PL_compiling); DEBUG_x( dump_sub(gv) ); - Perl_av_create_and_push(aTHX_ &PL_beginav, (SV*)cv); + Perl_av_create_and_push(aTHX_ &PL_beginav, MUTABLE_SV(cv)); GvCV(gv) = 0; /* cv has been hijacked */ call_list(oldscope, PL_beginav); @@ -5898,13 +5899,13 @@ S_process_special_blocks(pTHX_ const char *const fullname, GV *const gv, if (*name == 'E') { if strEQ(name, "END") { DEBUG_x( dump_sub(gv) ); - Perl_av_create_and_unshift_one(aTHX_ &PL_endav, (SV*)cv); + Perl_av_create_and_unshift_one(aTHX_ &PL_endav, MUTABLE_SV(cv)); } else return; } else if (*name == 'U') { if (strEQ(name, "UNITCHECK")) { /* It's never too late to run a unitcheck block */ - Perl_av_create_and_unshift_one(aTHX_ &PL_unitcheckav, (SV*)cv); + Perl_av_create_and_unshift_one(aTHX_ &PL_unitcheckav, MUTABLE_SV(cv)); } else return; @@ -5913,7 +5914,7 @@ S_process_special_blocks(pTHX_ const char *const fullname, GV *const gv, if (PL_main_start && ckWARN(WARN_VOID)) Perl_warner(aTHX_ packWARN(WARN_VOID), "Too late to run CHECK block"); - Perl_av_create_and_unshift_one(aTHX_ &PL_checkav, (SV*)cv); + Perl_av_create_and_unshift_one(aTHX_ &PL_checkav, MUTABLE_SV(cv)); } else return; @@ -5922,7 +5923,7 @@ S_process_special_blocks(pTHX_ const char *const fullname, GV *const gv, if (PL_main_start && ckWARN(WARN_VOID)) Perl_warner(aTHX_ packWARN(WARN_VOID), "Too late to run INIT block"); - Perl_av_create_and_push(aTHX_ &PL_initav, (SV*)cv); + Perl_av_create_and_push(aTHX_ &PL_initav, MUTABLE_SV(cv)); } else return; @@ -6028,7 +6029,7 @@ Perl_newXS_flags(pTHX_ const char *name, XSUBADDR_t subaddr, } /* This gets free()d. :-) */ - sv_usepvn_flags((SV*)cv, proto_and_file, proto_and_file_len, + sv_usepvn_flags(MUTABLE_SV(cv), proto_and_file, proto_and_file_len, SV_HAS_TRAILING_NUL); if (proto) { /* This gives us the correct prototype, rather than one with the @@ -6039,7 +6040,7 @@ Perl_newXS_flags(pTHX_ const char *name, XSUBADDR_t subaddr, } CvFILE(cv) = proto_and_file + proto_len; } else { - sv_setpv((SV *)cv, proto); + sv_setpv(MUTABLE_SV(cv), proto); } return cv; } @@ -6210,7 +6211,7 @@ Perl_newANONATTRSUB(pTHX_ I32 floor, OP *proto, OP *attrs, OP *block) { return newUNOP(OP_REFGEN, 0, newSVOP(OP_ANONCODE, 0, - (SV*)newATTRSUB(floor, 0, proto, attrs, block))); + MUTABLE_SV(newATTRSUB(floor, 0, proto, attrs, block)))); } OP * @@ -6558,7 +6559,7 @@ Perl_ck_eval(pTHX_ OP *o) if ((PL_hints & HINT_LOCALIZE_HH) != 0 && GvHV(PL_hintgv)) { /* Store a copy of %^H that pp_entereval can pick up. */ OP *hhop = newSVOP(OP_HINTSEVAL, 0, - (SV*)Perl_hv_copy_hints_hv(aTHX_ GvHV(PL_hintgv))); + MUTABLE_SV(Perl_hv_copy_hints_hv(aTHX_ GvHV(PL_hintgv)))); cUNOPo->op_first->op_sibling = hhop; o->op_private |= OPpEVAL_HAS_HH; } @@ -6734,7 +6735,7 @@ Perl_ck_rvconst(pTHX_ register OP *o) kPADOP->op_padix = pad_alloc(OP_GV, SVs_PADTMP); SvREFCNT_dec(PAD_SVl(kPADOP->op_padix)); GvIN_PAD_on(gv); - PAD_SETSV(kPADOP->op_padix, (SV*) SvREFCNT_inc_simple_NN(gv)); + PAD_SETSV(kPADOP->op_padix, MUTABLE_SV(SvREFCNT_inc_simple_NN(gv))); #else kid->op_sv = SvREFCNT_inc_simple_NN(gv); #endif @@ -7097,7 +7098,7 @@ Perl_ck_glob(pTHX_ OP *o) gv = gv_fetchpvs("CORE::GLOBAL::glob", 0, SVt_PVCV); glob_gv = gv_fetchpvs("File::Glob::csh_glob", 0, SVt_PVCV); GvCV(gv) = GvCV(glob_gv); - SvREFCNT_inc_void((SV*)GvCV(gv)); + SvREFCNT_inc_void(MUTABLE_SV(GvCV(gv))); GvIMPORTED_CV_on(gv); LEAVE; } @@ -7961,7 +7962,7 @@ Perl_ck_subr(pTHX_ OP *o) if (SvPOK(cv)) { STRLEN len; namegv = CvANON(cv) ? gv : CvGV(cv); - proto = SvPV((SV*)cv, len); + proto = SvPV(MUTABLE_SV(cv), len); proto_end = proto + len; } } @@ -8952,7 +8953,7 @@ const_sv_xsub(pTHX_ CV* cv) #endif } EXTEND(sp, 1); - ST(0) = (SV*)XSANY.any_ptr; + ST(0) = MUTABLE_SV(XSANY.any_ptr); XSRETURN(1); } diff --git a/pad.c b/pad.c index d1b9735..86fa7c4 100644 --- a/pad.c +++ b/pad.c @@ -197,7 +197,7 @@ Perl_pad_new(pTHX_ int flags) AV * const a0 = newAV(); /* will be @_ */ av_extend(a0, 0); - av_store(pad, 0, (SV*)a0); + av_store(pad, 0, MUTABLE_SV(a0)); AvREIFY_only(a0); } else { @@ -205,8 +205,8 @@ Perl_pad_new(pTHX_ int flags) } AvREAL_off(padlist); - av_store(padlist, 0, (SV*)padname); - av_store(padlist, 1, (SV*)pad); + av_store(padlist, 0, MUTABLE_SV(padname)); + av_store(padlist, 1, MUTABLE_SV(pad)); /* ... then update state variables */ @@ -319,16 +319,16 @@ Perl_pad_undef(pTHX_ CV* cv) while (ix >= 0) { SV* const sv = AvARRAY(padlist)[ix--]; if (sv) { - if (sv == (SV*)PL_comppad_name) + if (sv == (const SV *)PL_comppad_name) PL_comppad_name = NULL; - else if (sv == (SV*)PL_comppad) { + else if (sv == (const SV *)PL_comppad) { PL_comppad = NULL; PL_curpad = NULL; } } SvREFCNT_dec(sv); } - SvREFCNT_dec((SV*)CvPADLIST(cv)); + SvREFCNT_dec(MUTABLE_SV(CvPADLIST(cv))); CvPADLIST(cv) = NULL; } @@ -367,7 +367,7 @@ Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake if (typestash) { assert(SvTYPE(namesv) == SVt_PVMG); SvPAD_TYPED_on(namesv); - SvSTASH_set(namesv, MUTABLE_HV(SvREFCNT_inc_simple_NN((SV*)typestash))); + SvSTASH_set(namesv, MUTABLE_HV(SvREFCNT_inc_simple_NN(MUTABLE_SV(typestash)))); } if (ourstash) { SvPAD_OUR_on(namesv); @@ -396,9 +396,9 @@ Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake /* XXX DAPM since slot has been allocated, replace * av_store with PL_curpad[offset] ? */ if (*name == '@') - av_store(PL_comppad, offset, (SV*)newAV()); + av_store(PL_comppad, offset, MUTABLE_SV(newAV())); else if (*name == '%') - av_store(PL_comppad, offset, (SV*)newHV()); + av_store(PL_comppad, offset, MUTABLE_SV(newHV())); SvPADMY_on(PL_curpad[offset]); DEBUG_Xv(PerlIO_printf(Perl_debug_log, "Pad addname: %ld \"%s\" new lex=0x%"UVxf"\n", @@ -827,9 +827,9 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, } if (!*out_capture) { if (*name == '@') - *out_capture = sv_2mortal((SV*)newAV()); + *out_capture = sv_2mortal(MUTABLE_SV(newAV())); else if (*name == '%') - *out_capture = sv_2mortal((SV*)newHV()); + *out_capture = sv_2mortal(MUTABLE_SV(newHV())); else *out_capture = sv_newmortal(); } @@ -1250,7 +1250,7 @@ Perl_pad_tidy(pTHX_ padtidy_type type) /* XXX DAPM this same bit of code keeps appearing !!! Rationalise? */ AV * const av = newAV(); /* Will be @_ */ av_extend(av, 0); - av_store(PL_comppad, 0, (SV*)av); + av_store(PL_comppad, 0, MUTABLE_SV(av)); AvREIFY_only(av); } @@ -1506,7 +1506,7 @@ Perl_cv_clone(pTHX_ CV *proto) CvOUTSIDE_SEQ(cv) = CvOUTSIDE_SEQ(proto); if (SvPOK(proto)) - sv_setpvn((SV*)cv, SvPVX_const(proto), SvCUR(proto)); + sv_setpvn(MUTABLE_SV(cv), SvPVX_const(proto), SvCUR(proto)); CvPADLIST(cv) = pad_new(padnew_CLONE|padnew_SAVE); @@ -1542,9 +1542,9 @@ Perl_cv_clone(pTHX_ CV *proto) if (sigil == '&') sv = SvREFCNT_inc(ppad[ix]); else if (sigil == '@') - sv = (SV*)newAV(); + sv = MUTABLE_SV(newAV()); else if (sigil == '%') - sv = (SV*)newHV(); + sv = MUTABLE_SV(newHV()); else sv = newSV(0); SvPADMY_on(sv); @@ -1668,9 +1668,9 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth) else { /* our own lexical */ SV *sv; if (sigil == '@') - sv = (SV*)newAV(); + sv = MUTABLE_SV(newAV()); else if (sigil == '%') - sv = (SV*)newHV(); + sv = MUTABLE_SV(newHV()); else sv = newSV(0); av_store(newpad, ix, sv); @@ -1689,10 +1689,10 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth) } av = newAV(); av_extend(av, 0); - av_store(newpad, 0, (SV*)av); + av_store(newpad, 0, MUTABLE_SV(av)); AvREIFY_only(av); - av_store(padlist, depth, (SV*)newpad); + av_store(padlist, depth, MUTABLE_SV(newpad)); AvFILLp(padlist) = depth; } } diff --git a/perl.c b/perl.c index cca22c5..d0633c3 100644 --- a/perl.c +++ b/perl.c @@ -157,7 +157,7 @@ static I32 read_e_script(pTHX_ int idx, SV *buf_sv, int maxlen); #define CALL_LIST_BODY(cv) \ PUSHMARK(PL_stack_sp); \ - call_sv((SV*)(cv), G_EVAL|G_DISCARD); + call_sv(MUTABLE_SV((cv)), G_EVAL|G_DISCARD); static void S_init_tls_and_interp(PerlInterpreter *my_perl) @@ -901,7 +901,7 @@ perl_destruct(pTHXx) PL_regex_pad = NULL; #endif - SvREFCNT_dec((SV*) PL_stashcache); + SvREFCNT_dec(MUTABLE_SV(PL_stashcache)); PL_stashcache = NULL; /* loosen bonds of global variables */ @@ -1213,7 +1213,7 @@ perl_destruct(pTHXx) SV* sv; register SV* svend; - for (sva = PL_sv_arenaroot; sva; sva = (SV*)SvANY(sva)) { + for (sva = PL_sv_arenaroot; sva; sva = MUTABLE_SV(SvANY(sva))) { svend = &sva[SvREFCNT(sva)]; for (sv = sva + 1; sv < svend; ++sv) { if (SvTYPE(sv) != SVTYPEMASK) { @@ -2572,7 +2572,7 @@ Perl_call_pv(pTHX_ const char *sub_name, I32 flags) { PERL_ARGS_ASSERT_CALL_PV; - return call_sv((SV*)get_cv(sub_name, TRUE), flags); + return call_sv(MUTABLE_SV(get_cv(sub_name, TRUE)), flags); } /* @@ -2896,7 +2896,7 @@ Perl_magicname(pTHX_ const char *sym, const char *name, I32 namlen) PERL_ARGS_ASSERT_MAGICNAME; if (gv) - sv_magic(GvSV(gv), (SV*)gv, PERL_MAGIC_sv, name, namlen); + sv_magic(GvSV(gv), MUTABLE_SV(gv), PERL_MAGIC_sv, name, namlen); } STATIC void @@ -5118,15 +5118,15 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList) if (PL_savebegin) { if (paramList == PL_beginav) { /* save PL_beginav for compiler */ - Perl_av_create_and_push(aTHX_ &PL_beginav_save, (SV*)cv); + Perl_av_create_and_push(aTHX_ &PL_beginav_save, MUTABLE_SV(cv)); } else if (paramList == PL_checkav) { /* save PL_checkav for compiler */ - Perl_av_create_and_push(aTHX_ &PL_checkav_save, (SV*)cv); + Perl_av_create_and_push(aTHX_ &PL_checkav_save, MUTABLE_SV(cv)); } else if (paramList == PL_unitcheckav) { /* save PL_unitcheckav for compiler */ - Perl_av_create_and_push(aTHX_ &PL_unitcheckav_save, (SV*)cv); + Perl_av_create_and_push(aTHX_ &PL_unitcheckav_save, MUTABLE_SV(cv)); } } else { if (!PL_madskills) diff --git a/perlio.c b/perlio.c index faf8147..e2d64d4 100644 --- a/perlio.c +++ b/perlio.c @@ -810,7 +810,7 @@ PerlIO_find_layer(pTHX_ const char *name, STRLEN len, int load) SAVEINT(PL_in_load_module); if (cv) { SAVEGENERICSV(PL_warnhook); - PL_warnhook = (SV *) (SvREFCNT_inc_simple_NN(cv)); + PL_warnhook = MUTABLE_SV((SvREFCNT_inc_simple_NN(cv))); } PL_in_load_module++; /* @@ -884,7 +884,7 @@ XS(XS_io_MODIFY_SCALAR_ATTRIBUTES) MAGIC *mg; int count = 0; int i; - sv_magic(sv, (SV *) av, PERL_MAGIC_ext, NULL, 0); + sv_magic(sv, MUTABLE_SV(av), PERL_MAGIC_ext, NULL, 0); SvRMAGICAL_off(sv); mg = mg_find(sv, PERL_MAGIC_ext); mg->mg_virtual = &perlio_vtab; diff --git a/pp.c b/pp.c index 8234a77..5c83f32 100644 --- a/pp.c +++ b/pp.c @@ -141,7 +141,7 @@ PP(pp_rv2gv) gv_init(gv, 0, "", 0, 0); GvIOp(gv) = MUTABLE_IO(sv); SvREFCNT_inc_void_NN(sv); - sv = (SV*) gv; + sv = MUTABLE_SV(gv); } else if (!isGV_with_GP(sv)) DIE(aTHX_ "Not a GLOB reference"); @@ -173,7 +173,7 @@ PP(pp_rv2gv) gv = newGVgen(name); } prepare_SV_for_RV(sv); - SvRV_set(sv, (SV*)gv); + SvRV_set(sv, MUTABLE_SV(gv)); SvROK_on(sv); SvSETMAGIC(sv); goto wasref; @@ -188,10 +188,11 @@ PP(pp_rv2gv) if ((PL_op->op_flags & OPf_SPECIAL) && !(PL_op->op_flags & OPf_MOD)) { - SV * const temp = (SV*)gv_fetchsv(sv, 0, SVt_PVGV); + SV * const temp = MUTABLE_SV(gv_fetchsv(sv, 0, SVt_PVGV)); if (!temp && (!is_gv_magical_sv(sv,0) - || !(sv = (SV*)gv_fetchsv(sv, GV_ADD, SVt_PVGV)))) { + || !(sv = MUTABLE_SV(gv_fetchsv(sv, GV_ADD, + SVt_PVGV))))) { RETSETUNDEF; } sv = temp; @@ -206,7 +207,7 @@ PP(pp_rv2gv) things. */ RETURN; } - sv = (SV*)gv_fetchsv(sv, GV_ADD, SVt_PVGV); + sv = MUTABLE_SV(gv_fetchsv(sv, GV_ADD, SVt_PVGV)); } } } @@ -320,7 +321,7 @@ PP(pp_av2arylen) 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); + sv_magic(*sv, MUTABLE_SV(av), PERL_MAGIC_arylen, NULL, 0); } SETs(*sv); RETURN; @@ -376,7 +377,7 @@ PP(pp_rv2cv) CV *cv = sv_2cv(TOPs, &stash_unused, &gv, flags); if (cv) { if (CvCLONE(cv)) - cv = MUTABLE_CV(sv_2mortal((SV*)cv_clone(cv))); + cv = MUTABLE_CV(sv_2mortal(MUTABLE_SV(cv_clone(cv)))); if ((PL_op->op_private & OPpLVAL_INTRO)) { if (gv && GvCV(gv) == cv && (gv = gv_autoload4(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), FALSE))) cv = GvCV(gv); @@ -389,7 +390,7 @@ PP(pp_rv2cv) } else cv = MUTABLE_CV(&PL_sv_undef); - SETs((SV*)cv); + SETs(MUTABLE_SV(cv)); RETURN; } @@ -474,9 +475,9 @@ PP(pp_anoncode) dVAR; dSP; CV *cv = MUTABLE_CV(PAD_SV(PL_op->op_targ)); if (CvCLONE(cv)) - cv = MUTABLE_CV(sv_2mortal((SV*)cv_clone(cv))); + cv = MUTABLE_CV(sv_2mortal(MUTABLE_SV(cv_clone(cv)))); EXTEND(SP,1); - PUSHs((SV*)cv); + PUSHs(MUTABLE_SV(cv)); RETURN; } @@ -598,33 +599,33 @@ PP(pp_gelem) switch (*elem) { case 'A': if (strEQ(second_letter, "RRAY")) - tmpRef = (SV*)GvAV(gv); + tmpRef = MUTABLE_SV(GvAV(gv)); break; case 'C': if (strEQ(second_letter, "ODE")) - tmpRef = (SV*)GvCVu(gv); + tmpRef = MUTABLE_SV(GvCVu(gv)); break; case 'F': if (strEQ(second_letter, "ILEHANDLE")) { /* finally deprecated in 5.8.0 */ deprecate("*glob{FILEHANDLE}"); - tmpRef = (SV*)GvIOp(gv); + tmpRef = MUTABLE_SV(GvIOp(gv)); } else if (strEQ(second_letter, "ORMAT")) - tmpRef = (SV*)GvFORM(gv); + tmpRef = MUTABLE_SV(GvFORM(gv)); break; case 'G': if (strEQ(second_letter, "LOB")) - tmpRef = (SV*)gv; + tmpRef = MUTABLE_SV(gv); break; case 'H': if (strEQ(second_letter, "ASH")) - tmpRef = (SV*)GvHV(gv); + tmpRef = MUTABLE_SV(GvHV(gv)); break; case 'I': if (*second_letter == 'O' && !elem[2]) - tmpRef = (SV*)GvIOp(gv); + tmpRef = MUTABLE_SV(GvIOp(gv)); break; case 'N': if (strEQ(second_letter, "AME")) @@ -1549,7 +1550,7 @@ PP(pp_repeat) } MARK++; repeatcpy((char*)(MARK + items), (char*)MARK, - items * sizeof(SV*), count - 1); + items * sizeof(const SV *), count - 1); SP += max; } else if (count <= 0) @@ -4147,12 +4148,12 @@ PP(pp_hslice) MAGIC *mg; HV *stash; - other_magic = mg_find((SV*)hv, PERL_MAGIC_env) || - ((mg = mg_find((SV*)hv, PERL_MAGIC_tied)) + other_magic = mg_find((const SV *)hv, PERL_MAGIC_env) || + ((mg = mg_find((const SV *)hv, PERL_MAGIC_tied)) /* Try to preserve the existenceness of a tied hash * element by using EXISTS and DELETE if possible. * Fallback to FETCH and STORE otherwise */ - && (stash = SvSTASH(SvRV(SvTIED_obj((SV*)hv, mg)))) + && (stash = SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(hv), mg)))) && gv_fetchmethod_autoload(stash, "EXISTS", TRUE) && gv_fetchmethod_autoload(stash, "DELETE", TRUE)); } @@ -4273,7 +4274,7 @@ PP(pp_anonlist) { dVAR; dSP; dMARK; dORIGMARK; const I32 items = SP - MARK; - SV * const av = (SV *) av_make(items, MARK+1); + SV * const av = MUTABLE_SV(av_make(items, MARK+1)); SP = ORIGMARK; /* av_make() might realloc stack_sp */ mXPUSHs((PL_op->op_flags & OPf_SPECIAL) ? newRV_noinc(av) : av); @@ -4296,7 +4297,7 @@ PP(pp_anonhash) } SP = ORIGMARK; mXPUSHs((PL_op->op_flags & OPf_SPECIAL) - ? newRV_noinc((SV*) hv) : (SV*) hv); + ? newRV_noinc(MUTABLE_SV(hv)) : MUTABLE_SV(hv)); RETURN; } @@ -4312,10 +4313,10 @@ PP(pp_splice) I32 newlen; I32 after; I32 diff; - const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied); + const MAGIC * const mg = SvTIED_mg((const SV *)ary, PERL_MAGIC_tied); if (mg) { - *MARK-- = SvTIED_obj((SV*)ary, mg); + *MARK-- = SvTIED_obj(MUTABLE_SV(ary), mg); PUSHMARK(MARK); PUTBACK; ENTER; @@ -4509,10 +4510,10 @@ PP(pp_push) { dVAR; dSP; dMARK; dORIGMARK; dTARGET; register AV * const ary = MUTABLE_AV(*++MARK); - const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied); + const MAGIC * const mg = SvTIED_mg((const SV *)ary, PERL_MAGIC_tied); if (mg) { - *MARK-- = SvTIED_obj((SV*)ary, mg); + *MARK-- = SvTIED_obj(MUTABLE_SV(ary), mg); PUSHMARK(MARK); PUTBACK; ENTER; @@ -4531,7 +4532,7 @@ PP(pp_push) av_store(ary, AvFILLp(ary)+1, sv); } if (PL_delaymagic & DM_ARRAY) - mg_set((SV*)ary); + mg_set(MUTABLE_SV(ary)); PL_delaymagic = 0; SP = ORIGMARK; @@ -4558,10 +4559,10 @@ PP(pp_unshift) { dVAR; dSP; dMARK; dORIGMARK; dTARGET; register AV *ary = MUTABLE_AV(*++MARK); - const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied); + const MAGIC * const mg = SvTIED_mg((const SV *)ary, PERL_MAGIC_tied); if (mg) { - *MARK-- = SvTIED_obj((SV*)ary, mg); + *MARK-- = SvTIED_obj(MUTABLE_SV(ary), mg); PUSHMARK(MARK); PUTBACK; ENTER; @@ -4720,9 +4721,9 @@ PP(pp_split) av_extend(ary,0); av_clear(ary); SPAGAIN; - if ((mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied))) { + if ((mg = SvTIED_mg((const SV *)ary, PERL_MAGIC_tied))) { PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)ary, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(ary), mg)); } else { if (!AvREAL(ary)) { @@ -4977,7 +4978,7 @@ PP(pp_split) if (!mg) { if (SvSMAGICAL(ary)) { PUTBACK; - mg_set((SV*)ary); + mg_set(MUTABLE_SV(ary)); SPAGAIN; } if (gimme == G_ARRAY) { diff --git a/pp_ctl.c b/pp_ctl.c index f00b3be..052eea4 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1791,8 +1791,8 @@ PP(pp_caller) PUSHs(cx->blk_oldcop->cop_hints_hash ? sv_2mortal(newRV_noinc( - (SV*)Perl_refcounted_he_chain_2hv(aTHX_ - cx->blk_oldcop->cop_hints_hash))) + MUTABLE_SV(Perl_refcounted_he_chain_2hv(aTHX_ + cx->blk_oldcop->cop_hints_hash)))) : &PL_sv_undef); RETURN; } @@ -2474,7 +2474,7 @@ PP(pp_goto) av = newAV(); av_extend(av, items-1); AvREIFY_only(av); - PAD_SVl(0) = (SV*)(cx->blk_sub.argarray = av); + PAD_SVl(0) = MUTABLE_SV(cx->blk_sub.argarray = av); } } else if (CvISXSUB(cv)) { /* put GvAV(defgv) back onto stack */ @@ -2576,7 +2576,7 @@ PP(pp_goto) CV * const gotocv = get_cv("DB::goto", FALSE); if (gotocv) { PUSHMARK( PL_stack_sp ); - call_sv((SV*)gotocv, G_SCALAR | G_NODEBUG); + call_sv(MUTABLE_SV(gotocv), G_SCALAR | G_NODEBUG); PL_stack_sp--; } } @@ -3100,9 +3100,9 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq) if (cv) { dSP; PUSHMARK(SP); - XPUSHs((SV*)CopFILEGV(&PL_compiling)); + XPUSHs(MUTABLE_SV(CopFILEGV(&PL_compiling))); PUTBACK; - call_sv((SV*)cv, G_DISCARD); + call_sv(MUTABLE_SV(cv), G_DISCARD); } } @@ -3324,7 +3324,7 @@ PP(pp_require) for (i = 0; i <= AvFILL(ar); i++) { SV * const dirsv = *av_fetch(ar, i, TRUE); - if (SvTIED_mg((SV*)ar, PERL_MAGIC_tied)) + if (SvTIED_mg((const SV *)ar, PERL_MAGIC_tied)) mg_get(dirsv); if (SvROK(dirsv)) { int count; @@ -3639,7 +3639,7 @@ PP(pp_hintseval) { dVAR; dSP; - mXPUSHs((SV*)Perl_hv_copy_hints_hv(aTHX_ MUTABLE_HV(cSVOP_sv))); + mXPUSHs(MUTABLE_SV(Perl_hv_copy_hints_hv(aTHX_ MUTABLE_HV(cSVOP_sv)))); RETURN; } @@ -4118,13 +4118,13 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) if (SvTIED_mg(This, PERL_MAGIC_tied)) { tied = TRUE; } - else if (SvTIED_mg((SV *) other_hv, PERL_MAGIC_tied)) { + else if (SvTIED_mg((const SV *)other_hv, PERL_MAGIC_tied)) { HV * const temp = other_hv; other_hv = MUTABLE_HV(This); - This = (SV *) temp; + This = MUTABLE_SV(temp); tied = TRUE; } - if (SvTIED_mg((SV *) other_hv, PERL_MAGIC_tied)) + if (SvTIED_mg((const SV *)other_hv, PERL_MAGIC_tied)) other_tied = TRUE; if (!tied && HvUSEDKEYS((const HV *) This) != HvUSEDKEYS(other_hv)) @@ -4209,11 +4209,11 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) if (NULL == seen_this) { seen_this = newHV(); - (void) sv_2mortal((SV *) seen_this); + (void) sv_2mortal(MUTABLE_SV(seen_this)); } if (NULL == seen_other) { seen_this = newHV(); - (void) sv_2mortal((SV *) seen_other); + (void) sv_2mortal(MUTABLE_SV(seen_other)); } for(i = 0; i <= other_len; ++i) { SV * const * const this_elem = av_fetch(MUTABLE_AV(This), i, FALSE); @@ -4738,8 +4738,8 @@ S_run_user_filter(pTHX_ int idx, SV *buf_sv, int maxlen) dVAR; SV * const datasv = FILTER_DATA(idx); const int filter_has_file = IoLINES(datasv); - SV * const filter_state = (SV *)IoTOP_GV(datasv); - SV * const filter_sub = (SV *)IoBOTTOM_GV(datasv); + SV * const filter_state = MUTABLE_SV(IoTOP_GV(datasv)); + SV * const filter_sub = MUTABLE_SV(IoBOTTOM_GV(datasv)); int status = 0; SV *upstream; STRLEN got_len; @@ -4759,7 +4759,7 @@ S_run_user_filter(pTHX_ int idx, SV *buf_sv, int maxlen) not sure where the trouble is yet. XXX */ if (IoFMT_GV(datasv)) { - SV *const cache = (SV *)IoFMT_GV(datasv); + SV *const cache = MUTABLE_SV(IoFMT_GV(datasv)); if (SvOK(cache)) { STRLEN cache_len; const char *cache_p = SvPV(cache, cache_len); @@ -4858,7 +4858,7 @@ S_run_user_filter(pTHX_ int idx, SV *buf_sv, int maxlen) if (prune_from) { /* Oh. Too long. Stuff some in our cache. */ STRLEN cached_len = got_p + got_len - prune_from; - SV *cache = (SV *)IoFMT_GV(datasv); + SV *cache = MUTABLE_SV(IoFMT_GV(datasv)); if (!cache) { IoFMT_GV(datasv) = (GV*) (cache = newSV(got_len - umaxlen)); diff --git a/pp_hot.c b/pp_hot.c index 279389a..c86762e 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -89,7 +89,7 @@ PP(pp_stringify) PP(pp_gv) { dVAR; dSP; - XPUSHs((SV*)cGVOP_gv); + XPUSHs(MUTABLE_SV(cGVOP_gv)); RETURN; } @@ -136,7 +136,7 @@ PP(pp_sassign) The gv becomes a(nother) reference to the constant. */ SV *const value = SvRV(cv); - SvUPGRADE((SV *)gv, SVt_IV); + SvUPGRADE(MUTABLE_SV(gv), SVt_IV); SvPCS_IMPORTED_on(gv); SvRV_set(gv, value); SvREFCNT_inc_simple_void(value); @@ -148,7 +148,7 @@ PP(pp_sassign) /* Need to fix things up. */ if (gv_type != SVt_PVGV) { /* Need to fix GV. */ - right = (SV*)gv_fetchsv(right, GV_ADD, SVt_PVGV); + right = MUTABLE_SV(gv_fetchsv(right, GV_ADD, SVt_PVGV)); } if (!got_coderef) { @@ -162,8 +162,8 @@ PP(pp_sassign) all sorts of fun as the reference to our new sub is donated to the GV that we're about to assign to. */ - SvRV_set(left, (SV *)newCONSTSUB(GvSTASH(right), NULL, - SvRV(cv))); + SvRV_set(left, MUTABLE_SV(newCONSTSUB(GvSTASH(right), NULL, + SvRV(cv)))); SvREFCNT_dec(cv); LEAVE; } else { @@ -188,7 +188,7 @@ PP(pp_sassign) SvREFCNT_inc_void(source); SvREFCNT_dec(upgraded); - SvRV_set(left, (SV *)source); + SvRV_set(left, MUTABLE_SV(source)); } } @@ -312,7 +312,7 @@ PP(pp_readline) PL_last_in_gv = (GV*)SvRV(PL_last_in_gv); else { dSP; - XPUSHs((SV*)PL_last_in_gv); + XPUSHs(MUTABLE_SV(PL_last_in_gv)); PUTBACK; pp_rv2gv(); PL_last_in_gv = (GV*)(*PL_stack_sp--); @@ -685,7 +685,7 @@ PP(pp_pushre) Copy(&PL_op, &LvTARGOFF(sv), 1, OP*); XPUSHs(sv); #else - XPUSHs((SV*)PL_op); + XPUSHs(MUTABLE_SV(PL_op)); #endif RETURN; } @@ -701,7 +701,7 @@ PP(pp_print) GV * const gv = (PL_op->op_flags & OPf_STACKED) ? (GV*)*++MARK : PL_defoutgv; if (gv && (io = GvIO(gv)) - && (mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar))) + && (mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar))) { had_magic: if (MARK == ORIGMARK) { @@ -714,7 +714,7 @@ PP(pp_print) ++SP; } PUSHMARK(MARK - 1); - *MARK = SvTIED_obj((SV*)io, mg); + *MARK = SvTIED_obj(MUTABLE_SV(io), mg); PUTBACK; ENTER; if( PL_op->op_type == OP_SAY ) { @@ -732,7 +732,7 @@ PP(pp_print) } if (!(io = GvIO(gv))) { if ((GvEGV(gv)) && (io = GvIO(GvEGV(gv))) - && (mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar))) + && (mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar))) goto had_magic; if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) report_evil_fh(gv, io, PL_op->op_type); @@ -857,9 +857,9 @@ PP(pp_rv2av) else { gv = (GV*)sv; } - sv = is_pp_rv2av ? (SV*)GvAVn(gv) : (SV*)GvHVn(gv); + sv = is_pp_rv2av ? MUTABLE_SV(GvAVn(gv)) : MUTABLE_SV(GvHVn(gv)); if (PL_op->op_private & OPpLVAL_INTRO) - sv = is_pp_rv2av ? (SV*)save_ary(gv) : (SV*)save_hash(gv); + sv = is_pp_rv2av ? MUTABLE_SV(save_ary(gv)) : MUTABLE_SV(save_hash(gv)); if (PL_op->op_flags & OPf_REF) { SETs(sv); RETURN; @@ -1034,7 +1034,7 @@ PP(pp_aassign) TAINT_NOT; } if (PL_delaymagic & DM_ARRAY) - SvSETMAGIC((SV*)ary); + SvSETMAGIC(MUTABLE_SV(ary)); break; case SVt_PVHV: { /* normal hash */ SV *tmpstr; @@ -1207,7 +1207,7 @@ PP(pp_qr) /* This RV is about to own a reference to the regexp. (In addition to the reference already owned by the PMOP. */ ReREFCNT_inc(rx); - SvRV_set(rv, (SV*) rx); + SvRV_set(rv, MUTABLE_SV(rx)); SvROK_on(rv); if (pkg) { @@ -1544,10 +1544,10 @@ Perl_do_readline(pTHX) const I32 gimme = GIMME_V; if (io) { - MAGIC * const mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)io, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(io), mg)); PUTBACK; ENTER; call_method("READLINE", gimme); @@ -1785,12 +1785,12 @@ PP(pp_helem) /* does the element we're localizing already exist? */ preeminent = /* can we determine whether it exists? */ ( !SvRMAGICAL(hv) - || mg_find((SV*)hv, PERL_MAGIC_env) - || ( (mg = mg_find((SV*)hv, PERL_MAGIC_tied)) + || mg_find((const SV *)hv, PERL_MAGIC_env) + || ( (mg = mg_find((const SV *)hv, PERL_MAGIC_tied)) /* Try to preserve the existenceness of a tied hash * element by using EXISTS and DELETE if possible. * Fallback to FETCH and STORE otherwise */ - && (stash = SvSTASH(SvRV(SvTIED_obj((SV*)hv, mg)))) + && (stash = SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(hv), mg)))) && gv_fetchmethod_autoload(stash, "EXISTS", TRUE) && gv_fetchmethod_autoload(stash, "DELETE", TRUE) ) @@ -2973,10 +2973,10 @@ Perl_vivify_ref(pTHX_ SV *sv, U32 to_what) SvRV_set(sv, newSV(0)); break; case OPpDEREF_AV: - SvRV_set(sv, (SV*)newAV()); + SvRV_set(sv, MUTABLE_SV(newAV())); break; case OPpDEREF_HV: - SvRV_set(sv, (SV*)newHV()); + SvRV_set(sv, MUTABLE_SV(newHV())); break; } SvROK_on(sv); @@ -3032,7 +3032,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) SvGETMAGIC(sv); if (SvROK(sv)) - ob = (SV*)SvRV(sv); + ob = MUTABLE_SV(SvRV(sv)); else { GV* iogv; @@ -3048,7 +3048,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) if (!SvOK(sv) || !(packname) || !(iogv = gv_fetchsv(sv, 0, SVt_PVIO)) || - !(ob=(SV*)GvIO(iogv))) + !(ob=MUTABLE_SV(GvIO(iogv)))) { /* this isn't the name of a filehandle either */ if (!packname || @@ -3072,14 +3072,14 @@ S_method_common(pTHX_ SV* meth, U32* hashp) goto fetch; } /* it _is_ a filehandle name -- replace with a reference */ - *(PL_stack_base + TOPMARK + 1) = sv_2mortal(newRV((SV*)iogv)); + *(PL_stack_base + TOPMARK + 1) = sv_2mortal(newRV(MUTABLE_SV(iogv))); } /* if we got here, ob should be a reference or a glob */ if (!ob || !(SvOBJECT(ob) || (SvTYPE(ob) == SVt_PVGV && isGV_with_GP(ob) - && (ob = (SV*)GvIO((GV*)ob)) + && (ob = MUTABLE_SV(GvIO((GV*)ob))) && SvOBJECT(ob)))) { Perl_croak(aTHX_ "Can't call method \"%s\" on unblessed reference", @@ -3101,7 +3101,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) if (isGV(gv) && GvCV(gv) && (!GvCVGEN(gv) || GvCVGEN(gv) == (PL_sub_generation + HvMROMETA(stash)->cache_gen))) - return (SV*)GvCV(gv); + return MUTABLE_SV(GvCV(gv)); } } @@ -3110,7 +3110,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) assert(gv); - return isGV(gv) ? (SV*)GvCV(gv) : (SV*)gv; + return isGV(gv) ? MUTABLE_SV(GvCV(gv)) : MUTABLE_SV(gv); } /* diff --git a/pp_sort.c b/pp_sort.c index a239c01..d520f81 100644 --- a/pp_sort.c +++ b/pp_sort.c @@ -1516,7 +1516,7 @@ PP(pp_sort) else { cv = sv_2cv(*++MARK, &stash, &gv, 0); if (cv && SvPOK(cv)) { - const char * const proto = SvPV_nolen_const((SV*)cv); + const char * const proto = SvPV_nolen_const(MUTABLE_SV(cv)); if (proto && strEQ(proto, "$$")) { hasargs = TRUE; } diff --git a/pp_sys.c b/pp_sys.c index 6bc84d9..8e1c8cd 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -483,7 +483,7 @@ PP(pp_die) PUSHs(file); PUSHs(line); PUTBACK; - call_sv((SV*)GvCV(gv), + call_sv(MUTABLE_SV(GvCV(gv)), G_SCALAR|G_EVAL|G_KEEPERR); sv_setsv(error,*PL_stack_sp--); } @@ -532,11 +532,11 @@ PP(pp_open) Perl_warner(aTHX_ packWARN2(WARN_IO, WARN_DEPRECATED), "Opening dirhandle %s also as a file", GvENAME(gv)); - mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { /* Method's args are same as ours ... */ /* ... except handle is replaced by the object */ - *MARK-- = SvTIED_obj((SV*)io, mg); + *MARK-- = SvTIED_obj(MUTABLE_SV(io), mg); PUSHMARK(MARK); PUTBACK; ENTER; @@ -574,10 +574,10 @@ PP(pp_close) if (gv) { IO * const io = GvIO(gv); if (io) { - MAGIC * const mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)io, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(io), mg)); PUTBACK; ENTER; call_method("CLOSE", G_SCALAR); @@ -664,10 +664,10 @@ PP(pp_fileno) gv = (GV*)POPs; if (gv && (io = GvIO(gv)) - && (mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar))) + && (mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar))) { PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)io, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(io), mg)); PUTBACK; ENTER; call_method("FILENO", G_SCALAR); @@ -737,10 +737,10 @@ PP(pp_binmode) gv = (GV*)POPs; if (gv && (io = GvIO(gv))) { - MAGIC * const mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)io, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(io), mg)); if (discp) XPUSHs(discp); PUTBACK; @@ -818,7 +818,7 @@ PP(pp_tie) slot of the GP rather than the GV itself. AMS 20010812 */ if (!GvIOp(varsv)) GvIOp(varsv) = newIO(); - varsv = (SV *)GvIOp(varsv); + varsv = MUTABLE_SV(GvIOp(varsv)); break; } /* FALL THROUGH */ @@ -856,7 +856,7 @@ PP(pp_tie) while (items--) PUSHs(*MARK++); PUTBACK; - call_sv((SV*)GvCV(gv), G_SCALAR); + call_sv(MUTABLE_SV(GvCV(gv)), G_SCALAR); } SPAGAIN; @@ -886,7 +886,7 @@ PP(pp_untie) const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV) ? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar; - if (isGV_with_GP(sv) && !(sv = (SV *)GvIOp(sv))) + if (isGV_with_GP(sv) && !(sv = MUTABLE_SV(GvIOp(sv)))) RETPUSHYES; if ((mg = SvTIED_mg(sv, how))) { @@ -896,11 +896,11 @@ PP(pp_untie) CV *cv; if (gv && isGV(gv) && (cv = GvCV(gv))) { PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)gv, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(gv), mg)); mXPUSHi(SvREFCNT(obj) - 1); PUTBACK; ENTER; - call_sv((SV *)cv, G_VOID); + call_sv(MUTABLE_SV(cv), G_VOID); LEAVE; SPAGAIN; } @@ -924,7 +924,7 @@ PP(pp_tied) const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV) ? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar; - if (isGV_with_GP(sv) && !(sv = (SV *)GvIOp(sv))) + if (isGV_with_GP(sv) && !(sv = MUTABLE_SV(GvIOp(sv)))) RETPUSHUNDEF; if ((mg = SvTIED_mg(sv, how))) { @@ -967,7 +967,7 @@ PP(pp_dbmopen) mPUSHu(O_RDWR); PUSHs(right); PUTBACK; - call_sv((SV*)GvCV(gv), G_SCALAR); + call_sv(MUTABLE_SV(GvCV(gv)), G_SCALAR); SPAGAIN; if (!sv_isobject(TOPs)) { @@ -978,13 +978,13 @@ PP(pp_dbmopen) mPUSHu(O_RDONLY); PUSHs(right); PUTBACK; - call_sv((SV*)GvCV(gv), G_SCALAR); + call_sv(MUTABLE_SV(GvCV(gv)), G_SCALAR); SPAGAIN; } if (sv_isobject(TOPs)) { - sv_unmagic((SV *) hv, PERL_MAGIC_tied); - sv_magic((SV*)hv, TOPs, PERL_MAGIC_tied, NULL, 0); + sv_unmagic(MUTABLE_SV(hv), PERL_MAGIC_tied); + sv_magic(MUTABLE_SV(hv), TOPs, PERL_MAGIC_tied, NULL, 0); } LEAVE; RETURN; @@ -1183,7 +1183,7 @@ PP(pp_select) XPUSHTARG; } else { - mXPUSHs(newRV((SV*)egv)); + mXPUSHs(newRV(MUTABLE_SV(egv))); } } @@ -1203,11 +1203,11 @@ PP(pp_getc) GV * const gv = (MAXARG==0) ? PL_stdingv : (GV*)POPs; if (gv && (io = GvIO(gv))) { - MAGIC * const mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { const I32 gimme = GIMME_V; PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)io, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(io), mg)); PUTBACK; ENTER; call_method("GETC", gimme); @@ -1306,7 +1306,7 @@ PP(pp_enterwrite) DIE(aTHX_ "Not a format reference"); } if (CvCLONE(cv)) - cv = MUTABLE_CV(sv_2mortal((SV*)cv_clone(cv))); + cv = MUTABLE_CV(sv_2mortal(MUTABLE_SV(cv_clone(cv)))); IoFLAGS(io) &= ~IOf_DIDTOP; return doform(cv,gv,PL_op->op_next); @@ -1397,7 +1397,7 @@ PP(pp_leavewrite) DIE(aTHX_ "Undefined top format called"); } if (cv && CvCLONE(cv)) - cv = MUTABLE_CV(sv_2mortal((SV*)cv_clone(cv))); + cv = MUTABLE_CV(sv_2mortal(MUTABLE_SV(cv_clone(cv)))); return doform(cv, gv, PL_op); } @@ -1450,7 +1450,7 @@ PP(pp_prtf) GV * const gv = (PL_op->op_flags & OPf_STACKED) ? (GV*)*++MARK : PL_defoutgv; if (gv && (io = GvIO(gv))) { - MAGIC * const mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { if (MARK == ORIGMARK) { MEXTEND(SP, 1); @@ -1459,7 +1459,7 @@ PP(pp_prtf) ++SP; } PUSHMARK(MARK - 1); - *MARK = SvTIED_obj((SV*)io, mg); + *MARK = SvTIED_obj(MUTABLE_SV(io), mg); PUTBACK; ENTER; call_method("PRINTF", G_SCALAR); @@ -1559,11 +1559,11 @@ PP(pp_sysread) if ((PL_op->op_type == OP_READ || PL_op->op_type == OP_SYSREAD) && gv && (io = GvIO(gv)) ) { - const MAGIC * mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + const MAGIC * mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { SV *sv; PUSHMARK(MARK-1); - *MARK = SvTIED_obj((SV*)io, mg); + *MARK = SvTIED_obj(MUTABLE_SV(io), mg); ENTER; call_method("READ", G_SCALAR); LEAVE; @@ -1804,7 +1804,7 @@ PP(pp_send) GV *const gv = (GV*)*++MARK; if (PL_op->op_type == OP_SYSWRITE && gv && (io = GvIO(gv))) { - MAGIC * const mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { SV *sv; @@ -1816,7 +1816,7 @@ PP(pp_send) } PUSHMARK(ORIGMARK); - *(ORIGMARK+1) = SvTIED_obj((SV*)io, mg); + *(ORIGMARK+1) = SvTIED_obj(MUTABLE_SV(io), mg); ENTER; call_method("WRITE", G_SCALAR); LEAVE; @@ -2043,9 +2043,9 @@ PP(pp_eof) if (gv) { IO * const io = GvIO(gv); MAGIC * mg; - if (io && (mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar))) { + if (io && (mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar))) { PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)io, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(io), mg)); PUTBACK; ENTER; call_method("EOF", G_SCALAR); @@ -2070,10 +2070,10 @@ PP(pp_tell) gv = PL_last_in_gv; if (gv && (io = GvIO(gv))) { - MAGIC * const mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)io, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(io), mg)); PUTBACK; ENTER; call_method("TELL", G_SCALAR); @@ -2105,10 +2105,10 @@ PP(pp_sysseek) IO *io; if (gv && (io = GvIO(gv))) { - MAGIC * const mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)io, mg)); + XPUSHs(SvTIED_obj(MUTABLE_SV(io), mg)); #if LSEEKSIZE > IVSIZE mXPUSHn((NV) offset); #else diff --git a/regcomp.c b/regcomp.c index 8e197f7..054b4a0 100644 --- a/regcomp.c +++ b/regcomp.c @@ -4329,7 +4329,7 @@ redo_first_pass: + (sizeof(STD_PAT_MODS) - 1) + (sizeof("(?:)") - 1); - p = sv_grow((SV *)rx, wraplen + 1); + p = sv_grow(MUTABLE_SV(rx), wraplen + 1); SvCUR_set(rx, wraplen); SvPOK_on(rx); SvFLAGS(rx) |= SvUTF8(pattern); @@ -4990,7 +4990,7 @@ Perl_reg_named_buff_fetch(pTHX_ REGEXP * const r, SV * const namesv, av_push(retarray, ret); } if (retarray) - return newRV_noinc((SV*)retarray); + return newRV_noinc(MUTABLE_SV(retarray)); } } return NULL; @@ -5129,7 +5129,7 @@ Perl_reg_named_buff_all(pTHX_ REGEXP * const r, const U32 flags) } } - return newRV_noinc((SV*)av); + return newRV_noinc(MUTABLE_SV(av)); } void @@ -5269,7 +5269,7 @@ Perl_reg_numbered_buff_length(pTHX_ REGEXP * const r, const SV * const sv, goto getlen; } else { if (ckWARN(WARN_UNINITIALIZED)) - report_uninit((SV*)sv); + report_uninit((const SV *)sv); return 0; } } @@ -5637,10 +5637,10 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth) "panic: reg_scan_name returned NULL"); if (!RExC_paren_names) { RExC_paren_names= newHV(); - sv_2mortal((SV*)RExC_paren_names); + sv_2mortal(MUTABLE_SV(RExC_paren_names)); #ifdef DEBUGGING RExC_paren_name_list= newAV(); - sv_2mortal((SV*)RExC_paren_name_list); + sv_2mortal(MUTABLE_SV(RExC_paren_name_list)); #endif } he_str = hv_fetch_ent( RExC_paren_names, svname, 1, 0 ); @@ -6656,7 +6656,7 @@ S_reg_namedseq(pTHX_ RExC_state_t *pRExC_state, UV *valuep) if (!RExC_charnames) { /* make sure our cache is allocated */ RExC_charnames = newHV(); - sv_2mortal((SV*)RExC_charnames); + sv_2mortal(MUTABLE_SV(RExC_charnames)); } /* see if we have looked this one up before */ he_str = hv_fetch_ent( RExC_charnames, sv_name, 0, 0 ); @@ -8390,8 +8390,8 @@ parseit: * used later (regexec.c:S_reginclass()). */ av_store(av, 0, listsv); av_store(av, 1, NULL); - av_store(av, 2, (SV*)unicode_alternate); - rv = newRV_noinc((SV*)av); + av_store(av, 2, MUTABLE_SV(unicode_alternate)); + rv = newRV_noinc(MUTABLE_SV(av)); n = add_data(pRExC_state, 1, "s"); RExC_rxi->data->data[n] = (void*)rv; ARG_SET(ret, n); @@ -9061,7 +9061,7 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o) } else { AV *list= MUTABLE_AV(progi->data->data[ progi->name_list_idx ]); - SV *sv_dat=(SV*)progi->data->data[ ARG( o ) ]; + SV *sv_dat= MUTABLE_SV(progi->data->data[ ARG( o ) ]); I32 *nums=(I32*)SvPVX(sv_dat); SV **name= av_fetch(list, nums[0], 0 ); I32 n; @@ -9079,7 +9079,7 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o) else if (k == VERB) { if (!o->flags) Perl_sv_catpvf(aTHX_ sv, ":%"SVf, - SVfARG((SV*)progi->data->data[ ARG( o ) ])); + SVfARG((MUTABLE_SV(progi->data->data[ ARG( o ) ])))); } else if (k == LOGICAL) Perl_sv_catpvf(aTHX_ sv, "[%d]", o->flags); /* 2: embedded, otherwise 1 */ else if (k == FOLDCHAR) @@ -9427,7 +9427,7 @@ Perl_regfree_internal(pTHX_ REGEXP * const rx) case 's': case 'S': case 'u': - SvREFCNT_dec((SV*)ri->data->data[n]); + SvREFCNT_dec(MUTABLE_SV(ri->data->data[n])); break; case 'f': Safefree(ri->data->data[n]); @@ -9449,7 +9449,7 @@ Perl_regfree_internal(pTHX_ REGEXP * const rx) op_free((OP_4tree*)ri->data->data[n]); PAD_RESTORE_LOCAL(old_comppad); - SvREFCNT_dec((SV*)new_comppad); + SvREFCNT_dec(MUTABLE_SV(new_comppad)); new_comppad = NULL; break; case 'n': @@ -9654,7 +9654,7 @@ Perl_regdupe_internal(pTHX_ REGEXP * const rx, CLONE_PARAMS *param) case 'S': case 'p': /* actually an AV, but the dup function is identical. */ case 'u': /* actually an HV, but the dup function is identical. */ - d->data[i] = sv_dup_inc((SV *)ri->data->data[i], param); + d->data[i] = sv_dup_inc((const SV *)ri->data->data[i], param); break; case 'f': /* This is cheating. */ diff --git a/regexec.c b/regexec.c index 008e637..0c4329d 100644 --- a/regexec.c +++ b/regexec.c @@ -2681,7 +2681,7 @@ S_reg_check_named_buff_matched(pTHX_ const regexp *rex, const regnode *scan) { I32 n; RXi_GET_DECL(rex,rexi); - SV *sv_dat=(SV*)rexi->data->data[ ARG( scan ) ]; + SV *sv_dat= MUTABLE_SV(rexi->data->data[ ARG( scan ) ]); I32 *nums=(I32*)SvPVX(sv_dat); PERL_ARGS_ASSERT_REG_CHECK_NAMED_BUFF_MATCHED; @@ -3797,7 +3797,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) /* This isn't a first class regexp. Instead, it's caching a regexp onto an existing, Perl visible scalar. */ - sv_magic(ret, (SV*) rx, PERL_MAGIC_qr, 0, 0); + sv_magic(ret, MUTABLE_SV(rx), PERL_MAGIC_qr, 0, 0); } PL_regsize = osize; } @@ -4343,7 +4343,7 @@ NULL case CUTGROUP: PL_reginput = locinput; sv_yes_mark = st->u.mark.mark_name = scan->flags ? NULL : - (SV*)rexi->data->data[ ARG( scan ) ]; + MUTABLE_SV(rexi->data->data[ ARG( scan ) ]); PUSH_STATE_GOTO(CUTGROUP_next,next); /* NOTREACHED */ case CUTGROUP_next_fail: @@ -5018,7 +5018,7 @@ NULL case PRUNE: PL_reginput = locinput; if (!scan->flags) - sv_yes_mark = sv_commit = (SV*)rexi->data->data[ ARG( scan ) ]; + sv_yes_mark = sv_commit = MUTABLE_SV(rexi->data->data[ ARG( scan ) ]); PUSH_STATE_GOTO(COMMIT_next,next); /* NOTREACHED */ case COMMIT_next_fail: @@ -5032,7 +5032,7 @@ NULL case MARKPOINT: ST.prev_mark = mark_state; ST.mark_name = sv_commit = sv_yes_mark - = (SV*)rexi->data->data[ ARG( scan ) ]; + = MUTABLE_SV(rexi->data->data[ ARG( scan ) ]); mark_state = st; ST.mark_loc = PL_reginput = locinput; PUSH_YES_STATE_GOTO(MARKPOINT_next,next); @@ -5073,7 +5073,7 @@ NULL otherwise do nothing. Meaning we need to scan */ regmatch_state *cur = mark_state; - SV *find = (SV*)rexi->data->data[ ARG( scan ) ]; + SV *find = MUTABLE_SV(rexi->data->data[ ARG( scan ) ]); while (cur) { if ( sv_eq( cur->u.mark.mark_name, @@ -5685,8 +5685,8 @@ Perl_regclass_swash(pTHX_ const regexp *prog, register const regnode* node, bool const U32 n = ARG(node); if (data->what[n] == 's') { - SV * const rv = (SV*)data->data[n]; - AV * const av = MUTABLE_AV(SvRV((SV*)rv)); + SV * const rv = MUTABLE_SV(data->data[n]); + AV * const av = MUTABLE_AV(SvRV(rv)); SV **const ary = AvARRAY(av); SV **a, **b; diff --git a/scope.c b/scope.c index d808ac6..6e74978 100644 --- a/scope.c +++ b/scope.c @@ -319,7 +319,7 @@ Perl_save_ary(pTHX_ GV *gv) GvAV(gv) = NULL; av = GvAVn(gv); if (SvMAGIC(oav)) - mg_localize((SV*)oav, (SV*)av); + mg_localize(MUTABLE_SV(oav), MUTABLE_SV(av)); return av; } @@ -339,7 +339,7 @@ Perl_save_hash(pTHX_ GV *gv) GvHV(gv) = NULL; hv = GvHVn(gv); if (SvMAGIC(ohv)) - mg_localize((SV*)ohv, (SV*)hv); + mg_localize(MUTABLE_SV(ohv), MUTABLE_SV(hv)); return hv; } @@ -701,15 +701,15 @@ Perl_leave_scope(pTHX_ I32 base) while (PL_savestack_ix > base) { switch (SSPOPINT) { case SAVEt_ITEM: /* normal string */ - value = (SV*)SSPOPPTR; - sv = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); + sv = MUTABLE_SV(SSPOPPTR); sv_replace(sv,value); PL_localizing = 2; SvSETMAGIC(sv); PL_localizing = 0; break; case SAVEt_SV: /* scalar reference */ - value = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); gv = (GV*)SSPOPPTR; ptr = &GvSV(gv); av = MUTABLE_AV(gv); /* what to refcnt_dec */ @@ -745,7 +745,7 @@ Perl_leave_scope(pTHX_ I32 base) } break; case SAVEt_GENERIC_SVREF: /* generic sv */ - value = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); ptr = SSPOPPTR; sv = *(SV**)ptr; *(SV**)ptr = value; @@ -761,7 +761,7 @@ Perl_leave_scope(pTHX_ I32 base) GvAV(gv) = av; if (SvMAGICAL(av)) { PL_localizing = 2; - SvSETMAGIC((SV*)av); + SvSETMAGIC(MUTABLE_SV(av)); PL_localizing = 0; } break; @@ -774,7 +774,7 @@ Perl_leave_scope(pTHX_ I32 base) GvHV(gv) = hv; if (SvMAGICAL(hv)) { PL_localizing = 2; - SvSETMAGIC((SV*)hv); + SvSETMAGIC(MUTABLE_SV(hv)); PL_localizing = 0; } break; @@ -800,7 +800,7 @@ Perl_leave_scope(pTHX_ I32 base) break; case SAVEt_SPTR: /* SV* reference */ ptr = SSPOPPTR; - *(SV**)ptr = (SV*)SSPOPPTR; + *(SV**)ptr = MUTABLE_SV(SSPOPPTR); break; case SAVEt_VPTR: /* random* reference */ case SAVEt_PPTR: /* char* reference */ @@ -827,11 +827,11 @@ Perl_leave_scope(pTHX_ I32 base) break; case SAVEt_FREESV: ptr = SSPOPPTR; - SvREFCNT_dec((SV*)ptr); + SvREFCNT_dec(MUTABLE_SV(ptr)); break; case SAVEt_MORTALIZESV: ptr = SSPOPPTR; - sv_2mortal((SV*)ptr); + sv_2mortal(MUTABLE_SV(ptr)); break; case SAVEt_FREEOP: ptr = SSPOPPTR; @@ -888,8 +888,8 @@ Perl_leave_scope(pTHX_ I32 base) else { /* Someone has a claim on this, so abandon it. */ const U32 padflags = SvFLAGS(sv) & (SVs_PADMY|SVs_PADTMP); switch (SvTYPE(sv)) { /* Console ourselves with a new value */ - case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break; - case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break; + case SVt_PVAV: *(SV**)ptr = MUTABLE_SV(newAV()); break; + case SVt_PVHV: *(SV**)ptr = MUTABLE_SV(newHV()); break; default: *(SV**)ptr = newSV(0); break; } SvREFCNT_dec(sv); /* Cast current value to the winds. */ @@ -924,7 +924,7 @@ Perl_leave_scope(pTHX_ I32 base) cxstack[i].blk_oldsp = SSPOPINT; break; case SAVEt_AELEM: /* array element */ - value = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); i = SSPOPINT; av = MUTABLE_AV(SSPOPPTR); ptr = av_fetch(av,i,1); @@ -933,7 +933,7 @@ Perl_leave_scope(pTHX_ I32 base) if (ptr) { sv = *(SV**)ptr; if (sv && sv != &PL_sv_undef) { - if (SvTIED_mg((SV*)av, PERL_MAGIC_tied)) + if (SvTIED_mg((const SV *)av, PERL_MAGIC_tied)) SvREFCNT_inc_void_NN(sv); goto restore_sv; } @@ -942,15 +942,15 @@ Perl_leave_scope(pTHX_ I32 base) SvREFCNT_dec(value); break; case SAVEt_HELEM: /* hash element */ - value = (SV*)SSPOPPTR; - sv = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); + sv = MUTABLE_SV(SSPOPPTR); hv = MUTABLE_HV(SSPOPPTR); ptr = hv_fetch_ent(hv, sv, 1, 0); if (ptr) { const SV * const oval = HeVAL((HE*)ptr); if (oval && oval != &PL_sv_undef) { ptr = &HeVAL((HE*)ptr); - if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied)) + if (SvTIED_mg((const SV *)hv, PERL_MAGIC_tied)) SvREFCNT_inc_void(*(SV**)ptr); SvREFCNT_dec(sv); av = MUTABLE_AV(hv); /* what to refcnt_dec */ @@ -966,14 +966,14 @@ Perl_leave_scope(pTHX_ I32 base) break; case SAVEt_HINTS: if ((PL_hints & HINT_LOCALIZE_HH) && GvHV(PL_hintgv)) { - SvREFCNT_dec((SV*)GvHV(PL_hintgv)); + SvREFCNT_dec(MUTABLE_SV(GvHV(PL_hintgv))); GvHV(PL_hintgv) = NULL; } *(I32*)&PL_hints = (I32)SSPOPINT; Perl_refcounted_he_free(aTHX_ PL_compiling.cop_hints_hash); PL_compiling.cop_hints_hash = (struct refcounted_he *) SSPOPPTR; if (PL_hints & HINT_LOCALIZE_HH) { - SvREFCNT_dec((SV*)GvHV(PL_hintgv)); + SvREFCNT_dec(MUTABLE_SV(GvHV(PL_hintgv))); GvHV(PL_hintgv) = MUTABLE_HV(SSPOPPTR); assert(GvHV(PL_hintgv)); } else if (!GvHV(PL_hintgv)) { @@ -1016,7 +1016,7 @@ Perl_leave_scope(pTHX_ I32 base) But as we have all the information here, we can do it here, save even having to have itersave in the struct. */ sv_2mortal(*svp); - *svp = (SV*)SSPOPPTR; + *svp = MUTABLE_SV(SSPOPPTR); } break; case SAVEt_SAVESWITCHSTACK: @@ -1032,7 +1032,7 @@ Perl_leave_scope(pTHX_ I32 base) { const U32 val = (U32)SSPOPINT; const U32 mask = (U32)SSPOPINT; - sv = (SV*)SSPOPPTR; + sv = MUTABLE_SV(SSPOPPTR); SvFLAGS(sv) &= ~mask; SvFLAGS(sv) |= val; } @@ -1041,7 +1041,7 @@ Perl_leave_scope(pTHX_ I32 base) /* This would be a mathom, but Perl_save_svref() calls a static function, S_save_scalar_at(), so has to stay in this file. */ case SAVEt_SVREF: /* scalar reference */ - value = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); ptr = SSPOPPTR; av = NULL; /* what to refcnt_dec */ goto restore_sv; @@ -1049,7 +1049,7 @@ Perl_leave_scope(pTHX_ I32 base) /* These are only saved in mathoms.c */ case SAVEt_NSTAB: gv = (GV*)SSPOPPTR; - (void)sv_clear((SV*)gv); + (void)sv_clear(MUTABLE_SV(gv)); break; case SAVEt_LONG: /* long reference */ ptr = SSPOPPTR;