diff --git a/utils/parse_context.h b/utils/parse_context.h index e7224dc..febbfe3 100644 --- a/utils/parse_context.h +++ b/utils/parse_context.h @@ -485,7 +485,10 @@ struct Parse_Context { if (*cur_ != '\r') return false; // deal with DOS line endings - return match_literal("\r\n"); + if(match_literal("\r\n") || *cur_ == '\r') + return true; + + return false; } void expect_eol(const char * error = "expected eol") diff --git a/utils/testing/csv_parsing_test.cc b/utils/testing/csv_parsing_test.cc index 5e83efc..e2e86d0 100644 --- a/utils/testing/csv_parsing_test.cc +++ b/utils/testing/csv_parsing_test.cc @@ -41,4 +41,9 @@ BOOST_AUTO_TEST_CASE (test1) testCsvLine("\"\"", {""}); testCsvLine("\"\",", {"",""}); testCsvLine("\"\",\"\"", {"",""}); + + // check that we handle all line endings correctly + testCsvLine("\n", {}); + testCsvLine("\r\n", {}); + testCsvLine("\r", {}); }