* if it walks like a dirhandle, then let's assume that
* this is a dirhandle.
*/
- const char *fh = PL_op->op_type == OP_READDIR ||
+ const char * const fh =
+ PL_op->op_type == OP_READDIR ||
PL_op->op_type == OP_TELLDIR ||
PL_op->op_type == OP_SEEKDIR ||
PL_op->op_type == OP_REWINDDIR ||
{
dVAR;
register GP *gp;
- const bool doproto = SvTYPE(gv) > SVt_NULL;
+ const U32 old_type = SvTYPE(gv);
+ const bool doproto = old_type > SVt_NULL;
const char * const proto = (doproto && SvPOK(gv)) ? SvPVX_const(gv) : NULL;
SV *const has_constant = doproto && SvROK(gv) ? SvRV(gv) : NULL;
SvROK_off(gv);
}
- sv_upgrade((SV*)gv, SVt_PVGV);
+
+ if (old_type < SVt_PVGV) {
+ if (old_type >= SVt_PV)
+ SvCUR_set(gv, 0);
+ sv_upgrade((SV*)gv, SVt_PVGV);
+ }
if (SvLEN(gv)) {
if (proto) {
SvPV_set(gv, NULL);
Safefree(SvPVX_mutable(gv));
}
Newxz(gp, 1, GP);
+ SvSCREAM_on(gv);
GvGP(gv) = gp_ref(gp);
#ifdef PERL_DONT_CREATE_GVSV
GvSV(gv) = NULL;
GvFILE(gv) = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : (char *) "";
GvCVGEN(gv) = 0;
GvEGV(gv) = gv;
- sv_magic((SV*)gv, (SV*)gv, PERL_MAGIC_glob, NULL, 0);
- SvSCREAM_on(gv);
GvSTASH(gv) = stash;
if (stash)
Perl_sv_add_backref(aTHX_ (SV*)stash, (SV*)gv);
- GvNAME(gv) = savepvn(name, len);
- GvNAMELEN(gv) = len;
+ gv_name_set(gv, name, len, GV_ADD);
if (multi || doproto) /* doproto means it _was_ mentioned */
GvMULTI_on(gv);
if (doproto) { /* Replicate part of newSUB here. */
if (SvTYPE(gv) != SVt_PVGV)
gv_init(gv, stash, "ISA", 3, TRUE);
SvREFCNT_dec(GvAV(gv));
- GvAV(gv) = (AV*)SvREFCNT_inc(av);
+ GvAV(gv) = (AV*)SvREFCNT_inc_simple(av);
}
}
}
--nsplit;
if ((nsplit - origname) == 5 && strnEQ(origname, "SUPER", 5)) {
/* ->SUPER::method should really be looked up in original stash */
- SV *tmpstr = sv_2mortal(Perl_newSVpvf(aTHX_ "%s::SUPER",
+ SV * const tmpstr = sv_2mortal(Perl_newSVpvf(aTHX_ "%s::SUPER",
CopSTASHPV(PL_curcop)));
/* __PACKAGE__::SUPER stash should be autovivified */
stash = gv_stashpvn(SvPVX_const(tmpstr), SvCUR(tmpstr), TRUE);
goto ro_magicalize;
if (strEQ(name2, "TF8LOCALE"))
goto ro_magicalize;
+ if (strEQ(name2, "TF8CACHE"))
+ goto magicalize;
break;
case '\027': /* $^WARNING_BITS */
if (strEQ(name2, "ARNING_BITS"))
{
dVAR;
return gv_fetchpv(Perl_form(aTHX_ "%s::_GEN_%ld", pack, (long)PL_gensym++),
- TRUE, SVt_PVGV);
+ GV_ADD, SVt_PVGV);
}
/* hopefully this is only called on local symbol table entries */
dVAR;
GP* gp;
- if (!gv || !(gp = GvGP(gv)))
+ if (!gv || !isGV_with_GP(gv) || !(gp = GvGP(gv)))
return;
if (gp->gp_refcnt == 0) {
if (ckWARN_d(WARN_INTERNAL))
if (--gp->gp_refcnt > 0) {
if (gp->gp_egv == gv)
gp->gp_egv = 0;
+ GvGP(gv) = 0;
return;
}
int i;
for (i = 1; i < NofAMmeth; i++) {
CV * const cv = amtp->table[i];
- if (cv != NULL) {
+ if (cv) {
SvREFCNT_dec((SV *) cv);
amtp->table[i] = NULL;
}
cv = (CV*)gv;
filled = 1;
}
- amt.table[i]=(CV*)SvREFCNT_inc(cv);
+ amt.table[i]=(CV*)SvREFCNT_inc_simple(cv);
}
if (filled) {
AMT_AMAGIC_on(&amt);
CATCH_SET(TRUE);
Zero(&myop, 1, BINOP);
myop.op_last = (OP *) &myop;
- myop.op_next = Nullop;
+ myop.op_next = NULL;
myop.op_flags = OPf_WANT_SCALAR | OPf_STACKED;
PUSHSTACKi(PERLSI_OVERLOAD);
bool
Perl_is_gv_magical(pTHX_ const char *name, STRLEN len, U32 flags)
{
+ PERL_UNUSED_CONTEXT;
PERL_UNUSED_ARG(flags);
if (len > 1) {
return FALSE;
}
+void
+Perl_gv_name_set(pTHX_ GV *gv, const char *name, U32 len, U32 flags)
+{
+ dVAR;
+ U32 hash;
+
+ PERL_UNUSED_ARG(flags);
+
+ if (len > I32_MAX)
+ Perl_croak(aTHX_ "panic: gv name too long (%"UVuf")", (UV) len);
+
+ if (!(flags & GV_ADD) && GvNAME_HEK(gv)) {
+ unshare_hek(GvNAME_HEK(gv));
+ }
+
+ PERL_HASH(hash, name, len);
+ GvNAME_HEK(gv) = name ? share_hek(name, len, hash) : 0;
+}
+
/*
* Local variables:
* c-indentation-style: bsd