From c55fb3329f11c7539beae021063b3e04d9f0cfd2 Mon Sep 17 00:00:00 2001 From: Jeffrey Smith Date: Mon, 16 Oct 2023 09:03:03 +0000 Subject: [PATCH] Fixed newline format detection for files not ending with a newline (#2875) * Fixed newline format detection for files not ending with a newline Files with Windows-style line endings were being converted to Unix-style if the file did not end with a newline * Updated file format detection fix for consistency --- internal/buffer/line_array.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/buffer/line_array.go b/internal/buffer/line_array.go index b16fb0a0..a906b1f4 100644 --- a/internal/buffer/line_array.go +++ b/internal/buffer/line_array.go @@ -116,12 +116,12 @@ func NewLineArray(size uint64, endings FileFormat, reader io.Reader) *LineArray dlen := len(data) if dlen > 1 && data[dlen-2] == '\r' { data = append(data[:dlen-2], '\n') - if endings == FFAuto { + if la.Endings == FFAuto { la.Endings = FFDos } dlen = len(data) } else if dlen > 0 { - if endings == FFAuto { + if la.Endings == FFAuto { la.Endings = FFUnix } }