From bf5379163331720265335174a3396693246c4c98 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 14 Jun 2022 08:38:49 +0300 Subject: Autocommit at 14.06.2022 @ 08:38 --- src/Models/CellFormula.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Models/CellFormula.cpp') diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp index 59dac1d..db73866 100644 --- a/src/Models/CellFormula.cpp +++ b/src/Models/CellFormula.cpp @@ -98,6 +98,7 @@ void CellFormula::parseAndSetValue(const char* str) { Pair loc; char currOp = 0; + str++; // Removes = from the beginning while (*str != '\0') { List buffer; W(str); @@ -129,7 +130,6 @@ void CellFormula::parseAndSetValue(const char* str) { W(str); O(str, currOp); if (currOp == 0) throw std::logic_error("Error: Could not find operand!"); - W(str); // Operator priority magic if (currOp == '^') currOp *= -1; @@ -138,11 +138,14 @@ void CellFormula::parseAndSetValue(const char* str) { if (formula[i].right > 0) formula[i].right *= -1; } - if (currOp == '-') { + if (currOp == '-') { // a - b turns into a + -1 * b formula.add({loc, '+'}); localCells.add(CellDouble(-1.0)); - formula.add({{-1, (int)(localCells.get_count() - 1)}, '*' * -1}); + loc.left = -1; + loc.right = (int)(localCells.get_count() - 1); + currOp = '*' * -1; } + formula.add(Pair, char>(loc, currOp)); } } -- cgit v1.3.1-23-gd82d