diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-21 02:17:03 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-21 02:17:03 -0400 |
commit | 13812346b6ca97ae2f505f08d898e98db907ede6 (patch) | |
tree | a004311fd7fa570cf3794e59b7a825141de0a02b | |
parent | d0ac3a2e4e4b6a28c71755fe54089e28e3a7d4db (diff) | |
download | fork-ledger-13812346b6ca97ae2f505f08d898e98db907ede6.tar.gz fork-ledger-13812346b6ca97ae2f505f08d898e98db907ede6.tar.bz2 fork-ledger-13812346b6ca97ae2f505f08d898e98db907ede6.zip |
Handle reporting widths that are too small
-rw-r--r-- | src/format.cc | 2 | ||||
-rw-r--r-- | src/report.cc | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/format.cc b/src/format.cc index b841af23..5b813ee6 100644 --- a/src/format.cc +++ b/src/format.cc @@ -286,7 +286,7 @@ string format_t::truncate(const unistring& ustr, std::size_t width, assert(width < 4095); const std::size_t len = ustr.length(); - if (len <= width) + if (width == 0 || len <= width) return ustr.extract(); std::ostringstream buf; diff --git a/src/report.cc b/src/report.cc index 074af2f3..db70817c 100644 --- a/src/report.cc +++ b/src/report.cc @@ -163,7 +163,8 @@ value_t report_t::fn_truncate(call_scope_t& args) var_t<long> width(args, 1); var_t<long> account_abbrev(args, 2); - return string_value(format_t::truncate(args[0].as_string(), *width, + return string_value(format_t::truncate(args[0].as_string(), + width && *width > 0 ? *width : 0, account_abbrev ? *account_abbrev : -1)); } |