mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Classlib: fix bug in regexp implementation
This commit is contained in:
parent
19f070840c
commit
393ab3b09e
|
@ -700,6 +700,7 @@ public final class TMatcher implements TMatchResult {
|
||||||
this.rightBound = string.length();
|
this.rightBound = string.length();
|
||||||
matchResult = new TMatchResultImpl(cs, leftBound, rightBound, pat.groupCount(), pat.compCount(),
|
matchResult = new TMatchResultImpl(cs, leftBound, rightBound, pat.groupCount(), pat.compCount(),
|
||||||
pat.consCount());
|
pat.consCount());
|
||||||
|
matchResult.useAnchoringBounds(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -52,7 +52,7 @@ class TMultiLineEOLSet extends TAbstractSet {
|
||||||
@Override
|
@Override
|
||||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||||
int strDif = matchResult.hasAnchoringBounds()
|
int strDif = matchResult.hasAnchoringBounds()
|
||||||
? matchResult.getLeftBound() - strIndex
|
? matchResult.getRightBound() - strIndex
|
||||||
: testString.length() - strIndex;
|
: testString.length() - strIndex;
|
||||||
char ch1;
|
char ch1;
|
||||||
char ch2;
|
char ch2;
|
||||||
|
|
|
@ -47,8 +47,7 @@ final class TSOLSet extends TAbstractSet {
|
||||||
public int matches(int strIndex, CharSequence testString,
|
public int matches(int strIndex, CharSequence testString,
|
||||||
TMatchResultImpl matchResult) {
|
TMatchResultImpl matchResult) {
|
||||||
if (strIndex == 0
|
if (strIndex == 0
|
||||||
|| (matchResult.hasAnchoringBounds() && strIndex == matchResult
|
|| (matchResult.hasAnchoringBounds() && strIndex == matchResult.getLeftBound())) {
|
||||||
.getLeftBound())) {
|
|
||||||
return next.matches(strIndex, testString, matchResult);
|
return next.matches(strIndex, testString, matchResult);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -726,6 +726,15 @@ public class MatcherTest {
|
||||||
assertTrue("The result doesn't contain pattern info", result.contains("(\\d{1,3})"));
|
assertTrue("The result doesn't contain pattern info", result.contains("(\\d{1,3})"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSOLRegion() {
|
||||||
|
Pattern pattern = Pattern.compile("^cd");
|
||||||
|
String input = "abcde";
|
||||||
|
Matcher matcher = pattern.matcher(input);
|
||||||
|
matcher.region(2, input.length());
|
||||||
|
assertTrue(matcher.lookingAt());
|
||||||
|
}
|
||||||
|
|
||||||
private void hitEndTest(boolean callFind, String testNo, String regex,
|
private void hitEndTest(boolean callFind, String testNo, String regex,
|
||||||
String input, boolean hit) {
|
String input, boolean hit) {
|
||||||
Pattern pattern = Pattern.compile(regex);
|
Pattern pattern = Pattern.compile(regex);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user