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
This commit is contained in:
Jeffrey Smith 2023-10-16 09:03:03 +00:00 committed by GitHub
parent c27593c163
commit c55fb3329f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}
}