commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1306325 - /commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java
Date Wed, 28 Mar 2012 13:46:27 GMT
Author: sebb
Date: Wed Mar 28 13:46:27 2012
New Revision: 1306325

URL: http://svn.apache.org/viewvc?rev=1306325&view=rev
Log:
CSV-84 Clarify comment handling
Fix code so comment only detected at start of a line

Modified:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.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=1306325&r1=1306324&r2=1306325&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 Mar 28
13:46:27 2012
@@ -49,12 +49,19 @@ class CSVLexer extends Lexer {
         *       is to call 'readAgain' on the stream...
         */
         int c = in.read();
+
+        if (isStartOfLine(lastChar) && isCommentStart(c)) {
+            in.readLine();
+            tkn.type = COMMENT;
+            return tkn;
+        }
+
         boolean eol = isEndOfLine(c);
         c = in.readAgain();
 
         //  empty line detection: eol AND (last char was EOL or beginning)
         if (emptyLinesIgnored) {
-            while (eol && (lastChar == '\n' || lastChar == '\r' || lastChar == ExtendedBufferedReader.UNDEFINED))
{
+            while (eol && isStartOfLine(lastChar)) {
                 // go on char ahead ...
                 lastChar = c;
                 c = in.read();
@@ -86,12 +93,8 @@ class CSVLexer extends Lexer {
                 }
             }
             
-            // ok, start of token reached: comment, encapsulated, or token
-            if (isCommentStart(c)) { // TODO should only match at start of line
-                // ignore everything till end of line and continue (incr linecount)
-                in.readLine();
-                tkn.type = COMMENT;
-            } else if (isDelimiter(c)) {
+            // ok, start of token reached: encapsulated, or token
+            if (isDelimiter(c)) {
                 // empty token return TOKEN("")
                 tkn.type = TOKEN;
             } else if (eol) {



Mime
View raw message