diff options
author | Yves Orton <demerphq@gmail.com> | 2023-03-08 12:59:18 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-03-08 21:56:48 +0800 |
commit | e792c028462d5d3771e15dff0293056e2eab3af6 (patch) | |
tree | 452a7d9c38021d7dd01c3db4f3edd20aee755639 /mg.c | |
parent | 067d2df440e3814f94fc68e4b8920522362283e8 (diff) | |
download | perl-e792c028462d5d3771e15dff0293056e2eab3af6.tar.gz |
mg.c - fix $+ combined with branch reset
I missed that $+ needs to do the parno_to_logical lookup.
We had tests for $^N, but not $+. This also fixes the code
for $^N to only do the lookup when the paren is not 0.
Fixes #20912
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -1141,20 +1141,26 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) } } break; - case '+': + case '+': /* $+ */ if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { paren = RX_LASTPAREN(rx); - if (paren) + if (paren) { + I32 *parno_to_logical = RX_PARNO_TO_LOGICAL(rx); + if (parno_to_logical) + paren = parno_to_logical[paren]; goto do_numbuf_fetch; + } } goto set_undef; - case '\016': /* ^N */ + case '\016': /* $^N */ if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { paren = RX_LASTCLOSEPAREN(rx); - if (RX_PARNO_TO_LOGICAL(rx)) - paren = RX_PARNO_TO_LOGICAL(rx)[paren]; - if (paren) + if (paren) { + I32 *parno_to_logical = RX_PARNO_TO_LOGICAL(rx); + if (parno_to_logical) + paren = parno_to_logical[paren]; goto do_numbuf_fetch; + } } goto set_undef; case '.': |