env.warning(L.l("Delimiter is empty"));
return BooleanValue.FALSE;
}
int head = 0;
ArrayValue array = new ArrayValueImpl();
int separatorLength = separator.length();
int stringLength = string.length();
long ulimit;
if (limit >= 0) {
ulimit = limit;
} else {
ulimit = 0x7fffffff;
}
for (int i = 0; i < stringLength; ++i) {
if (ulimit <= array.getSize() + 1) {
break;
}
if (string.regionMatches(i, separator, 0, separatorLength)) {
StringValue chunk = string.substring(head, i);
array.append(chunk);
head = i + separatorLength;
i = head - 1;
}
}
StringValue chunk = string.substring(head);
array.append(chunk);
while (array.getSize() > 0 && limit++ < 0) {
array.pop(env);
}
return array;
}