diff options
author | Yves Orton <demerphq@gmail.com> | 2012-03-20 00:46:45 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2012-03-20 01:18:57 +0100 |
commit | 84ca160f41c0f4e0b5653cd86f0da76d5cca6cbc (patch) | |
tree | db639708b79ff9315d145d4184e8556d79709134 | |
parent | 68a91acb87c0e5d700bf9bc52e8374e6ce77f878 (diff) | |
download | perl-84ca160f41c0f4e0b5653cd86f0da76d5cca6cbc.tar.gz |
[RT #111842] prevent TRIE overwriting EXACT following NOTHING at start
Fixes RT #111842. Example:
"x" =~ /\A(?>(?:(?:)A|B|C?x))\z/
Should match, but didn't due to allowing NOTHING to start a sequence.
See comment in patch for details.
This also changes a test to no longer be TODO, and improves the test
name to explain its purpose.
-rw-r--r-- | regcomp.c | 22 | ||||
-rw-r--r-- | t/re/pat_advanced.t | 6 |
2 files changed, 19 insertions, 9 deletions
@@ -3325,11 +3325,23 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, if ( noper_trietype && ( - ( noper_trietype == NOTHING ) - || - ( trietype == NOTHING ) - || - ( trietype == noper_trietype ) + /* XXX: Currently we cannot allow a NOTHING node to be the first element + * of a TRIEABLE sequence, Otherwise we will overwrite the regop following + * the NOTHING with the TRIE regop later on. This is because a NOTHING node + * is only one regnode wide, and a TRIE is two regnodes. An example of a + * problematic pattern is: "x" =~ /\A(?>(?:(?:)A|B|C?x))\z/ + * At a later point of time we can somewhat workaround this by handling + * NOTHING -> EXACT sequences as generated by /(?:)A|(?:)B/ type patterns, + * as we can effectively ignore the NOTHING regop in that case. + * This clause, which allows NOTHING to start a sequence is left commented + * out as a reference. + * - Yves + + ( noper_trietype == NOTHING) + || ( trietype == NOTHING ) + */ + ( noper_trietype == NOTHING && trietype ) + || ( trietype == noper_trietype ) ) #ifdef NOJUMPTRIE && noper_next == tail diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t index 775f663b34..15f25b59a2 100644 --- a/t/re/pat_advanced.t +++ b/t/re/pat_advanced.t @@ -2069,10 +2069,8 @@ EOP like("\xC0", $p, "Verify \"\\xC0\" =~ /[\\xE0_]/i; pattern in utf8"); } - { - local $::TODO = 'RT #111842'; - ok "x" =~ /\A(?>(?:(?:)A|B|C?x))\z/, "EXACT nodetypes"; - } + ok "x" =~ /\A(?>(?:(?:)A|B|C?x))\z/, + "Check TRIE does not overwrite EXACT following NOTHING at start - RT #111842"; # # Keep the following tests last -- they may crash perl |