This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Amazingly, it seems that none of the other GV specific macros are
authorNicholas Clark <nick@ccl4.org>
Sat, 25 Feb 2006 14:50:38 +0000 (14:50 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 25 Feb 2006 14:50:38 +0000 (14:50 +0000)
accessed unless the GV thinks that it is a GV.

p4raw-id: //depot/perl@27324

gv.h
sv.c

diff --git a/gv.h b/gv.h
index 1e4797a..4ba000d 100644 (file)
--- a/gv.h
+++ b/gv.h
@@ -24,32 +24,45 @@ struct gp {
 
 #define GvXPVGV(gv)    ((XPVGV*)SvANY(gv))
 
-/* MSVC++ 6.0 (_MSC_VER == 1200) can't compile pp_hot.c with DEBUGGING enabled
- * if we include the following assert(). Must be a compiler bug because it
- * works fine with MSVC++ 7.0. Borland (5.5.1) has the same problem. */
-#if defined(DEBUGGING) && \
-    ((!defined(_MSC_VER) || _MSC_VER > 1200) && !defined(__BORLANDC__))
-#  define GvGP(gv)     (*(assert(SvTYPE(gv) == SVt_PVGV || \
-                                 SvTYPE(gv) == SVt_PVLV), \
-                       assert(isGV_with_GP(gv)),       \
-                          &((gv)->sv_u.svu_gp)))
-#else
-#  define GvGP(gv)     ((gv)->sv_u.svu_gp)
-#endif
-
-#define GvNAME(gv)     (GvXPVGV(gv)->xgv_name)
-#define GvNAMELEN(gv)  (GvXPVGV(gv)->xgv_namelen)
-#define GvFLAGS(gv)    (GvXPVGV(gv)->xgv_flags)
 
 #if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
+#  define GvGP(gv)                                                     \
+       (*({GV *const shplep = (GV *) gv;                               \
+           assert(SvTYPE(shplep) == SVt_PVGV ||                        \
+           SvTYPE(shplep) == SVt_PVLV);                                \
+           assert(isGV_with_GP(shplep));                               \
+           &((shplep)->sv_u.svu_gp);}))
+#  define GvFLAGS(gv)                                                  \
+       (*({GV *const yaah  = (GV *) gv;                                \
+           assert(SvTYPE(yaah) == SVt_PVGV || SvTYPE(yaah) == SVt_PVLV); \
+           assert(isGV_with_GP(yaah));                                 \
+           &(GvXPVGV(yaah)->xgv_flags);}))
 #  define GvSTASH(gv)                                                  \
        (*({ GV *_gv = (GV *) gv;                                       \
+           assert(isGV_with_GP(_gv));                                  \
            assert(SvTYPE(_gv) == SVt_PVGV || SvTYPE(_gv) >= SVt_PVLV); \
            &(GvXPVGV(_gv)->xgv_stash);                                 \
         }))
+#  define GvNAME(gv)                                                   \
+       (*({ GV *zzzz = (GV *) gv;                                      \
+           assert(isGV_with_GP(zzzz));                                 \
+           assert(SvTYPE(zzzz) == SVt_PVGV || SvTYPE(zzzz) >= SVt_PVLV); \
+           &(GvXPVGV(zzzz)->xgv_name);                                 \
+        }))
+#  define GvNAMELEN(gv)                                                        \
+       (*({ GV *glank = (GV *) gv;                                     \
+           assert(isGV_with_GP(glank));                                \
+           assert(SvTYPE(glank) == SVt_PVGV || SvTYPE(glank) >= SVt_PVLV); \
+           &(GvXPVGV(glank)->xgv_namelen);                             \
+        }))
 #else
-#define GvSTASH(gv)    (GvXPVGV(gv)->xgv_stash)
+#  define GvGP(gv)     ((gv)->sv_u.svu_gp)
+#  define GvFLAGS(gv)  (GvXPVGV(gv)->xgv_flags)
+#  define GvSTASH(gv)  (GvXPVGV(gv)->xgv_stash)
+#  define GvNAME(gv)   (GvXPVGV(gv)->xgv_name)
+#  define GvNAMELEN(gv)        (GvXPVGV(gv)->xgv_namelen)
 #endif
+
 /*
 =head1 GV Functions
 
diff --git a/sv.c b/sv.c
index 6d550d9..7e7d631 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3191,6 +3191,8 @@ S_glob_assign_glob(pTHX_ SV *dstr, SV *sstr, const int dtype)
                SvCUR_set(dstr, 0);
            }
            sv_upgrade(dstr, SVt_PVGV);
+           (void)SvOK_off(dstr);
+           SvSCREAM_on(dstr);
        }
        GvSTASH(dstr) = GvSTASH(sstr);
        if (GvSTASH(dstr))
@@ -3209,8 +3211,8 @@ S_glob_assign_glob(pTHX_ SV *dstr, SV *sstr, const int dtype)
     gp_free((GV*)dstr);
     SvSCREAM_off(dstr);
     (void)SvOK_off(dstr);
-    GvINTRO_off(dstr);         /* one-shot flag */
     SvSCREAM_on(dstr);
+    GvINTRO_off(dstr);         /* one-shot flag */
     GvGP(dstr) = gp_ref(GvGP(sstr));
     if (SvTAINTED(sstr))
        SvTAINT(dstr);
@@ -7700,9 +7702,9 @@ S_sv_unglob(pTHX_ SV *sv)
        sv_del_backref((SV*)GvSTASH(sv), sv);
        GvSTASH(sv) = NULL;
     }
-    SvSCREAM_off(sv);
-    Safefree(GvNAME(sv));
     GvMULTI_off(sv);
+    Safefree(GvNAME(sv));
+    SvSCREAM_off(sv);
 
     /* need to keep SvANY(sv) in the right arena */
     xpvmg = new_XPVMG();