summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJohn Peacock <jpeacock@cpan.org>2011-12-06 20:55:09 -0500
committerDavid Golden <dagolden@cpan.org>2011-12-09 14:59:04 -0500
commit573a19fb2c79f41cfc7f3db5a8ad14e14a4dccf9 (patch)
treee7c0c975264052c4d7fb48acafc9a91c8566ebc2 /util.c
parenta97f6d148c766c74f3c3200d95d9fbf569067b45 (diff)
downloadperl-573a19fb2c79f41cfc7f3db5a8ad14e14a4dccf9.tar.gz
Use syntax from perlguts for testing objects
The following paragraph is in perlguts.pod: To check if you've got an object derived from a specific class you have to write: if (sv_isobject(sv) && sv_derived_from(sv, class)) { ... } which does the right thing with magical things like tied scalars. Signed-off-by: David Golden <dagolden@cpan.org>
Diffstat (limited to 'util.c')
-rw-r--r--util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/util.c b/util.c
index 052cb2c87e..316b1cc524 100644
--- a/util.c
+++ b/util.c
@@ -4857,7 +4857,7 @@ Perl_new_version(pTHX_ SV *ver)
dVAR;
SV * const rv = newSV(0);
PERL_ARGS_ASSERT_NEW_VERSION;
- if ( sv_derived_from(ver,"version") && SvROK(ver) )
+ if ( sv_isobject(ver) && sv_derived_from(ver, "version") )
/* can just copy directly */
{
I32 key;
@@ -6430,7 +6430,7 @@ Perl_xs_version_bootcheck(pTHX_ U32 items, U32 ax, const char *xs_p,
}
if (sv) {
SV *xssv = Perl_newSVpvn_flags(aTHX_ xs_p, xs_len, SVs_TEMP);
- SV *pmsv = sv_derived_from(sv, "version") && SvROK(sv)
+ SV *pmsv = sv_isobject(sv) && sv_derived_from(sv, "version")
? sv : sv_2mortal(new_version(sv));
xssv = upg_version(xssv, 0);
if ( vcmp(pmsv,xssv) ) {