summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2005-01-28 07:53:10 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:40:50 -0400
commit9cd4cf6df82f9246c07896def2f0316ad8247a70 (patch)
tree4b81d6bb74523f30a2612c59a9431e27445da04a
parent632c54788c4cbcc49f095cf68cc394f67ec60a7e (diff)
downloadfork-ledger-9cd4cf6df82f9246c07896def2f0316ad8247a70.tar.gz
fork-ledger-9cd4cf6df82f9246c07896def2f0316ad8247a70.tar.bz2
fork-ledger-9cd4cf6df82f9246c07896def2f0316ad8247a70.zip
(format): Pay attention to the max_width setting for each formatting
element. This means that "%.20N" can no longer exceed 20 characters of width.
-rw-r--r--format.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/format.cc b/format.cc
index 57bd3c88..534a592a 100644
--- a/format.cc
+++ b/format.cc
@@ -210,9 +210,11 @@ element_t * format_t::parse_elements(const std::string& fmt)
return result.release();
}
-void format_t::format(std::ostream& out, const details_t& details) const
+void format_t::format(std::ostream& out_str, const details_t& details) const
{
for (const element_t * elem = elements; elem; elem = elem->next) {
+ std::ostringstream out;
+
if (elem->align_left)
out << std::left;
else
@@ -430,6 +432,11 @@ void format_t::format(std::ostream& out, const details_t& details) const
assert(0);
break;
}
+
+ std::string temp = out.str();
+ if (elem->max_width > 0 && elem->max_width < temp.length())
+ temp.erase(elem->max_width);
+ out_str << temp;
}
}