mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 04:24:49 +02:00
8023647: "abc1c".matches("(\\w)+1\\1")) returns false
To correct the wrong GroupCurly group index backoff code Reviewed-by: alanb
This commit is contained in:
parent
b87db568f0
commit
d912aa501e
2 changed files with 13 additions and 5 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue