From 12616dd030811b79b4e4270628fff3d478bf7074 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 17:30:34 -0400 Subject: [PATCH 1/9] Fixed an error with post-simplified math --- src/value.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/value.cc b/src/value.cc index cd4c4aa1..23806d24 100644 --- a/src/value.cc +++ b/src/value.cc @@ -658,7 +658,18 @@ value_t& value_t::operator/=(const value_t& val) return *this; case BALANCE: if (val.as_balance().single_amount()) { - as_amount_lval() /= val.simplified().as_amount(); + value_t simpler(val.simplified()); + switch (simpler.type()) { + case INTEGER: + as_amount_lval() /= simpler.as_long(); + break; + case AMOUNT: + as_amount_lval() /= simpler.as_amount(); + break; + default: + assert(0); + break; + } return *this; } break; From cbf8f355d16224bc119e2d41a22a1d0b9d7bf0ff Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 17:30:53 -0400 Subject: [PATCH 2/9] In budget report, color large percentages magenta --- src/report.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/report.h b/src/report.h index 8c66c88a..c0c8c4a6 100644 --- a/src/report.h +++ b/src/report.h @@ -378,15 +378,31 @@ public: on(none, "%(justify(scrub(get_at(total_expr, 0)), 12, -1, true, color))" " %(justify(scrub(- get_at(total_expr, 1)), 12, -1, true, color))" - " %(justify(scrub(get_at(total_expr, 1) + get_at(total_expr, 0)), 12, -1, true, color))" - " %(justify(scrub((100% * get_at(total_expr, 0)) / - get_at(total_expr, 1)), 5, -1, true, color))" + " %(justify(scrub(get_at(total_expr, 1) + " + " get_at(total_expr, 0)), 12, -1, true, color))" + " %(ansify_if(" + " justify((get_at(total_expr, 1) ? " + " scrub((100% * get_at(total_expr, 0)) / " + " - get_at(total_expr, 1)) : 0), " + " 5, -1, true, false)," + " magenta if (color and get_at(total_expr, 1) and " + " (abs(quantity(get_at(total_expr, 0)) / " + " quantity(get_at(total_expr, 1))) >= 1))))" " %(!options.flat ? depth_spacer : \"\")" "%-(ansify_if(partial_account(options.flat), blue if color))\n" "%/" "%(justify(scrub(get_at(total_expr, 0)), 12, -1, true, color))" " %(justify(scrub(- get_at(total_expr, 1)), 12, -1, true, color))" - " %(justify(scrub(get_at(total_expr, 1) + get_at(total_expr, 0)), 12, -1, true, color))" - " %(justify(scrub((100% * get_at(total_expr, 0)) / - get_at(total_expr, 1)), 5, -1, true, color))\n%/" + " %(justify(scrub(get_at(total_expr, 1) + " + " get_at(total_expr, 0)), 12, -1, true, color))" + " %(ansify_if(" + " justify((get_at(total_expr, 1) ? " + " scrub((100% * get_at(total_expr, 0)) / " + " - get_at(total_expr, 1)) : 0), " + " 5, -1, true, false)," + " magenta if (color and get_at(total_expr, 1) and " + " (abs(quantity(get_at(total_expr, 0)) / " + " quantity(get_at(total_expr, 1))) >= 1))))\n%/" "------------ ------------ ------------ -----\n"); }); From aae134f69275e4f71ec70d893cdfd0b5839fef8e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 19:01:55 -0400 Subject: [PATCH 3/9] Fixed a display issue with the balance report --- src/balance.cc | 6 +++++- src/flags.h | 5 +++++ src/format.cc | 57 +++++++++++++++++++++++++------------------------- src/format.h | 24 +++++++++++++++++---- src/output.cc | 14 ++++++------- src/report.h | 44 ++++++++------------------------------ src/value.cc | 10 ++++----- 7 files changed, 79 insertions(+), 81 deletions(-) diff --git a/src/balance.cc b/src/balance.cc index 274f860a..86352fa2 100644 --- a/src/balance.cc +++ b/src/balance.cc @@ -290,7 +290,11 @@ void balance_t::print(std::ostream& out, if (first) { out.width(first_width); - out << (right_justify ? std::right : std::left) << 0; + if (right_justify) + out << std::right; + else + out << std::left; + out << 0; } } diff --git a/src/flags.h b/src/flags.h index fb51a3e6..21607fc2 100644 --- a/src/flags.h +++ b/src/flags.h @@ -75,6 +75,11 @@ public: TRACE_DTOR(supports_flags); } + supports_flags& operator=(const supports_flags& other) { + _flags = other._flags; + return *this; + } + flags_t flags() const { return _flags; } diff --git a/src/format.cc b/src/format.cc index ea38c861..8ac14aa2 100644 --- a/src/format.cc +++ b/src/format.cc @@ -92,7 +92,8 @@ namespace { } } -format_t::element_t * format_t::parse_elements(const string& fmt) +format_t::element_t * format_t::parse_elements(const string& fmt, + const optional& tmpl) { std::auto_ptr result; @@ -101,34 +102,6 @@ format_t::element_t * format_t::parse_elements(const string& fmt) char buf[1024]; char * q = buf; - // The following format codes need to be implemented as functions: - // - // d: COMPLETE_DATE_STRING - // D: DATE_STRING - // S: SOURCE; break - // B: XACT_BEG_POS - // b: XACT_BEG_LINE - // E: XACT_END_POS - // e: XACT_END_LINE - // X: CLEARED - // Y: XACT_CLEARED - // C: CODE - // P: PAYEE - // W: OPT_ACCOUNT - // a: ACCOUNT_NAME - // A: ACCOUNT_FULLNAME - // t: AMOUNT - // o: OPT_AMOUNT - // T: TOTAL - // N: NOTE - // n: OPT_NOTE - // _: DEPTH_SPACER - // - // xB: POST_BEG_POS - // xb: POST_BEG_LINE - // xE: POST_END_POS - // xe: POST_END_LINE - for (const char * p = fmt.c_str(); *p; p++) { if (*p != '%' && *p != '\\') { *q++ = *p; @@ -203,6 +176,32 @@ format_t::element_t * format_t::parse_elements(const string& fmt) current->chars = "%"; break; + case '$': { + if (! tmpl) + throw_(format_error, _("Prior field reference, but no template")); + + p++; + if (*p == '0' || (! std::isdigit(*p) && + *p != 'A' && *p != 'B' && *p != 'C' && + *p != 'D' && *p != 'E' && *p != 'F')) + throw_(format_error, _("%$ field reference must be a digit from 1-9")); + + unsigned int index = std::isdigit(*p) ? *p - '0' : (*p - 'A' + 10); + element_t * tmpl_elem = tmpl->elements.get(); + + for (unsigned int i = 1; i < index && tmpl_elem; i++) { + tmpl_elem = tmpl_elem->next.get(); + while (tmpl_elem && tmpl_elem->type != element_t::EXPR) + tmpl_elem = tmpl_elem->next.get(); + } + + if (! tmpl_elem) + throw_(format_error, _("%$ reference to a non-existent prior field")); + + *current = *tmpl_elem; + break; + } + case '(': case '{': { bool format_amount = *p == '{'; diff --git a/src/format.h b/src/format.h index bc513f71..8b2a7965 100644 --- a/src/format.h +++ b/src/format.h @@ -61,7 +61,7 @@ DECLARE_EXCEPTION(format_error, std::runtime_error); */ class format_t : public noncopyable { - struct element_t : public supports_flags<>, public noncopyable + struct element_t : public supports_flags<> { #define ELEMENT_ALIGN_LEFT 0x01 @@ -82,6 +82,21 @@ class format_t : public noncopyable ~element_t() throw() { TRACE_DTOR(element_t); } + element_t(const element_t& elem) : supports_flags<>() { + *this = elem; + } + + element_t& operator=(const element_t& elem) { + if (this != &elem) { + supports_flags<>::operator=(elem); + type = elem.type; + min_width = elem.min_width; + max_width = elem.max_width; + chars = elem.chars; + expr = elem.expr; + } + return *this; + } friend inline void mark_red(std::ostream& out, const element_t * elem) { out.setf(std::ios::left); @@ -114,7 +129,8 @@ public: static bool default_style_changed; private: - static element_t * parse_elements(const string& fmt); + static element_t * parse_elements(const string& fmt, + const optional& tmpl); public: format_t() { @@ -128,8 +144,8 @@ public: TRACE_DTOR(format_t); } - void parse(const string& _format) { - elements.reset(parse_elements(_format)); + void parse(const string& _format, const optional& tmpl = none) { + elements.reset(parse_elements(_format, tmpl)); format_string = _format; } diff --git a/src/output.cc b/src/output.cc index b1a8cb1b..371319bd 100644 --- a/src/output.cc +++ b/src/output.cc @@ -54,10 +54,10 @@ format_posts::format_posts(report_t& _report, first_line_format.parse(string(f, 0, p - f)); const char * n = p + 2; if (const char * p = std::strstr(n, "%/")) { - next_lines_format.parse(string(n, 0, p - n)); - between_format.parse(string(p + 2)); + next_lines_format.parse(string(n, 0, p - n), first_line_format); + between_format.parse(string(p + 2), first_line_format); } else { - next_lines_format.parse(n); + next_lines_format.parse(n, first_line_format); } } else { first_line_format.parse(format); @@ -125,14 +125,14 @@ format_accounts::format_accounts(report_t& _report, account_line_format.parse(string(f, 0, p - f)); const char * n = p + 2; if (const char * p = std::strstr(n, "%/")) { - total_line_format.parse(string(n, 0, p - n)); - separator_format.parse(string(p + 2)); + total_line_format.parse(string(n, 0, p - n), account_line_format); + separator_format.parse(string(p + 2), account_line_format); } else { - total_line_format.parse(n); + total_line_format.parse(n, account_line_format); } } else { account_line_format.parse(format); - total_line_format.parse(format); + total_line_format.parse(format, account_line_format); } } diff --git a/src/report.h b/src/report.h index c0c8c4a6..e665ac2d 100644 --- a/src/report.h +++ b/src/report.h @@ -347,7 +347,7 @@ public: "%(justify(scrub(display_total), 20, -1, true, color))" " %(!options.flat ? depth_spacer : \"\")" "%-(ansify_if(partial_account(options.flat), blue if color))\n%/" - "%(justify(scrub(display_total), 20, -1, true, color))\n%/" + "%$1\n%/" "--------------------\n"); }); @@ -377,9 +377,11 @@ public: OPTION__(report_t, budget_format_, CTOR(report_t, budget_format_) { on(none, "%(justify(scrub(get_at(total_expr, 0)), 12, -1, true, color))" - " %(justify(scrub(- get_at(total_expr, 1)), 12, -1, true, color))" + " %(justify(scrub(- get_at(total_expr, 1)), 12, " + " 12 + 1 + 12, true, color))" " %(justify(scrub(get_at(total_expr, 1) + " - " get_at(total_expr, 0)), 12, -1, true, color))" + " get_at(total_expr, 0)), 12, " + " 12 + 1 + 12 + 1 + 12, true, color))" " %(ansify_if(" " justify((get_at(total_expr, 1) ? " " scrub((100% * get_at(total_expr, 0)) / " @@ -390,19 +392,7 @@ public: " quantity(get_at(total_expr, 1))) >= 1))))" " %(!options.flat ? depth_spacer : \"\")" "%-(ansify_if(partial_account(options.flat), blue if color))\n" - "%/" - "%(justify(scrub(get_at(total_expr, 0)), 12, -1, true, color))" - " %(justify(scrub(- get_at(total_expr, 1)), 12, -1, true, color))" - " %(justify(scrub(get_at(total_expr, 1) + " - " get_at(total_expr, 0)), 12, -1, true, color))" - " %(ansify_if(" - " justify((get_at(total_expr, 1) ? " - " scrub((100% * get_at(total_expr, 0)) / " - " - get_at(total_expr, 1)) : 0), " - " 5, -1, true, false)," - " magenta if (color and get_at(total_expr, 1) and " - " (abs(quantity(get_at(total_expr, 0)) / " - " quantity(get_at(total_expr, 1))) >= 1))))\n%/" + "%/%$1 %$2 %$3 %$4\n%/" "------------ ------------ ------------ -----\n"); }); @@ -419,9 +409,7 @@ public: " %(latest_cleared ? format_date(latest_cleared) : \" \")" " %(!options.flat ? depth_spacer : \"\")" "%-(ansify_if(partial_account(options.flat), blue if color))\n%/" - "%(justify(scrub(get_at(total_expr, 0)), 16, -1, true, color))" - " %(justify(scrub(get_at(total_expr, 1)), 16, -1, true, color))" - " %(latest_cleared ? format_date(latest_cleared) : \" \")\n%/" + "%$1 %$2 %$3\n%/" "---------------- ---------------- ---------\n"); }); @@ -694,13 +682,7 @@ public: "%(has_cost & !cost_calculated ?" " \" @ \" + justify(scrub(abs(cost / amount)), 0) : \"\")" "%(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"); + " %$7%$8 %$9%$A%$B\n%/\n"); }); OPTION_(report_t, quantity, DO() { // -O @@ -733,15 +715,7 @@ public: " %(justify(scrub(display_total), total_width, " " 4 + date_width + payee_width + account_width + amount_width " " + total_width, true, color))\n%/" - "%(justify(\" \", 2 + date_width + payee_width))" - "%(ansify_if(justify(truncated(account, account_width, abbrev_len), " - " account_width), blue if color))" - " %(justify(scrub(display_amount), amount_width, " - " 3 + date_width + payee_width + account_width + amount_width, " - " true, color))" - " %(justify(scrub(display_total), total_width, " - " 4 + date_width + payee_width + account_width + amount_width " - " + total_width, true, color))\n"); + "%(justify(\" \", 2 + date_width + payee_width))%$3 %$4 %$5\n"); }); OPTION(report_t, related); // -r diff --git a/src/value.cc b/src/value.cc index 23806d24..36149bff 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1558,6 +1558,11 @@ void value_t::print(std::ostream& out, break; } + case BALANCE: + as_balance().print(out, first_width, latter_width, right_justify, + colorize); + break; + case STRING: justify(out, as_string(), first_width, right_justify); break; @@ -1582,11 +1587,6 @@ void value_t::print(std::ostream& out, break; } - case BALANCE: - as_balance().print(out, first_width, latter_width, right_justify, - colorize); - break; - case POINTER: out << ""; break; From ab433d28e08bbe23bbc75d333ed63343356e043a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 21:32:55 -0400 Subject: [PATCH 4/9] Support a --now option, for testing purposes This sets Ledger's notion of the "current time" to the given date. This makes it possible to have stable output from budgeting and forecasting reports, for the sake of baseline tests. --- src/report.cc | 1 + src/report.h | 10 ++++++++++ src/times.cc | 2 ++ src/times.h | 11 ++++++++--- ...recast-while.test.save => opt-forecast-while.test} | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) rename test/baseline/{opt-forecast-while.test.save => opt-forecast-while.test} (99%) diff --git a/src/report.cc b/src/report.cc index 7f31b615..87ebb71d 100644 --- a/src/report.cc +++ b/src/report.cc @@ -592,6 +592,7 @@ option_t * report_t::lookup_option(const char * p) OPT_CH(collapse); else OPT(no_color); else OPT(no_total); + else OPT(now_); break; case 'o': OPT(only_); diff --git a/src/report.h b/src/report.h index e665ac2d..40097c8d 100644 --- a/src/report.h +++ b/src/report.h @@ -250,6 +250,7 @@ public: HANDLER(market).report(out); HANDLER(monthly).report(out); HANDLER(no_total).report(out); + HANDLER(now_).report(out); HANDLER(only_).report(out); HANDLER(output_).report(out); HANDLER(pager_).report(out); @@ -602,6 +603,15 @@ public: OPTION(report_t, no_total); + OPTION_(report_t, now_, DO_(args) { + date_interval_t interval(args[1].to_string()); + if (! interval.start) + throw_(std::invalid_argument, + _("Could not determine beginning of period '%1'") + << args[1].to_string()); + ledger::epoch = datetime_t(*interval.start); + }); + OPTION__ (report_t, only_, CTOR(report_t, only_) {} diff --git a/src/times.cc b/src/times.cc index facdc4f6..7b6eb6e8 100644 --- a/src/times.cc +++ b/src/times.cc @@ -35,6 +35,8 @@ namespace ledger { +optional epoch; + date_time::weekdays start_of_week = gregorian::Sunday; //#define USE_BOOST_FACETS 1 diff --git a/src/times.h b/src/times.h index c77cde1d..035d86cd 100644 --- a/src/times.h +++ b/src/times.h @@ -66,12 +66,17 @@ inline bool is_valid(const date_t& moment) { return ! moment.is_not_a_date(); } +extern optional epoch; + #ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK -#define CURRENT_TIME() boost::posix_time::microsec_clock::universal_time() +#define CURRENT_TIME() \ + (epoch ? *epoch : boost::posix_time::microsec_clock::universal_time()) #else -#define CURRENT_TIME() boost::posix_time::second_clock::universal_time() +#define CURRENT_TIME() \ + (epoch ? *epoch : boost::posix_time::second_clock::universal_time()) #endif -#define CURRENT_DATE() boost::gregorian::day_clock::universal_day() +#define CURRENT_DATE() \ + (epoch ? epoch->date() : boost::gregorian::day_clock::universal_day()) extern date_time::weekdays start_of_week; diff --git a/test/baseline/opt-forecast-while.test.save b/test/baseline/opt-forecast-while.test similarity index 99% rename from test/baseline/opt-forecast-while.test.save rename to test/baseline/opt-forecast-while.test index 91e3a24f..e3f1c57a 100644 --- a/test/baseline/opt-forecast-while.test.save +++ b/test/baseline/opt-forecast-while.test @@ -1,4 +1,4 @@ -reg --forecast-while='total < $3500' books +reg --now=2009/03/21 --forecast-while='total < $3500' books <<< ~ monthly Expenses:Books $10.00 From 07cca71893ef82e4199dc0dcadba25cc0185c4ed Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 21:33:33 -0400 Subject: [PATCH 5/9] Renamed two methods, for consistency's sake --- src/account.cc | 12 ++++++------ src/account.h | 4 ++-- src/post.cc | 2 +- src/textual.cc | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/account.cc b/src/account.cc index c8fd3a6a..4bcb0c25 100644 --- a/src/account.cc +++ b/src/account.cc @@ -179,11 +179,11 @@ namespace { } value_t get_amount(account_t& account) { - return VALUE_OR_ZERO(account.self_total()); + return VALUE_OR_ZERO(account.amount()); } value_t get_total(account_t& account) { - return VALUE_OR_ZERO(account.family_total()); + return VALUE_OR_ZERO(account.total()); } value_t get_subcount(account_t& account) { @@ -377,7 +377,7 @@ account_t::xdata_t::details_t::operator+=(const details_t& other) return *this; } -value_t account_t::self_total(const optional& expr) const +value_t account_t::amount(const optional& expr) const { if (xdata_ && xdata_->has_flags(ACCOUNT_EXT_VISITED)) { posts_list::const_iterator i; @@ -402,19 +402,19 @@ value_t account_t::self_total(const optional& expr) const } } -value_t account_t::family_total(const optional& expr) const +value_t account_t::total(const optional& expr) const { if (! (xdata_ && xdata_->family_details.calculated)) { const_cast(*this).xdata().family_details.calculated = true; value_t temp; foreach (const accounts_map::value_type& pair, accounts) { - temp = pair.second->family_total(expr); + temp = pair.second->total(expr); if (! temp.is_null()) add_or_set_value(xdata_->family_details.total, temp); } - temp = self_total(expr); + temp = amount(expr); if (! temp.is_null()) add_or_set_value(xdata_->family_details.total, temp); } diff --git a/src/account.h b/src/account.h index 428f6c63..8c276c8a 100644 --- a/src/account.h +++ b/src/account.h @@ -222,8 +222,8 @@ public: return *xdata_; } - value_t self_total(const optional& expr = none) const; - value_t family_total(const optional& expr = none) const; + value_t amount(const optional& expr = none) const; + value_t total(const optional& expr = none) const; const xdata_t::details_t& self_details(bool gather_all = true) const; const xdata_t::details_t& family_details(bool gather_all = true) const; diff --git a/src/post.cc b/src/post.cc index 89d69ec1..2a44ebd8 100644 --- a/src/post.cc +++ b/src/post.cc @@ -244,7 +244,7 @@ namespace { DEBUG("post.account_amount", "Found account: " << account->fullname()); - value_t total = account->self_total(); + value_t total = account->amount(); if (total.is_null()) return 0L; else diff --git a/src/textual.cc b/src/textual.cc index 09cd8360..26500596 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -981,7 +981,7 @@ post_t * instance_t::parse_post(char * line, << "POST assign: parsed amt = " << *post->assigned_amount); amount_t& amt(*post->assigned_amount); - value_t account_total(post->account->self_total(false) + value_t account_total(post->account->amount(false) .strip_annotations(keep_details_t())); DEBUG("post.assign", From 828a1e8bf98365b6266cba95caba08a48b4c745b Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 21:34:08 -0400 Subject: [PATCH 6/9] Added --actual-dates, for overriding --effective This is so that if someone has --effective in their .ledgerrc, they can force the use of actual dates. --- src/global.cc | 4 +++- src/report.cc | 1 + src/report.h | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/global.cc b/src/global.cc index 02c9e79a..e05b2bd8 100644 --- a/src/global.cc +++ b/src/global.cc @@ -419,7 +419,9 @@ void global_scope_t::normalize_report_options(const string& verb) report_t& rep(report()); // jww (2009-02-09): These globals are a hack, but hard to avoid. - item_t::use_effective_date = rep.HANDLED(effective); + item_t::use_effective_date = (rep.HANDLED(effective) && + ! rep.HANDLED(actual_dates)); + rep.session.commodity_pool->keep_base = rep.HANDLED(base); rep.session.commodity_pool->get_quotes = rep.session.HANDLED(download); diff --git a/src/report.cc b/src/report.cc index 87ebb71d..ac51203c 100644 --- a/src/report.cc +++ b/src/report.cc @@ -506,6 +506,7 @@ option_t * report_t::lookup_option(const char * p) OPT(abbrev_len_); else OPT(account_); else OPT(actual); + else OPT(actual_dates); else OPT(add_budget); else OPT(amount_); else OPT(amount_data); diff --git a/src/report.h b/src/report.h index 40097c8d..31f65c4f 100644 --- a/src/report.h +++ b/src/report.h @@ -196,6 +196,7 @@ public: HANDLER(abbrev_len_).report(out); HANDLER(account_).report(out); HANDLER(actual).report(out); + HANDLER(actual_dates).report(out); HANDLER(add_budget).report(out); HANDLER(amount_).report(out); HANDLER(amount_data).report(out); @@ -317,6 +318,8 @@ public: parent->HANDLER(limit_).on(string("--actual"), "actual"); }); + OPTION(report_t, actual_dates); + OPTION_(report_t, add_budget, DO() { parent->budget_flags |= BUDGET_BUDGETED | BUDGET_UNBUDGETED; }); From c4f4e6b5be04c5a1b61f71c271e772928b4fb4a5 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 22:24:51 -0400 Subject: [PATCH 7/9] Added note to doc file. --- doc/Ledger.scriv/binder.scrivproj | 38 +++++++++++++++---------------- doc/Ledger.scriv/ui.xml | 4 +++- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/doc/Ledger.scriv/binder.scrivproj b/doc/Ledger.scriv/binder.scrivproj index 28592f26..d5d7401f 100644 --- a/doc/Ledger.scriv/binder.scrivproj +++ b/doc/Ledger.scriv/binder.scrivproj @@ -34589,18 +34589,17 @@ CF$UID - 1960 + 1971 CF$UID - 1959 + 1971 - ParseFootnotes MetaData ParseAnnotations - + ParseFootnotes $class @@ -34611,15 +34610,15 @@ CF$UID - 1961 + 1960 CF$UID - 1966 + 1965 CF$UID - 1969 + 1968 @@ -34633,22 +34632,22 @@ CF$UID - 1962 + 1961 CF$UID - 1963 + 1962 NS.objects CF$UID - 1964 + 1963 CF$UID - 1965 + 1964 @@ -34666,22 +34665,22 @@ CF$UID - 1962 + 1961 CF$UID - 1963 + 1962 NS.objects CF$UID - 1967 + 1966 CF$UID - 1968 + 1967 @@ -34697,27 +34696,28 @@ CF$UID - 1962 + 1961 CF$UID - 1963 + 1962 NS.objects CF$UID - 1970 + 1969 CF$UID - 1971 + 1970 Base Header Level 1 + $top diff --git a/doc/Ledger.scriv/ui.xml b/doc/Ledger.scriv/ui.xml index 5897a712..a81ce1ac 100644 --- a/doc/Ledger.scriv/ui.xml +++ b/doc/Ledger.scriv/ui.xml @@ -141,6 +141,8 @@ inspectorIsCollapsed + inspectorNotesMode + 1 inspectorReferencesColumns order @@ -160,7 +162,7 @@ inspectorSelectedDataTab - 0 + 2 inspectorSplitFrames {{0, 0}, {785, 852}} From 432be9e98981104062917e248f570d4d9f1d21ce Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 22:25:13 -0400 Subject: [PATCH 8/9] Removed unnused parameter to value_t::print --- src/report.cc | 7 ++----- src/value.cc | 24 ++++++++---------------- src/value.h | 3 +-- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/report.cc b/src/report.cc index ac51203c..e6194541 100644 --- a/src/report.cc +++ b/src/report.cc @@ -225,16 +225,13 @@ value_t report_t::fn_truncated(call_scope_t& scope) value_t report_t::fn_justify(call_scope_t& scope) { - interactive_t args(scope, "vl&lbbs"); + interactive_t args(scope, "vl&lbb"); std::ostringstream out; args.value_at(0) .print(out, args.get(1), args.has(2) ? args.get(2) : -1, args.has(3) ? args.get(3) : false, - args.has(4) ? args.get(4) : false, - args.has(5) ? args.get(5) : - (HANDLED(date_format_) ? - HANDLER(date_format_).str() : optional())); + args.has(4) ? args.get(4) : false); return string_value(out.str()); } diff --git a/src/value.cc b/src/value.cc index 36149bff..a6bbb2fb 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1497,12 +1497,11 @@ value_t value_t::strip_annotations(const keep_details_t& what_to_keep) const return NULL_VALUE; } -void value_t::print(std::ostream& out, - const int first_width, - const int latter_width, - const bool right_justify, - const bool colorize, - const optional& date_format) const +void value_t::print(std::ostream& out, + const int first_width, + const int latter_width, + const bool right_justify, + const bool colorize) const { if (first_width > 0 && (! is_amount() || as_amount().is_zero()) && @@ -1525,18 +1524,11 @@ void value_t::print(std::ostream& out, break; case DATETIME: - if (date_format) - out << format_datetime(as_datetime(), FMT_CUSTOM, - date_format->c_str()); - else - out << format_datetime(as_datetime(), FMT_WRITTEN); + out << format_datetime(as_datetime(), FMT_WRITTEN); break; case DATE: - if (date_format) - out << format_date(as_date(), FMT_CUSTOM, date_format->c_str()); - else - out << format_date(as_date(), FMT_WRITTEN); + out << format_date(as_date(), FMT_WRITTEN); break; case INTEGER: @@ -1581,7 +1573,7 @@ void value_t::print(std::ostream& out, out << ", "; value.print(out, first_width, latter_width, right_justify, - colorize, date_format); + colorize); } out << ')'; break; diff --git a/src/value.h b/src/value.h index 23c8c8d5..9aa3cb04 100644 --- a/src/value.h +++ b/src/value.h @@ -927,8 +927,7 @@ public: const int first_width = -1, const int latter_width = -1, const bool right_justify = false, - const bool colorize = false, - const optional& date_format = none) const; + const bool colorize = false) const; void dump(std::ostream& out, const bool relaxed = true) const; /** From 6c9cf1237e1e813c2d56ed51a38cc0685614e8e0 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 22:25:19 -0400 Subject: [PATCH 9/9] Whitespace change --- src/global.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/global.cc b/src/global.cc index e05b2bd8..2ce73bae 100644 --- a/src/global.cc +++ b/src/global.cc @@ -434,12 +434,10 @@ void global_scope_t::normalize_report_options(const string& verb) else rep.session.commodity_pool->price_db = none; - if (rep.HANDLED(date_format_)) { + if (rep.HANDLED(date_format_)) set_date_format(rep.HANDLER(date_format_).str().c_str()); - } - if (rep.HANDLED(datetime_format_)) { + if (rep.HANDLED(datetime_format_)) set_datetime_format(rep.HANDLER(datetime_format_).str().c_str()); - } if (rep.HANDLED(start_of_week_)) { if (optional weekday = string_to_day_of_week(rep.HANDLER(start_of_week_).str()))