Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
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);