From 3ffb85595605ca79273898be0693d1b37fc39166 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 18 Jun 2009 23:14:26 -0400 Subject: [PATCH] Bug Fixes - Att, Subst - Fixed but that required all known attributes to be listed by name in order to be recognized by creating new Att::validInternalName method. - Fixed bug in non-global Subst that failed to save a modified annotation. --- src/Att.cpp | 35 +++++++++++++---------------------- src/Att.h | 1 + src/Subst.cpp | 1 + src/tests/subproject.t | 2 +- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/Att.cpp b/src/Att.cpp index 2360de0cf..430f17d5c 100644 --- a/src/Att.cpp +++ b/src/Att.cpp @@ -187,6 +187,16 @@ bool Att::valid (const std::string& input) const return false; } +//////////////////////////////////////////////////////////////////////////////// +bool Att::validInternalName (const std::string& name) +{ + for (unsigned int i = 0; i < NUM_INTERNAL_NAMES; ++i) + if (name == internalNames[i]) + return true; + + return false; +} + //////////////////////////////////////////////////////////////////////////////// bool Att::validModifiableName (const std::string& name) { @@ -206,19 +216,7 @@ bool Att::validNameValue ( std::string writableName = name; std::string writableMod = mod; std::string writableValue = value; - bool status = Att::validNameValue (writableName, writableMod, writableValue); -/* - // TODO Is this even worth doing? - if (name != writableName) - throw std::string ("The attribute '") + name + "' was not fully qualified."; - - if (mod != writableMod) - throw std::string ("The modifier '") + mod + "' was not fully qualified."; - - if (value != writableValue) - throw std::string ("The value '") + value + "' was not fully qualified."; -*/ - return status; + return Att::validNameValue (writableName, writableMod, writableValue); } //////////////////////////////////////////////////////////////////////////////// @@ -369,15 +367,8 @@ bool Att::validNameValue ( "\" is not a valid status. Use 'pending', 'completed', 'deleted' or 'recurring'."; } - else if (name == "parent") - { - } - - else if (name == "uuid") - { - } - - else + else if (! validInternalName (name) && + ! validModifiableName (name)) throw std::string ("'") + name + "' is not a recognized attribute."; return true; diff --git a/src/Att.h b/src/Att.h index 6bc83a592..deb906bea 100644 --- a/src/Att.h +++ b/src/Att.h @@ -44,6 +44,7 @@ public: ~Att (); bool valid (const std::string&) const; + static bool validInternalName (const std::string&); static bool validModifiableName (const std::string&); static bool validNameValue (const std::string&, const std::string&, const std::string&); static bool validNameValue (std::string&, std::string&, std::string&); diff --git a/src/Subst.cpp b/src/Subst.cpp index 4dd02a6c1..4a966b084 100644 --- a/src/Subst.cpp +++ b/src/Subst.cpp @@ -158,6 +158,7 @@ void Subst::apply ( if ((pattern = description.find (mFrom)) != std::string::npos) { description.replace (pattern, mFrom.length (), mTo); + i->value (description); break; } } diff --git a/src/tests/subproject.t b/src/tests/subproject.t index 04703a28a..4fb46bd19 100755 --- a/src/tests/subproject.t +++ b/src/tests/subproject.t @@ -60,7 +60,7 @@ $output = qx{../task rc:sp.rc list project:abc}; like ($output, qr/\babc\s*$/m, 'abc,ab,a,b | a -> abc'); $output = qx{../task rc:sp.rc list project:abcd}; -like ($output, qr/^No matches.$/, 'abc,ab,a,b | abcd -> nul'); +like ($output, qr/No matches./, 'abc,ab,a,b | abcd -> nul'); # Cleanup. unlink 'pending.data';