From 2aa224d278b73786bd1796acc8409f163f5ea21b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 15 Apr 2014 23:37:05 -0400 Subject: [PATCH] TW-1298 - TW-1298 The color 'orange' is not recognized. - taskwarrior will not start anymore (thanks to Bernd Humpa). --- AUTHORS | 1 + ChangeLog | 2 ++ src/rules.cpp | 64 +++++++++++++++++++++++++++++---------------------- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/AUTHORS b/AUTHORS index 1d87fc60b..86ed68c76 100644 --- a/AUTHORS +++ b/AUTHORS @@ -207,3 +207,4 @@ suggestions: Michele Vetturi Jeremiah Marks Profpatsch + Bernd Humpa diff --git a/ChangeLog b/ChangeLog index 0622819f2..de1b738be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,8 @@ Wilk). - TW-1296 make test/run_all exit with non-zero code if a test fail (thanks to Jakub Wilk). +- TW-1298 The color 'orange' is not recognized. - taskwarrior will not start + anymore (thanks to Bernd Humpa). - TW-1300 _get could use return codes (thanks to Scott Kostyshak). - TW-1301 Virtual tag +PENDING (thanks to Profpatsch). - TW-1302 CmdShow.cpp:244: bad length in substr ? (thanks to David Binderman). diff --git a/src/rules.cpp b/src/rules.cpp index 3d7652a70..0e6015d26 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -41,40 +41,48 @@ static Date now; //////////////////////////////////////////////////////////////////////////////// void initializeColorRules () { - gsColor.clear (); - gsPrecedence.clear (); - - // Load all the configuration values, filter to only the ones that begin with - // "color.", then store name/value in gsColor, and name in rules. - std::vector rules; - Config::const_iterator v; - for (v = context.config.begin (); v != context.config.end (); ++v) + try { - if (v->first.substr (0, 6) == "color.") - { - Color c (v->second); - gsColor[v->first] = c; + gsColor.clear (); + gsPrecedence.clear (); - rules.push_back (v->first); + // Load all the configuration values, filter to only the ones that begin with + // "color.", then store name/value in gsColor, and name in rules. + std::vector rules; + Config::const_iterator v; + for (v = context.config.begin (); v != context.config.end (); ++v) + { + if (v->first.substr (0, 6) == "color.") + { + Color c (v->second); + gsColor[v->first] = c; + + rules.push_back (v->first); + } + } + + // Load the rule.precedence.color list, split it, then autocomplete against + // the 'rules' vector loaded above. + std::vector results; + std::vector precedence; + split (precedence, context.config.get ("rule.precedence.color"), ','); + + std::vector ::iterator p; + for (p = precedence.begin (); p != precedence.end (); ++p) + { + // Add the leading "color." string. + std::string rule = "color." + *p; + autoComplete (rule, rules, results, 3); // Hard-coded 3. + + std::vector ::iterator r; + for (r = results.begin (); r != results.end (); ++r) + gsPrecedence.push_back (*r); } } - // Load the rule.precedence.color list, split it, then autocomplete against - // the 'rules' vector loaded above. - std::vector results; - std::vector precedence; - split (precedence, context.config.get ("rule.precedence.color"), ','); - - std::vector ::iterator p; - for (p = precedence.begin (); p != precedence.end (); ++p) + catch (const std::string& e) { - // Add the leading "color." string. - std::string rule = "color." + *p; - autoComplete (rule, rules, results, 3); // Hard-coded 3. - - std::vector ::iterator r; - for (r = results.begin (); r != results.end (); ++r) - gsPrecedence.push_back (*r); + context.error (e); } }