Upgrade to Encode 1.92.
[p5sagit/p5-mst-13.2.git] / universal.c
index 9764ee4..f5ce23e 100644 (file)
@@ -1,6 +1,6 @@
 /*    universal.c
  *
- *    Copyright (c) 1997-2002, Larry Wall
+ *    Copyright (c) 1997-2003, Larry Wall
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -94,8 +94,8 @@ S_isa_lookup(pTHX_ HV *stash, const char *name, HV* name_stash,
                if (!basestash) {
                    if (ckWARN(WARN_MISC))
                        Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
-                            "Can't locate package %s for @%s::ISA",
-                           SvPVX(sv), HvNAME(stash));
+                            "Can't locate package %"SVf" for @%s::ISA",
+                           sv, HvNAME(stash));
                    continue;
                }
                if (&PL_sv_yes == isa_lookup(basestash, name, name_stash, 
@@ -232,7 +232,8 @@ XS(XS_UNIVERSAL_isa)
     if (SvGMAGICAL(sv))
        mg_get(sv);
 
-    if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))))
+    if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
+               || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
        XSRETURN_UNDEF;
 
     name = (char *)SvPV(ST(1),n_a);
@@ -258,7 +259,8 @@ XS(XS_UNIVERSAL_can)
     if (SvGMAGICAL(sv))
        mg_get(sv);
 
-    if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))))
+    if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
+               || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
        XSRETURN_UNDEF;
 
     name = (char *)SvPV(ST(1),n_a);
@@ -338,7 +340,8 @@ XS(XS_UNIVERSAL_VERSION)
            req = new_version(req);
 
        if ( vcmp( SvRV(req), SvRV(sv) ) > 0 )
-           Perl_croak(aTHX_ "%s version %_ required--this is only version %_",
+           Perl_croak(aTHX_
+               "%s version %"SVf" required--this is only version %"SVf,
                HvNAME(pkg), req, sv);
     }
 
@@ -350,17 +353,19 @@ XS(XS_UNIVERSAL_VERSION)
 XS(XS_version_new)
 {
     dXSARGS;
-    if (items != 2)
+    if (items > 3)
        Perl_croak(aTHX_ "Usage: version::new(class, version)");
     SP -= items;
     {
 /*     char *  class = (char *)SvPV_nolen(ST(0)); */
-       SV *    version = ST(1);
-
-{
-    PUSHs(new_version(version));
-}
+        SV *version = ST(1);
+       if (items == 3 )
+       {
+           char *vs = savepvn(SvPVX(ST(2)),SvCUR(ST(2)));
+           version = Perl_newSVpvf(aTHX_ "v%s",vs);
+       }
 
+       PUSHs(new_version(version));
        PUTBACK;
        return;
     }