diff options
author | John Wiegley <johnw@newartisans.com> | 2009-10-25 21:27:56 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-10-25 21:27:56 -0400 |
commit | 9dadaebfeb461ba795124281018d0f7eac200cf4 (patch) | |
tree | 941243868b1dcacd68cbd52a2f96e40bf70a5d3b /src/format.cc | |
parent | f35bc939c96c3a3bf09c5881d638b5ba60449c03 (diff) | |
parent | e696bfd913a10edd19f9e35eb1aee2c97b11e7f6 (diff) | |
download | fork-ledger-9dadaebfeb461ba795124281018d0f7eac200cf4.tar.gz fork-ledger-9dadaebfeb461ba795124281018d0f7eac200cf4.tar.bz2 fork-ledger-9dadaebfeb461ba795124281018d0f7eac200cf4.zip |
Merge branch 'next'
Diffstat (limited to 'src/format.cc')
-rw-r--r-- | src/format.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/format.cc b/src/format.cc index ecac1133..ea38c861 100644 --- a/src/format.cc +++ b/src/format.cc @@ -345,7 +345,7 @@ void format_t::format(std::ostream& out_str, scope_t& scope) } DEBUG("format.expr", "value = (" << value << ")"); - value.print(out, elem->min_width, -1, + value.print(out, static_cast<int>(elem->min_width), -1, ! elem->has_flags(ELEMENT_ALIGN_LEFT)); } catch (const calc_error&) { @@ -362,15 +362,15 @@ void format_t::format(std::ostream& out_str, scope_t& scope) if (elem->max_width > 0 || elem->min_width > 0) { unistring temp(out.str()); + string result; - string result; if (elem->max_width > 0 && elem->max_width < temp.length()) { result = truncate(temp, elem->max_width); } else { result = temp.extract(); - for (int i = 0; i < (static_cast<int>(elem->min_width) - - static_cast<int>(temp.length())); i++) - result += " "; + if (elem->min_width > temp.length()) + for (std::size_t i = 0; i < elem->min_width - temp.length(); i++) + result += " "; } out_str << result; } else { @@ -379,8 +379,9 @@ void format_t::format(std::ostream& out_str, scope_t& scope) } } -string format_t::truncate(const unistring& ustr, std::size_t width, - const int account_abbrev_length) +string format_t::truncate(const unistring& ustr, + const std::size_t width, + const std::size_t account_abbrev_length) { assert(width < 4095); @@ -434,7 +435,7 @@ string format_t::truncate(const unistring& ustr, std::size_t width, if (newlen > width) { unistring temp(*i); - if (temp.length() > static_cast<std::size_t>(account_abbrev_length)) { + if (temp.length() > account_abbrev_length) { result << temp.extract(0, account_abbrev_length) << ":"; newlen -= temp.length() - account_abbrev_length; } else { |