X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.c;h=575d663302b586806a25d96494bfffaef72718c5;hb=ea726b52599b52cf534201a46ec3455418c9eb8e;hp=1954b959b720fc0149ef3ae4396c12374b43521e;hpb=1129b882ced9d5881a47214405219a2e6e332a92;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.c b/sv.c index 1954b95..575d663 100644 --- a/sv.c +++ b/sv.c @@ -3502,7 +3502,7 @@ S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr) common: if (intro) { if (stype == SVt_PVCV) { - /*if (GvCVGEN(dstr) && (GvCV(dstr) != (CV*)sref || GvCVGEN(dstr))) {*/ + /*if (GvCVGEN(dstr) && (GvCV(dstr) != (const CV *)sref || GvCVGEN(dstr))) {*/ if (GvCVGEN(dstr)) { SvREFCNT_dec(GvCV(dstr)); GvCV(dstr) = NULL; @@ -3514,15 +3514,16 @@ S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr) else dref = *location; if (stype == SVt_PVCV && (*location != sref || GvCVGEN(dstr))) { - CV* const cv = (CV*)*location; + CV* const cv = MUTABLE_CV(*location); if (cv) { if (!GvCVGEN((GV*)dstr) && (CvROOT(cv) || CvXSUB(cv))) { /* Redefining a sub - warning is mandatory if it was a const and its value changed. */ - if (CvCONST(cv) && CvCONST((CV*)sref) - && cv_const_sv(cv) == cv_const_sv((CV*)sref)) { + if (CvCONST(cv) && CvCONST((const CV *)sref) + && cv_const_sv(cv) + == cv_const_sv((const CV *)sref)) { NOOP; /* They are 2 constant subroutines generated from the same constant. This probably means that @@ -3533,9 +3534,10 @@ S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr) } else if (ckWARN(WARN_REDEFINE) || (CvCONST(cv) - && (!CvCONST((CV*)sref) + && (!CvCONST((const CV *)sref) || sv_cmp(cv_const_sv(cv), - cv_const_sv((CV*)sref))))) { + cv_const_sv((const CV *) + sref))))) { Perl_warner(aTHX_ packWARN(WARN_REDEFINE), (const char *) (CvCONST(cv) @@ -4714,9 +4716,9 @@ Perl_sv_magicext(pTHX_ SV *const sv, SV *const obj, const int how, how == PERL_MAGIC_arylen || how == PERL_MAGIC_symtab || (SvTYPE(obj) == SVt_PVGV && - (GvSV(obj) == sv || GvHV(obj) == (HV*)sv || GvAV(obj) == (AV*)sv || - GvCV(obj) == (CV*)sv || GvIOp(obj) == (IO*)sv || - GvFORM(obj) == (CV*)sv))) + (GvSV(obj) == sv || GvHV(obj) == (const HV *)sv + || GvAV(obj) == (const AV *)sv || GvCV(obj) == (const CV *)sv + || GvIOp(obj) == (const IO *)sv || GvFORM(obj) == (const CV *)sv))) { mg->mg_obj = obj; } @@ -5067,7 +5069,7 @@ Perl_sv_add_backref(pTHX_ SV *const tsv, SV *const sv) PERL_ARGS_ASSERT_SV_ADD_BACKREF; if (SvTYPE(tsv) == SVt_PVHV) { - AV **const avp = Perl_hv_backreferences_p(aTHX_ (HV*)tsv); + AV **const avp = Perl_hv_backreferences_p(aTHX_ MUTABLE_HV(tsv)); av = *avp; if (!av) { @@ -5123,7 +5125,7 @@ S_sv_del_backref(pTHX_ SV *const tsv, SV *const sv) PERL_ARGS_ASSERT_SV_DEL_BACKREF; if (SvTYPE(tsv) == SVt_PVHV && SvOOK(tsv)) { - av = *Perl_hv_backreferences_p(aTHX_ (HV*)tsv); + av = *Perl_hv_backreferences_p(aTHX_ MUTABLE_HV(tsv)); /* We mustn't attempt to "fix up" the hash here by moving the backreference array back to the hv_aux structure, as that is stored in the main HvARRAY(), and hfreentries assumes that no-one @@ -5186,7 +5188,7 @@ Perl_sv_kill_backrefs(pTHX_ SV *const sv, AV *const av) SvTYPE(referrer) == SVt_PVLV) { /* You lookin' at me? */ assert(GvSTASH(referrer)); - assert(GvSTASH(referrer) == (HV*)sv); + assert(GvSTASH(referrer) == (const HV *)sv); GvSTASH(referrer) = 0; } else { Perl_croak(aTHX_ @@ -5507,14 +5509,14 @@ Perl_sv_clear(pTHX_ register SV *const sv) goto freescalar; case SVt_PVCV: case SVt_PVFM: - cv_undef((CV*)sv); + cv_undef(MUTABLE_CV(sv)); goto freescalar; case SVt_PVHV: - if (PL_last_swash_hv == (HV*)sv) { + if (PL_last_swash_hv == (const HV *)sv) { PL_last_swash_hv = NULL; } - Perl_hv_kill_backrefs(aTHX_ (HV*)sv); - hv_undef((HV*)sv); + Perl_hv_kill_backrefs(aTHX_ MUTABLE_HV(sv)); + hv_undef(MUTABLE_HV(sv)); break; case SVt_PVAV: if (PL_comppad == (AV*)sv) { @@ -7943,7 +7945,7 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **const st, GV **const gvp, const I32 lref) case SVt_PVCV: *st = CvSTASH(sv); *gvp = NULL; - return (CV*)sv; + return MUTABLE_CV(sv); case SVt_PVHV: case SVt_PVAV: *st = NULL; @@ -7966,7 +7968,7 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **const st, GV **const gvp, const I32 lref) sv = SvRV(sv); if (SvTYPE(sv) == SVt_PVCV) { - cv = (CV*)sv; + cv = MUTABLE_CV(sv); *gvp = NULL; *st = CvSTASH(cv); return cv; @@ -8477,7 +8479,7 @@ Perl_sv_bless(pTHX_ SV *const sv, HV *const stash) if (SvTYPE(tmpRef) != SVt_PVIO) ++PL_sv_objcount; SvUPGRADE(tmpRef, SVt_PVMG); - SvSTASH_set(tmpRef, (HV*)SvREFCNT_inc_simple(stash)); + SvSTASH_set(tmpRef, MUTABLE_HV(SvREFCNT_inc_simple(stash))); if (Gv_AMG(stash)) SvAMAGIC_on(sv); @@ -9307,7 +9309,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, */ if (sv_derived_from(vecsv, "version")) { char *version = savesvpv(vecsv); - if ( hv_exists((HV*)SvRV(vecsv), "alpha", 5 ) ) { + if ( hv_exists(MUTABLE_HV(SvRV(vecsv)), "alpha", 5 ) ) { Perl_warner(aTHX_ packWARN(WARN_INTERNAL), "vector argument not supported with alpha versions"); goto unknown; @@ -10082,16 +10084,16 @@ ptr_table_* functions. If this changes, please unmerge ss_dup. */ #define sv_dup_inc(s,t) SvREFCNT_inc(sv_dup(s,t)) #define sv_dup_inc_NN(s,t) SvREFCNT_inc_NN(sv_dup(s,t)) -#define av_dup(s,t) (AV*)sv_dup((SV*)s,t) -#define av_dup_inc(s,t) (AV*)SvREFCNT_inc(sv_dup((SV*)s,t)) -#define hv_dup(s,t) (HV*)sv_dup((SV*)s,t) -#define hv_dup_inc(s,t) (HV*)SvREFCNT_inc(sv_dup((SV*)s,t)) -#define cv_dup(s,t) (CV*)sv_dup((SV*)s,t) -#define cv_dup_inc(s,t) (CV*)SvREFCNT_inc(sv_dup((SV*)s,t)) +#define av_dup(s,t) (AV*)sv_dup((const SV *)s,t) +#define av_dup_inc(s,t) (AV*)SvREFCNT_inc(sv_dup((const SV *)s,t)) +#define hv_dup(s,t) MUTABLE_HV(sv_dup((const SV *)s,t)) +#define hv_dup_inc(s,t) MUTABLE_HV(SvREFCNT_inc(sv_dup((const SV *)s,t))) +#define cv_dup(s,t) MUTABLE_CV(sv_dup((SV*)s,t)) +#define cv_dup_inc(s,t) MUTABLE_CV(SvREFCNT_inc(sv_dup((const SV *)s,t))) #define io_dup(s,t) (IO*)sv_dup((SV*)s,t) -#define io_dup_inc(s,t) (IO*)SvREFCNT_inc(sv_dup((SV*)s,t)) +#define io_dup_inc(s,t) (IO*)SvREFCNT_inc(sv_dup((const SV *)s,t)) #define gv_dup(s,t) (GV*)sv_dup((SV*)s,t) -#define gv_dup_inc(s,t) (GV*)SvREFCNT_inc(sv_dup((SV*)s,t)) +#define gv_dup_inc(s,t) (GV*)SvREFCNT_inc(sv_dup((const SV *)s,t)) #define SAVEPV(p) ((p) ? savepv(p) : NULL) #define SAVEPVN(p,n) ((p) ? savepvn(p,n) : NULL) @@ -10803,7 +10805,7 @@ Perl_sv_dup(pTHX_ const SV *const sstr, CLONE_PARAMS *const param) } break; case SVt_PVHV: - if (HvARRAY((HV*)sstr)) { + if (HvARRAY((const HV *)sstr)) { STRLEN i = 0; const bool sharekeys = !!HvSHAREKEYS(sstr); XPVHV * const dxhv = (XPVHV*)SvANY(dstr); @@ -10851,7 +10853,7 @@ Perl_sv_dup(pTHX_ const SV *const sstr, CLONE_PARAMS *const param) } } else - HvARRAY((HV*)dstr) = NULL; + HvARRAY(MUTABLE_HV(dstr)) = NULL; break; case SVt_PVCV: if (!(param->flags & CLONEf_COPY_STACKS)) { @@ -11070,9 +11072,9 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) I32 ix = proto_perl->Isavestack_ix; ANY *nss; SV *sv; - GV *gv; - AV *av; - HV *hv; + const GV *gv; + const AV *av; + const HV *hv; void* ptr; int intval; long longval; @@ -11216,7 +11218,7 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) TOPPTR(nss,ix) = pv_dup_inc(c); break; case SAVEt_DELETE: - hv = (HV*)POPPTR(ss,ix); + hv = (const HV *)POPPTR(ss,ix); TOPPTR(nss,ix) = hv_dup_inc(hv, param); c = (char*)POPPTR(ss,ix); TOPPTR(nss,ix) = pv_dup_inc(c); @@ -11270,7 +11272,7 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) } TOPPTR(nss,ix) = ptr; if (i & HINT_LOCALIZE_HH) { - hv = (HV*)POPPTR(ss,ix); + hv = (const HV *)POPPTR(ss,ix); TOPPTR(nss,ix) = hv_dup_inc(hv, param); } break; @@ -11382,9 +11384,9 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) static void do_mark_cloneable_stash(pTHX_ SV *const sv) { - const HEK * const hvname = HvNAME_HEK((HV*)sv); + const HEK * const hvname = HvNAME_HEK((const HV *)sv); if (hvname) { - GV* const cloner = gv_fetchmethod_autoload((HV*)sv, "CLONE_SKIP", 0); + GV* const cloner = gv_fetchmethod_autoload(MUTABLE_HV(sv), "CLONE_SKIP", 0); SvFLAGS(sv) |= SVphv_CLONEABLE; /* clone objects by default */ if (cloner && GvCV(cloner)) { dSP; @@ -12128,7 +12130,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, identified by sv_dup() above. */ while(av_len(param->stashes) != -1) { - HV* const stash = (HV*) av_shift(param->stashes); + HV* const stash = MUTABLE_HV(av_shift(param->stashes)); GV* const cloner = gv_fetchmethod_autoload(stash, "CLONE", 0); if (cloner && GvCV(cloner)) { dSP; @@ -12289,7 +12291,7 @@ Perl_sv_cat_decode(pTHX_ SV *dsv, SV *encoding, * If so, return a mortal copy of the key. */ STATIC SV* -S_find_hash_subscript(pTHX_ HV *hv, SV* val) +S_find_hash_subscript(pTHX_ const HV *const hv, const SV *const val) { dVAR; register HE **array; @@ -12325,7 +12327,7 @@ S_find_hash_subscript(pTHX_ HV *hv, SV* val) * If so, return the index, otherwise return -1. */ STATIC I32 -S_find_array_subscript(pTHX_ AV *av, SV* val) +S_find_array_subscript(pTHX_ const AV *const av, const SV *const val) { dVAR; @@ -12358,8 +12360,8 @@ S_find_array_subscript(pTHX_ AV *av, SV* val) #define FUV_SUBSCRIPT_WITHIN 4 /* "within @foo" */ STATIC SV* -S_varname(pTHX_ GV *gv, const char gvtype, PADOFFSET targ, - SV* keyname, I32 aindex, int subscript_type) +S_varname(pTHX_ const GV *const gv, const char gvtype, PADOFFSET targ, + const SV *const keyname, I32 aindex, int subscript_type) { SV * const name = sv_newmortal(); @@ -12434,13 +12436,13 @@ PL_comppad/PL_curpad points to the currently executing pad. */ STATIC SV * -S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) +S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv, + bool match) { dVAR; SV *sv; - AV *av; - GV *gv; - OP *o, *o2, *kid; + const GV *gv; + const OP *o, *o2, *kid; if (!obase || (match && (!uninit_sv || uninit_sv == &PL_sv_undef || uninit_sv == &PL_sv_placeholder))) @@ -12478,7 +12480,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) /* attempt to find a match within the aggregate */ if (hash) { - keysv = find_hash_subscript((HV*)sv, uninit_sv); + keysv = find_hash_subscript((const HV*)sv, uninit_sv); if (keysv) subscript_type = FUV_SUBSCRIPT_HASH; } @@ -12511,7 +12513,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) if (obase->op_flags & OPf_SPECIAL) { /* lexical array */ if (match) { SV **svp; - av = (AV*)PAD_SV(obase->op_targ); + AV *av = (AV*)PAD_SV(obase->op_targ); if (!av || SvRMAGICAL(av)) break; svp = av_fetch(av, (I32)obase->op_private, FALSE); @@ -12527,7 +12529,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) break; if (match) { SV **svp; - av = GvAV(gv); + AV *const av = GvAV(gv); if (!av || SvRMAGICAL(av)) break; svp = av_fetch(av, (I32)obase->op_private, FALSE); @@ -12578,7 +12580,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) if (SvMAGICAL(sv)) break; if (obase->op_type == OP_HELEM) { - HE* he = hv_fetch_ent((HV*)sv, cSVOPx_sv(kid), 0, 0); + HE* he = hv_fetch_ent(MUTABLE_HV(sv), cSVOPx_sv(kid), 0, 0); if (!he || HeVAL(he) != uninit_sv) break; } @@ -12599,7 +12601,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) /* index is an expression; * attempt to find a match within the aggregate */ if (obase->op_type == OP_HELEM) { - SV * const keysv = find_hash_subscript((HV*)sv, uninit_sv); + SV * const keysv = find_hash_subscript((const HV*)sv, uninit_sv); if (keysv) return varname(gv, '%', o->op_targ, keysv, 0, FUV_SUBSCRIPT_HASH);