summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embed.fnc1
-rw-r--r--embed.h2
-rw-r--r--gv.c36
-rw-r--r--proto.h3
-rw-r--r--scope.c14
5 files changed, 30 insertions, 26 deletions
diff --git a/embed.fnc b/embed.fnc
index 55f65fbd37..9e32b5e197 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -282,6 +282,7 @@ Ap |GV* |gv_fetchpv |NN const char* name|I32 add|I32 sv_type
Ap |void |gv_fullname |NN SV* sv|NN const GV* gv
Apmb |void |gv_fullname3 |NN SV* sv|NN const GV* gv|NULLOK const char* prefix
Ap |void |gv_fullname4 |NN SV* sv|NN const GV* gv|NULLOK const char* prefix|bool keepmain
+pMox |GP * |newGP |NN GV *const gv
Ap |void |gv_init |NN GV* gv|NULLOK HV* stash|NN const char* name|STRLEN len|int multi
Ap |void |gv_name_set |NN GV* gv|NN const char *name|U32 len|U32 flags
Apd |HV* |gv_stashpv |NN const char* name|I32 create
diff --git a/embed.h b/embed.h
index 8476916a85..7000eb0d12 100644
--- a/embed.h
+++ b/embed.h
@@ -2430,6 +2430,8 @@
#define gv_fetchpv(a,b,c) Perl_gv_fetchpv(aTHX_ a,b,c)
#define gv_fullname(a,b) Perl_gv_fullname(aTHX_ a,b)
#define gv_fullname4(a,b,c,d) Perl_gv_fullname4(aTHX_ a,b,c,d)
+#ifdef PERL_CORE
+#endif
#define gv_init(a,b,c,d,e) Perl_gv_init(aTHX_ a,b,c,d,e)
#define gv_name_set(a,b,c,d) Perl_gv_name_set(aTHX_ a,b,c,d)
#define gv_stashpv(a,b) Perl_gv_stashpv(aTHX_ a,b)
diff --git a/gv.c b/gv.c
index 32a3aa6f82..b57060ca5c 100644
--- a/gv.c
+++ b/gv.c
@@ -157,11 +157,30 @@ Perl_gv_const_sv(pTHX_ GV *gv)
return SvROK(gv) ? SvRV(gv) : NULL;
}
+GP *
+Perl_newGP(pTHX_ GV *const gv)
+{
+ GP *gp;
+ Newxz(gp, 1, GP);
+
+#ifndef PERL_DONT_CREATE_GVSV
+ gp->gv_sv = newSV(0);
+#endif
+
+ gp->gp_line = CopLINE(PL_curcop);
+ /* XXX Ideally this cast would be replaced with a change to const char*
+ in the struct. */
+ gp->gp_file = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : (char *) "";
+ gp->gp_egv = gv;
+ gp->gp_refcnt = 1;
+
+ return gp;
+}
+
void
Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
{
dVAR;
- register GP *gp;
const U32 old_type = SvTYPE(gv);
const bool doproto = old_type > SVt_NULL;
const char * const proto = (doproto && SvPOK(gv)) ? SvPVX_const(gv) : NULL;
@@ -198,20 +217,9 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
} else
Safefree(SvPVX_mutable(gv));
}
- Newxz(gp, 1, GP);
SvSCREAM_on(gv);
- GvGP(gv) = gp_ref(gp);
-#ifdef PERL_DONT_CREATE_GVSV
- GvSV(gv) = NULL;
-#else
- GvSV(gv) = newSV(0);
-#endif
- GvLINE(gv) = CopLINE(PL_curcop);
- /* XXX Ideally this cast would be replaced with a change to const char*
- in the struct. */
- GvFILE(gv) = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : (char *) "";
- GvCVGEN(gv) = 0;
- GvEGV(gv) = gv;
+
+ GvGP(gv) = Perl_newGP(aTHX_ gv);
GvSTASH(gv) = stash;
if (stash)
Perl_sv_add_backref(aTHX_ (SV*)stash, (SV*)gv);
diff --git a/proto.h b/proto.h
index bd5d285edf..ed3faeafd6 100644
--- a/proto.h
+++ b/proto.h
@@ -645,6 +645,9 @@ PERL_CALLCONV void Perl_gv_fullname4(pTHX_ SV* sv, const GV* gv, const char* pre
__attribute__nonnull__(pTHX_1)
__attribute__nonnull__(pTHX_2);
+PERL_CALLCONV GP * Perl_newGP(pTHX_ GV *const gv)
+ __attribute__nonnull__(pTHX_1);
+
PERL_CALLCONV void Perl_gv_init(pTHX_ GV* gv, HV* stash, const char* name, STRLEN len, int multi)
__attribute__nonnull__(pTHX_1)
__attribute__nonnull__(pTHX_3);
diff --git a/scope.c b/scope.c
index 8e40e8e3e2..c0f3428c77 100644
--- a/scope.c
+++ b/scope.c
@@ -267,9 +267,7 @@ Perl_save_gp(pTHX_ GV *gv, I32 empty)
SSPUSHINT(SAVEt_GP);
if (empty) {
- register GP *gp;
-
- Newxz(gp, 1, GP);
+ GP *gp = Perl_newGP(aTHX_ gv);
if (GvCVu(gv))
PL_sub_generation++; /* taking a method out of circulation */
@@ -277,15 +275,7 @@ Perl_save_gp(pTHX_ GV *gv, I32 empty)
gp->gp_io = newIO();
IoFLAGS(gp->gp_io) |= IOf_ARGV|IOf_START;
}
- GvGP(gv) = gp_ref(gp);
-#ifndef PERL_DONT_CREATE_GVSV
- GvSV(gv) = newSV(0);
-#endif
- GvLINE(gv) = CopLINE(PL_curcop);
- /* XXX Ideally this cast would be replaced with a change to const char*
- in the struct. */
- GvFILE(gv) = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : (char *) "";
- GvEGV(gv) = gv;
+ GvGP(gv) = gp;
}
else {
gp_ref(GvGP(gv));