erroneous const in dump.c.
p4raw-id: //depot/perl@34675
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;
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;
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);
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)))
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));
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
}
}
if (val != &PL_sv_undef) {
- mg_copy((SV*)av, val, 0, key);
+ mg_copy(MUTABLE_SV(av), val, 0, key);
}
return NULL;
}
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];
}
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)
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)) {
AvARRAY(av) = NULL;
AvMAX(av) = AvFILLp(av) = -1;
- if(SvRMAGICAL(av)) mg_clear((SV*)av);
+ if(SvRMAGICAL(av)) mg_clear(MUTABLE_SV(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);
EXTEND(SP,2);
- PUSHs(SvTIED_obj((SV*)av, mg));
+ PUSHs(SvTIED_obj(MUTABLE_SV(av), mg));
PUSHs(val);
PUTBACK;
ENTER;
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)) {
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;
}
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);
}
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)) {
AvMAX(av)--;
AvFILLp(av)--;
if (SvSMAGICAL(av))
- mg_set((SV*)av);
+ mg_set(MUTABLE_SV(av));
return retval;
}
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);
AvFILLp(av) = fill;
if (SvSMAGICAL(av))
- mg_set((SV*)av);
+ mg_set(MUTABLE_SV(av));
}
else
(void)av_store(av,fill,&PL_sv_undef);
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
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);
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 */
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
}
}
- 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);
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;
#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);
#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);
#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);
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);
}
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);
}
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);
RETURN;
}
- if (! SvTIED_mg((SV*)keys, PERL_MAGIC_tied) )
+ if (! SvTIED_mg((const SV *)keys, PERL_MAGIC_tied) )
{
i = HvKEYS(keys);
}
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;
}
sv_catpv(t, "...");
goto finish;
}
- sv = (SV*)SvRV(sv);
+ sv = SvRV(sv);
goto retry;
}
type = SvTYPE(sv);
}
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
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);
}
}
: 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:
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. */
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));
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));
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;
}
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);
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, "<mad_sv key=%s/>\n", SvPVX(tmpsv));
break;
{
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);
{
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();
{
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();
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
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) {
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);
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);
}
}
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
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;
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 {
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)
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)
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);
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 */
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;
}
}
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;
&& 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)) );
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;
}
/* 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;
}
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;
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))
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))
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)))
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));
}
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;
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;
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. */
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;
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;
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)
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])) {
#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();
} 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);
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. */
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);
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. */
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;
}
#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) {
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);
}
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) {
}
k_flags |= HVhek_WASUTF8 | HVhek_FREEKEY;
}
- HvHASKFLAGS_on((SV*)hv);
+ HvHASKFLAGS_on(MUTABLE_SV(hv));
}
if (HvREHASH(hv)) {
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);
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);
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;
HvPLACEHOLDERS_set(hv, 0);
if (SvRMAGICAL(hv))
- mg_clear((SV*)hv);
+ mg_clear(MUTABLE_SV(hv));
}
static struct xpvhv_aux*
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);
}
}
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));
/* 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));
}
}
#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
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;
}
}
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");
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. */
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)) {
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);
} 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);
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);
{
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 *
{
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**
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 */
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);
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))
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);
{
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;
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;
}
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));
hv_stores(sih, "band", newSViv(sip->si_band));
#endif
EXTEND(SP, 2);
- PUSHs((SV*)rv);
+ PUSHs(rv);
mPUSHp((char *)sip, sizeof(*sip));
}
#endif
PUTBACK;
- call_sv((SV*)cv, G_DISCARD|G_EVAL);
+ call_sv(MUTABLE_SV(cv), G_DISCARD|G_EVAL);
POPSTACK;
if (SvTRUE(ERRSV)) {
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;
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;
}
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;
}
/* 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);
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) {
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.
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"
/* 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) {
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)
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
/* 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) {
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);
}
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;
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);
}
}
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:
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**);
newSVOP(OP_CONST, 0, newSVpv(stashpv,0)),
prepend_elem(OP_LIST,
newSVOP(OP_CONST, 0,
- newRV((SV*)cv)),
+ newRV(MUTABLE_SV(cv))),
attrs)));
}
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;
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);
}
}
}
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;
/* 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) {
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");
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));
CvSTART(cv) = NULL;
LEAVE;
}
- SvPOK_off((SV*)cv); /* forget prototype */
+ SvPOK_off(MUTABLE_SV(cv)); /* forget prototype */
CvGV(cv) = NULL;
pad_undef(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)) {
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.
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");
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;
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);
|| 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)))
}
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
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);
}
}
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);
PUSHMARK(SP);
XPUSHs(tmpstr);
PUTBACK;
- call_sv((SV*)pcv, G_DISCARD);
+ call_sv(MUTABLE_SV(pcv), G_DISCARD);
}
}
}
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);
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;
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;
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;
}
/* 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
}
CvFILE(cv) = proto_and_file + proto_len;
} else {
- sv_setpv((SV *)cv, proto);
+ sv_setpv(MUTABLE_SV(cv), proto);
}
return cv;
}
{
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 *
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;
}
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
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;
}
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;
}
}
#endif
}
EXTEND(sp, 1);
- ST(0) = (SV*)XSANY.any_ptr;
+ ST(0) = MUTABLE_SV(XSANY.any_ptr);
XSRETURN(1);
}
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 {
}
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 */
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;
}
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);
/* 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",
}
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();
}
/* 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);
}
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);
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);
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);
}
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;
}
}
#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)
PL_regex_pad = NULL;
#endif
- SvREFCNT_dec((SV*) PL_stashcache);
+ SvREFCNT_dec(MUTABLE_SV(PL_stashcache));
PL_stashcache = NULL;
/* loosen bonds of global variables */
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) {
{
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);
}
/*
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
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)
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++;
/*
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;
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");
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;
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;
things. */
RETURN;
}
- sv = (SV*)gv_fetchsv(sv, GV_ADD, SVt_PVGV);
+ sv = MUTABLE_SV(gv_fetchsv(sv, GV_ADD, SVt_PVGV));
}
}
}
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;
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);
}
else
cv = MUTABLE_CV(&PL_sv_undef);
- SETs((SV*)cv);
+ SETs(MUTABLE_SV(cv));
RETURN;
}
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;
}
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"))
}
MARK++;
repeatcpy((char*)(MARK + items), (char*)MARK,
- items * sizeof(SV*), count - 1);
+ items * sizeof(const SV *), count - 1);
SP += max;
}
else if (count <= 0)
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));
}
{
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);
}
SP = ORIGMARK;
mXPUSHs((PL_op->op_flags & OPf_SPECIAL)
- ? newRV_noinc((SV*) hv) : (SV*) hv);
+ ? newRV_noinc(MUTABLE_SV(hv)) : MUTABLE_SV(hv));
RETURN;
}
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;
{
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;
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;
{
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;
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)) {
if (!mg) {
if (SvSMAGICAL(ary)) {
PUTBACK;
- mg_set((SV*)ary);
+ mg_set(MUTABLE_SV(ary));
SPAGAIN;
}
if (gimme == G_ARRAY) {
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;
}
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 */
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--;
}
}
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);
}
}
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;
{
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;
}
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))
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);
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;
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);
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));
PP(pp_gv)
{
dVAR; dSP;
- XPUSHs((SV*)cGVOP_gv);
+ XPUSHs(MUTABLE_SV(cGVOP_gv));
RETURN;
}
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);
/* 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) {
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 {
SvREFCNT_inc_void(source);
SvREFCNT_dec(upgraded);
- SvRV_set(left, (SV *)source);
+ SvRV_set(left, MUTABLE_SV(source));
}
}
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--);
Copy(&PL_op, &LvTARGOFF(sv), 1, OP*);
XPUSHs(sv);
#else
- XPUSHs((SV*)PL_op);
+ XPUSHs(MUTABLE_SV(PL_op));
#endif
RETURN;
}
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) {
++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 ) {
}
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);
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;
TAINT_NOT;
}
if (PL_delaymagic & DM_ARRAY)
- SvSETMAGIC((SV*)ary);
+ SvSETMAGIC(MUTABLE_SV(ary));
break;
case SVt_PVHV: { /* normal hash */
SV *tmpstr;
/* 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) {
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);
/* 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)
)
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);
SvGETMAGIC(sv);
if (SvROK(sv))
- ob = (SV*)SvRV(sv);
+ ob = MUTABLE_SV(SvRV(sv));
else {
GV* iogv;
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 ||
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",
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));
}
}
assert(gv);
- return isGV(gv) ? (SV*)GvCV(gv) : (SV*)gv;
+ return isGV(gv) ? MUTABLE_SV(GvCV(gv)) : MUTABLE_SV(gv);
}
/*
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;
}
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--);
}
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;
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);
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);
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;
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 */
while (items--)
PUSHs(*MARK++);
PUTBACK;
- call_sv((SV*)GvCV(gv), G_SCALAR);
+ call_sv(MUTABLE_SV(GvCV(gv)), G_SCALAR);
}
SPAGAIN;
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))) {
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;
}
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))) {
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)) {
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;
XPUSHTARG;
}
else {
- mXPUSHs(newRV((SV*)egv));
+ mXPUSHs(newRV(MUTABLE_SV(egv)));
}
}
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);
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);
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);
}
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);
++SP;
}
PUSHMARK(MARK - 1);
- *MARK = SvTIED_obj((SV*)io, mg);
+ *MARK = SvTIED_obj(MUTABLE_SV(io), mg);
PUTBACK;
ENTER;
call_method("PRINTF", G_SCALAR);
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;
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;
}
PUSHMARK(ORIGMARK);
- *(ORIGMARK+1) = SvTIED_obj((SV*)io, mg);
+ *(ORIGMARK+1) = SvTIED_obj(MUTABLE_SV(io), mg);
ENTER;
call_method("WRITE", G_SCALAR);
LEAVE;
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);
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);
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
+ (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);
av_push(retarray, ret);
}
if (retarray)
- return newRV_noinc((SV*)retarray);
+ return newRV_noinc(MUTABLE_SV(retarray));
}
}
return NULL;
}
}
- return newRV_noinc((SV*)av);
+ return newRV_noinc(MUTABLE_SV(av));
}
void
goto getlen;
} else {
if (ckWARN(WARN_UNINITIALIZED))
- report_uninit((SV*)sv);
+ report_uninit((const SV *)sv);
return 0;
}
}
"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 );
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 );
* 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);
}
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;
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)
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]);
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':
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. */
{
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;
/* 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;
}
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:
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:
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);
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,
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;
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;
}
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;
}
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 */
}
break;
case SAVEt_GENERIC_SVREF: /* generic sv */
- value = (SV*)SSPOPPTR;
+ value = MUTABLE_SV(SSPOPPTR);
ptr = SSPOPPTR;
sv = *(SV**)ptr;
*(SV**)ptr = value;
GvAV(gv) = av;
if (SvMAGICAL(av)) {
PL_localizing = 2;
- SvSETMAGIC((SV*)av);
+ SvSETMAGIC(MUTABLE_SV(av));
PL_localizing = 0;
}
break;
GvHV(gv) = hv;
if (SvMAGICAL(hv)) {
PL_localizing = 2;
- SvSETMAGIC((SV*)hv);
+ SvSETMAGIC(MUTABLE_SV(hv));
PL_localizing = 0;
}
break;
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 */
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;
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. */
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);
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;
}
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 */
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)) {
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:
{
const U32 val = (U32)SSPOPINT;
const U32 mask = (U32)SSPOPINT;
- sv = (SV*)SSPOPPTR;
+ sv = MUTABLE_SV(SSPOPPTR);
SvFLAGS(sv) &= ~mask;
SvFLAGS(sv) |= val;
}
/* 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;
/* 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;