/* gv.c
*
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- * 2000, 2001, 2002, 2003, by Larry Wall and others
+ * 2000, 2001, 2002, 2003, 2004, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
/*
=head1 GV Functions
+
+A GV is a structure which corresponds to to a Perl typeglob, ie *foo.
+It is a structure that holds a pointer to a scalar, an array, a hash etc,
+corresponding to $foo, @foo, %foo.
+
+GVs are usually found as values in stashes (symbol table hashes) where
+Perl stores its global variables.
+
+=cut
*/
#include "EXTERN.h"
}
len = namend - name;
+ /* $_ should always be in main:: even when our'ed */
+ if (*name == '_' && !name[1])
+ stash = PL_defstash;
+
/* No stash in name, so see how we can default */
if (!stash) {
case ']':
if (len == 1) {
SV *sv = GvSV(gv);
- (void)SvUPGRADE(sv, SVt_PVNV);
- Perl_sv_setpvf(aTHX_ sv,
-#if defined(PERL_SUBVERSION) && (PERL_SUBVERSION > 0)
- "%8.6"
-#else
- "%5.3"
-#endif
- NVff,
- SvNVX(PL_patchlevel));
- SvNVX(sv) = SvNVX(PL_patchlevel);
- SvNOK_on(sv);
- SvREADONLY_on(sv);
+ if (!sv_derived_from(PL_patchlevel, "version"))
+ (void *)upg_version(PL_patchlevel);
+ GvSV(gv) = vnumify(PL_patchlevel);
+ SvREADONLY_on(GvSV(gv));
+ SvREFCNT_dec(sv);
}
break;
case '\026': /* $^V */
if (len == 1) {
SV *sv = GvSV(gv);
- GvSV(gv) = SvREFCNT_inc(PL_patchlevel);
+ GvSV(gv) = new_version(PL_patchlevel);
+ SvREADONLY_on(GvSV(gv));
SvREFCNT_dec(sv);
}
break;
char *name;
HV *hv = GvSTASH(gv);
if (!hv) {
- (void)SvOK_off(sv);
+ SvOK_off(sv);
return;
}
sv_setpv(sv, prefix ? prefix : "");
if (gp->gp_refcnt == 0) {
if (ckWARN_d(WARN_INTERNAL))
Perl_warner(aTHX_ packWARN(WARN_INTERNAL),
- "Attempt to free unreferenced glob pointers");
+ "Attempt to free unreferenced glob pointers"
+ pTHX__FORMAT pTHX__VALUE);
return;
}
if (gp->gp_cv) {
}
if (gp->gp_sv) SvREFCNT_dec(gp->gp_sv);
- if (gp->gp_sv) SvREFCNT_dec(gp->gp_av);
+ if (gp->gp_av) SvREFCNT_dec(gp->gp_av);
if (gp->gp_hv) {
if (PL_stashcache && HvNAME(gp->gp_hv))
hv_delete(PL_stashcache,