Skip to content

Commit ba26844

Browse files
committed
CSV-70 Improve readability of CSVLexer
Simplify; remove while(true) loop git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1306079 13f79535-47bb-0310-9956-ffa450edef68
1 parent 7c2cfea commit ba26844

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,27 +133,21 @@ Token nextToken(Token tkn) throws IOException {
133133
* @throws IOException on stream access error
134134
*/
135135
private Token simpleTokenLexer(Token tkn, int c) throws IOException {
136-
while (true) {
136+
while (tkn.type == INVALID) {
137137
if (isEndOfLine(c)) {
138-
// end of record
139138
tkn.type = EORECORD;
140-
break;
141139
} else if (isEndOfFile(c)) {
142-
// end of file
143140
tkn.type = EOF;
144141
tkn.isReady = true; // There is data at EOF
145-
break;
146142
} else if (isDelimiter(c)) {
147-
// end of token
148143
tkn.type = TOKEN;
149-
break;
150144
} else if (isEscape(c)) {
151145
tkn.content.append((char) readEscape());
146+
c = in.read(); // continue
152147
} else {
153148
tkn.content.append((char) c);
149+
c = in.read(); // continue
154150
}
155-
156-
c = in.read();
157151
}
158152

159153
if (surroundingSpacesIgnored) {

0 commit comments

Comments
 (0)