commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaco...@apache.org
Subject svn commit: r1065496 - /commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java
Date Mon, 31 Jan 2011 07:10:57 GMT
Author: jacopoc
Date: Mon Jan 31 07:10:57 2011
New Revision: 1065496

URL: http://svn.apache.org/viewvc?rev=1065496&view=rev
Log:
Fix for issue reported in SANDBOX-218: CSV reader doesn't handle older Mac line endings (\r)
that are also used by recent versions of Excel for Mac.

Modified:
    commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java

Modified: commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java?rev=1065496&r1=1065495&r2=1065496&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java (original)
+++ commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java Mon Jan 31 07:10:57
2011
@@ -322,6 +322,7 @@ public class CSVParser {
     //  empty line detection: eol AND (last char was EOL or beginning)
     while (strategy.getIgnoreEmptyLines() && eol 
       && (lastChar == '\n' 
+      || lastChar == '\r' 
       || lastChar == ExtendedBufferedReader.UNDEFINED) 
       && !isEndOfFile(lastChar)) {
       // go on char ahead ...
@@ -580,7 +581,7 @@ public class CSVParser {
   }
   
   /**
-   * Greedy - accepts \n and \r\n 
+   * Greedy - accepts \n, \r and \r\n 
    * This checker consumes silently the second control-character...
    * 
    * @return true if the given character is a line-terminator
@@ -593,7 +594,7 @@ public class CSVParser {
         c = in.read();
       }
     }
-    return (c == '\n');
+    return (c == '\n' || c == '\r');
   }
   
   /**



Mime
View raw message