summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-02 09:40:27 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-02 09:40:27 (GMT)
commit76a5c00be6ee10310571f6dac5147c212f5be5d9 (patch)
treea8789b8bd9f0f9d796f04288625ec09f8c2d1cea /regcomp.c
parent1c0dfeef41dd0386e9b1ab479b58eaf7d4eccab4 (diff)
* 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
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index 57c0262..b681e66 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;
}