diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-16 05:30:34 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-16 05:30:34 -0500 |
commit | 630585599786427e25d9758638ff3b7d74680b4f (patch) | |
tree | 12ea6bfd90d7308a4920cbddae4edcec60c3bfa3 /src/format.cc | |
parent | 2605d8a711348dd677a99749b155ed2d6085cd59 (diff) | |
download | fork-ledger-630585599786427e25d9758638ff3b7d74680b4f.tar.gz fork-ledger-630585599786427e25d9758638ff3b7d74680b4f.tar.bz2 fork-ledger-630585599786427e25d9758638ff3b7d74680b4f.zip |
Don't allow trailing ws in abbrev. account segments
Fixes #358
Diffstat (limited to 'src/format.cc')
-rw-r--r-- | src/format.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/format.cc b/src/format.cc index 79f94869..8c3cbc14 100644 --- a/src/format.cc +++ b/src/format.cc @@ -599,6 +599,7 @@ string format_t::truncate(const unistring& ustr, index = 0; #endif std::size_t counter = lens.size(); + std::list<string>::iterator x = parts.begin(); for (std::list<std::size_t>::iterator i = lens.begin(); i != lens.end(); i++) { @@ -628,12 +629,21 @@ string format_t::truncate(const unistring& ustr, if (adjust > 0) { DEBUG("format.abbrev", "Reducing segment " << ++index << " by " << adjust << " chars"); + while (std::isspace((*x)[*i - adjust - 1]) && adjust < *i) { + DEBUG("format.abbrev", + "Segment ends in whitespace, adjusting down"); + ++adjust; + } (*i) -= adjust; DEBUG("format.abbrev", "Segment " << index << " is now " << *i << " chars wide"); - overflow -= adjust; + if (adjust > overflow) + overflow = 0; + else + overflow -= adjust; DEBUG("format.abbrev", "Overflow is now " << overflow << " chars"); } + ++x; } DEBUG("format.abbrev", "Overflow ending this time at " << overflow << " chars"); |