Skip to content

Commit

Permalink
CSV-283: Remove Whitespace Check Determines Delimiter Twice
Browse files Browse the repository at this point in the history
  • Loading branch information
belugabehr committed Jul 13, 2021
1 parent 3627c5a commit 7c44e66
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/main/java/org/apache/commons/csv/Lexer.java
Expand Up @@ -193,16 +193,6 @@ boolean isStartOfLine(final int ch) {
return ch == LF || ch == CR || ch == UNDEFINED;
}

/**
* Tests if the given char is a whitespace character.
*
* @return true if the given char is a whitespace character.
* @throws IOException If an I/O error occurs.
*/
boolean isWhitespace(final int ch) throws IOException {
return !isDelimiter(ch) && Character.isWhitespace((char) ch);
}

private char mapNullToDisabled(final Character c) {
return c == null ? DISABLED : c.charValue();
}
Expand Down Expand Up @@ -271,7 +261,7 @@ Token nextToken(final Token token) throws IOException {
while (token.type == INVALID) {
// ignore whitespaces at beginning of a token
if (ignoreSurroundingSpaces) {
while (isWhitespace(c) && !eol) {
while (Character.isWhitespace((char)c) && !isDelimiter(c) && !eol) {
c = reader.read();
eol = readEndOfLine(c);
}
Expand Down Expand Up @@ -364,7 +354,7 @@ private Token parseEncapsulatedToken(final Token token) throws IOException {
token.type = EORECORD;
return token;
}
if (!isWhitespace(c)) {
if (!Character.isWhitespace((char)c)) {
// error invalid char between token and next delimiter
throw new IOException("(line " + getCurrentLineNumber() +
") invalid char between encapsulated token and delimiter");
Expand Down

0 comments on commit 7c44e66

Please sign in to comment.