- Added regex support to substirutions.
- Fixed bug that prevented 1.9.4 from shipping with regexes.  If the
  description is "aXXaaXXa", and the substitution is /XX/.../ then the
  first substitutions changes the length of the string to "a...aaXXa"
  and therefore invalidates the index for the second match, and makes
  this change: "a...a...Xa".  The fix is to keep a running 'skew' count
  of the difference in 'from' and 'to' length, to adjust the match
  indexes.
- Moved the helper deltaSubstitutions function into the Task object,
  which makes more sense.
- Cleaned up output composition for CmdAdd.
- Eliminated #ifdef FEATURE_REGEX.  They are here to stay.
This commit is contained in:
Paul Beckingham 2011-06-25 16:33:55 -04:00
parent 622e9c5e1e
commit b58438bdd4
11 changed files with 152 additions and 166 deletions

View file

@ -27,8 +27,6 @@
#define L10N // Localization complete.
#include <sstream>
#include <stdlib.h>
#include <Context.h>
#include <text.h>
#include <i18n.h>
@ -59,7 +57,7 @@ int CmdAdd::execute (std::string& output)
std::vector <Task> all;
context.tdb.loadPending (all);
// Every task needs a UUID.
// Every new task needs a UUID.
Task task;
task.set ("uuid", uuid ());
@ -73,19 +71,15 @@ int CmdAdd::execute (std::string& output)
context.tdb.add (task);
std::stringstream out;
// TODO This should be a call in to feedback.cpp.
#ifdef FEATURE_NEW_ID
out << format (STRING_CMD_ADD_FEEDBACK, context.tdb.nextId ())
<< "\n";
output = format (STRING_CMD_ADD_FEEDBACK, context.tdb.nextId ()) + "\n";
#endif
context.footnote (onProjectChange (task));
context.tdb.commit ();
context.tdb.unlock ();
output = out.str ();
return rc;
}

View file

@ -343,6 +343,16 @@ void Command::modify_task (Task& task, Arguments& arguments)
description += arg->first;
}
// Substitutions.
else if (arg->second == "subst")
{
std::string from;
std::string to;
bool global;
Arguments::extract_subst (arg->first, from, to, global);
task.substitute (from, to, global);
}
// Any additional argument types are indicative of a failure in
// Arguments::extract_modifications.
else