This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add IP probe for ip_mreq
[perl5.git] / universal.c
index 2bcc740..a7c480f 100644 (file)
@@ -164,6 +164,8 @@ Perl_sv_derived_from_pvn(pTHX_ SV *sv, const char *const name, const STRLEN len,
     }
     else {
         stash = gv_stashsv(sv, 0);
+        if (!stash)
+            stash = gv_stashpv("UNIVERSAL", 0);
     }
 
     return stash ? isa_lookup(stash, name, len, flags) : FALSE;
@@ -356,8 +358,8 @@ XS(XS_UNIVERSAL_can)
 
     SvGETMAGIC(sv);
 
-    if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
-               || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
+    if (!SvOK(sv) || !(SvROK(sv) || SvNIOK(sv) || (SvPOK(sv) && SvCUR(sv))
+       || (SvGMAGICAL(sv) && (SvNIOKp(sv) || (SvPOKp(sv) && SvCUR(sv))))))
        XSRETURN_UNDEF;
 
     rv = &PL_sv_undef;
@@ -369,6 +371,8 @@ XS(XS_UNIVERSAL_can)
     }
     else {
         pkg = gv_stashsv(sv, 0);
+        if (!pkg)
+            pkg = gv_stashpv("UNIVERSAL", 0);
     }
 
     if (pkg) {
@@ -652,7 +656,13 @@ XS(XS_version_boolean)
     SP -= items;
     if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "version")) {
        SV * const lobj = SvRV(ST(0));
-       SV * const rs = newSViv( vcmp(lobj,new_version(newSVpvs("0"))) );
+       SV * const rs =
+           newSViv( vcmp(lobj,
+                         sv_2mortal(new_version(
+                                       sv_2mortal(newSVpvs("0"))
+                                   ))
+                        )
+                  );
        mPUSHs(rs);
        PUTBACK;
        return;
@@ -812,7 +822,7 @@ XS(XS_utf8_decode)
     else {
        SV * const sv = ST(0);
        bool RETVAL;
-       if (SvIsCOW(sv)) sv_force_normal(sv);
+       SvPV_force_nolen(sv);
        RETVAL = sv_utf8_decode(sv);
        ST(0) = boolSV(RETVAL);
     }
@@ -1004,14 +1014,10 @@ XS(XS_PerlIO_get_layers)
        }
 
        sv = POPs;
-       gv = MUTABLE_GV(sv);
+       gv = MAYBE_DEREF_GV(sv);
 
-       if (!isGV(sv)) {
-            if (SvROK(sv) && isGV(SvRV(sv)))
-                 gv = MUTABLE_GV(SvRV(sv));
-            else if (SvPOKp(sv))
-                 gv = gv_fetchsv(sv, 0, SVt_PVIO);
-       }
+       if (!gv && !SvROK(sv))
+           gv = gv_fetchsv_nomg(sv, 0, SVt_PVIO);
 
        if (gv && (io = GvIO(gv))) {
             AV* const av = PerlIO_get_layers(aTHX_ input ?
@@ -1417,9 +1423,6 @@ Perl_boot_core_UNIVERSAL(pTHX)
        newXS_flags(xsub->name, xsub->xsub, file, xsub->proto, 0);
     } while (++xsub < end);
 
-    /* register the overloading (type 'A') magic */
-    PL_amagic_generation++;
-
     /* Providing a Regexp::DESTROY fixes #21347. See test in t/op/ref.t  */
     {
        CV * const cv =
@@ -1434,8 +1437,8 @@ Perl_boot_core_UNIVERSAL(pTHX)
  * Local variables:
  * c-indentation-style: bsd
  * c-basic-offset: 4
- * indent-tabs-mode: t
+ * indent-tabs-mode: nil
  * End:
  *
- * ex: set ts=8 sts=4 sw=4 noet:
+ * ex: set ts=8 sts=4 sw=4 et:
  */