summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2020-04-22 15:01:40 +1000
committerSawyer X <xsawyerx@cpan.org>2020-05-27 11:09:11 +0300
commite2d0e9a5d1dd29d4005ca9a3e73222eeabd9e2b7 (patch)
tree28c988858a6ce533fb3c87eb44ffcae9d827de7e /pp.c
parent69d4d9c8182035ceb44091b35b4b34a326a6f058 (diff)
downloadperl-e2d0e9a5d1dd29d4005ca9a3e73222eeabd9e2b7.tar.gz
set magic on $lex for $lex = (index(...) == -1) and make it an lvalue
related to #17737 and fixes #17739 re-work of my original patch that only pushes the final result
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/pp.c b/pp.c
index a061fae363..c3b18b57f8 100644
--- a/pp.c
+++ b/pp.c
@@ -3520,11 +3520,16 @@ PP(pp_index)
push_result:
/* OPpTRUEBOOL indicates an '== -1' has been optimised away */
if (PL_op->op_private & OPpTRUEBOOL) {
- PUSHs( ((retval != -1) ^ cBOOL(PL_op->op_private & OPpINDEX_BOOLNEG))
- ? &PL_sv_yes : &PL_sv_no);
- if (PL_op->op_private & OPpTARGET_MY)
+ SV *result = ((retval != -1) ^ cBOOL(PL_op->op_private & OPpINDEX_BOOLNEG))
+ ? &PL_sv_yes : &PL_sv_no;
+ if (PL_op->op_private & OPpTARGET_MY) {
/* $lex = (index() == -1) */
- sv_setsv(TARG, TOPs);
+ sv_setsv_mg(TARG, result);
+ PUSHs(TARG);
+ }
+ else {
+ PUSHs(result);
+ }
}
else
PUSHi(retval);