mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 12:34:32 +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+1] = i;
|
||||||
groups[groupIndex] = i - k;
|
groups[groupIndex] = i - k;
|
||||||
}
|
}
|
||||||
i = i - k;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// backing off
|
// backing off
|
||||||
|
i = i - k;
|
||||||
if (capture) {
|
if (capture) {
|
||||||
groups[groupIndex+1] = i;
|
groups[groupIndex+1] = i;
|
||||||
groups[groupIndex] = i - k;
|
groups[groupIndex] = i - k;
|
||||||
}
|
}
|
||||||
i = i - k;
|
|
||||||
j--;
|
j--;
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4883,7 +4883,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
||||||
int k = matcher.groups[groupIndex+1];
|
int k = matcher.groups[groupIndex+1];
|
||||||
|
|
||||||
int groupSize = k - j;
|
int groupSize = k - j;
|
||||||
|
|
||||||
// If the referenced group didn't match, neither can this
|
// If the referenced group didn't match, neither can this
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -4893,7 +4892,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
||||||
matcher.hitEnd = true;
|
matcher.hitEnd = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check each new char to make sure it matches what the group
|
// Check each new char to make sure it matches what the group
|
||||||
// referenced matched last time around
|
// referenced matched last time around
|
||||||
for (int index=0; index<groupSize; index++)
|
for (int index=0; index<groupSize; index++)
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
|
* 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
|
||||||
* 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
|
* 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
|
||||||
* 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
|
* 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.*;
|
import java.util.regex.*;
|
||||||
|
@ -146,6 +146,7 @@ public class RegExTest {
|
||||||
linebreakTest();
|
linebreakTest();
|
||||||
branchTest();
|
branchTest();
|
||||||
groupCurlyNotFoundSuppTest();
|
groupCurlyNotFoundSuppTest();
|
||||||
|
groupCurlyBackoffTest();
|
||||||
patternAsPredicate();
|
patternAsPredicate();
|
||||||
if (failure) {
|
if (failure) {
|
||||||
throw new
|
throw new
|
||||||
|
@ -3999,6 +4000,15 @@ public class RegExTest {
|
||||||
report("GroupCurly NotFoundSupp");
|
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
|
// This test is for 8012646
|
||||||
private static void patternAsPredicate() throws Exception {
|
private static void patternAsPredicate() throws Exception {
|
||||||
Predicate<String> p = Pattern.compile("[a-z]+").asPredicate();
|
Predicate<String> p = Pattern.compile("[a-z]+").asPredicate();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue