mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Variant
- Corrected handling for ::operator_partial when one of the operands is trivial.
This commit is contained in:
parent
adb5f2b4bd
commit
2a3c5e59c7
1 changed files with 13 additions and 17 deletions
|
@ -1022,26 +1022,28 @@ bool Variant::operator_partial (const Variant& other) const
|
||||||
case type_integer:
|
case type_integer:
|
||||||
case type_real:
|
case type_real:
|
||||||
case type_string:
|
case type_string:
|
||||||
if (left.trivial () || right.trivial ())
|
{
|
||||||
|
right.cast (type_string);
|
||||||
|
int left_len = left._string.length ();
|
||||||
|
int right_len = right._string.length ();
|
||||||
|
|
||||||
|
if ((left_len == 0 && right_len != 0) ||
|
||||||
|
(left_len != 0 && right_len == 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
right.cast (type_string);
|
// Dodgy.
|
||||||
if (left._string.length () < right._string.length ())
|
if (left._string.length () < right._string.length ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return left._string.substr (0, right._string.length ()) == right._string;
|
return left._string.substr (0, right._string.length ()) == right._string;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Implement same-day comparison.
|
// TODO Implement same-day comparison.
|
||||||
case type_date:
|
case type_date:
|
||||||
if (left.trivial () || right.trivial ())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
left.cast (type_date);
|
left.cast (type_date);
|
||||||
return left._date == right._date;
|
return left._date == right._date;
|
||||||
|
|
||||||
case type_duration:
|
case type_duration:
|
||||||
if (left.trivial () || right.trivial ())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
left.cast (type_duration);
|
left.cast (type_duration);
|
||||||
return left._duration == right._duration;
|
return left._duration == right._duration;
|
||||||
|
@ -1061,9 +1063,6 @@ bool Variant::operator_partial (const Variant& other) const
|
||||||
case type_string:
|
case type_string:
|
||||||
case type_date:
|
case type_date:
|
||||||
case type_duration:
|
case type_duration:
|
||||||
if (left.trivial () || right.trivial ())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
right.cast (type_date);
|
right.cast (type_date);
|
||||||
return left._date == right._date;
|
return left._date == right._date;
|
||||||
}
|
}
|
||||||
|
@ -1082,9 +1081,6 @@ bool Variant::operator_partial (const Variant& other) const
|
||||||
case type_string:
|
case type_string:
|
||||||
case type_date:
|
case type_date:
|
||||||
case type_duration:
|
case type_duration:
|
||||||
if (left.trivial () || right.trivial ())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
right.cast (type_duration);
|
right.cast (type_duration);
|
||||||
return left._duration == right._duration;
|
return left._duration == right._duration;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue