Re: [perl #34493] h2ph `extern inline' problems
[p5sagit/p5-mst-13.2.git] / universal.c
index b84e554..760c33b 100644 (file)
@@ -1,7 +1,7 @@
 /*    universal.c
  *
- *    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- *    by Larry Wall and others
+ *    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+ *    2005, 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.
  * 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"
@@ -369,12 +373,16 @@ XS(XS_UNIVERSAL_VERSION)
        }
 
        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);
 }
@@ -594,7 +602,7 @@ XS(XS_version_qv)
            }
            else
            {
-               version = savepv(SvPV_nolen(ver));
+               version = savesvpv(ver);
            }
            (void)scan_version(version,vs,TRUE);
            Safefree(version);
@@ -851,7 +859,7 @@ XS(XS_PerlIO_get_layers)
             if (SvROK(sv) && isGV(SvRV(sv)))
                  gv = (GV*)SvRV(sv);
             else
-                 gv = gv_fetchpv(SvPVX(sv), FALSE, SVt_PVIO);
+                 gv = gv_fetchsv(sv, FALSE, SVt_PVIO);
        }
 
        if (gv && (io = GvIO(gv))) {
@@ -947,3 +955,13 @@ XS(XS_Internals_HvREHASH)  /* Subject to change  */
     }
     Perl_croak(aTHX_ "Internals::HvREHASH $hashref");
 }
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vim: shiftwidth=4:
+*/