diff options
author | Tony Cook <tony@develop-help.com> | 2020-04-22 15:01:40 +1000 |
---|---|---|
committer | Sawyer X <xsawyerx@cpan.org> | 2020-05-27 11:09:11 +0300 |
commit | e2d0e9a5d1dd29d4005ca9a3e73222eeabd9e2b7 (patch) | |
tree | 28c988858a6ce533fb3c87eb44ffcae9d827de7e /pp.c | |
parent | 69d4d9c8182035ceb44091b35b4b34a326a6f058 (diff) | |
download | perl-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.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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); |