From 473b71190ad39c2fa930ad7d8c90b892fe1840b6 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 14 Jun 2022 14:24:30 +0300 Subject: Autocommit at 14.06.2022 @ 14:24 --- src/Models/Table.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/Models/Table.cpp') diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index 2604046..3b1c8f2 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -151,14 +151,20 @@ void Table::putCell(unsigned row, unsigned col, const char* rawValue) { while (*rawValue == ' ') rawValue++; if (*rawValue == '"') { - String temp(++rawValue); - if (temp[temp.get_length() - 1] != '"') + List buffer; + rawValue++; + while (*rawValue != '"' && *rawValue != '\0') { + if (*rawValue == '\\') rawValue++; + buffer.add(*rawValue); + } + if (*rawValue == '"' && *(rawValue + 1) != '\0') + throw std::logic_error("Error: Text after closing (inescaped) brace!"); + else if (*rawValue != '"') throw std::logic_error("Error: No closing brace found!"); - temp[temp.get_length() - 1] = '\0'; - newCell = (temp[0] == '=') - ? (Cell*)new CellFormula(temp.get_cstr(), &cells) - : (Cell*)new CellString(temp.get_cstr()); + newCell = (buffer[0] == '=') + ? (Cell*)new CellFormula(buffer.raw_data(), &cells) + : (Cell*)new CellString(buffer.raw_data()); } else if ((*rawValue == '+' || *rawValue == '-') || (*rawValue >= '0' && *rawValue <= '9')) { double doubleParse = atof(rawValue); -- cgit v1.3.1-23-gd82d