Skip to content

Commit a062477

Browse files
committed
Use ch instead of c as a character var name.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1508937 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9599bfe commit a062477

2 files changed

Lines changed: 39 additions & 39 deletions

File tree

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,36 +146,36 @@ Token nextToken(final Token token) throws IOException {
146146
*
147147
* @param token
148148
* the current token
149-
* @param c
149+
* @param ch
150150
* the current character
151151
* @return the filled token
152152
* @throws IOException
153153
* on stream access error
154154
*/
155-
private Token parseSimpleToken(final Token token, int c) throws IOException {
155+
private Token parseSimpleToken(final Token token, int ch) throws IOException {
156156
// Faster to use while(true)+break than while(token.type == INVALID)
157157
while (true) {
158-
if (readEndOfLine(c)) {
158+
if (readEndOfLine(ch)) {
159159
token.type = EORECORD;
160160
break;
161-
} else if (isEndOfFile(c)) {
161+
} else if (isEndOfFile(ch)) {
162162
token.type = EOF;
163163
token.isReady = true; // There is data at EOF
164164
break;
165-
} else if (isDelimiter(c)) {
165+
} else if (isDelimiter(ch)) {
166166
token.type = TOKEN;
167167
break;
168-
} else if (isEscape(c)) {
168+
} else if (isEscape(ch)) {
169169
final int unescaped = readEscape();
170170
if (unescaped == Constants.END_OF_STREAM) { // unexpected char after escape
171-
token.content.append((char) c).append((char) in.getLastChar());
171+
token.content.append((char) ch).append((char) in.getLastChar());
172172
} else {
173173
token.content.append((char) unescaped);
174174
}
175-
c = in.read(); // continue
175+
ch = in.read(); // continue
176176
} else {
177-
token.content.append((char) c);
178-
c = in.read(); // continue
177+
token.content.append((char) ch);
178+
ch = in.read(); // continue
179179
}
180180
}
181181

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ long getCurrentLineNumber() {
9292
*/
9393
int readEscape() throws IOException {
9494
// the escape char has just been read (normally a backslash)
95-
final int c = in.read();
96-
switch (c) {
95+
final int ch = in.read();
96+
switch (ch) {
9797
case 'r':
9898
return CR;
9999
case 'n':
@@ -109,13 +109,13 @@ int readEscape() throws IOException {
109109
case FF: // TODO is this correct?
110110
case TAB: // TODO is this correct? Do tabs need to be escaped?
111111
case BACKSPACE: // TODO is this correct?
112-
return c;
112+
return ch;
113113
case END_OF_STREAM:
114114
throw new IOException("EOF whilst processing escape sequence");
115115
default:
116116
// Now check for meta-characters
117-
if (isMetaChar(c)) {
118-
return c;
117+
if (isMetaChar(ch)) {
118+
return ch;
119119
}
120120
// indicate unexpected char - available from in.getLastChar()
121121
return END_OF_STREAM;
@@ -137,13 +137,13 @@ void trimTrailingSpaces(final StringBuilder buffer) {
137137
*
138138
* @return true if the given or next character is a line-terminator
139139
*/
140-
boolean readEndOfLine(int c) throws IOException {
140+
boolean readEndOfLine(int ch) throws IOException {
141141
// check if we have \r\n...
142-
if (c == CR && in.lookAhead() == LF) {
142+
if (ch == CR && in.lookAhead() == LF) {
143143
// note: does not change c outside of this method!
144-
c = in.read();
144+
ch = in.read();
145145
}
146-
return c == LF || c == CR;
146+
return ch == LF || ch == CR;
147147
}
148148

149149
abstract Token nextToken(Token reusableToken) throws IOException;
@@ -155,48 +155,48 @@ boolean isClosed() {
155155
/**
156156
* @return true if the given char is a whitespace character
157157
*/
158-
boolean isWhitespace(final int c) {
159-
return !isDelimiter(c) && Character.isWhitespace((char) c);
158+
boolean isWhitespace(final int ch) {
159+
return !isDelimiter(ch) && Character.isWhitespace((char) ch);
160160
}
161161

162162
/**
163163
* Checks if the current character represents the start of a line: a CR, LF or is at the start of the file.
164164
*
165-
* @param c the character to check
165+
* @param ch the character to check
166166
* @return true if the character is at the start of a line.
167167
*/
168-
boolean isStartOfLine(final int c) {
169-
return c == LF || c == CR || c == UNDEFINED;
168+
boolean isStartOfLine(final int ch) {
169+
return ch == LF || ch == CR || ch == UNDEFINED;
170170
}
171171

172172
/**
173173
* @return true if the given character indicates end of file
174174
*/
175-
boolean isEndOfFile(final int c) {
176-
return c == END_OF_STREAM;
175+
boolean isEndOfFile(final int ch) {
176+
return ch == END_OF_STREAM;
177177
}
178178

179-
boolean isDelimiter(final int c) {
180-
return c == delimiter;
179+
boolean isDelimiter(final int ch) {
180+
return ch == delimiter;
181181
}
182182

183-
boolean isEscape(final int c) {
184-
return c == escape;
183+
boolean isEscape(final int ch) {
184+
return ch == escape;
185185
}
186186

187-
boolean isQuoteChar(final int c) {
188-
return c == quoteChar;
187+
boolean isQuoteChar(final int ch) {
188+
return ch == quoteChar;
189189
}
190190

191-
boolean isCommentStart(final int c) {
192-
return c == commmentStart;
191+
boolean isCommentStart(final int ch) {
192+
return ch == commmentStart;
193193
}
194194

195-
private boolean isMetaChar(final int c) {
196-
return c == delimiter ||
197-
c == escape ||
198-
c == quoteChar ||
199-
c == commmentStart;
195+
private boolean isMetaChar(final int ch) {
196+
return ch == delimiter ||
197+
ch == escape ||
198+
ch == quoteChar ||
199+
ch == commmentStart;
200200
}
201201

202202
/**

0 commit comments

Comments
 (0)