This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add a comment on why TRIE.jump does a UNWIND_PAREN
authorDavid Mitchell <davem@iabyn.com>
Tue, 14 Feb 2017 16:21:40 +0000 (16:21 +0000)
committerDavid Mitchell <davem@iabyn.com>
Tue, 14 Feb 2017 17:49:58 +0000 (17:49 +0000)
(it wasn't obvious to me)

regexec.c

index e383655..f097e3e 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -5736,6 +5736,11 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
         {
             U8 *uc;
             if ( ST.jump ) {
+                /* undo any captures done in the tail part of a branch,
+                 * e.g.
+                 *    /(?:X(.)(.)|Y(.)).../
+                 * where the trie just matches X then calls out to do the
+                 * rest of the branch */
                 REGCP_UNWIND(ST.cp);
                 UNWIND_PAREN(ST.lastparen, ST.lastcloseparen);
            }