提交 ed3b16b9 编写于 作者: S sherman

8023647: "abc1c".matches("(\\w)+1\\1")) returns false

Summary: to correct the wrong GroupCurly group index backoff code
Reviewed-by: alanb
上级 f12576d1
......@@ -4456,16 +4456,16 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
groups[groupIndex+1] = i;
groups[groupIndex] = i - k;
}
i = i - k;
return true;
}
// backing off
i = i - k;
if (capture) {
groups[groupIndex+1] = i;
groups[groupIndex] = i - k;
}
i = i - k;
j--;
}
break;
}
......@@ -4883,7 +4883,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
int k = matcher.groups[groupIndex+1];
int groupSize = k - j;
// If the referenced group didn't match, neither can this
if (j < 0)
return false;
......@@ -4893,7 +4892,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
matcher.hitEnd = true;
return false;
}
// Check each new char to make sure it matches what the group
// referenced matched last time around
for (int index=0; index<groupSize; index++)
......
......@@ -33,7 +33,7 @@
* 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
* 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
* 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
* 7067045 7014640 7189363 8007395 8013252 8013254 8012646
* 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647
*/
import java.util.regex.*;
......@@ -146,6 +146,7 @@ public class RegExTest {
linebreakTest();
branchTest();
groupCurlyNotFoundSuppTest();
groupCurlyBackoffTest();
patternAsPredicate();
if (failure) {
throw new
......@@ -3999,6 +4000,15 @@ public class RegExTest {
report("GroupCurly NotFoundSupp");
}
// This test is for 8023647
private static void groupCurlyBackoffTest() throws Exception {
if (!"abc1c".matches("(\\w)+1\\1") ||
"abc11".matches("(\\w)+1\\1")) {
failCount++;
}
report("GroupCurly backoff");
}
// This test is for 8012646
private static void patternAsPredicate() throws Exception {
Predicate<String> p = Pattern.compile("[a-z]+").asPredicate();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册