Skip to content

Commit

Permalink
Updated T4 template for CsvParser.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshClose committed Apr 17, 2020
1 parent 8751336 commit e72b6f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/CsvHelper/CsvParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,8 @@ protected virtual async Task<bool> ReadDelimiterAsync()
return true;
}

var originalC = c;
var charsRead = 0;
for (var i = 1; i < context.ParserConfiguration.Delimiter.Length; i++)
{
if (fieldReader.IsBufferEmpty && !await fieldReader.FillBufferAsync().ConfigureAwait(false))
Expand All @@ -928,8 +930,12 @@ protected virtual async Task<bool> ReadDelimiterAsync()
}

c = fieldReader.GetChar();
charsRead++;
if (c != context.ParserConfiguration.Delimiter[i])
{
c = originalC;
fieldReader.SetBufferPosition(-charsRead);

return false;
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/CsvHelper/CsvParser.tt
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ namespace CsvHelper
return true;
}

var originalC = c;
var charsRead = 0;
for (var i = 1; i < context.ParserConfiguration.Delimiter.Length; i++)
{
if (fieldReader.IsBufferEmpty && !<#= Await(isAsync) #>fieldReader.FillBuffer<#= AsyncPostfix(isAsync) #>()<#= ConfigureAwait(isAsync) #>)
Expand All @@ -547,8 +549,12 @@ namespace CsvHelper
}

c = fieldReader.GetChar();
charsRead++;
if (c != context.ParserConfiguration.Delimiter[i])
{
c = originalC;
fieldReader.SetBufferPosition(-charsRead);

return false;
}
}
Expand Down

0 comments on commit e72b6f2

Please sign in to comment.