From 59d184e2dbe1794a896954cc4e9b8100943f3528 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 5 Sep 2011 14:11:10 -0400 Subject: [PATCH] Bug - Expressions - Fixed a bug that confused left and right operands. - Fixed a bug where E9::coerce was dropping data. --- src/E9.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/E9.cpp b/src/E9.cpp index acd3ed0a8..6f45de0b1 100644 --- a/src/E9.cpp +++ b/src/E9.cpp @@ -177,7 +177,7 @@ void E9::eval (const Task& task, std::vector & value_stack) else operand._value = operand._raw; - //std::cout << "# E9::eval operand " << operand << "\n"; + // std::cout << "# E9::eval operand " << operand << "\n"; value_stack.push_back (operand); } } @@ -508,29 +508,24 @@ void E9::operator_match ( { result._type = Arg::type_bool; - // TODO The problem is that description/dom -> /string and we lose the original value. - if (eval_match (left, right, case_sensitive)) { - // std::cout << "# operator_match description match\n"; result._value = "true"; } else if (left._raw == "description") { - // std::cout << "# operator_match escalation\n"; std::map annotations; task.getAnnotations (annotations); std::map ::iterator a; for (a = annotations.begin (); a != annotations.end (); ++a) { - // Clone 'right', override _value. - Arg alternate (right); + // Clone 'left', override _value. + Arg alternate (left); alternate._value = a->second; - if (eval_match (left, alternate, case_sensitive)) + if (eval_match (alternate, right, case_sensitive)) { - // std::cout << "# operator_match annotation match\n"; result._value = "true"; break; } @@ -539,7 +534,7 @@ void E9::operator_match ( else result._value = "false"; - // std::cout << "# " << left << " " << right << " --> " << result << "\n"; +// std::cout << "# " << left << " " << right << " --> " << result << "\n"; } //////////////////////////////////////////////////////////////////////////////// @@ -565,11 +560,11 @@ void E9::operator_nomatch ( std::map ::iterator a; for (a = annotations.begin (); a != annotations.end (); ++a) { - // Clone 'right', override _value. - Arg alternate (right); + // Clone 'left', override _value. + Arg alternate (left); alternate._value = a->second; - if (eval_match (left, alternate, case_sensitive)) + if (eval_match (alternate, right, case_sensitive)) { result._value = "false"; break; @@ -613,19 +608,27 @@ const Arg E9::coerce (const Arg& input, const Arg::type type) if (type == Arg::type_bool) { - result._type = Arg::type_bool; + result._raw = input._raw; result._value = get_bool (input) ? "true" : "false"; + result._type = Arg::type_bool; + result._category = input._category; } - if (type == Arg::type_string) + else if (type == Arg::type_string) { // TODO Convert date? + result._raw = input._raw; result._value = input._value; result._type = Arg::type_string; + result._category = input._category; } // TODO Date // TODO Duration + else + { + result = input; + } return result; }