Skip to content

Commit 9141cb3

Browse files
committed
Changed while loops (CSV-55)
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1299706 13f79535-47bb-0310-9956-ffa450edef68
1 parent afc831b commit 9141cb3

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/main/java/org/apache/commons/csv/CSVParser.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public String[][] getRecords() throws IOException {
143143
String[] getRecord() throws IOException {
144144
String[] result = EMPTY_STRING_ARRAY;
145145
record.clear();
146-
while (true) {
146+
do {
147147
reusableToken.reset();
148148
lexer.nextToken(reusableToken);
149149
switch (reusableToken.type) {
@@ -165,10 +165,8 @@ String[] getRecord() throws IOException {
165165
throw new IOException("(line " + getLineNumber() + ") invalid parse sequence");
166166
// unreachable: break;
167167
}
168-
if (reusableToken.type != TOKEN) {
169-
break;
170-
}
171-
}
168+
} while (reusableToken.type == TOKEN);
169+
172170
if (!record.isEmpty()) {
173171
result = record.toArray(new String[record.size()]);
174172
}
@@ -403,7 +401,7 @@ Token nextToken(Token tkn) throws IOException {
403401
* @throws IOException on stream access error
404402
*/
405403
private Token simpleTokenLexer(Token tkn, int c) throws IOException {
406-
for (; ;) {
404+
while (true) {
407405
if (isEndOfLine(c)) {
408406
// end of record
409407
tkn.type = EORECORD;
@@ -454,7 +452,7 @@ private Token encapsulatedTokenLexer(Token tkn, int c) throws IOException {
454452
int startLineNumber = getLineNumber();
455453
// ignore the given delimiter
456454
// assert c == delimiter;
457-
for (; ;) {
455+
while (true) {
458456
c = in.read();
459457

460458
if (c == format.getEscape()) {
@@ -466,7 +464,7 @@ private Token encapsulatedTokenLexer(Token tkn, int c) throws IOException {
466464
tkn.content.append((char) c);
467465
} else {
468466
// token finish mark (encapsulator) reached: ignore whitespace till delimiter
469-
for (; ;) {
467+
while (true) {
470468
c = in.read();
471469
if (c == format.getDelimiter()) {
472470
tkn.type = TOKEN;

0 commit comments

Comments
 (0)