summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-04-13 05:06:13 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 05:06:13 -0400
commita451dd9285cc9c220532691f4b3617f3ab467a17 (patch)
tree9dff75cb05ab0f47eed4281232d680a0b608c1e4 /amount.cc
parentb72236d544b89a482fb389edc16aa958db138a09 (diff)
downloadfork-ledger-a451dd9285cc9c220532691f4b3617f3ab467a17.tar.gz
fork-ledger-a451dd9285cc9c220532691f4b3617f3ab467a17.tar.bz2
fork-ledger-a451dd9285cc9c220532691f4b3617f3ab467a17.zip
Fixes to the commodity comparison logic.
Diffstat (limited to 'amount.cc')
-rw-r--r--amount.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/amount.cc b/amount.cc
index 948c1738..4f07b0b0 100644
--- a/amount.cc
+++ b/amount.cc
@@ -1793,9 +1793,9 @@ bool compare_amount_commodities::operator()(const amount_t * left,
rightprice.reduce();
if (leftprice.commodity() == rightprice.commodity()) {
- amount_t val = leftprice - rightprice;
- if (val)
- return val < 0;
+ int diff = leftprice.compare(rightprice);
+ if (diff)
+ return diff;
} else {
// Since we have two different amounts, there's really no way
// to establish a true sorting order; we'll just do it based
@@ -1803,9 +1803,9 @@ bool compare_amount_commodities::operator()(const amount_t * left,
leftprice.clear_commodity();
rightprice.clear_commodity();
- amount_t val = leftprice - rightprice;
- if (val)
- return val < 0;
+ int diff = leftprice.compare(rightprice);
+ if (diff)
+ return diff;
}
}
@@ -1828,6 +1828,8 @@ bool compare_amount_commodities::operator()(const amount_t * left,
if (! aleftcomm.tag.empty() && ! arightcomm.tag.empty())
return aleftcomm.tag < arightcomm.tag;
+ // The two annotated commodities don't differ enough to matter. This
+ // should make this identical.
assert(0);
return true;
}