diff --git a/src/Expression.cpp b/src/Expression.cpp index f8ea6b8c0..b4b214a9e 100644 --- a/src/Expression.cpp +++ b/src/Expression.cpp @@ -95,13 +95,13 @@ std::string Expression::evalExpression (const Task& task) { _args.dump ("Expression::evalExpression"); - expand_sequence (); - implicit_and (); - expand_tag (); - expand_pattern (); - expand_attr (); - expand_attmod (); - expand_word (); +// expand_sequence (); +// implicit_and (); +// expand_tag (); +// expand_pattern (); +// expand_attr (); +// expand_attmod (); +// expand_word (); expand_tokens (); postfix (); @@ -786,10 +786,11 @@ void Expression::expand_attr () // Canonicalize 'name'. Arguments::is_attribute (name, name); +/* // Always quote the value, so that empty values, or values containing spaces // are preserved. value = "\"" + value + "\""; - +*/ temp.push_back (Triple (name, "lvalue", arg->_third)); temp.push_back (Triple ("=", "op", arg->_third)); temp.push_back (Triple (value, "exp", arg->_third)); @@ -833,10 +834,12 @@ void Expression::expand_attmod () Arguments::is_attribute (name, name); Arguments::is_modifier (mod); +/* // Always quote the value, so that empty values, or values containing spaces // are preserved. std::string raw_value = value; value = "\"" + value + "\""; +*/ if (mod == "before" || mod == "under" || mod == "below") { @@ -888,27 +891,31 @@ void Expression::expand_attmod () } else if (mod == "startswith" || mod == "left") { - temp.push_back (Triple (name, "lvalue", arg->_third)); - temp.push_back (Triple ("~", "op", arg->_third)); - temp.push_back (Triple ("^" + raw_value, "rx", arg->_third)); + temp.push_back (Triple (name, "lvalue", arg->_third)); + temp.push_back (Triple ("~", "op", arg->_third)); +// temp.push_back (Triple ("^" + raw_value, "rx", arg->_third)); + temp.push_back (Triple ("^" + value, "rx", arg->_third)); } else if (mod == "endswith" || mod == "right") { - temp.push_back (Triple (name, "lvalue", arg->_third)); - temp.push_back (Triple ("~", "op", arg->_third)); - temp.push_back (Triple (raw_value + "$", "rx", arg->_third)); + temp.push_back (Triple (name, "lvalue", arg->_third)); + temp.push_back (Triple ("~", "op", arg->_third)); +// temp.push_back (Triple (raw_value + "$", "rx", arg->_third)); + temp.push_back (Triple (value + "$", "rx", arg->_third)); } else if (mod == "word") { - temp.push_back (Triple (name, "lvalue", arg->_third)); - temp.push_back (Triple ("~", "op", arg->_third)); - temp.push_back (Triple ("\\b" + raw_value + "\\b", "rx", arg->_third)); + temp.push_back (Triple (name, "lvalue", arg->_third)); + temp.push_back (Triple ("~", "op", arg->_third)); +// temp.push_back (Triple ("\\b" + raw_value + "\\b", "rx", arg->_third)); + temp.push_back (Triple ("\\b" + value + "\\b", "rx", arg->_third)); } else if (mod == "noword") { - temp.push_back (Triple (name, "lvalue", arg->_third)); - temp.push_back (Triple ("!~", "op", arg->_third)); - temp.push_back (Triple ("\\b" + raw_value + "\\b", "rx", arg->_third)); + temp.push_back (Triple (name, "lvalue", arg->_third)); + temp.push_back (Triple ("!~", "op", arg->_third)); +// temp.push_back (Triple ("\\b" + raw_value + "\\b", "rx", arg->_third)); + temp.push_back (Triple ("\\b" + value + "\\b", "rx", arg->_third)); } else throw std::string ("Error: unrecognized attribute modifier '") + mod + "'."; diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 2c1fa343a..70f36a1b8 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -417,16 +417,21 @@ void Command::modify_task ( std::string name; std::string value; Arguments::extract_attr (arg->_first, name, value); - if (Arguments::is_attribute (name, name)) + if (Arguments::is_attribute (name, name)) // Canonicalize { - // TODO All 'value's must be eval'd first. + // All values must be eval'd first. + Arguments fragment; + fragment.push_back (Triple (value, "exp", "attr")); + Expression e (fragment); + std::string result = e.evalExpression (task); + context.debug (std::string ("Eval '") + value + "' --> '" + result + "'"); // Dependencies must be resolved to UUIDs. if (name == "depends") { // Convert ID to UUID. std::vector deps; - split (deps, value, ','); + split (deps, result, ','); // Apply or remove dendencies in turn. std::vector ::iterator i; @@ -442,7 +447,7 @@ void Command::modify_task ( // By default, just add it. else - task.set (name, value); + task.set (name, result); } else throw format (STRING_CMD_ADD_BAD_ATTRIBUTE, name);