StringTokenizer bugfixes

This commit is contained in:
Joel Dice 2007-08-23 18:21:56 -06:00
parent e9cafcad37
commit 8377016b0f

View File

@ -31,10 +31,14 @@ public class StringTokenizer implements Enumeration {
boolean sawNonDelimiter = false;
for (int i = position; i < in.length(); ++i) {
if (isDelimiter(in.charAt(i))) {
if (includeDelimiters || sawNonDelimiter) {
if (sawNonDelimiter) {
sawNonDelimiter = false;
++ count;
}
if (includeDelimiters) {
++ count;
}
sawNonDelimiter = false;
} else {
sawNonDelimiter = true;
}
@ -69,7 +73,7 @@ public class StringTokenizer implements Enumeration {
}
} else {
position = i;
while (position < in.length() && ! isDelimiter(in.charAt(i))) {
while (position < in.length() && ! isDelimiter(in.charAt(position))) {
++ position;
}
return in.substring(i, position);