if (io && (IoFLAGS(io) & IOf_ARGV)
&& PL_argvout_stack && AvFILLp(PL_argvout_stack) >= 0)
{
- GV * const oldout = (GV*)av_pop(PL_argvout_stack);
+ GV * const oldout = MUTABLE_GV(av_pop(PL_argvout_stack));
setdefout(oldout);
SvREFCNT_dec(oldout);
return NULL;
STRLEN len;
PUTBACK;
if (isGV_with_GP(sv)) {
- gv = (GV*)sv;
+ gv = MUTABLE_GV(sv);
goto do_fstat;
}
else if (SvROK(sv) && isGV_with_GP(SvRV(sv))) {
- gv = (GV*)SvRV(sv);
+ gv = MUTABLE_GV(SvRV(sv));
goto do_fstat;
}
else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVIO) {
PUTBACK;
if (SvROK(sv) && isGV_with_GP(SvRV(sv)) && ckWARN(WARN_IO)) {
Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s",
- GvENAME((GV*) SvRV(sv)));
+ GvENAME((const GV *)SvRV(sv)));
return (PL_laststatval = -1);
}
file = SvPV_nolen_const(sv);
while (++mark <= sp) {
GV* gv;
if (isGV_with_GP(*mark)) {
- gv = (GV*)*mark;
+ gv = MUTABLE_GV(*mark);
do_fchmod:
if (GvIO(gv) && IoIFP(GvIOp(gv))) {
#ifdef HAS_FCHMOD
}
}
else if (SvROK(*mark) && isGV_with_GP(SvRV(*mark))) {
- gv = (GV*)SvRV(*mark);
+ gv = MUTABLE_GV(SvRV(*mark));
goto do_fchmod;
}
else {
while (++mark <= sp) {
GV* gv;
if (isGV_with_GP(*mark)) {
- gv = (GV*)*mark;
+ gv = MUTABLE_GV(*mark);
do_fchown:
if (GvIO(gv) && IoIFP(GvIOp(gv))) {
#ifdef HAS_FCHOWN
}
}
else if (SvROK(*mark) && isGV_with_GP(SvRV(*mark))) {
- gv = (GV*)SvRV(*mark);
+ gv = MUTABLE_GV(SvRV(*mark));
goto do_fchown;
}
else {
while (++mark <= sp) {
GV* gv;
if (isGV_with_GP(*mark)) {
- gv = (GV*)*mark;
+ gv = MUTABLE_GV(*mark);
do_futimes:
if (GvIO(gv) && IoIFP(GvIOp(gv))) {
#ifdef HAS_FUTIMES
}
}
else if (SvROK(*mark) && isGV_with_GP(SvRV(*mark))) {
- gv = (GV*)SvRV(*mark);
+ gv = MUTABLE_GV(SvRV(*mark));
goto do_futimes;
}
else {
for (i = 0; i <= (I32) HvMAX(stash); i++) {
const HE *entry;
for (entry = HvARRAY(stash)[i]; entry; entry = HeNEXT(entry)) {
- const GV * const gv = (GV*)HeVAL(entry);
+ const GV * const gv = (const GV *)HeVAL(entry);
if (SvTYPE(gv) != SVt_PVGV || !GvGP(gv))
continue;
if (GvCVu(gv))
UTF-8 cleanliness of the dump file handle? */
SvUTF8_on(tmpsv);
#endif
- gv_fullname3(tmpsv, (GV*)cSVOPo->op_sv, NULL);
+ gv_fullname3(tmpsv, MUTABLE_GV(cSVOPo->op_sv), NULL);
Perl_dump_indent(aTHX_ level, file, "GV = %s\n",
SvPV_nolen_const(tmpsv));
LEAVE;
return;
for (i = 0; i <= (I32) HvMAX(stash); i++) {
for (entry = HvARRAY(stash)[i]; entry; entry = HeNEXT(entry)) {
- GV *gv = (GV*)HeVAL(entry);
+ GV *gv = MUTABLE_GV(HeVAL(entry));
HV *hv;
if (SvTYPE(gv) != SVt_PVGV || !GvGP(gv))
continue;
ENTER;
SAVEFREESV(tmpsv1);
SAVEFREESV(tmpsv2);
- gv_fullname3(tmpsv1, (GV*)cSVOPo->op_sv, NULL);
+ gv_fullname3(tmpsv1, MUTABLE_GV(cSVOPo->op_sv), NULL);
s = SvPV(tmpsv1,len);
sv_catxmlpvn(tmpsv2, s, len, 1);
S_xmldump_attr(aTHX_ level, file, "gv=\"%s\"", SvPV(tmpsv2, len));
gv = gv_fetchmeth(stash, name, nend - name, 0);
if (!gv) {
if (strEQ(name,"import") || strEQ(name,"unimport"))
- gv = (GV*)&PL_sv_yes;
+ gv = MUTABLE_GV(&PL_sv_yes);
else if (autoload)
gv = gv_autoload4(ostash, name, nend - name, TRUE);
if (!gv && do_croak) {
tmpbuf[len++] = ':';
gvp = (GV**)hv_fetch(stash,tmpbuf,len,add);
gv = gvp ? *gvp : NULL;
- if (gv && gv != (GV*)&PL_sv_undef) {
+ if (gv && gv != (const GV *)&PL_sv_undef) {
if (SvTYPE(gv) != SVt_PVGV)
gv_init(gv, stash, tmpbuf, len, (add & GV_ADDMULTI));
else
}
if (tmpbuf != smallbuf)
Safefree(tmpbuf);
- if (!gv || gv == (GV*)&PL_sv_undef)
+ if (!gv || gv == (const GV *)&PL_sv_undef)
return NULL;
if (!(stash = GvHV(gv)))
name_cursor++;
name = name_cursor;
if (name == name_end)
- return gv ? gv : (GV*)*hv_fetchs(PL_defstash, "main::", TRUE);
+ return gv
+ ? gv : MUTABLE_GV(*hv_fetchs(PL_defstash, "main::", TRUE));
}
}
len = name_cursor - name;
{
gvp = (GV**)hv_fetch(stash,name,len,0);
if (!gvp ||
- *gvp == (GV*)&PL_sv_undef ||
+ *gvp == (const GV *)&PL_sv_undef ||
SvTYPE(*gvp) != SVt_PVGV)
{
stash = NULL;
return NULL;
gvp = (GV**)hv_fetch(stash,name,len,add);
- if (!gvp || *gvp == (GV*)&PL_sv_undef)
+ if (!gvp || *gvp == (const GV *)&PL_sv_undef)
return NULL;
gv = *gvp;
if (SvTYPE(gv) == SVt_PVGV) {
register GV *gv;
HV *hv;
if (HeKEY(entry)[HeKLEN(entry)-1] == ':' &&
- (gv = (GV*)HeVAL(entry)) && isGV(gv) && (hv = GvHV(gv)))
+ (gv = MUTABLE_GV(HeVAL(entry))) && isGV(gv) && (hv = GvHV(gv)))
{
if (hv != PL_defstash && hv != stash)
gv_check(hv); /* nested package */
}
else if (isALPHA(*HeKEY(entry))) {
const char *file;
- gv = (GV*)HeVAL(entry);
+ gv = MUTABLE_GV(HeVAL(entry));
if (SvTYPE(gv) != SVt_PVGV || GvMULTI(gv))
continue;
file = GvFILE(gv);
#define MUTABLE_AV(p) ((AV *)MUTABLE_PTR(p))
#define MUTABLE_CV(p) ((CV *)MUTABLE_PTR(p))
+#define MUTABLE_GV(p) ((GV *)MUTABLE_PTR(p))
#define MUTABLE_HV(p) ((HV *)MUTABLE_PTR(p))
#define MUTABLE_IO(p) ((IO *)MUTABLE_PTR(p))
#define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p))
case '5': case '6': case '7': case '8': case '9': case '&':
if (PL_curpm && (rx = PM_GETRE(PL_curpm))) {
/*
- * Pre-threads, this was paren = atoi(GvENAME((GV*)mg->mg_obj));
+ * Pre-threads, this was paren = atoi(GvENAME((const GV *)mg->mg_obj));
* XXX Does the new way break anything?
*/
paren = atoi(mg->mg_ptr); /* $& is in [0] */
calls this same magic */
stash = GvSTASH(
SvTYPE(mg->mg_obj) == SVt_PVGV
- ? (GV*)mg->mg_obj
- : (GV*)mg_find(mg->mg_obj, PERL_MAGIC_isa)->mg_obj
+ ? (const GV *)mg->mg_obj
+ : (const GV *)mg_find(mg->mg_obj, PERL_MAGIC_isa)->mg_obj
);
if (stash)
/* XXX see comments in magic_setisa */
stash = GvSTASH(
SvTYPE(mg->mg_obj) == SVt_PVGV
- ? (GV*)mg->mg_obj
- : (GV*)mg_find(mg->mg_obj, PERL_MAGIC_isa)->mg_obj
+ ? (const GV *)mg->mg_obj
+ : (const GV *)mg_find(mg->mg_obj, PERL_MAGIC_isa)->mg_obj
);
if (stash)
#endif
assert(sv);
if (type == OP_RV2GV)
- newop = newGVOP(OP_GV, 0, (GV*)sv);
+ newop = newGVOP(OP_GV, 0, MUTABLE_GV(sv));
else
newop = newSVOP(OP_CONST, 0, MUTABLE_SV(sv));
op_getmad(o,newop,'f');
else if (curop->op_type == OP_PUSHRE) {
#ifdef USE_ITHREADS
if (((PMOP*)curop)->op_pmreplrootu.op_pmtargetoff) {
- GV *const gv = (GV*)PAD_SVl(((PMOP*)curop)->op_pmreplrootu.op_pmtargetoff);
+ GV *const gv = MUTABLE_GV(PAD_SVl(((PMOP*)curop)->op_pmreplrootu.op_pmtargetoff));
if (gv == PL_defgv
|| (int)GvASSIGN_GENERATION(gv) == PL_generation)
break;
cPADOPx(tmpop)->op_padix = 0; /* steal it */
#else
pm->op_pmreplrootu.op_pmtargetgv
- = (GV*)cSVOPx(tmpop)->op_sv;
+ = MUTABLE_GV(cSVOPx(tmpop)->op_sv);
cSVOPx(tmpop)->op_sv = NULL; /* steal it */
#endif
pm->op_pmflags |= PMf_ONCE;
perlio_mg_set(pTHX_ SV *sv, MAGIC *mg)
{
if (SvROK(sv)) {
- IO * const io = GvIOn((GV *) SvRV(sv));
+ IO * const io = GvIOn(MUTABLE_GV(SvRV(sv)));
PerlIO * const ifp = IoIFP(io);
PerlIO * const ofp = IoOFP(io);
Perl_warn(aTHX_ "set %" SVf " %p %p %p",
perlio_mg_get(pTHX_ SV *sv, MAGIC *mg)
{
if (SvROK(sv)) {
- IO * const io = GvIOn((GV *) SvRV(sv));
+ IO * const io = GvIOn(MUTABLE_GV(SvRV(sv)));
PerlIO * const ifp = IoIFP(io);
PerlIO * const ofp = IoOFP(io);
Perl_warn(aTHX_ "get %" SVf " %p %p %p",
sv = SvRV(sv);
if (SvTYPE(sv) == SVt_PVIO) {
- GV * const gv = (GV*) sv_newmortal();
+ GV * const gv = MUTABLE_GV(sv_newmortal());
gv_init(gv, 0, "", 0, 0);
GvIOp(gv) = MUTABLE_IO(sv);
SvREFCNT_inc_void_NN(sv);
STRLEN len;
SV * const namesv = PAD_SV(cUNOP->op_targ);
const char * const name = SvPV(namesv, len);
- gv = (GV*)newSV(0);
+ gv = MUTABLE_GV(newSV(0));
gv_init(gv, CopSTASH(PL_curcop), name, len, 0);
}
else {
}
}
if (PL_op->op_private & OPpLVAL_INTRO)
- save_gp((GV*)sv, !(PL_op->op_flags & OPf_SPECIAL));
+ save_gp(MUTABLE_GV(sv), !(PL_op->op_flags & OPf_SPECIAL));
SETs(sv);
RETURN;
}
}
}
else {
- gv = (GV*)sv;
+ gv = MUTABLE_GV(sv);
if (!isGV_with_GP(gv)) {
if (SvGMAGICAL(sv)) {
if (PL_op->op_flags & OPf_MOD) {
if (PL_op->op_private & OPpLVAL_INTRO) {
if (cUNOP->op_first->op_type == OP_NULL)
- sv = save_scalar((GV*)TOPs);
+ sv = save_scalar(MUTABLE_GV(TOPs));
else if (gv)
sv = save_scalar(gv);
else
SV *sv = POPs;
const char * const elem = SvPV_nolen_const(sv);
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
SV * tmpRef = NULL;
sv = NULL;
HV *stash;
/* undef *Foo:: */
- if((stash = GvHV((GV*)sv)) && HvNAME_get(stash))
+ if((stash = GvHV((const GV *)sv)) && HvNAME_get(stash))
mro_isa_changed_in(stash);
/* undef *Pkg::meth_name ... */
- else if(GvCVu((GV*)sv) && (stash = GvSTASH((GV*)sv)) && HvNAME_get(stash))
+ else if(GvCVu((const GV *)sv) && (stash = GvSTASH((const GV *)sv))
+ && HvNAME_get(stash))
mro_method_changed_in(stash);
- gp_free((GV*)sv);
+ gp_free(MUTABLE_GV(sv));
Newxz(gp, 1, GP);
GvGP(sv) = gp_ref(gp);
GvSV(sv) = newSV(0);
GvLINE(sv) = CopLINE(PL_curcop);
- GvEGV(sv) = (GV*)sv;
+ GvEGV(sv) = MUTABLE_GV(sv);
GvMULTI_on(sv);
break;
}
}
if (localizing) {
if (HvNAME_get(hv) && isGV(*svp))
- save_gp((GV*)*svp, !(PL_op->op_flags & OPf_SPECIAL));
+ save_gp(MUTABLE_GV(*svp), !(PL_op->op_flags & OPf_SPECIAL));
else {
if (preeminent)
save_helem(hv, keysv, svp);
#ifdef USE_ITHREADS
if (pm->op_pmreplrootu.op_pmtargetoff) {
- ary = GvAVn((GV*)PAD_SVl(pm->op_pmreplrootu.op_pmtargetoff));
+ ary = GvAVn(MUTABLE_GV(PAD_SVl(pm->op_pmreplrootu.op_pmtargetoff)));
}
#else
if (pm->op_pmreplrootu.op_pmtargetgv) {
#endif
}
else {
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
svp = &GvSV(gv); /* symbol table variable */
SAVEGENERICSV(*svp);
*svp = newSV(0);
}
if (isGV_with_GP(arg)) {
- IO * const io = GvIO((GV *)arg);
+ IO * const io = GvIO((const GV *)arg);
++filter_has_file;
if (filter_sub || filter_cache) {
SV * const datasv = filter_add(S_run_user_filter, NULL);
IoLINES(datasv) = filter_has_file;
- IoTOP_GV(datasv) = (GV *)filter_state;
- IoBOTTOM_GV(datasv) = (GV *)filter_sub;
- IoFMT_GV(datasv) = (GV *)filter_cache;
+ IoTOP_GV(datasv) = MUTABLE_GV(filter_state);
+ IoBOTTOM_GV(datasv) = MUTABLE_GV(filter_sub);
+ IoFMT_GV(datasv) = MUTABLE_GV(filter_cache);
}
/* switch to eval mode */
SV *cache = MUTABLE_SV(IoFMT_GV(datasv));
if (!cache) {
- IoFMT_GV(datasv) = (GV*) (cache = newSV(got_len - umaxlen));
+ IoFMT_GV(datasv) = MUTABLE_GV((cache = newSV(got_len - umaxlen)));
} else if (SvOK(cache)) {
/* Cache should be empty. */
assert(!SvCUR(cache));
So change the reference so that it points to the subroutine
of that typeglob, as that's what they were after all along.
*/
- GV *const upgraded = (GV *) cv;
+ GV *const upgraded = MUTABLE_GV(cv);
CV *const source = GvCV(upgraded);
assert(source);
{
dVAR;
tryAMAGICunTARGET(iter, 0);
- PL_last_in_gv = (GV*)(*PL_stack_sp--);
+ PL_last_in_gv = MUTABLE_GV(*PL_stack_sp--);
if (!isGV_with_GP(PL_last_in_gv)) {
if (SvROK(PL_last_in_gv) && isGV_with_GP(SvRV(PL_last_in_gv)))
- PL_last_in_gv = (GV*)SvRV(PL_last_in_gv);
+ PL_last_in_gv = MUTABLE_GV(SvRV(PL_last_in_gv));
else {
dSP;
XPUSHs(MUTABLE_SV(PL_last_in_gv));
PUTBACK;
pp_rv2gv();
- PL_last_in_gv = (GV*)(*PL_stack_sp--);
+ PL_last_in_gv = MUTABLE_GV(*PL_stack_sp--);
}
}
return do_readline();
IO *io;
register PerlIO *fp;
MAGIC *mg;
- GV * const gv = (PL_op->op_flags & OPf_STACKED) ? (GV*)*++MARK : PL_defoutgv;
+ GV * const gv
+ = (PL_op->op_flags & OPf_STACKED) ? MUTABLE_GV(*++MARK) : PL_defoutgv;
if (gv && (io = GvIO(gv))
&& (mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar)))
RETURN;
}
else {
- gv = (GV*)sv;
+ gv = MUTABLE_GV(sv);
}
sv = is_pp_rv2av ? MUTABLE_SV(GvAVn(gv)) : MUTABLE_SV(GvHVn(gv));
if (PL_op->op_private & OPpLVAL_INTRO)
}
if (PL_op->op_private & OPpLVAL_INTRO) {
if (HvNAME_get(hv) && isGV(*svp))
- save_gp((GV*)*svp, !(PL_op->op_flags & OPf_SPECIAL));
+ save_gp(MUTABLE_GV(*svp), !(PL_op->op_flags & OPf_SPECIAL));
else {
if (!preeminent) {
STRLEN keylen;
case SVt_PVGV:
if (!isGV_with_GP(sv))
DIE(aTHX_ "Not a CODE reference");
- if (!(cv = GvCVu((GV*)sv))) {
+ if (!(cv = GvCVu((const GV *)sv))) {
HV *stash;
cv = sv_2cv(sv, &stash, &gv, 0);
}
if (!ob || !(SvOBJECT(ob)
|| (SvTYPE(ob) == SVt_PVGV
&& isGV_with_GP(ob)
- && (ob = MUTABLE_SV(GvIO((GV*)ob)))
+ && (ob = MUTABLE_SV(GvIO((const GV *)ob)))
&& SvOBJECT(ob))))
{
Perl_croak(aTHX_ "Can't call method \"%s\" on unblessed reference",
if (hashp) {
const HE* const he = hv_fetch_ent(stash, meth, 0, *hashp);
if (he) {
- gv = (GV*)HeVAL(he);
+ gv = MUTABLE_GV(HeVAL(he));
if (isGV(gv) && GvCV(gv) &&
(!GvCVGEN(gv) || GvCVGEN(gv)
== (PL_sub_generation + HvMROMETA(stash)->cache_gen)))
#endif /* !VMS */
SAVESPTR(PL_last_in_gv); /* We don't want this to be permanent. */
- PL_last_in_gv = (GV*)*PL_stack_sp--;
+ PL_last_in_gv = MUTABLE_GV(*PL_stack_sp--);
SAVESPTR(PL_rs); /* This is not permanent, either. */
PL_rs = newSVpvs_flags("\000", SVs_TEMP);
STRLEN len;
bool ok;
- GV * const gv = (GV *)*++MARK;
+ GV * const gv = MUTABLE_GV(*++MARK);
if (!isGV(gv))
DIE(aTHX_ PL_no_usym, "filehandle");
PP(pp_close)
{
dVAR; dSP;
- GV * const gv = (MAXARG == 0) ? PL_defoutgv : (GV*)POPs;
+ GV * const gv = (MAXARG == 0) ? PL_defoutgv : MUTABLE_GV(POPs);
if (gv) {
IO * const io = GvIO(gv);
register IO *wstio;
int fd[2];
- GV * const wgv = (GV*)POPs;
- GV * const rgv = (GV*)POPs;
+ GV * const wgv = MUTABLE_GV(POPs);
+ GV * const rgv = MUTABLE_GV(POPs);
if (!rgv || !wgv)
goto badexit;
if (MAXARG < 1)
RETPUSHUNDEF;
- gv = (GV*)POPs;
+ gv = MUTABLE_GV(POPs);
if (gv && (io = GvIO(gv))
&& (mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar)))
discp = POPs;
}
- gv = (GV*)POPs;
+ gv = MUTABLE_GV(POPs);
if (gv && (io = GvIO(gv))) {
MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar);
case SVt_PVGV:
if (isGV_with_GP(varsv)) {
#ifdef GV_UNIQUE_CHECK
- if (GvUNIQUE((GV*)varsv)) {
+ if (GvUNIQUE((const GV *)varsv)) {
Perl_croak(aTHX_ "Attempt to tie unique GV");
}
#endif
{
dVAR; dSP; dTARGET;
HV *hv;
- GV * const newdefout = (PL_op->op_private > 0) ? ((GV *) POPs) : NULL;
+ GV * const newdefout = (PL_op->op_private > 0) ? (MUTABLE_GV(POPs)) : NULL;
GV * egv = GvEGV(PL_defoutgv);
if (!egv)
{
dVAR; dSP; dTARGET;
IO *io = NULL;
- GV * const gv = (MAXARG==0) ? PL_stdingv : (GV*)POPs;
+ GV * const gv = (MAXARG==0) ? PL_stdingv : MUTABLE_GV(POPs);
if (gv && (io = GvIO(gv))) {
MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar);
if (MAXARG == 0)
gv = PL_defoutgv;
else {
- gv = (GV*)POPs;
+ gv = MUTABLE_GV(POPs);
if (!gv)
gv = PL_defoutgv;
}
PerlIO *fp;
SV *sv;
- GV * const gv = (PL_op->op_flags & OPf_STACKED) ? (GV*)*++MARK : PL_defoutgv;
+ GV * const gv
+ = (PL_op->op_flags & OPf_STACKED) ? MUTABLE_GV(*++MARK) : PL_defoutgv;
if (gv && (io = GvIO(gv))) {
MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar);
const int perm = (MAXARG > 3) ? POPi : 0666;
const int mode = POPi;
SV * const sv = POPs;
- GV * const gv = (GV *)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
STRLEN len;
/* Need TIEHANDLE method ? */
STRLEN charskip = 0;
STRLEN skip = 0;
- GV * const gv = (GV*)*++MARK;
+ GV * const gv = MUTABLE_GV(*++MARK);
if ((PL_op->op_type == OP_READ || PL_op->op_type == OP_SYSREAD)
&& gv && (io = GvIO(gv)) )
{
bool doing_utf8;
U8 *tmpbuf = NULL;
- GV *const gv = (GV*)*++MARK;
+ GV *const gv = MUTABLE_GV(*++MARK);
if (PL_op->op_type == OP_SYSWRITE
&& gv && (io = GvIO(gv))) {
MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar);
gv = PL_last_in_gv; /* eof */
}
else
- gv = PL_last_in_gv = (GV*)POPs; /* eof(FH) */
+ gv = PL_last_in_gv = MUTABLE_GV(POPs); /* eof(FH) */
if (gv) {
IO * const io = GvIO(gv);
IO *io;
if (MAXARG != 0)
- PL_last_in_gv = (GV*)POPs;
+ PL_last_in_gv = MUTABLE_GV(POPs);
gv = PL_last_in_gv;
if (gv && (io = GvIO(gv))) {
const Off_t offset = (Off_t)SvIVx(POPs);
#endif
- GV * const gv = PL_last_in_gv = (GV*)POPs;
+ GV * const gv = PL_last_in_gv = MUTABLE_GV(POPs);
IO *io;
if (gv && (io = GvIO(gv))) {
const char *name;
if (isGV_with_GP(sv)) {
- tmpgv = (GV*)sv; /* *main::FRED for example */
+ tmpgv = MUTABLE_GV(sv); /* *main::FRED for example */
goto do_ftruncate_gv;
}
else if (SvROK(sv) && isGV_with_GP(SvRV(sv))) {
- tmpgv = (GV*) SvRV(sv); /* \*main::FRED for example */
+ tmpgv = MUTABLE_GV(SvRV(sv)); /* \*main::FRED for example */
goto do_ftruncate_gv;
}
else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVIO) {
SV * const argsv = POPs;
const unsigned int func = POPu;
const int optype = PL_op->op_type;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
IO * const io = gv ? GvIOn(gv) : NULL;
char *s;
IV retval;
IO *io = NULL;
PerlIO *fp;
const int argtype = POPi;
- GV * const gv = (MAXARG == 0) ? PL_last_in_gv : (GV*)POPs;
+ GV * const gv = (MAXARG == 0) ? PL_last_in_gv : MUTABLE_GV(POPs);
if (gv && (io = GvIO(gv)))
fp = IoIFP(io);
const int protocol = POPi;
const int type = POPi;
const int domain = POPi;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = gv ? GvIOn(gv) : NULL;
int fd;
const int protocol = POPi;
const int type = POPi;
const int domain = POPi;
- GV * const gv2 = (GV*)POPs;
- GV * const gv1 = (GV*)POPs;
+ GV * const gv2 = MUTABLE_GV(POPs);
+ GV * const gv1 = MUTABLE_GV(POPs);
register IO * const io1 = gv1 ? GvIOn(gv1) : NULL;
register IO * const io2 = gv2 ? GvIOn(gv2) : NULL;
int fd[2];
SV * const addrsv = POPs;
/* OK, so on what platform does bind modify addr? */
const char *addr;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = GvIOn(gv);
STRLEN len;
#ifdef HAS_SOCKET
dVAR; dSP;
SV * const addrsv = POPs;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = GvIOn(gv);
const char *addr;
STRLEN len;
#ifdef HAS_SOCKET
dVAR; dSP;
const int backlog = POPi;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = gv ? GvIOn(gv) : NULL;
if (!gv || !io || !IoIFP(io))
#else
Sock_size_t len = sizeof namebuf;
#endif
- GV * const ggv = (GV*)POPs;
- GV * const ngv = (GV*)POPs;
+ GV * const ggv = MUTABLE_GV(POPs);
+ GV * const ngv = MUTABLE_GV(POPs);
int fd;
if (!ngv)
#ifdef HAS_SOCKET
dVAR; dSP; dTARGET;
const int how = POPi;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = GvIOn(gv);
if (!io || !IoIFP(io))
SV * const sv = (optype == OP_GSOCKOPT) ? sv_2mortal(newSV(257)) : POPs;
const unsigned int optname = (unsigned int) POPi;
const unsigned int lvl = (unsigned int) POPi;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = GvIOn(gv);
int fd;
Sock_size_t len;
#ifdef HAS_SOCKET
dVAR; dSP;
const int optype = PL_op->op_type;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = GvIOn(gv);
Sock_size_t len;
SV *sv;
else {
SV* const sv = POPs;
if (isGV_with_GP(sv)) {
- gv = (GV*)sv;
+ gv = MUTABLE_GV(sv);
goto do_fstat;
} else if(SvROK(sv) && isGV_with_GP(SvRV(sv))) {
- gv = (GV*)SvRV(sv);
+ gv = MUTABLE_GV(SvRV(sv));
if (PL_op->op_type == OP_LSTAT)
goto do_fstat_warning_check;
goto do_fstat;
if (PL_op->op_flags & OPf_REF)
gv = cGVOP_gv;
else if (isGV(TOPs))
- gv = (GV*)POPs;
+ gv = MUTABLE_GV(POPs);
else if (SvROK(TOPs) && isGV(SvRV(TOPs)))
- gv = (GV*)SvRV(POPs);
+ gv = MUTABLE_GV(SvRV(POPs));
else
gv = gv_fetchsv(tmpsv = POPs, 0, SVt_PVIO);
if (PL_op->op_flags & OPf_REF)
gv = cGVOP_gv;
else if (isGV(TOPs))
- gv = (GV*)POPs;
+ gv = MUTABLE_GV(POPs);
else if (SvROK(TOPs) && isGV(SvRV(TOPs)))
- gv = (GV*)SvRV(POPs);
+ gv = MUTABLE_GV(SvRV(POPs));
else
gv = NULL;
gv = gv_fetchsv(sv, 0, SVt_PVIO);
}
else if (isGV_with_GP(sv)) {
- gv = (GV*)sv;
+ gv = MUTABLE_GV(sv);
}
else if (SvROK(sv) && isGV_with_GP(SvRV(sv))) {
- gv = (GV*)SvRV(sv);
+ gv = MUTABLE_GV(SvRV(sv));
}
else {
tmps = SvPV_nolen_const(sv);
#if defined(Direntry_t) && defined(HAS_READDIR)
dVAR; dSP;
const char * const dirname = POPpconstx;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = GvIOn(gv);
if (!io)
SV *sv;
const I32 gimme = GIMME;
- GV * const gv = (GV *)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register const Direntry_t *dp;
register IO * const io = GvIOn(gv);
# if !defined(HAS_TELLDIR_PROTO) || defined(NEED_TELLDIR_PROTO)
long telldir (DIR *);
# endif
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = GvIOn(gv);
if (!io || !IoDIRP(io)) {
#if defined(HAS_SEEKDIR) || defined(seekdir)
dVAR; dSP;
const long along = POPl;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = GvIOn(gv);
if (!io || !IoDIRP(io)) {
{
#if defined(HAS_REWINDDIR) || defined(rewinddir)
dVAR; dSP;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = GvIOn(gv);
if (!io || !IoDIRP(io)) {
{
#if defined(Direntry_t) && defined(HAS_READDIR)
dVAR; dSP;
- GV * const gv = (GV*)POPs;
+ GV * const gv = MUTABLE_GV(POPs);
register IO * const io = GvIOn(gv);
if (!io || !IoDIRP(io)) {
break;
case SAVEt_SV: /* scalar reference */
value = MUTABLE_SV(SSPOPPTR);
- gv = (GV*)SSPOPPTR;
+ gv = MUTABLE_GV(SSPOPPTR);
ptr = &GvSV(gv);
av = MUTABLE_AV(gv); /* what to refcnt_dec */
restore_sv:
break;
case SAVEt_AV: /* array reference */
av = MUTABLE_AV(SSPOPPTR);
- gv = (GV*)SSPOPPTR;
+ gv = MUTABLE_GV(SSPOPPTR);
if (GvAV(gv)) {
SvREFCNT_dec(GvAV(gv));
}
break;
case SAVEt_HV: /* hash reference */
hv = MUTABLE_HV(SSPOPPTR);
- gv = (GV*)SSPOPPTR;
+ gv = MUTABLE_GV(SSPOPPTR);
if (GvHV(gv)) {
SvREFCNT_dec(GvHV(gv));
}
break;
case SAVEt_GP: /* scalar reference */
ptr = SSPOPPTR;
- gv = (GV*)SSPOPPTR;
+ gv = MUTABLE_GV(SSPOPPTR);
gp_free(gv);
GvGP(gv) = (GP*)ptr;
/* putting a method back into circulation ("local")*/
/* These are only saved in mathoms.c */
case SAVEt_NSTAB:
- gv = (GV*)SSPOPPTR;
+ gv = MUTABLE_GV(SSPOPPTR);
(void)sv_clear(MUTABLE_SV(gv));
break;
case SAVEt_LONG: /* long reference */
}
else {
if (isGV_with_GP(sv))
- return glob_2number((GV *)sv);
+ return glob_2number(MUTABLE_GV(sv));
if (!(SvFLAGS(sv) & SVs_PADTMP)) {
if (!PL_localizing && ckWARN(WARN_UNINITIALIZED))
}
else {
if (isGV_with_GP(sv)) {
- glob_2number((GV *)sv);
+ glob_2number(MUTABLE_GV(sv));
return 0.0;
}
}
else {
if (isGV_with_GP(sv))
- return glob_2pv((GV *)sv, lp);
+ return glob_2pv(MUTABLE_GV(sv), lp);
if (lp)
*lp = 0;
GvSTASH(dstr) = GvSTASH(sstr);
if (GvSTASH(dstr))
Perl_sv_add_backref(aTHX_ MUTABLE_SV(GvSTASH(dstr)), dstr);
- gv_name_set((GV *)dstr, name, len, GV_ADD);
+ gv_name_set(MUTABLE_GV(dstr), name, len, GV_ADD);
SvFAKE_on(dstr); /* can coerce to non-glob */
}
#ifdef GV_UNIQUE_CHECK
- if (GvUNIQUE((GV*)dstr)) {
+ if (GvUNIQUE((const GV *)dstr)) {
Perl_croak(aTHX_ PL_no_modify);
}
#endif
- if(GvGP((GV*)sstr)) {
+ if(GvGP(MUTABLE_GV(sstr))) {
/* If source has method cache entry, clear it */
if(GvCVGEN(sstr)) {
SvREFCNT_dec(GvCV(sstr));
}
/* If source has a real method, then a method is
going to change */
- else if(GvCV((GV*)sstr)) {
+ else if(GvCV((const GV *)sstr)) {
mro_changes = 1;
}
}
/* If dest already had a real method, that's a change as well */
- if(!mro_changes && GvGP((GV*)dstr) && GvCVu((GV*)dstr)) {
+ if(!mro_changes && GvGP(MUTABLE_GV(dstr)) && GvCVu((const GV *)dstr)) {
mro_changes = 1;
}
- if(strEQ(GvNAME((GV*)dstr),"ISA"))
+ if(strEQ(GvNAME((const GV *)dstr),"ISA"))
mro_changes = 2;
- gp_free((GV*)dstr);
+ gp_free(MUTABLE_GV(dstr));
isGV_with_GP_off(dstr);
(void)SvOK_off(dstr);
isGV_with_GP_on(dstr);
PERL_ARGS_ASSERT_GLOB_ASSIGN_REF;
#ifdef GV_UNIQUE_CHECK
- if (GvUNIQUE((GV*)dstr)) {
+ if (GvUNIQUE((const GV *)dstr)) {
Perl_croak(aTHX_ PL_no_modify);
}
#endif
if (intro) {
GvINTRO_off(dstr); /* one-shot flag */
GvLINE(dstr) = CopLINE(PL_curcop);
- GvEGV(dstr) = (GV*)dstr;
+ GvEGV(dstr) = MUTABLE_GV(dstr);
}
GvMULTI_on(dstr);
switch (stype) {
if (stype == SVt_PVCV && (*location != sref || GvCVGEN(dstr))) {
CV* const cv = MUTABLE_CV(*location);
if (cv) {
- if (!GvCVGEN((GV*)dstr) &&
+ if (!GvCVGEN((const GV *)dstr) &&
(CvROOT(cv) || CvXSUB(cv)))
{
/* Redefining a sub - warning is mandatory if
(CvCONST(cv)
? "Constant subroutine %s::%s redefined"
: "Subroutine %s::%s redefined"),
- HvNAME_get(GvSTASH((GV*)dstr)),
- GvENAME((GV*)dstr));
+ HvNAME_get(GvSTASH((const GV *)dstr)),
+ GvENAME(MUTABLE_GV(dstr)));
}
}
if (!intro)
- cv_ckproto_len(cv, (GV*)dstr,
+ cv_ckproto_len(cv, (const GV *)dstr,
SvPOK(sref) ? SvPVX_const(sref) : NULL,
SvPOK(sref) ? SvCUR(sref) : 0);
}
GV *gv = gv_fetchsv(sstr, GV_ADD, SVt_PVGV);
if (dstr != (const SV *)gv) {
if (GvGP(dstr))
- gp_free((GV*)dstr);
+ gp_free(MUTABLE_GV(dstr));
GvGP(dstr) = gp_ref(GvGP(gv));
}
}
/* FAKE globs can get coerced, so need to turn this off
temporarily if it is on. */
SvFAKE_off(sstr);
- gv_efullname3(dstr, (GV *)sstr, "*");
+ gv_efullname3(dstr, MUTABLE_GV(sstr), "*");
SvFLAGS(sstr) |= wasfake;
}
else
SvREFCNT_dec(LvTARG(sv));
case SVt_PVGV:
if (isGV_with_GP(sv)) {
- if(GvCVu((GV*)sv) && (stash = GvSTASH((GV*)sv)) && HvNAME_get(stash))
+ if(GvCVu((const GV *)sv) && (stash = GvSTASH(MUTABLE_GV(sv)))
+ && HvNAME_get(stash))
mro_method_changed_in(stash);
- gp_free((GV*)sv);
+ gp_free(MUTABLE_GV(sv));
if (GvNAME_HEK(sv))
unshare_hek(GvNAME_HEK(sv));
/* If we're in a stash, we don't own a reference to it. However it does
/* FIXME. There are probably more unreferenced pointers to SVs in the
interpreter struct that we should check and tidy in a similar
fashion to this: */
- if ((GV*)sv == PL_last_in_gv)
+ if ((const GV *)sv == PL_last_in_gv)
PL_last_in_gv = NULL;
case SVt_PVMG:
case SVt_PVNV:
if (!todo[(U8)*HeKEY(entry)])
continue;
- gv = (GV*)HeVAL(entry);
+ gv = MUTABLE_GV(HeVAL(entry));
sv = GvSV(gv);
if (sv) {
if (SvTHINKFIRST(sv)) {
break;
case SVt_PVGV:
if (isGV_with_GP(sv)) {
- gv = (GV*)sv;
+ gv = MUTABLE_GV(sv);
io = GvIO(gv);
if (!io)
Perl_croak(aTHX_ "Bad filehandle: %s", GvNAME(gv));
return NULL;
case SVt_PVGV:
if (isGV_with_GP(sv)) {
- gv = (GV*)sv;
+ gv = MUTABLE_GV(sv);
*gvp = gv;
*st = GvESTASH(gv);
goto fix_gv;
return cv;
}
else if(isGV_with_GP(sv))
- gv = (GV*)sv;
+ gv = MUTABLE_GV(sv);
else
Perl_croak(aTHX_ "Not a subroutine reference");
}
else if (isGV_with_GP(sv)) {
SvGETMAGIC(sv);
- gv = (GV*)sv;
+ gv = MUTABLE_GV(sv);
}
else
gv = gv_fetchsv(sv, lref, SVt_PVCV); /* Calls get magic */
assert(SvTYPE(sv) == SVt_PVGV);
SvFAKE_off(sv);
- gv_efullname3(temp, (GV *) sv, "*");
+ gv_efullname3(temp, MUTABLE_GV(sv), "*");
if (GvGP(sv)) {
- if(GvCVu((GV*)sv) && (stash = GvSTASH((GV*)sv)) && HvNAME_get(stash))
+ if(GvCVu((const GV *)sv) && (stash = GvSTASH(MUTABLE_GV(sv)))
+ && HvNAME_get(stash))
mro_method_changed_in(stash);
- gp_free((GV*)sv);
+ gp_free(MUTABLE_GV(sv));
}
if (GvSTASH(sv)) {
sv_del_backref(MUTABLE_SV(GvSTASH(sv)), sv);
#define cv_dup_inc(s,t) MUTABLE_CV(SvREFCNT_inc(sv_dup((const SV *)s,t)))
#define io_dup(s,t) MUTABLE_IO(sv_dup((const SV *)s,t))
#define io_dup_inc(s,t) MUTABLE_IO(SvREFCNT_inc(sv_dup((const SV *)s,t)))
-#define gv_dup(s,t) (GV*)sv_dup((const SV *)s,t)
-#define gv_dup_inc(s,t) (GV*)SvREFCNT_inc(sv_dup((const SV *)s,t))
+#define gv_dup(s,t) MUTABLE_GV(sv_dup((const SV *)s,t))
+#define gv_dup_inc(s,t) MUTABLE_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)
break;
case SVt_PVGV:
- if (GvUNIQUE((GV*)sstr)) {
+ if (GvUNIQUE((const GV *)sstr)) {
NOOP; /* Do sharing here, and fall through */
}
case SVt_PVIO:
ncx->blk_loop.oldcomppad);
} else {
ncx->blk_loop.oldcomppad
- = (PAD*)gv_dup((GV*)ncx->blk_loop.oldcomppad, param);
+ = (PAD*)gv_dup((const GV *)ncx->blk_loop.oldcomppad,
+ param);
}
break;
case CXt_FORMAT:
gp = (GP*)POPPTR(ss,ix);
TOPPTR(nss,ix) = gp = gp_dup(gp, param);
(void)GpREFCNT_inc(gp);
- gv = (GV*)POPPTR(ss,ix);
+ gv = (const GV *)POPPTR(ss,ix);
TOPPTR(nss,ix) = gv_dup_inc(gv, param);
break;
case SAVEt_FREEOP:
}
sv = POPs;
- gv = (GV*)sv;
+ gv = MUTABLE_GV(sv);
if (!isGV(sv)) {
if (SvROK(sv) && isGV(SvRV(sv)))
- gv = (GV*)SvRV(sv);
+ gv = MUTABLE_GV(SvRV(sv));
else if (SvPOKp(sv))
gv = gv_fetchsv(sv, 0, SVt_PVIO);
}
if ( svp && ((CvFLAGS(cv) & (CVf_ANON | CVf_CLONED))
|| strEQ(GvNAME(gv), "END")
|| ((GvCV(gv) != cv) && /* Could be imported, and old sub redefined. */
- !( (SvTYPE(*svp) == SVt_PVGV) && (GvCV((GV*)*svp) == cv) )))) {
+ !( (SvTYPE(*svp) == SVt_PVGV)
+ && (GvCV((const GV *)*svp) == cv) )))) {
/* Use GV from the stack as a fallback. */
/* GV is potentially non-unique, or contain different CV. */
SV * const tmp = newRV(MUTABLE_SV(cv));
stash = CvSTASH(sv);
break;
case SVt_PVGV:
- if (isGV_with_GP(sv) && GvGP(sv) && GvESTASH((GV*)sv))
- stash = GvESTASH((GV*)sv);
+ if (isGV_with_GP(sv) && GvGP(sv) && GvESTASH(MUTABLE_GV(sv)))
+ stash = GvESTASH(MUTABLE_GV(sv));
break;
default:
break;