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();
|
||||
matchResult = new TMatchResultImpl(cs, leftBound, rightBound, pat.groupCount(), pat.compCount(),
|
||||
pat.consCount());
|
||||
matchResult.useAnchoringBounds(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,7 +52,7 @@ class TMultiLineEOLSet extends TAbstractSet {
|
|||
@Override
|
||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strDif = matchResult.hasAnchoringBounds()
|
||||
? matchResult.getLeftBound() - strIndex
|
||||
? matchResult.getRightBound() - strIndex
|
||||
: testString.length() - strIndex;
|
||||
char ch1;
|
||||
char ch2;
|
||||
|
|
|
@ -47,8 +47,7 @@ final class TSOLSet extends TAbstractSet {
|
|||
public int matches(int strIndex, CharSequence testString,
|
||||
TMatchResultImpl matchResult) {
|
||||
if (strIndex == 0
|
||||
|| (matchResult.hasAnchoringBounds() && strIndex == matchResult
|
||||
.getLeftBound())) {
|
||||
|| (matchResult.hasAnchoringBounds() && strIndex == matchResult.getLeftBound())) {
|
||||
return next.matches(strIndex, testString, matchResult);
|
||||
}
|
||||
return -1;
|
||||
|
|
|
@ -726,6 +726,15 @@ public class MatcherTest {
|
|||
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,
|
||||
String input, boolean hit) {
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
|
|
Loading…
Reference in New Issue
Block a user