Skip to content

Commit

Permalink
Do not trim CR on Windows when --read0 is set
Browse files Browse the repository at this point in the history
  • Loading branch information
junegunn committed Apr 4, 2024
1 parent 9b9ad77 commit 68a35e4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ func (r *Reader) feed(src io.Reader) {
*/

delim := byte('\n')
trimCR := util.IsWindows()
if r.delimNil {
delim = '\000'
trimCR = false
}

slab := make([]byte, readerSlabSize)
Expand Down Expand Up @@ -157,7 +159,7 @@ func (r *Reader) feed(src io.Reader) {
// Found the delimiter
slice := buf[:i+1]
buf = buf[i+1:]
if util.IsWindows() && len(slice) >= 2 && slice[len(slice)-2] == byte('\r') {
if trimCR && len(slice) >= 2 && slice[len(slice)-2] == byte('\r') {
slice = slice[:len(slice)-2]
} else {
slice = slice[:len(slice)-1]
Expand Down

0 comments on commit 68a35e4

Please sign in to comment.