Skip to content

Bug in buffer handling in readlines() function for \r\n new line type #22430

Closed
@pszufe

Description

@pszufe

There some buffering error in how windows new line characters are being handled by the readlines() function.

Please consider the following code:

stream = open("foo.txt", "w")
write(stream, "a")
for i = 1:2^17
  write(stream, "ab\r\n")
end
close(stream)

lineNo = 0
for line in readlines("foo.txt")
   lineNo += 1;
   if '\r' in line
       println("line ",lineNo," contains \\r character")
   end
end

And the output:

line 32768 contains \r character
line 65536 contains \r character
line 98304 contains \r character
line 131072 contains \r character

Seems like improper handling of the last character in the buffer.

Tested on Julia 0.6.0-rc3 and 0.7.0-DEV.636

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorioInvolving the I/O subsystem: libuv, read, write, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions