Don't allow trailing ws in abbrev. account segments

Fixes #358
This commit is contained in:
John Wiegley 2012-03-16 05:30:34 -05:00
parent 2605d8a711
commit 6305855997
4 changed files with 22 additions and 4 deletions

View file

@ -4,7 +4,7 @@
""
:group 'ledger)
(defcustom ledger-post-auto-adjust-amounts t
(defcustom ledger-post-auto-adjust-amounts nil
"If non-nil, ."
:type 'boolean
:group 'ledger-post)

View file

@ -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");

View file

@ -21,11 +21,11 @@
test reg --account=payee
08-Jan-01 January January:Expenses:Books $10.00 $10.00
08-Jan-01 January January:Assets:Cash $-10.00 0
08-Jan-31 End of January End of :Expenses:Books $10.00 $10.00
08-Jan-31 End of January End of:Expenses:Books $10.00 $10.00
08-Jan-31 End of January End of Jan:Assets:Cash $-10.00 0
08-Feb-01 February Februar:Expenses:Books $20.00 $20.00
08-Feb-01 February February:Assets:Cash $-20.00 0
08-Feb-28 End of February End of :Expenses:Books $20.00 $20.00
08-Feb-28 End of February End of:Expenses:Books $20.00 $20.00
08-Feb-28 End of February End of Feb:Assets:Cash $-20.00 0
08-Mar-01 March March:Expenses:Books $30.00 $30.00
08-Mar-01 March March:Assets:Cash $-30.00 0

View file

@ -0,0 +1,8 @@
2012-03-16 KFC
Expenses:E of March: End of April $100.00
Assets:Cash
test reg
12-Mar-16 KFC Ex:E of: End of April $100.00 $100.00
Assets:Cash $-100.00 0
end test