This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix up missing and duplicate AUTHORS
[perl5.git] / universal.c
index 10dddb5..5c147b6 100644 (file)
@@ -38,8 +38,8 @@ S_isa_lookup(pTHX_ HV *stash, const char *name, HV* name_stash,
     AV* av;
     GV* gv;
     GV** gvp;
-    HV* hv = Nullhv;
-    SV* subgen = Nullsv;
+    HV* hv = NULL;
+    SV* subgen = NULL;
     const char *hvname;
 
     /* A stash/class can go by many names (ie. User == main::User), so 
@@ -140,29 +140,29 @@ for class names as well as for objects.
 bool
 Perl_sv_derived_from(pTHX_ SV *sv, const char *name)
 {
-    const char *type = Nullch;
-    HV *stash = Nullhv;
-    HV *name_stash;
+    HV *stash;
 
     SvGETMAGIC(sv);
 
     if (SvROK(sv)) {
+       const char *type;
         sv = SvRV(sv);
         type = sv_reftype(sv,0);
-        if (SvOBJECT(sv))
-            stash = SvSTASH(sv);
+       if (type && strEQ(type,name))
+           return TRUE;
+       stash = SvOBJECT(sv) ? SvSTASH(sv) : NULL;
     }
     else {
         stash = gv_stashsv(sv, FALSE);
     }
 
-    name_stash = gv_stashpv(name, FALSE);
+    if (stash) {
+       HV * const name_stash = gv_stashpv(name, FALSE);
+       return isa_lookup(stash, name, name_stash, strlen(name), 0) == &PL_sv_yes;
+    }
+    else
+       return FALSE;
 
-    return (type && strEQ(type,name)) ||
-            (stash && isa_lookup(stash, name, name_stash, strlen(name), 0) 
-             == &PL_sv_yes)
-        ? TRUE
-        : FALSE ;
 }
 
 #include "XSUB.h"
@@ -199,6 +199,7 @@ XS(XS_Regexp_DESTROY);
 XS(XS_Internals_hash_seed);
 XS(XS_Internals_rehash_seed);
 XS(XS_Internals_HvREHASH);
+XS(XS_Internals_inc_sub_generation);
 
 void
 Perl_boot_core_UNIVERSAL(pTHX)
@@ -247,6 +248,8 @@ Perl_boot_core_UNIVERSAL(pTHX)
     newXSproto("Internals::hash_seed",XS_Internals_hash_seed, file, "");
     newXSproto("Internals::rehash_seed",XS_Internals_rehash_seed, file, "");
     newXSproto("Internals::HvREHASH", XS_Internals_HvREHASH, file, "\\%");
+    newXSproto("Internals::inc_sub_generation",XS_Internals_inc_sub_generation,
+              file, "");
 }
 
 
@@ -341,7 +344,7 @@ XS(XS_UNIVERSAL_VERSION)
         sv = nsv;
        if ( !sv_derived_from(sv, "version"))
            upg_version(sv);
-        undef = Nullch;
+        undef = NULL;
     }
     else {
         sv = (SV*)&PL_sv_undef;
@@ -851,7 +854,7 @@ XS(XS_PerlIO_get_layers)
             if (SvROK(sv) && isGV(SvRV(sv)))
                  gv = (GV*)SvRV(sv);
             else if (SvPOKp(sv))
-                 gv = gv_fetchsv(sv, FALSE, SVt_PVIO);
+                 gv = gv_fetchsv(sv, 0, SVt_PVIO);
        }
 
        if (gv && (io = GvIO(gv))) {
@@ -949,6 +952,17 @@ XS(XS_Internals_HvREHASH)  /* Subject to change  */
     Perl_croak(aTHX_ "Internals::HvREHASH $hashref");
 }
 
+XS(XS_Internals_inc_sub_generation)
+{
+    /* Using dXSARGS would also have dITEM and dSP,
+     * which define 2 unused local variables.  */
+    dAXMARK;
+    PERL_UNUSED_ARG(cv);
+    PERL_UNUSED_VAR(mark);
+    ++PL_sub_generation;
+    XSRETURN_EMPTY;
+}
+
 /*
  * Local variables:
  * c-indentation-style: bsd