From 76a5c00be6ee10310571f6dac5147c212f5be5d9 Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 2 Mar 2010 09:40:27 +0000 Subject: * regcomp.c (noname_disable_map): add NT_ANCHOR case. Without this change, captured groups in anchors (look-ahead, look-behind, and so on) are not removed and unintended invalid backref error occur. [ruby-core:28235] * regcomp.c (renumber_by_map): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- regcomp.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'regcomp.c') diff --git a/regcomp.c b/regcomp.c index 57c02626ae..b681e669bf 100644 --- a/regcomp.c +++ b/regcomp.c @@ -1794,6 +1794,20 @@ noname_disable_map(Node** plink, GroupNumRemap* map, int* counter) } break; + case NT_ANCHOR: + { + AnchorNode* an = NANCHOR(node); + switch (an->type) { + case ANCHOR_PREC_READ: + case ANCHOR_PREC_READ_NOT: + case ANCHOR_LOOK_BEHIND: + case ANCHOR_LOOK_BEHIND_NOT: + r = noname_disable_map(&(an->target), map, counter); + break; + } + } + break; + default: break; } @@ -1852,6 +1866,20 @@ renumber_by_map(Node* node, GroupNumRemap* map) r = renumber_node_backref(node, map); break; + case NT_ANCHOR: + { + AnchorNode* an = NANCHOR(node); + switch (an->type) { + case ANCHOR_PREC_READ: + case ANCHOR_PREC_READ_NOT: + case ANCHOR_LOOK_BEHIND: + case ANCHOR_LOOK_BEHIND_NOT: + r = renumber_by_map(an->target, map); + break; + } + } + break; + default: break; } -- cgit v1.2.1