From ccf84a4709eaad4369e432a9707ecda3c6376334 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 27 Mar 2021 17:05:09 +0430 Subject: [PATCH] Spreadsheet: Ignore extra empty lines after the rows We now ignore the last CRLF in e.g. ```csv aaa,bbb,ccc CRLF zzz,yyy,xxx CRLF ``` --- Userland/Applications/Spreadsheet/Readers/XSV.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Userland/Applications/Spreadsheet/Readers/XSV.cpp b/Userland/Applications/Spreadsheet/Readers/XSV.cpp index ca9c3eb4a1..649ed2894a 100644 --- a/Userland/Applications/Spreadsheet/Readers/XSV.cpp +++ b/Userland/Applications/Spreadsheet/Readers/XSV.cpp @@ -71,6 +71,12 @@ void XSV::parse() while (!has_error() && !m_lexer.is_eof()) m_rows.append(read_row()); + // Read and drop any extra lines at the end. + while (!m_lexer.is_eof()) { + if (!m_lexer.consume_specific("\r\n") && !m_lexer.consume_specific('\n')) + break; + } + if (!m_lexer.is_eof()) set_error(ReadError::DataPastLogicalEnd); }