From 62f240aad4ef19151d196366320992b524d8d3f9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 15 Jun 2009 12:37:35 -0400 Subject: [PATCH] Bug Fix - composeF4 -> parse -> composeF4 - Fixed bug that meant Task::composeF4 added a newline, but Task::parse did not expect a newline. This caused Task::determineVersion to detect a format 1 encoding and throw. Changed TDB::load to not remove any \n characters, and Task::parse to accept lines either with or without. --- src/TDB.cpp | 1 - src/Task.cpp | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/TDB.cpp b/src/TDB.cpp index ba0de0f27..41e75b340 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -181,7 +181,6 @@ int TDB::loadPending (std::vector & tasks, Filter& filter) if (length > 1) { // TODO Add hidden attribute indicating source? - line[length - 1] = '\0'; // Kill \n Task task (line); task.id = mId++; diff --git a/src/Task.cpp b/src/Task.cpp index 3da4002ec..50e3da78c 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -125,14 +125,20 @@ void Task::setStatus (Task::status status) //////////////////////////////////////////////////////////////////////////////// void Task::parse (const std::string& line) { + std::string copy; + if (line[line.length () - 1] == '\n') + copy = line.substr (0, line.length () - 1); + else + copy = line; + try { - Record::parse (line); + Record::parse (copy); } catch (std::string& e) { - legacyParse (line); + legacyParse (copy); } }