diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-03-13 11:47:58 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-03-13 11:47:58 +0100 |
commit | 62ec5f58625ce7dd38f2ee3ba00b450373b0de40 (patch) | |
tree | 49aad23b733eb6db30fd902091b0f9100e295255 /pp_ctl.c | |
parent | 85af77a5094f7cce94729e17e3c28f0a2e709ebe (diff) | |
download | perl-62ec5f58625ce7dd38f2ee3ba00b450373b0de40.tar.gz |
Make smart matching ~~ undef dispatch only on the RHS
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 24 |
1 files changed, 8 insertions, 16 deletions
@@ -4042,12 +4042,6 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) && (this_regex = (REGEXP*) This) \ && (Other = d)) ) - -# define SM_OBJECT ( \ - (sv_isobject(d) && (SvTYPE(SvRV(d)) != SVt_REGEXP)) \ - || \ - (sv_isobject(e) && (SvTYPE(SvRV(e)) != SVt_REGEXP)) ) \ - # define SM_OTHER_REF(type) \ (SvROK(Other) && SvTYPE(SvRV(Other)) == SVt_##type) @@ -4063,7 +4057,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) sv_2mortal(newSViv(PTR2IV(sv))), 0) tryAMAGICbinSET(smart, 0); - + SP -= 2; /* Pop the values */ /* Take care only to invoke mg_get() once for each argument. @@ -4079,13 +4073,17 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) if (SvGMAGICAL(e)) e = sv_mortalcopy(e); - if (SM_OBJECT) { - if (!SvOK(d) || !SvOK(e)) + if (!SvOK(e)) { + if (SvOK(d)) RETPUSHNO; else - Perl_croak(aTHX_ "Smart matching a non-overloaded object breaks encapsulation"); + RETPUSHYES; } + if ((sv_isobject(d) && (SvTYPE(SvRV(d)) != SVt_REGEXP)) + || (sv_isobject(e) && (SvTYPE(SvRV(e)) != SVt_REGEXP))) + Perl_croak(aTHX_ "Smart matching a non-overloaded object breaks encapsulation"); + if (SM_REF(PVCV)) { I32 c; ENTER; @@ -4305,12 +4303,6 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) RETPUSHNO; } } - else if (!SvOK(d) || !SvOK(e)) { - if (!SvOK(d) && !SvOK(e)) - RETPUSHYES; - else - RETPUSHNO; - } else if (SM_REGEX) { PMOP * const matcher = make_matcher(this_regex); |