This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
introduce illegal symbols into null package so that gv_fetchpv(...,TRUE)
authorGurusamy Sarathy <gsar@cpan.org>
Sun, 16 Apr 2000 16:51:08 +0000 (16:51 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Sun, 16 Apr 2000 16:51:08 +0000 (16:51 +0000)
always returns a valid GV even when the symbol is trapped by strictures
(avoids coredumps)

TODO: the C<package;> hack needs similar treatment

p4raw-id: //depot/perl@5908

embedvar.h
gv.c
intrpvar.h
perl.c
perlapi.h
t/pragma/strict-vars

index e790976..889b4d4 100644 (file)
 #define PL_nomemok             (PERL_GET_INTERP->Inomemok)
 #define PL_nthreads            (PERL_GET_INTERP->Inthreads)
 #define PL_nthreads_cond       (PERL_GET_INTERP->Inthreads_cond)
+#define PL_nullstash           (PERL_GET_INTERP->Inullstash)
 #define PL_numeric_local       (PERL_GET_INTERP->Inumeric_local)
 #define PL_numeric_name                (PERL_GET_INTERP->Inumeric_name)
 #define PL_numeric_radix       (PERL_GET_INTERP->Inumeric_radix)
 #define PL_nomemok             (vTHX->Inomemok)
 #define PL_nthreads            (vTHX->Inthreads)
 #define PL_nthreads_cond       (vTHX->Inthreads_cond)
+#define PL_nullstash           (vTHX->Inullstash)
 #define PL_numeric_local       (vTHX->Inumeric_local)
 #define PL_numeric_name                (vTHX->Inumeric_name)
 #define PL_numeric_radix       (vTHX->Inumeric_radix)
 #define PL_nomemok             (aTHXo->interp.Inomemok)
 #define PL_nthreads            (aTHXo->interp.Inthreads)
 #define PL_nthreads_cond       (aTHXo->interp.Inthreads_cond)
+#define PL_nullstash           (aTHXo->interp.Inullstash)
 #define PL_numeric_local       (aTHXo->interp.Inumeric_local)
 #define PL_numeric_name                (aTHXo->interp.Inumeric_name)
 #define PL_numeric_radix       (aTHXo->interp.Inumeric_radix)
 #define PL_Inomemok            PL_nomemok
 #define PL_Inthreads           PL_nthreads
 #define PL_Inthreads_cond      PL_nthreads_cond
+#define PL_Inullstash          PL_nullstash
 #define PL_Inumeric_local      PL_numeric_local
 #define PL_Inumeric_name       PL_numeric_name
 #define PL_Inumeric_radix      PL_numeric_radix
diff --git a/gv.c b/gv.c
index be19355..5ab21b1 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -520,7 +520,6 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type)
     I32 len;
     register const char *namend;
     HV *stash = 0;
-    U32 add_gvflags = 0;
 
     if (*name == '*' && isALPHA(name[1])) /* accidental stringify on a GV? */
        name++;
@@ -653,8 +652,10 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type)
                  : sv_type == SVt_PVAV ? "@"
                  : sv_type == SVt_PVHV ? "%"
                  : ""), name));
+           stash = PL_nullstash;
        }
-       return Nullgv;
+       else
+           return Nullgv;
     }
 
     if (!SvREFCNT(stash))      /* symbol table under destruction */
@@ -680,7 +681,6 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type)
        Perl_warner(aTHX_ WARN_INTERNAL, "Had to create %s unexpectedly", nambeg);
     gv_init(gv, stash, name, len, add & GV_ADDMULTI);
     gv_init_sv(gv, sv_type);
-    GvFLAGS(gv) |= add_gvflags;
 
     if (isLEXWARN_on && isALPHA(name[0]) && ! ckWARN(WARN_ONCE))
         GvMULTI_on(gv) ;
index 39d14c9..8ed93f8 100644 (file)
@@ -443,3 +443,5 @@ PERLVAR(IProc,              struct IPerlProc*)
 #if defined(USE_ITHREADS)
 PERLVAR(Iptr_table,    PTR_TBL_t*)
 #endif
+
+PERLVAR(Inullstash,    HV *)           /* illegal symbols end up here */
diff --git a/perl.c b/perl.c
index 578fafc..04544b5 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -2425,6 +2425,7 @@ S_init_main_stash(pTHX)
     CopSTASH_set(&PL_compiling, PL_defstash);
     PL_debstash = GvHV(gv_fetchpv("DB::", GV_ADDMULTI, SVt_PVHV));
     PL_globalstash = GvHV(gv_fetchpv("CORE::GLOBAL::", GV_ADDMULTI, SVt_PVHV));
+    PL_nullstash = GvHV(gv_fetchpv("<none>::", GV_ADDMULTI, SVt_PVHV));
     /* We must init $/ before switches are processed. */
     sv_setpvn(get_sv("/", TRUE), "\n", 1);
 }
index 5e5ac28..634634c 100644 (file)
--- a/perlapi.h
+++ b/perlapi.h
@@ -382,6 +382,8 @@ START_EXTERN_C
 #define PL_nthreads            (*Perl_Inthreads_ptr(aTHXo))
 #undef  PL_nthreads_cond
 #define PL_nthreads_cond       (*Perl_Inthreads_cond_ptr(aTHXo))
+#undef  PL_nullstash
+#define PL_nullstash           (*Perl_Inullstash_ptr(aTHXo))
 #undef  PL_numeric_local
 #define PL_numeric_local       (*Perl_Inumeric_local_ptr(aTHXo))
 #undef  PL_numeric_name
index ae09742..2ccfef7 100644 (file)
@@ -55,7 +55,7 @@ Execution of - aborted due to compilation errors.
 
 # strict vars - error
 use strict 'vars' ;
-$fred ;
+<$fred> ;
 EXPECT
 Global symbol "$fred" requires explicit package name at - line 4.
 Execution of - aborted due to compilation errors.