summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-01 19:37:43 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-01 19:37:43 (GMT)
commit1e3fc7dcfae209ab511eb5194d626de021be69e7 (patch)
tree8b2ee6cc4171c5e8597902c850ce4e0968bc65ae /regcomp.c
parent3418a277d8359ac10ba0ccc047b9189d8f5f6fe3 (diff)
* regcomp.c (noname_disable_map): don't optimize out group 0
Ruby's Regexp doesn't allow normal numbered groups if the regexp has named groups. On such case it optimizes out related NT_ENCLOSE. But even on the case it can use \g<0>. This fix not to remove NT_ENCLOSE whose regnum is 0. [ruby-core:75828] [Bug #12454] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/regcomp.c b/regcomp.c
index add0e8f..869299c 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -1870,17 +1870,16 @@ noname_disable_map(Node** plink, GroupNumRemap* map, int* counter)
(*counter)++;
map[en->regnum].new_val = *counter;
en->regnum = *counter;
- r = noname_disable_map(&(en->target), map, counter);
}
- else {
+ else if (en->regnum != 0) {
*plink = en->target;
en->target = NULL_NODE;
onig_node_free(node);
r = noname_disable_map(plink, map, counter);
+ break;
}
}
- else
- r = noname_disable_map(&(en->target), map, counter);
+ r = noname_disable_map(&(en->target), map, counter);
}
break;