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.
This commit is contained in:
Paul Beckingham 2009-06-18 23:14:26 -04:00
parent cea84b3d3b
commit 3ffb855956
4 changed files with 16 additions and 23 deletions

View file

@ -187,6 +187,16 @@ bool Att::valid (const std::string& input) const
return false; 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) bool Att::validModifiableName (const std::string& name)
{ {
@ -206,19 +216,7 @@ bool Att::validNameValue (
std::string writableName = name; std::string writableName = name;
std::string writableMod = mod; std::string writableMod = mod;
std::string writableValue = value; std::string writableValue = value;
bool status = Att::validNameValue (writableName, writableMod, writableValue); return 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;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -369,15 +367,8 @@ bool Att::validNameValue (
"\" is not a valid status. Use 'pending', 'completed', 'deleted' or 'recurring'."; "\" is not a valid status. Use 'pending', 'completed', 'deleted' or 'recurring'.";
} }
else if (name == "parent") else if (! validInternalName (name) &&
{ ! validModifiableName (name))
}
else if (name == "uuid")
{
}
else
throw std::string ("'") + name + "' is not a recognized attribute."; throw std::string ("'") + name + "' is not a recognized attribute.";
return true; return true;

View file

@ -44,6 +44,7 @@ public:
~Att (); ~Att ();
bool valid (const std::string&) const; bool valid (const std::string&) const;
static bool validInternalName (const std::string&);
static bool validModifiableName (const std::string&); static bool validModifiableName (const std::string&);
static bool validNameValue (const std::string&, const std::string&, const std::string&); static bool validNameValue (const std::string&, const std::string&, const std::string&);
static bool validNameValue (std::string&, std::string&, std::string&); static bool validNameValue (std::string&, std::string&, std::string&);

View file

@ -158,6 +158,7 @@ void Subst::apply (
if ((pattern = description.find (mFrom)) != std::string::npos) if ((pattern = description.find (mFrom)) != std::string::npos)
{ {
description.replace (pattern, mFrom.length (), mTo); description.replace (pattern, mFrom.length (), mTo);
i->value (description);
break; break;
} }
} }

View file

@ -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'); like ($output, qr/\babc\s*$/m, 'abc,ab,a,b | a -> abc');
$output = qx{../task rc:sp.rc list project:abcd}; $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. # Cleanup.
unlink 'pending.data'; unlink 'pending.data';