[win32] Support case-tolerant %ENV
[p5sagit/p5-mst-13.2.git] / universal.c
index 74d182d..9a86763 100644 (file)
@@ -8,11 +8,7 @@
  */
 
 static SV *
-isa_lookup(stash, name, len, level)
-HV *stash;
-char *name;
-int len;
-int level;
+isa_lookup(HV *stash, char *name, int len, int level)
 {
     AV* av;
     GV* gv;
@@ -71,13 +67,11 @@ int level;
        }
     }
 
-    return &sv_no;
+    return boolSV(strEQ(name, "UNIVERSAL"));
 }
 
 bool
-sv_derived_from(sv, name)
-SV * sv ;
-char * name ;
+sv_derived_from(SV *sv, char *name)
 {
     SV *rv;
     char *type;
@@ -120,8 +114,7 @@ XS(XS_UNIVERSAL_isa)
     sv = ST(0);
     name = (char *)SvPV(ST(1),na);
 
-    ST(0) = (sv_derived_from(sv, name) ? &sv_yes : &sv_no) ;
-
+    ST(0) = boolSV(sv_derived_from(sv, name));
     XSRETURN(1);
 }
 
@@ -132,8 +125,6 @@ XS(XS_UNIVERSAL_can)
     SV   *sv;
     char *name;
     SV   *rv;
-    GV   *gv;
-    CV   *cvp;
     HV   *pkg = NULL;
 
     if (items != 2)
@@ -153,16 +144,9 @@ XS(XS_UNIVERSAL_can)
     }
 
     if (pkg) {
-        gv = gv_fetchmethod(pkg, name);
-
-        if(gv && GvCV(gv)) {
-            /* If the sub is only a stub then we may have a gv to AUTOLOAD */
-            GV **gvp = (GV**)hv_fetch(GvSTASH(gv), name, strlen(name), TRUE);
-            if(gvp && (cvp = GvCV(*gvp))) {
-                rv = sv_newmortal();
-                sv_setsv(rv, newRV((SV*)cvp));
-            }
-        }
+        GV *gv = gv_fetchmethod_autoload(pkg, name, FALSE);
+        if (gv && isGV(gv))
+           rv = sv_2mortal(newRV((SV*)GvCV(gv)));
     }
 
     ST(0) = rv;
@@ -170,26 +154,6 @@ XS(XS_UNIVERSAL_can)
 }
 
 static
-XS(XS_UNIVERSAL_is_instance)
-{
-    dXSARGS;
-    ST(0) = SvROK(ST(0)) ? &sv_yes : &sv_no;
-    XSRETURN(1);
-}
-
-static
-XS(XS_UNIVERSAL_class)
-{
-    dXSARGS;
-    if(SvROK(ST(0)) && SvOBJECT(SvRV(ST(0)))) {
-        SV *sv = sv_newmortal();
-        sv_setpv(sv, HvNAME(SvSTASH(SvRV(ST(0)))));
-        ST(0) = sv;
-    }
-    XSRETURN(1);
-}
-
-static
 XS(XS_UNIVERSAL_VERSION)
 {
     dXSARGS;
@@ -233,13 +197,11 @@ XS(XS_UNIVERSAL_VERSION)
 }
 
 void
-boot_core_UNIVERSAL()
+boot_core_UNIVERSAL(void)
 {
     char *file = __FILE__;
 
     newXS("UNIVERSAL::isa",             XS_UNIVERSAL_isa,         file);
     newXS("UNIVERSAL::can",             XS_UNIVERSAL_can,         file);
-    newXS("UNIVERSAL::class",           XS_UNIVERSAL_class,       file);
-    newXS("UNIVERSAL::is_instance",     XS_UNIVERSAL_is_instance, file);
     newXS("UNIVERSAL::VERSION",        XS_UNIVERSAL_VERSION,     file);
 }