/* universal.c
*
- * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+ * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
* by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* 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"
}
if ( vcmp( req, sv ) > 0 )
- Perl_croak(aTHX_
- "%s version %"SVf" required--this is only version %"SVf,
- HvNAME(pkg), req, sv);
+ Perl_croak(aTHX_ "%s version %"SVf" (%"SVf") required--"
+ "this is only version %"SVf" (%"SVf")", HvNAME(pkg),
+ vnumify(req),vnormal(req),vnumify(sv),vnormal(sv));
}
- ST(0) = sv;
+ if ( SvOK(sv) && sv_derived_from(sv, "version") ) {
+ ST(0) = vnumify(sv);
+ } else {
+ ST(0) = sv;
+ }
XSRETURN(1);
}