summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Peacock <jpeacock@cpan.org>2011-12-06 20:52:11 -0500
committerDavid Golden <dagolden@cpan.org>2011-12-09 14:59:04 -0500
commita97f6d148c766c74f3c3200d95d9fbf569067b45 (patch)
tree1b3d470a8ff7e2e8a8b0da2ad74611080878677a
parent73512201d7f34e916ab9c04a5f41248b4740e29a (diff)
downloadperl-a97f6d148c766c74f3c3200d95d9fbf569067b45.tar.gz
Revert 9bf41c1d to UNIVERSAL::VERSION
Return the previous behavior where CLASS->VERSION will return a stringified version object of the contents of $CLASS::VERSION. Signed-off-by: David Golden <dagolden@cpan.org>
-rw-r--r--universal.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/universal.c b/universal.c
index aeefca80ba..563761eb83 100644
--- a/universal.c
+++ b/universal.c
@@ -406,7 +406,6 @@ XS(XS_UNIVERSAL_VERSION)
GV **gvp;
GV *gv;
SV *sv;
- SV *ret;
const char *undef;
PERL_UNUSED_ARG(cv);
@@ -423,12 +422,16 @@ XS(XS_UNIVERSAL_VERSION)
gvp = pkg ? (GV**)hv_fetchs(pkg, "VERSION", FALSE) : NULL;
if (gvp && isGV(gv = *gvp) && (sv = GvSV(gv)) && SvOK(sv)) {
- ret = sv_newmortal();
- sv_setsv(ret, sv);
+ SV * const nsv = sv_newmortal();
+ sv_setsv(nsv, sv);
+ sv = nsv;
+ if ( !sv_derived_from(sv, "version") || !SvROK(sv))
+ upg_version(sv, FALSE);
+
undef = NULL;
}
else {
- sv = ret = &PL_sv_undef;
+ sv = &PL_sv_undef;
undef = "(undef)";
}
@@ -449,9 +452,6 @@ XS(XS_UNIVERSAL_VERSION)
}
}
- if ( !sv_derived_from(sv, "version") || !SvROK(sv))
- upg_version(sv, FALSE);
-
if ( !sv_derived_from(req, "version") || !SvROK(req)) {
/* req may very well be R/O, so create a new object */
req = sv_2mortal( new_version(req) );
@@ -475,7 +475,11 @@ XS(XS_UNIVERSAL_VERSION)
}
- ST(0) = ret;
+ if ( SvOK(sv) && sv_derived_from(sv, "version") ) {
+ ST(0) = sv_2mortal(vstringify(sv));
+ } else {
+ ST(0) = sv;
+ }
XSRETURN(1);
}