diff --git a/src/Eval.cpp b/src/Eval.cpp index b62f39bf4..4e933aa10 100644 --- a/src/Eval.cpp +++ b/src/Eval.cpp @@ -28,10 +28,12 @@ #include #include #include +#include #include #include extern Context context; +extern Task& contextTask; //////////////////////////////////////////////////////////////////////////////// // Supported operators, borrowed from C++, particularly the precedence. @@ -287,8 +289,8 @@ void Eval::evaluatePostfixStack ( else if (token->first == "xor") left = left.operator_xor (right); else if (token->first == "~") left = left.operator_match (right); else if (token->first == "!~") left = left.operator_nomatch (right); - else if (token->first == "_hastag_") left = left.operator_hastag (right); - else if (token->first == "_notag_") left = left.operator_notag (right); + else if (token->first == "_hastag_") left = left.operator_hastag (right, contextTask); + else if (token->first == "_notag_") left = left.operator_notag (right, contextTask); else std::cout << "# Unrecognized operator '" << token->first << "'\n"; diff --git a/src/Variant.cpp b/src/Variant.cpp index cefbaf96c..59cbe00e8 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -917,29 +917,17 @@ bool Variant::operator_nopartial (const Variant& other) const } //////////////////////////////////////////////////////////////////////////////// -bool Variant::operator_hastag (const Variant& other) const +bool Variant::operator_hastag (const Variant& other, const Task& task) const { - Variant left (*this); // tags - Variant right (other); // tag - - left.cast (type_string); + Variant right (other); right.cast (type_string); - - std::vector individual; - split (individual, left._string, ','); - - std::vector ::iterator i; - for (i = individual.begin (); i != individual.end (); ++i) - if (*i == right._string) - return true; - - return false; + return task.hasTag (right._string); } //////////////////////////////////////////////////////////////////////////////// -bool Variant::operator_notag (const Variant& other) const +bool Variant::operator_notag (const Variant& other, const Task& task) const { - return ! operator_hastag (other); + return ! operator_hastag (other, task); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Variant.h b/src/Variant.h index 137640f3e..bd6ddb0f6 100644 --- a/src/Variant.h +++ b/src/Variant.h @@ -29,6 +29,7 @@ #include #include +#include class Variant { @@ -67,8 +68,8 @@ public: bool operator_nomatch (const Variant&) const; bool operator_partial (const Variant&) const; bool operator_nopartial (const Variant&) const; - bool operator_hastag (const Variant&) const; - bool operator_notag (const Variant&) const; + bool operator_hastag (const Variant&, const Task&) const; + bool operator_notag (const Variant&, const Task&) const; bool operator! () const; Variant& operator^= (const Variant&);