From 5ec2551343ec2b3d73ce6a156efae6473bb7fc94 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sat, 13 Apr 2024 17:20:08 +0200 Subject: [PATCH] Try some fixes --- dotnet/Gherkin/GherkinLine.cs | 4 ++-- perl/lib/Gherkin/Line.pm | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dotnet/Gherkin/GherkinLine.cs b/dotnet/Gherkin/GherkinLine.cs index 2c131b70b..0ebc625ee 100644 --- a/dotnet/Gherkin/GherkinLine.cs +++ b/dotnet/Gherkin/GherkinLine.cs @@ -125,9 +125,9 @@ private IEnumerable> SplitCells(string row) cell = ""; startPos = pos; } else if (c == GherkinLanguageConstants.TABLE_CELL_ESCAPE_CHAR) { - rowEnum.MoveNext(); + bool hasNext = rowEnum.MoveNext(); pos++; - c = rowEnum.Current; + c = hasNext ? rowEnum.Current : ''; if (c == GherkinLanguageConstants.TABLE_CELL_NEWLINE_ESCAPE) { cell += "\n"; } else { diff --git a/perl/lib/Gherkin/Line.pm b/perl/lib/Gherkin/Line.pm index 2e879bd04..2c311513c 100644 --- a/perl/lib/Gherkin/Line.pm +++ b/perl/lib/Gherkin/Line.pm @@ -86,9 +86,12 @@ sub _split_table_cells_iterator { return ( $cell, $start_col ); } } elsif ( $char eq "\\" ) { - $row =~ s/^(.)// || die "Unpossible"; - $col += 1; - $cell .= '\\' . $1; + if ($row =~ s/^(.)//) { + $col += 1; + $cell .= '\\' . $1; + } else { + $cell .= '\\'; + } } elsif ( defined $char ) { $cell .= $char; } else {