From cf67e0142cececa39fb994f8889d19b074dbe152 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 7 Jun 2009 22:57:14 -0400 Subject: [PATCH] Bug Fix - Att::match - Fixed Att::match bug that succeeded when no modifiers were present. --- src/Att.cpp | 5 +++++ src/TDB2.cpp | 17 +++++------------ src/sandbox/main.cpp | 7 ------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/Att.cpp b/src/Att.cpp index 760c69f4f..07359be70 100644 --- a/src/Att.cpp +++ b/src/Att.cpp @@ -194,6 +194,11 @@ bool Att::validMod (const std::string& mod) const // Record that does not have modifiers, but may have a value. bool Att::match (const Att& other) const { + // If there are no mods, just perform a straight compares on value. + if (mMods.size () == 0) + if (mName != other.mName || mValue != other.mValue) + return false; + // Assume a match, and short-circuit on mismatch. foreach (mod, mMods) { diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 0e7e78dd6..f444fc401 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -156,6 +156,9 @@ void TDB2::unlock () // Returns number of filtered tasks. int TDB2::load (std::vector & tasks, Filter& filter) { + // Note: tasks.clear () is deliberately not called, to allow the combination + // of multiple files. + std::string file; int line_number; @@ -173,16 +176,11 @@ int TDB2::load (std::vector & tasks, Filter& filter) int length = ::strlen (line); if (length > 1) { + // TODO Add hidden attribute indicating source? line[length - 1] = '\0'; // Kill \n - std::cout << "# line: " << line << std::endl; - T2 task (line); - if (filter.pass (task)) - { - // TODO Add hidden attribute indicating source. tasks.push_back (task); - } } ++line_number; @@ -198,16 +196,11 @@ int TDB2::load (std::vector & tasks, Filter& filter) int length = ::strlen (line); if (length > 1) { + // TODO Add hidden attribute indicating source? line[length - 1] = '\0'; // Kill \n - std::cout << "# line: " << line << std::endl; - T2 task (line); - if (filter.pass (task)) - { - // TODO Add hidden attribute indicating source. tasks.push_back (task); - } } ++line_number; diff --git a/src/sandbox/main.cpp b/src/sandbox/main.cpp index 904c117e5..4ddb9d388 100644 --- a/src/sandbox/main.cpp +++ b/src/sandbox/main.cpp @@ -10,10 +10,6 @@ int main (int argc, char** argv) try { context.initialize (argc, argv); -// context.run (); - -//////////////////////////////////////////////////////////////////////////////// - context.tdb.lock (context.config.get ("locking", true)); context.filter.push_back (Att ("priority", "L")); @@ -23,9 +19,6 @@ int main (int argc, char** argv) std::cout << "# " << quantity << " <-- context.tdb.load" << std::endl; context.tdb.unlock (); - -//////////////////////////////////////////////////////////////////////////////// - return 0; }