Corrects to code that compares balances to zero

This commit is contained in:
John Wiegley 2009-02-23 14:46:30 -04:00
parent 4ab50df564
commit f96daf5fde

View file

@ -788,19 +788,19 @@ bool value_t::is_less_than(const value_t& val) const
case BALANCE:
switch (val.type()) {
case INTEGER:
if (val.as_long() != 0)
break;
// fall through...
case AMOUNT:
case AMOUNT: {
if (val.is_nonzero())
break;
bool no_amounts = true;
foreach (const balance_t::amounts_map::value_type& pair,
as_balance().amounts) {
if (pair.second > 0L)
if (pair.second >= 0L)
return false;
no_amounts = false;
}
return true;
return ! no_amounts;
}
default:
break;
}
@ -858,19 +858,19 @@ bool value_t::is_greater_than(const value_t& val) const
case BALANCE:
switch (val.type()) {
case INTEGER:
if (val.as_long() != 0)
break;
// fall through...
case AMOUNT:
case AMOUNT: {
if (val.is_nonzero())
break;
bool no_amounts = true;
foreach (const balance_t::amounts_map::value_type& pair,
as_balance().amounts) {
if (pair.second < 0L)
if (pair.second <= 0L)
return false;
no_amounts = false;
}
return true;
return ! no_amounts;
}
default:
break;
}