Merge branch 'master' of oss.readytalk.com:/var/local/git/avian into openjdk

This commit is contained in:
Joel Dice
2010-09-10 15:58:43 -06:00
4 changed files with 66 additions and 61 deletions

View File

@ -115,23 +115,34 @@ public class Pattern {
List<CharSequence> list = new LinkedList();
int index = 0;
int trailing = 0;
while (index < input.length() && list.size() < limit) {
int i = indexOf(input, pattern, index);
int patternLength = pattern.length();
while (index < input.length() && list.size() < limit - 1) {
int i;
if (patternLength == 0) {
if (list.size() == 0) {
i = 0;
} else {
i = index + 1;
}
} else {
i = indexOf(input, pattern, index);
}
if (i >= 0) {
if (i == index) {
if (patternLength != 0 && i == index) {
++ trailing;
} else {
trailing = 0;
}
list.add(input.subSequence(index, i));
index = i + pattern.length();
index = i + patternLength;
} else {
break;
}
}
if (strip && index == input.length()) {
if (strip && index > 0 && index == input.length()) {
++ trailing;
} else {
trailing = 0;