Fixes to the commodity comparison logic.

This commit is contained in:
John Wiegley 2008-04-13 05:06:13 -04:00
parent b72236d544
commit a451dd9285

View file

@ -1793,9 +1793,9 @@ bool compare_amount_commodities::operator()(const amount_t * left,
rightprice.reduce(); rightprice.reduce();
if (leftprice.commodity() == rightprice.commodity()) { if (leftprice.commodity() == rightprice.commodity()) {
amount_t val = leftprice - rightprice; int diff = leftprice.compare(rightprice);
if (val) if (diff)
return val < 0; return diff;
} else { } else {
// Since we have two different amounts, there's really no way // Since we have two different amounts, there's really no way
// to establish a true sorting order; we'll just do it based // 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(); leftprice.clear_commodity();
rightprice.clear_commodity(); rightprice.clear_commodity();
amount_t val = leftprice - rightprice; int diff = leftprice.compare(rightprice);
if (val) if (diff)
return val < 0; return diff;
} }
} }
@ -1828,6 +1828,8 @@ bool compare_amount_commodities::operator()(const amount_t * left,
if (! aleftcomm.tag.empty() && ! arightcomm.tag.empty()) if (! aleftcomm.tag.empty() && ! arightcomm.tag.empty())
return aleftcomm.tag < arightcomm.tag; return aleftcomm.tag < arightcomm.tag;
// The two annotated commodities don't differ enough to matter. This
// should make this identical.
assert(0); assert(0);
return true; return true;
} }