Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commit473b71190ad39c2fa930ad7d8c90b892fe1840b6 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-06-14 14:24:30 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-06-14 14:24:30 +0300
Files5384256f556ae932dddfb370764fb2fabb38ed6e /src/Models/Table.cpp
FMI-OOP-P2_Tables-473b71190ad39c2fa930ad7d8c90b892fe1840b6.tar
FMI-OOP-P2_Tables-473b71190ad39c2fa930ad7d8c90b892fe1840b6.tar.gz
FMI-OOP-P2_Tables-473b71190ad39c2fa930ad7d8c90b892fe1840b6.zip
Parent290227ba63d59b103bd069c331c2813cb3d469f9 (diff)
Autocommit at 14.06.2022 @ 14:24
1 files changed, 12 insertions, 6 deletions
-rw-r--r--src/Models/Table.cpp18
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<char> 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);