[ 
https://issues.apache.org/jira/browse/CSV-149?focusedWorklogId=410285&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-410285
 ]

ASF GitHub Bot logged work on CSV-149:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Mar/20 13:57
            Start Date: 26/Mar/20 13:57
    Worklog Time Spent: 10m 
      Work Description: garydgregory commented on 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 expression.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 410285)
    Time Spent: 1h  (was: 50m)

> Line number is not proper at EOF
> --------------------------------
>
>                 Key: CSV-149
>                 URL: https://issues.apache.org/jira/browse/CSV-149
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Parser
>    Affects Versions: 1.1
>         Environment: CSV 1.1, Java 1.6, Windows OS
>            Reporter: Kranthi
>            Priority: Major
>             Fix For: Patch Needed
>
>         Attachments: csv-145-unit-test.diff
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> CSVParser.getCurrentLineNumber() is returning wrong line number (actual line 
> number - 1) when EOF file is reached without record delimiter (\r\n).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to