diff options
author | David Mitchell <davem@iabyn.com> | 2018-08-18 12:49:12 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2018-08-26 20:57:34 +0100 |
commit | 3be2a9fdd7457a889837547a6bc98b1068add744 (patch) | |
tree | 55507ceb485118dda8e8054fec144f232d99aeac | |
parent | db0098d3b52693a85d8f8c125d2a4e12fa9b9754 (diff) | |
download | perl-3be2a9fdd7457a889837547a6bc98b1068add744.tar.gz |
S_rematch(): CLOSE_CAPTURE(): set last(close)paren
Every use of the CLOSE_CAPTURE() macro is followed by the setting of
lastparen and lastcloseparen, so include these actions in the macro
itself.
-rw-r--r-- | regexec.c | 24 |
1 files changed, 7 insertions, 17 deletions
@@ -328,20 +328,22 @@ S_regcppush(pTHX_ const regexp *rex, I32 parenfloor, U32 maxopenparen _pDEPTH) ); \ regcpblow(cp) -/* XXX really need to log other places start/end are set too */ - /* set the start and end positions of capture ix */ #define CLOSE_CAPTURE(ix, s, e) \ rex->offs[ix].start = s; \ rex->offs[ix].end = e; \ + if (ix > rex->lastparen) \ + rex->lastparen = ix; \ + rex->lastcloseparen = ix; \ DEBUG_BUFFERS_r(Perl_re_exec_indentf( aTHX_ \ - "CLOSE: rex=0x%" UVxf " offs=0x%" UVxf ": \\%" UVuf ": set %" IVdf "..%" IVdf "\n", \ + "CLOSE: rex=0x%" UVxf " offs=0x%" UVxf ": \\%" UVuf ": set %" IVdf "..%" IVdf "max: %" UVuf "\n", \ depth, \ PTR2UV(rex), \ PTR2UV(rex->offs), \ (UV)ix, \ (IV)rex->offs[ix].start, \ - (IV)rex->offs[ix].end \ + (IV)rex->offs[ix].end, \ + (UV)rex->lastparen \ )) #define UNWIND_PAREN(lp, lcp) \ @@ -7605,9 +7607,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) n = ARG(scan); /* which paren pair */ CLOSE_CAPTURE(n, rex->offs[n].start_tmp, locinput - reginfo->strbeg); - if (n > rex->lastparen) - rex->lastparen = n; - rex->lastcloseparen = n; if ( EVAL_CLOSE_PAREN_IS( cur_eval, n ) ) goto fake_end; @@ -7637,9 +7636,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) if ( n <= lastopen ) { CLOSE_CAPTURE(n, rex->offs[n].start_tmp, locinput - reginfo->strbeg); - if (n > rex->lastparen) - rex->lastparen = n; - rex->lastcloseparen = n; if ( n == ARG(scan) || EVAL_CLOSE_PAREN_IS(cur_eval, n) ) break; } @@ -8265,14 +8261,11 @@ NULL if (ST.me->flags) { /* emulate CLOSE: mark current A as captured */ - I32 paren = ST.me->flags; + U32 paren = (U32)ST.me->flags; if (ST.count) { CLOSE_CAPTURE(paren, HOPc(locinput, -ST.alen) - reginfo->strbeg, locinput - reginfo->strbeg); - if ((U32)paren > rex->lastparen) - rex->lastparen = paren; - rex->lastcloseparen = paren; } else rex->offs[paren].end = -1; @@ -8313,9 +8306,6 @@ NULL if (success) { \ CLOSE_CAPTURE(paren, HOPc(locinput, -1) - reginfo->strbeg, \ locinput - reginfo->strbeg); \ - if (paren > rex->lastparen) \ - rex->lastparen = paren; \ - rex->lastcloseparen = paren; \ } \ else { \ rex->offs[paren].end = -1; \ |