You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2013/07/31 17:46:06 UTC

svn commit: r1508937 - in /commons/proper/csv/trunk/src/main/java/org/apache/commons/csv: CSVLexer.java Lexer.java

Author: ggregory
Date: Wed Jul 31 15:46:05 2013
New Revision: 1508937

URL: http://svn.apache.org/r1508937
Log:
Use ch instead of c as a character var name.

Modified:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java?rev=1508937&r1=1508936&r2=1508937&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java Wed Jul 31 15:46:05 2013
@@ -146,36 +146,36 @@ final class CSVLexer extends Lexer {
      *
      * @param token
      *            the current token
-     * @param c
+     * @param ch
      *            the current character
      * @return the filled token
      * @throws IOException
      *             on stream access error
      */
-    private Token parseSimpleToken(final Token token, int c) throws IOException {
+    private Token parseSimpleToken(final Token token, int ch) throws IOException {
         // Faster to use while(true)+break than while(token.type == INVALID)
         while (true) {
-            if (readEndOfLine(c)) {
+            if (readEndOfLine(ch)) {
                 token.type = EORECORD;
                 break;
-            } else if (isEndOfFile(c)) {
+            } else if (isEndOfFile(ch)) {
                 token.type = EOF;
                 token.isReady = true; // There is data at EOF
                 break;
-            } else if (isDelimiter(c)) {
+            } else if (isDelimiter(ch)) {
                 token.type = TOKEN;
                 break;
-            } else if (isEscape(c)) {
+            } else if (isEscape(ch)) {
                 final int unescaped = readEscape();
                 if (unescaped == Constants.END_OF_STREAM) { // unexpected char after escape
-                    token.content.append((char) c).append((char) in.getLastChar());
+                    token.content.append((char) ch).append((char) in.getLastChar());
                 } else {
                     token.content.append((char) unescaped);
                 }
-                c = in.read(); // continue
+                ch = in.read(); // continue
             } else {
-                token.content.append((char) c);
-                c = in.read(); // continue
+                token.content.append((char) ch);
+                ch = in.read(); // continue
             }
         }
 

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java?rev=1508937&r1=1508936&r2=1508937&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java Wed Jul 31 15:46:05 2013
@@ -92,8 +92,8 @@ abstract class Lexer implements Closeabl
      */
     int readEscape() throws IOException {
         // the escape char has just been read (normally a backslash)
-        final int c = in.read();
-        switch (c) {
+        final int ch = in.read();
+        switch (ch) {
         case 'r':
             return CR;
         case 'n':
@@ -109,13 +109,13 @@ abstract class Lexer implements Closeabl
         case FF: // TODO is this correct?
         case TAB: // TODO is this correct? Do tabs need to be escaped?
         case BACKSPACE: // TODO is this correct?
-            return c;
+            return ch;
         case END_OF_STREAM:
             throw new IOException("EOF whilst processing escape sequence");
         default:
             // Now check for meta-characters
-            if (isMetaChar(c)) {
-                return c;
+            if (isMetaChar(ch)) {
+                return ch;
             }
             // indicate unexpected char - available from in.getLastChar()
             return END_OF_STREAM;
@@ -137,13 +137,13 @@ abstract class Lexer implements Closeabl
      *
      * @return true if the given or next character is a line-terminator
      */
-    boolean readEndOfLine(int c) throws IOException {
+    boolean readEndOfLine(int ch) throws IOException {
         // check if we have \r\n...
-        if (c == CR && in.lookAhead() == LF) {
+        if (ch == CR && in.lookAhead() == LF) {
             // note: does not change c outside of this method!
-            c = in.read();
+            ch = in.read();
         }
-        return c == LF || c == CR;
+        return ch == LF || ch == CR;
     }
 
     abstract Token nextToken(Token reusableToken) throws IOException;
@@ -155,48 +155,48 @@ abstract class Lexer implements Closeabl
     /**
      * @return true if the given char is a whitespace character
      */
-    boolean isWhitespace(final int c) {
-        return !isDelimiter(c) && Character.isWhitespace((char) c);
+    boolean isWhitespace(final int ch) {
+        return !isDelimiter(ch) && Character.isWhitespace((char) ch);
     }
 
     /**
      * Checks if the current character represents the start of a line: a CR, LF or is at the start of the file.
      *
-     * @param c the character to check
+     * @param ch the character to check
      * @return true if the character is at the start of a line.
      */
-    boolean isStartOfLine(final int c) {
-        return c == LF || c == CR || c == UNDEFINED;
+    boolean isStartOfLine(final int ch) {
+        return ch == LF || ch == CR || ch == UNDEFINED;
     }
 
     /**
      * @return true if the given character indicates end of file
      */
-    boolean isEndOfFile(final int c) {
-        return c == END_OF_STREAM;
+    boolean isEndOfFile(final int ch) {
+        return ch == END_OF_STREAM;
     }
 
-    boolean isDelimiter(final int c) {
-        return c == delimiter;
+    boolean isDelimiter(final int ch) {
+        return ch == delimiter;
     }
 
-    boolean isEscape(final int c) {
-        return c == escape;
+    boolean isEscape(final int ch) {
+        return ch == escape;
     }
 
-    boolean isQuoteChar(final int c) {
-        return c == quoteChar;
+    boolean isQuoteChar(final int ch) {
+        return ch == quoteChar;
     }
 
-    boolean isCommentStart(final int c) {
-        return c == commmentStart;
+    boolean isCommentStart(final int ch) {
+        return ch == commmentStart;
     }
 
-    private boolean isMetaChar(final int c) {
-        return c == delimiter ||
-               c == escape ||
-               c == quoteChar ||
-               c == commmentStart;
+    private boolean isMetaChar(final int ch) {
+        return ch == delimiter ||
+               ch == escape ||
+               ch == quoteChar ||
+               ch == commmentStart;
     }
 
     /**