Bug Fix - Att::match

- Fixed Att::match bug that succeeded when no modifiers were present.
This commit is contained in:
Paul Beckingham 2009-06-07 22:57:14 -04:00
parent 9d48faa759
commit cf67e0142c
3 changed files with 10 additions and 19 deletions

View file

@ -194,6 +194,11 @@ bool Att::validMod (const std::string& mod) const
// Record that does not have modifiers, but may have a value. // Record that does not have modifiers, but may have a value.
bool Att::match (const Att& other) const 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. // Assume a match, and short-circuit on mismatch.
foreach (mod, mMods) foreach (mod, mMods)
{ {

View file

@ -156,6 +156,9 @@ void TDB2::unlock ()
// Returns number of filtered tasks. // Returns number of filtered tasks.
int TDB2::load (std::vector <T2>& tasks, Filter& filter) int TDB2::load (std::vector <T2>& tasks, Filter& filter)
{ {
// Note: tasks.clear () is deliberately not called, to allow the combination
// of multiple files.
std::string file; std::string file;
int line_number; int line_number;
@ -173,17 +176,12 @@ int TDB2::load (std::vector <T2>& tasks, Filter& filter)
int length = ::strlen (line); int length = ::strlen (line);
if (length > 1) if (length > 1)
{ {
// TODO Add hidden attribute indicating source?
line[length - 1] = '\0'; // Kill \n line[length - 1] = '\0'; // Kill \n
std::cout << "# line: " << line << std::endl;
T2 task (line); T2 task (line);
if (filter.pass (task)) if (filter.pass (task))
{
// TODO Add hidden attribute indicating source.
tasks.push_back (task); tasks.push_back (task);
} }
}
++line_number; ++line_number;
} }
@ -198,17 +196,12 @@ int TDB2::load (std::vector <T2>& tasks, Filter& filter)
int length = ::strlen (line); int length = ::strlen (line);
if (length > 1) if (length > 1)
{ {
// TODO Add hidden attribute indicating source?
line[length - 1] = '\0'; // Kill \n line[length - 1] = '\0'; // Kill \n
std::cout << "# line: " << line << std::endl;
T2 task (line); T2 task (line);
if (filter.pass (task)) if (filter.pass (task))
{
// TODO Add hidden attribute indicating source.
tasks.push_back (task); tasks.push_back (task);
} }
}
++line_number; ++line_number;
} }

View file

@ -10,10 +10,6 @@ int main (int argc, char** argv)
try try
{ {
context.initialize (argc, argv); context.initialize (argc, argv);
// context.run ();
////////////////////////////////////////////////////////////////////////////////
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
context.filter.push_back (Att ("priority", "L")); 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; std::cout << "# " << quantity << " <-- context.tdb.load" << std::endl;
context.tdb.unlock (); context.tdb.unlock ();
////////////////////////////////////////////////////////////////////////////////
return 0; return 0;
} }