summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-03-16 11:03:28 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 05:48:44 -0400
commit022594bb2f48c115b55ac786aa160b546ff318f8 (patch)
tree2998d30b1e0b2b3c2c55a65e728ab2e3083d3f95
parentfd3ae9b4dd7d6dda8068ca35ec22d3d319cb804d (diff)
downloadfork-ledger-022594bb2f48c115b55ac786aa160b546ff318f8.tar.gz
fork-ledger-022594bb2f48c115b55ac786aa160b546ff318f8.tar.bz2
fork-ledger-022594bb2f48c115b55ac786aa160b546ff318f8.zip
*** no comment ***
-rw-r--r--amount.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/amount.cc b/amount.cc
index d9171715..c22e229b 100644
--- a/amount.cc
+++ b/amount.cc
@@ -818,8 +818,6 @@ std::ostream& operator<<(std::ostream& _out, const amount_t& amt)
}
if (precision) {
- out << ((comm.flags & COMMODITY_STYLE_EUROPEAN) ? ',' : '.');
-
std::ostringstream final;
final.width(precision);
final.fill('0');
@@ -834,12 +832,18 @@ std::ostream& operator<<(std::ostream& _out, const amount_t& amt)
if (q[i - 1] != '0')
break;
+ std::string ender;
if (i == len)
- out << str;
- else if (i < comm.precision)
- out << std::string(str, 0, comm.precision);
+ ender = str;
+ else if (i < comm.precision())
+ ender = std::string(str, 0, comm.precision());
else
- out << std::string(str, 0, i);
+ ender = std::string(str, 0, i);
+
+ if (! ender.empty()) {
+ out << ((comm.flags() & COMMODITY_STYLE_EUROPEAN) ? ',' : '.');
+ out << ender;
+ }
}
if (comm.flags & COMMODITY_STYLE_SUFFIXED) {