summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-12-16 23:03:42 +0000
committerNicholas Clark <nick@ccl4.org>2006-12-16 23:03:42 +0000
commit1ccdb7301362000755034d5e6a7e73f566973104 (patch)
tree0fa142dae37f66fff801c799e2f2d0829fbdec0b /gv.c
parent2e5b91de24d62e1e2bf0fd32a1d4d1d849cafc82 (diff)
downloadperl-1ccdb7301362000755034d5e6a7e73f566973104.tar.gz
Add a new flag SVprv_PCS_IMPORTED (which is a pseudonym for SVf_SCREAM)
to note when a proxy constant subroutine is copied. This allows us to correctly set GvIMPORTED_CV_on() if the symbol is ever turned into a real GV. p4raw-id: //depot/perl@29566
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gv.c b/gv.c
index fc22aeb131..394e684ad5 100644
--- a/gv.c
+++ b/gv.c
@@ -191,6 +191,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
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;
+ const U32 exported_constant = has_constant ? SvPCS_IMPORTED(gv) : 0;
assert (!(proto && has_constant));
@@ -239,6 +240,11 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
if (has_constant) {
/* newCONSTSUB takes ownership of the reference from us. */
GvCV(gv) = newCONSTSUB(stash, name, has_constant);
+ /* If this reference was a copy of another, then the subroutine
+ must have been "imported", by a Perl space assignment to a GV
+ from a reference to CV. */
+ if (exported_constant)
+ GvIMPORTED_CV_on(gv);
} else {
/* XXX unsafe for threads if eval_owner isn't held */
(void) start_subparse(0,0); /* Create empty CV in compcv. */