diff options
Diffstat (limited to 'src/jdk/nashorn/internal/objects/NativeRegExp.java')
-rw-r--r-- | src/jdk/nashorn/internal/objects/NativeRegExp.java | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/jdk/nashorn/internal/objects/NativeRegExp.java b/src/jdk/nashorn/internal/objects/NativeRegExp.java index 9a12911f..8b469bc1 100644 --- a/src/jdk/nashorn/internal/objects/NativeRegExp.java +++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java @@ -794,15 +794,15 @@ public final class NativeRegExp extends ScriptObject { RegExpResult match; final int inputLength = string.length(); - int lastLength = -1; - int lastIndex = 0; - int lastLastIndex = 0; + int splitLastLength = -1; + int splitLastIndex = 0; + int splitLastLastIndex = 0; - while ((match = execSplit(string, lastIndex)) != null) { - lastIndex = match.getIndex() + match.length(); + while ((match = execSplit(string, splitLastIndex)) != null) { + splitLastIndex = match.getIndex() + match.length(); - if (lastIndex > lastLastIndex) { - matches.add(string.substring(lastLastIndex, match.getIndex())); + if (splitLastIndex > splitLastLastIndex) { + matches.add(string.substring(splitLastLastIndex, match.getIndex())); final Object[] groups = match.getGroups(); if (groups.length > 1 && match.getIndex() < inputLength) { for (int index = 1; index < groups.length && matches.size() < limit; index++) { @@ -810,7 +810,7 @@ public final class NativeRegExp extends ScriptObject { } } - lastLength = match.length(); + splitLastLength = match.length(); if (matches.size() >= limit) { break; @@ -818,10 +818,10 @@ public final class NativeRegExp extends ScriptObject { } // bump the index to avoid infinite loop - if (lastIndex == lastLastIndex) { - lastIndex++; + if (splitLastIndex == splitLastLastIndex) { + splitLastIndex++; } else { - lastLastIndex = lastIndex; + splitLastLastIndex = splitLastIndex; } } @@ -829,12 +829,12 @@ public final class NativeRegExp extends ScriptObject { // check special case if we need to append an empty string at the // end of the match // if the lastIndex was the entire string - if (lastLastIndex == string.length()) { - if (lastLength > 0 || execSplit("", 0) == null) { + if (splitLastLastIndex == string.length()) { + if (splitLastLength > 0 || execSplit("", 0) == null) { matches.add(""); } } else { - matches.add(string.substring(lastLastIndex, inputLength)); + matches.add(string.substring(splitLastLastIndex, inputLength)); } } @@ -899,10 +899,6 @@ public final class NativeRegExp extends ScriptObject { } } - private void setGlobal(final boolean global) { - regexp.setGlobal(global); - } - boolean getGlobal() { return regexp.isGlobal(); } |