Merge the common code from Perl_vdie and Perl_vwarner into a
[p5sagit/p5-mst-13.2.git] / universal.c
index bac641c..caab476 100644 (file)
  * beginning." --Gandalf, relating Gollum's story
  */
 
+/* This file contains the code that implements the functions in Perl's
+ * UNIVERSAL package, such as UNIVERSAL->can().
+ */
+
 #include "EXTERN.h"
 #define PERL_IN_UNIVERSAL_C
 #include "perl.h"
@@ -374,7 +378,11 @@ XS(XS_UNIVERSAL_VERSION)
                    vnumify(req),vnormal(req),vnumify(sv),vnormal(sv));
     }
 
-    ST(0) = vnumify(sv);
+    if ( SvOK(sv) && sv_derived_from(sv, "version") ) {
+       ST(0) = vnumify(sv);
+    } else {
+       ST(0) = sv;
+    }
 
     XSRETURN(1);
 }