You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/03/26 13:56:45 UTC

[GitHub] [commons-csv] garydgregory commented on a change in pull request #60: Fix CSV-149 and CSV-195

garydgregory commented on a change in pull request #60: Fix CSV-149 and CSV-195
URL: https://github.com/apache/commons-csv/pull/60#discussion_r398591805
 
 

 ##########
 File path: src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java
 ##########
 @@ -88,11 +89,13 @@ public int read(final char[] buf, final int offset, final int length) throws IOE
 
             for (int i = offset; i < offset + len; i++) {
                 final char ch = buf[i];
+                final int previous = i > 0 ? buf[i - 1] : lastChar;
                 if (ch == LF) {
-                    if (CR != (i > 0 ? buf[i - 1] : lastChar)) {
+                    if (CR != previous) {
                         eolCounter++;
                     }
-                } else if (ch == CR) {
+                } else if ((ch == CR)
+                        || (ch == END_OF_STREAM && previous != LF && previous != CR)) {
 
 Review comment:
   This looks wrong as `ch == END_OF_STREAM` will always be false since a `char` cannot be negative. If you remove `ch == END_OF_STREAM &&` from the line, the test still passes. Either this code is wrong or the test does not cover the intent of this test.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services