diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-03-28 23:38:05 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-03-28 23:38:05 -0700 |
commit | d6642e439baafa141608cfa0e6d38478f841f837 (patch) | |
tree | 0dfbd582977f42dbaf640a0d5048ea93cf52c24b /pp_sys.c | |
parent | 055745bae74336e677beadf16f2aa0f2fd3fa227 (diff) | |
download | perl-d6642e439baafa141608cfa0e6d38478f841f837.tar.gz |
[perl #111864] Don’t leave obj on stack for -x $overloaded
Commit 8db8f6b697e changed the way filetest operators use the stack,
in order to make stacked -t work.
Filetest operators were changed to pop the argument off the stack for
a standalone operator, but to leave it on the stack for a stacking op
(so the next operator could use it). The code for handling overloaded
objects, which was separate, was already doing something similar, by
not popping the object off the stack.
I made the mistake of changing overloaded objects’ return code to
share code with regular filetest operators (the FT_RETURN_* macros),
but without changing the way the overload code got the item from the
stack to begin with. Hence, the returning code assumed that the argu-
ment had been popped for non-stacking ops, which was not the case.
This commit changes the way the overload case does it’s return, to
account for the fact that the object must be left on the stack when
initially fetched from it (in case the object turns out not to have -X
overloading and the regular code has to kick in).
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -2961,10 +2961,14 @@ S_try_amagic_ftest(pTHX_ char chr) { if (!tmpsv) return NULL; + if (PL_op->op_private & OPpFT_STACKING) { + if (SvTRUE(tmpsv)) return NORMAL; + return S_ft_stacking_return_false(aTHX_ tmpsv); + } + SPAGAIN; - if (SvTRUE(tmpsv)) FT_RETURN_TRUE(tmpsv); - FT_RETURN_FALSE(tmpsv); + RETURNX(SETs(tmpsv)); } return NULL; } |