Changed how comments are output to be more logical

This commit is contained in:
John Wiegley 2009-03-01 05:40:44 -04:00
parent 9a23b73491
commit ad42447475
3 changed files with 16 additions and 12 deletions

View file

@ -158,11 +158,12 @@ void item_t::parse_tags(const char * p, int current_year)
void item_t::append_note(const char * p, int current_year)
{
if (note)
if (note) {
*note += '\n';
*note += p;
else
} else {
note = p;
*note += '\n';
}
parse_tags(p, current_year);
}
@ -251,15 +252,17 @@ namespace {
value_t get_comment(item_t& item)
{
if (! item.note) {
return false;
return string_value("");
} else {
// jww (2009-03-01): If the comment is a short one-liner, put it at the
// end of the post/xact
std::ostringstream buf;
buf << "\n ;";
bool need_separator = false;
for (const char * p = item.note->c_str(); *p; p++) {
if (*p == '\n')
if (*p == '\n') {
need_separator = true;
else {
} else {
if (need_separator) {
buf << "\n ;";
need_separator = false;

View file

@ -267,6 +267,8 @@ value_t report_t::fn_join(call_scope_t& args)
foreach (const char ch, args[0].to_string())
if (ch != '\n')
out << ch;
else
out << "\\n";
return string_value(out.str());
}

View file

@ -301,10 +301,9 @@ public:
"%(quoted(payee)),"
"%(quoted(account)),"
"%(quoted(scrub(display_amount))),"
"%(quoted((cleared or xact.cleared) ?"
" \"*\" : ((pending or xact.pending) ? \"!\" : \"\"))),"
"%(quoted(cleared ? \"*\" : (pending ? \"!\" : \"\"))),"
"%(quoted(code)),"
"%(quoted(join(note)))\n");
"%(quoted(join(note | xact.note)))\n");
});
OPTION_(report_t, current, DO() { // -c
@ -521,21 +520,21 @@ public:
" \"=\" + format_date(xact.effective_date, \"%Y/%m/%d\") : \"\")"
"%(xact.cleared ? \" *\" : (xact.pending ? \" !\" : \"\"))"
"%(code ? \" (\" + code + \")\" :"
" \"\") %(payee)%(xact.comment | \"\")\n"
" \"\") %(payee)%(xact.comment)\n"
" %(xact.uncleared ?"
" (cleared ? \"* \" : (pending ? \"! \" : \"\")) : \"\")"
"%-34(account)"
" %12(calculated ? \"\" : justify(scrub(amount), 12, -1, true))"
"%(has_cost & !cost_calculated ?"
" \" @ \" + justify(scrub(abs(cost / amount)), 0) : \"\")"
"%(comment | \"\")\n%/"
"%(comment)\n%/"
" %(xact.uncleared ?"
" (cleared ? \"* \" : (pending ? \"! \" : \"\")) : \"\")"
"%-34(account)"
" %12(calculated ? \"\" : justify(scrub(amount), 12, -1, true))"
"%(has_cost & !cost_calculated ?"
" \" @ \" + justify(scrub(abs(cost / amount)), 0) : \"\")"
"%(comment | \"\")\n%/\n");
"%(comment)\n%/\n");
});
OPTION_(report_t, quantity, DO() { // -O