From a2ad22319e3d85ec50269b59cb2a1106cf92dce7 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 14 Jun 2022 07:33:30 +0300 Subject: Autocommit at 14.06.2022 @ 07:33 --- src/Models/Table.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Models/Table.cpp') diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index fe84115..c80c7dd 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -42,7 +42,7 @@ void A(std::ifstream& in, List& buffer) { void throwException(std::ifstream& inFile, unsigned row) { throw std::logic_error(( (((((String("Error: Invalid character \"") += inFile.peek()) - += "\" at row ") += row) += "\" and column ") += ((int)inFile.tellg() / row)) + += "\" at row ") += row) += "\" and column ") += ((int)inFile.tellg() / (row + 1))) ).get_cstr()); } @@ -50,7 +50,7 @@ void Table::readFromFile(std::ifstream& inFile) { unsigned row = 0; cells.add(List()); - while (inFile.peek() != EOF) { + while (!inFile.eof()) { if (inFile.peek() == '\n') { row++; inFile.get(); @@ -68,6 +68,7 @@ void Table::readFromFile(std::ifstream& inFile) { W(inFile); if (inFile.peek() != ',') throwException(inFile, row); + inFile.get(); cells[row].add((buffer[0] == '=') ? (Cell*)new CellFormula(buffer.raw_data(), &cells) @@ -82,12 +83,14 @@ void Table::readFromFile(std::ifstream& inFile) { W(inFile); if (inFile.peek() != ',') throwException(inFile, row); + inFile.get(); cells[row].add((Cell*)new CellDouble(buffer.raw_data())); } else { W(inFile); if (inFile.peek() != ',') throwException(inFile, row); + inFile.get(); cells[row].add((Cell*)new CellInt(buffer.raw_data())); } -- cgit v1.3.1-23-gd82d