From d59e984752ad8be68467d31e65a4b15324bf874d Mon Sep 17 00:00:00 2001 From: Peter Mihalik Date: Mon, 22 Apr 2024 21:44:14 +0200 Subject: [PATCH] MacOS newline detect fix (#250) * MacOS newline detect fix * DetectNewLine fix --- source/Sylvan.Data.Csv/CsvDataReader+Async.cs | 3 ++- source/Sylvan.Data.Csv/CsvDataReader.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/Sylvan.Data.Csv/CsvDataReader+Async.cs b/source/Sylvan.Data.Csv/CsvDataReader+Async.cs index 3b17c73..acea491 100644 --- a/source/Sylvan.Data.Csv/CsvDataReader+Async.cs +++ b/source/Sylvan.Data.Csv/CsvDataReader+Async.cs @@ -142,7 +142,8 @@ async Task InitializeReaderAsync(CancellationToken cancel = default) } if (this.newLineMode == NewLineMode.Unknown) { - this.DetectNewLine(); + var m = this.DetectNewLine(); + this.newLineMode = m; } this.minSafe = delimiter < '\r' ? '\r' : delimiter; diff --git a/source/Sylvan.Data.Csv/CsvDataReader.cs b/source/Sylvan.Data.Csv/CsvDataReader.cs index e1b327f..fc849fc 100644 --- a/source/Sylvan.Data.Csv/CsvDataReader.cs +++ b/source/Sylvan.Data.Csv/CsvDataReader.cs @@ -294,7 +294,7 @@ NewLineMode DetectNewLine() var c = this.buffer[idx]; if (c == '\r') { - if (c + 1 < this.buffer.Length && this.buffer[c + 1] != '\n') + if (idx + 1 < this.buffer.Length && this.buffer[idx + 1] != '\n') { return NewLineMode.MacOS; }