diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-23 14:46:30 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-23 14:46:30 -0400 |
commit | f96daf5fdee73e001ab392b1af904c0f3c824121 (patch) | |
tree | 842f94bf116a26ef9ffd379ad66441a7d7582704 /src/value.cc | |
parent | 4ab50df56434cc6f50c2f99dbfef14768524de51 (diff) | |
download | fork-ledger-f96daf5fdee73e001ab392b1af904c0f3c824121.tar.gz fork-ledger-f96daf5fdee73e001ab392b1af904c0f3c824121.tar.bz2 fork-ledger-f96daf5fdee73e001ab392b1af904c0f3c824121.zip |
Corrects to code that compares balances to zero
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/value.cc b/src/value.cc index 4ccfad81..5d32f8b7 100644 --- a/src/value.cc +++ b/src/value.cc @@ -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; } |