This is a live mirror of the Perl 5 development currently hosted at
https://github.com/perl/perl5
https://perl5.git.perl.org
/
perl5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More VMS patches from Peter Prymmer.
[perl5.git]
/
universal.c
diff --git
a/universal.c
b/universal.c
index
aa5487f
..
6ccff2f
100644
(file)
--- a/
universal.c
+++ b/
universal.c
@@
-73,6
+73,16
@@
S_isa_lookup(pTHX_ HV *stash, const char *name, int len, int level)
return boolSV(strEQ(name, "UNIVERSAL"));
}
return boolSV(strEQ(name, "UNIVERSAL"));
}
+/*
+=for apidoc sv_derived_from
+
+Returns a boolean indicating whether the SV is derived from the specified
+class. This is the function that implements C<UNIVERSAL::isa>. It works
+for class names as well as for objects.
+
+=cut
+*/
+
bool
Perl_sv_derived_from(pTHX_ SV *sv, const char *name)
{
bool
Perl_sv_derived_from(pTHX_ SV *sv, const char *name)
{
@@
-130,6
+140,10
@@
XS(XS_UNIVERSAL_isa)
Perl_croak(aTHX_ "Usage: UNIVERSAL::isa(reference, kind)");
sv = ST(0);
Perl_croak(aTHX_ "Usage: UNIVERSAL::isa(reference, kind)");
sv = ST(0);
+
+ if (!SvOK(sv) || !(SvROK(sv) || SvCUR(sv)))
+ XSRETURN_UNDEF;
+
name = (char *)SvPV(ST(1),n_a);
ST(0) = boolSV(sv_derived_from(sv, name));
name = (char *)SvPV(ST(1),n_a);
ST(0) = boolSV(sv_derived_from(sv, name));
@@
-149,6
+163,10
@@
XS(XS_UNIVERSAL_can)
Perl_croak(aTHX_ "Usage: UNIVERSAL::can(object-ref, method)");
sv = ST(0);
Perl_croak(aTHX_ "Usage: UNIVERSAL::can(object-ref, method)");
sv = ST(0);
+
+ if (!SvOK(sv) || !(SvROK(sv) || SvCUR(sv)))
+ XSRETURN_UNDEF;
+
name = (char *)SvPV(ST(1),n_a);
rv = &PL_sv_undef;
name = (char *)SvPV(ST(1),n_a);
rv = &PL_sv_undef;