This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add a GV_NOADD_NOINIT flag to gv_fetch{pv,pvn,sv} that disables
authorNicholas Clark <nick@ccl4.org>
Tue, 20 Dec 2005 19:55:46 +0000 (19:55 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 20 Dec 2005 19:55:46 +0000 (19:55 +0000)
addition of new typeglobs, and also disables initialisation of any
typeglob placeholders. Needed to make the new constant subroutine
proxy references work efficiently.

p4raw-id: //depot/perl@26425

gv.c
gv.h

diff --git a/gv.c b/gv.c
index 97c3448..9e4dcad 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -722,7 +722,8 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
     I32 len;
     register const char *namend;
     HV *stash = 0;
-    const I32 add = flags & ~SVf_UTF8;
+    const I32 no_init = flags & (GV_NOADD_NOINIT | GV_NOINIT);
+    const I32 add = flags & ~SVf_UTF8 & ~ GV_NOADD_NOINIT;
 
     PERL_UNUSED_ARG(full_len);
 
@@ -887,7 +888,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
                require_errno(gv);
        }
        return gv;
-    } else if (add & GV_NOINIT) {
+    } else if (no_init) {
        return gv;
     }
 
diff --git a/gv.h b/gv.h
index f179494..73814a8 100644 (file)
--- a/gv.h
+++ b/gv.h
@@ -162,6 +162,11 @@ Return the SV from the GV.
 #define GV_ADDWARN     0x04    /* add, but warn if symbol wasn't already there */
 #define GV_ADDINEVAL   0x08    /* add, as though we're doing so within an eval */
 #define GV_NOINIT      0x10    /* add, but don't init symbol, if type != PVGV */
+/* This is used by toke.c to avoid turing placeholder constants in the symbol
+   table into full PVGVs with attached constant subroutines.  */
+#define GV_NOADD_NOINIT        0x20    /* Don't add the symbol if it's not there.
+                                  Don't init it if it is there but ! PVGV */
+
 /*      SVf_UTF8 (more accurately the return value from SvUTF8) is also valid
        as a flag to gv_fetch_pvn_flags, so ensure it lies outside this range.
 */