mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8222684: Better support for patterns
8223163: Better pattern recognition Reviewed-by: ahgross, bchristi, jeff, rhalade, rriggs, smarks
This commit is contained in:
parent
75745ee70d
commit
844e811d56
1 changed files with 17 additions and 4 deletions
|
@ -1427,7 +1427,11 @@ public final class Pattern
|
|||
localTCNCount = 0;
|
||||
|
||||
if (!pattern.isEmpty()) {
|
||||
compile();
|
||||
try {
|
||||
compile();
|
||||
} catch (StackOverflowError soe) {
|
||||
throw error("Stack overflow during pattern compilation");
|
||||
}
|
||||
} else {
|
||||
root = new Start(lastAccept);
|
||||
matchRoot = lastAccept;
|
||||
|
@ -1965,6 +1969,10 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
int ch = temp[cursor++];
|
||||
while (ch != 0 && !isLineSeparator(ch))
|
||||
ch = temp[cursor++];
|
||||
if (ch == 0 && cursor > patternLength) {
|
||||
cursor = patternLength;
|
||||
ch = temp[cursor++];
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
@ -1975,6 +1983,10 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
int ch = temp[++cursor];
|
||||
while (ch != 0 && !isLineSeparator(ch))
|
||||
ch = temp[++cursor];
|
||||
if (ch == 0 && cursor > patternLength) {
|
||||
cursor = patternLength;
|
||||
ch = temp[cursor];
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
@ -3415,9 +3427,10 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
private int N() {
|
||||
if (read() == '{') {
|
||||
int i = cursor;
|
||||
while (cursor < patternLength && read() != '}') {}
|
||||
if (cursor > patternLength)
|
||||
throw error("Unclosed character name escape sequence");
|
||||
while (read() != '}') {
|
||||
if (cursor >= patternLength)
|
||||
throw error("Unclosed character name escape sequence");
|
||||
}
|
||||
String name = new String(temp, i, cursor - i - 1);
|
||||
try {
|
||||
return Character.codePointOf(name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue