From e18749dec9bb2ab9d041ec231e56768e39623b00 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 14 Aug 2008 04:15:35 -0400 Subject: [PATCH] If a comparison between amounts fails, fall back and try to compare commodities instead. --- src/value.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/value.cc b/src/value.cc index 5a0c7e70..660c7663 100644 --- a/src/value.cc +++ b/src/value.cc @@ -967,7 +967,12 @@ bool value_t::operator<(const value_t& val) const case INTEGER: return as_amount() < val.as_long(); case AMOUNT: - return as_amount() < val.as_amount(); + try { + return as_amount() < val.as_amount(); + } + catch (const amount_error&) { + return compare_amount_commodities()(&as_amount(), &val.as_amount()); + } default: break; }