From 8869566331b5b95a43214157b3dd36ce076deee3 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 27 Jun 2012 16:55:46 -0500 Subject: Fixed a subtle memory overwrite Fixes #608 --- src/xact.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/xact.cc b/src/xact.cc index b5cb2a38..a54da81a 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -355,14 +355,16 @@ bool xact_base_t::finalize() } } } else { - if (post->amount.has_annotation()) { - if (breakdown.amount.has_annotation()) - breakdown.amount.annotation().tag = post->amount.annotation().tag; - else - breakdown.amount.annotate - (annotation_t(none, none, post->amount.annotation().tag)); - } - post->amount = breakdown.amount; + post->amount = + breakdown.amount.has_annotation() ? + amount_t(breakdown.amount, + annotation_t(breakdown.amount.annotation().price, + breakdown.amount.annotation().date, + post->amount.has_annotation() ? + post->amount.annotation().tag : + breakdown.amount.annotation().tag, + breakdown.amount.annotation().value_expr)) : + breakdown.amount; DEBUG("xact.finalize", "added breakdown, balance = " << balance); } -- cgit v1.2.3 From 8538878d8dc685b9dd6abae91312e52b9c35bfbd Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 30 Jul 2012 23:24:15 -0500 Subject: Guard some function definitions for ASan --- src/utils.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/utils.cc b/src/utils.cc index 1a82787d..bdce009f 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -153,6 +153,8 @@ std::size_t current_memory_size() return memory_size; } +#if !defined(__has_feature) || !__has_feature(address_sanitizer) + static void trace_new_func(void * ptr, const char * which, std::size_t size) { if (! live_memory || ! memory_tracing_active) return; @@ -221,8 +223,12 @@ static void trace_delete_func(void * ptr, const char * which) memory_tracing_active = true; } +#endif // !defined(__has_feature) || !__has_feature(address_sanitizer) + } // namespace ledger +#if !defined(__has_feature) || !__has_feature(address_sanitizer) + void * operator new(std::size_t size) throw (std::bad_alloc) { void * ptr = std::malloc(size); if (DO_VERIFY() && ledger::memory_tracing_active) @@ -268,6 +274,8 @@ void operator delete[](void * ptr, const std::nothrow_t&) throw() { std::free(ptr); } +#endif // !defined(__has_feature) || !__has_feature(address_sanitizer) + namespace ledger { namespace { -- cgit v1.2.3 From 2de6af2761672c1b0697e285de20b291a3fc3a55 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 2 Aug 2012 13:11:19 -0500 Subject: Don't use __has_feature in utils.cc --- src/utils.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/utils.cc b/src/utils.cc index bdce009f..e5faf184 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -153,7 +153,7 @@ std::size_t current_memory_size() return memory_size; } -#if !defined(__has_feature) || !__has_feature(address_sanitizer) +//#if !defined(__has_feature) || !__has_feature(address_sanitizer) static void trace_new_func(void * ptr, const char * which, std::size_t size) { @@ -223,11 +223,11 @@ static void trace_delete_func(void * ptr, const char * which) memory_tracing_active = true; } -#endif // !defined(__has_feature) || !__has_feature(address_sanitizer) +//#endif // !defined(__has_feature) || !__has_feature(address_sanitizer) } // namespace ledger -#if !defined(__has_feature) || !__has_feature(address_sanitizer) +//#if !defined(__has_feature) || !__has_feature(address_sanitizer) void * operator new(std::size_t size) throw (std::bad_alloc) { void * ptr = std::malloc(size); @@ -274,7 +274,7 @@ void operator delete[](void * ptr, const std::nothrow_t&) throw() { std::free(ptr); } -#endif // !defined(__has_feature) || !__has_feature(address_sanitizer) +//#endif // !defined(__has_feature) || !__has_feature(address_sanitizer) namespace ledger { -- cgit v1.2.3 From afc023406ad658f6f9a2cda69d7d6ce9492bc3af Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 2 Aug 2012 16:13:58 -0500 Subject: Always store absolute paths internally --- src/context.h | 12 ++++++------ src/textual.cc | 5 ++--- test/baseline/cmd-convert.test | 4 ++-- test/baseline/opt-file.test | 2 +- test/regress/25A099C9.test | 40 ++++++++++++++++++++-------------------- 5 files changed, 31 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/context.h b/src/context.h index 09734b3e..7373be39 100644 --- a/src/context.h +++ b/src/context.h @@ -112,16 +112,16 @@ inline parse_context_t open_for_reading(const path& pathname, const path& cwd) { path filename = resolve_path(pathname); - +#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3 + filename = filesystem::absolute(filename, cwd); +#else + filename = filesystem::complete(filename, cwd); +#endif if (! exists(filename)) throw_(std::runtime_error, _f("Cannot read journal file %1%") % filename); -#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3 - path parent(filesystem::absolute(pathname, cwd).parent_path()); -#else - path parent(filesystem::complete(pathname, cwd).parent_path()); -#endif + path parent(pathname.parent_path()); shared_ptr stream(new ifstream(filename)); parse_context_t context(stream, parent); context.pathname = filename; diff --git a/src/textual.cc b/src/textual.cc index a5ae2f68..0ead9232 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -532,9 +532,8 @@ void instance_t::option_directive(char * line) *p++ = '\0'; } - path abs_path(filesystem::absolute(context.pathname, - context.current_directory)); - if (! process_option(abs_path.string(), line + 2, *context.scope, p, line)) + if (! process_option(context.pathname.string(), line + 2, *context.scope, + p, line)) throw_(option_error, _f("Illegal option --%1%") % (line + 2)); } diff --git a/test/baseline/cmd-convert.test b/test/baseline/cmd-convert.test index 181165df..1c36d4bb 100644 --- a/test/baseline/cmd-convert.test +++ b/test/baseline/cmd-convert.test @@ -17,7 +17,7 @@ end test test -f /dev/null --input-date-format "%m/%d/%Y" convert test/baseline/cmd-convert3.dat -> 1 __ERROR__ -While parsing file "test/baseline/cmd-convert3.dat", line 1: +While parsing file "$sourcepath/test/baseline/cmd-convert3.dat", line 1: While parsing CSV line: 01/01/2011,, @@ -26,7 +26,7 @@ end test test -f /dev/null convert test/baseline/cmd-convert4.dat -> 1 __ERROR__ -While parsing file "test/baseline/cmd-convert4.dat", line 1: +While parsing file "$sourcepath/test/baseline/cmd-convert4.dat", line 1: While parsing CSV line: bogus,$10, diff --git a/test/baseline/opt-file.test b/test/baseline/opt-file.test index e01d929d..66d0ab1b 100644 --- a/test/baseline/opt-file.test +++ b/test/baseline/opt-file.test @@ -1,6 +1,6 @@ test -f opt-file-does-not-exist.dat bal -> 1 __ERROR__ -Error: Cannot read journal file "opt-file-does-not-exist.dat" +Error: Cannot read journal file "$sourcepath/opt-file-does-not-exist.dat" end test test -f test/baseline/opt-file1.dat -f test/baseline/opt-file2.dat bal diff --git a/test/regress/25A099C9.test b/test/regress/25A099C9.test index 1ef5ebef..d4eab662 100644 --- a/test/regress/25A099C9.test +++ b/test/regress/25A099C9.test @@ -1,43 +1,43 @@ test -f src/amount.h reg -> 20 __ERROR__ -While parsing file "src/amount.h", line 2: +While parsing file "$sourcepath/src/amount.h", line 2: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 33: +While parsing file "$sourcepath/src/amount.h", line 33: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 37: +While parsing file "$sourcepath/src/amount.h", line 37: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 66: +While parsing file "$sourcepath/src/amount.h", line 66: Error: No quantity specified for amount -While parsing file "src/amount.h", line 69: +While parsing file "$sourcepath/src/amount.h", line 69: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 83: +While parsing file "$sourcepath/src/amount.h", line 83: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 93: +While parsing file "$sourcepath/src/amount.h", line 93: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 99: +While parsing file "$sourcepath/src/amount.h", line 99: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 121: +While parsing file "$sourcepath/src/amount.h", line 121: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 132: +While parsing file "$sourcepath/src/amount.h", line 132: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 702: +While parsing file "$sourcepath/src/amount.h", line 702: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 732: +While parsing file "$sourcepath/src/amount.h", line 732: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 740: +While parsing file "$sourcepath/src/amount.h", line 740: Error: Unexpected whitespace at beginning of line -While parsing file "src/amount.h", line 743: +While parsing file "$sourcepath/src/amount.h", line 743: Error: Invalid date/time: line amount_t amoun -While parsing file "src/amount.h", line 749: +While parsing file "$sourcepath/src/amount.h", line 749: Error: Invalid date/time: line string amount_ -While parsing file "src/amount.h", line 755: +While parsing file "$sourcepath/src/amount.h", line 755: Error: Invalid date/time: line string amount_ -While parsing file "src/amount.h", line 761: +While parsing file "$sourcepath/src/amount.h", line 761: Error: Invalid date/time: line string amount_ -While parsing file "src/amount.h", line 767: +While parsing file "$sourcepath/src/amount.h", line 767: Error: Invalid date/time: line std::ostream& -While parsing file "src/amount.h", line 774: +While parsing file "$sourcepath/src/amount.h", line 774: Error: Invalid date/time: line std::istream& -While parsing file "src/amount.h", line 780: +While parsing file "$sourcepath/src/amount.h", line 780: Error: Unexpected whitespace at beginning of line end test -- cgit v1.2.3 From 97693b43b54423e023091c7b866a1061b644eebc Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 9 Aug 2012 16:56:53 -0500 Subject: Resolve account.date to latest post in the account --- src/account.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/account.cc b/src/account.cc index 72709f95..8a5cdffa 100644 --- a/src/account.cc +++ b/src/account.cc @@ -380,7 +380,9 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind, break; case 'd': - if (fn_name == "depth") + if (fn_name == "date") + return WRAP_FUNCTOR(get_wrapper<&get_latest>); + else if (fn_name == "depth") return WRAP_FUNCTOR(get_wrapper<&get_depth>); else if (fn_name == "depth_spacer") return WRAP_FUNCTOR(get_wrapper<&get_depth_spacer>); -- cgit v1.2.3 From 6ccb5e96873716086e6d86a491df862627de5451 Mon Sep 17 00:00:00 2001 From: Hyrum Wright Date: Tue, 14 Aug 2012 01:23:04 -0400 Subject: Fix compilation warning: be sure we call the base class copy constructor. --- src/report.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/report.h b/src/report.h index 0f4fc103..4a02843e 100644 --- a/src/report.h +++ b/src/report.h @@ -123,7 +123,7 @@ public: TRACE_CTOR(report_t, "session_t&"); } report_t(const report_t& report) - : session(report.session), + : scope_t(report), session(report.session), output_stream(report.output_stream), terminus(report.terminus), budget_flags(report.budget_flags) { -- cgit v1.2.3 From 73aa585efae21cf596996f76330834a83da299ac Mon Sep 17 00:00:00 2001 From: Hyrum Wright Date: Tue, 14 Aug 2012 01:23:32 -0400 Subject: Fix compilation warning: ensure a destructor is properly defined to avoid compiler confusion. --- src/history.cc | 4 ++++ src/history.h | 1 + 2 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/history.cc b/src/history.cc index 25335680..414fc15d 100644 --- a/src/history.cc +++ b/src/history.cc @@ -129,6 +129,10 @@ commodity_history_t::commodity_history_t() p_impl.reset(new commodity_history_impl_t); } +commodity_history_t::~commodity_history_t() +{ +} + void commodity_history_t::add_commodity(commodity_t& comm) { p_impl->add_commodity(comm); diff --git a/src/history.h b/src/history.h index 4362c9f9..b763cb0b 100644 --- a/src/history.h +++ b/src/history.h @@ -88,6 +88,7 @@ public: const datetime_t& oldest = datetime_t()); void print_map(std::ostream& out, const datetime_t& moment = datetime_t()); + ~commodity_history_t(); }; } // namespace ledger -- cgit v1.2.3 From 49b02614a39ad86bb499df8b410232a5948247d7 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Sat, 13 Oct 2012 15:17:09 +0200 Subject: fix account mapping in csv conversion By using payees_for_unknown_accounts instead of account_mappings in csv.cc ledger will have the same behaviour as in `ledger -f - print` in that it uses payee fields in account directives to rewrite the account. --- src/csv.cc | 2 +- test/baseline/feat-convert-with-diretives.dat | 3 +++ test/baseline/feat-convert-with-diretives.test | 28 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/baseline/feat-convert-with-diretives.dat create mode 100644 test/baseline/feat-convert-with-diretives.test (limited to 'src') diff --git a/src/csv.cc b/src/csv.cc index 71b6516a..dbd2dbfe 100644 --- a/src/csv.cc +++ b/src/csv.cc @@ -243,7 +243,7 @@ xact_t * csv_reader::read_xact(bool rich_data) // Translate the account name, if we have enough information to do so - foreach (account_mapping_t& value, context.journal->account_mappings) { + foreach (account_mapping_t& value, context.journal->payees_for_unknown_accounts) { if (value.first.match(xact->payee)) { post->account = value.second; break; diff --git a/test/baseline/feat-convert-with-diretives.dat b/test/baseline/feat-convert-with-diretives.dat new file mode 100644 index 00000000..ac13ff81 --- /dev/null +++ b/test/baseline/feat-convert-with-diretives.dat @@ -0,0 +1,3 @@ +date,payee,amount +2012/01/01,KFC,$10 +2012/01/02,"REWE SAGT DANKE 123454321",10€ diff --git a/test/baseline/feat-convert-with-diretives.test b/test/baseline/feat-convert-with-diretives.test new file mode 100644 index 00000000..2f6e0102 --- /dev/null +++ b/test/baseline/feat-convert-with-diretives.test @@ -0,0 +1,28 @@ +account Expenses:Food + payee KFC + payee REWE + +payee REWE + alias REWE SAGT DANKE + +# When reading csv file without directives: +test -f /dev/null convert test/baseline/feat-convert-with-diretives.dat +2012/01/01 * KFC + Expenses:Unknown $10 + Equity:Unknown + +2012/01/02 * REWE SAGT DANKE 123454321 + Expenses:Unknown 10€ + Equity:Unknown +end test + +# When reading csv file with directives: +test --account "Assets:Cash" convert test/baseline/feat-convert-with-diretives.dat +2012/01/01 * KFC + Expenses:Food $10 + Assets:Cash + +2012/01/02 * REWE + Expenses:Food 10€ + Assets:Cash +end test -- cgit v1.2.3 From e824070b4ac098010f993dbdbcdff9a4bf1a3ba6 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Tue, 23 Oct 2012 12:13:22 +0200 Subject: fix bucket directive (bug 765) This was caused by both 'A' and 'bucket' using default_account_directive. This function was still stripping the 'A' directive, so the first character of the account name used with 'bucket' was cut off. Maybe the code for the other directives should be changed accordingly for consistency (put line + 1 in call instead of function). --- src/textual.cc | 8 ++++---- test/regress/0161EB1E.test | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 test/regress/0161EB1E.test (limited to 'src') diff --git a/src/textual.cc b/src/textual.cc index 0ead9232..7f2f2a69 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -148,7 +148,7 @@ namespace { void account_value_directive(account_t * account, string expr_str); void account_default_directive(account_t * account); - void default_account_directive(char * line); + void default_account_directive(char * args); void alias_directive(char * line); void payee_directive(char * line); @@ -397,7 +397,7 @@ void instance_t::read_next_directive(bool& error_flag) #endif // TIMELOG_SUPPORT case 'A': // a default account for unbalanced posts - default_account_directive(line); + default_account_directive(line + 1); break; case 'C': // a set of conversions price_conversion_directive(line); @@ -490,9 +490,9 @@ void instance_t::default_commodity_directive(char * line) amt.commodity().add_flags(COMMODITY_KNOWN); } -void instance_t::default_account_directive(char * line) +void instance_t::default_account_directive(char * args) { - context.journal->bucket = top_account()->find_account(skip_ws(line + 1)); + context.journal->bucket = top_account()->find_account(skip_ws(name)); context.journal->bucket->add_flags(ACCOUNT_KNOWN); } diff --git a/test/regress/0161EB1E.test b/test/regress/0161EB1E.test new file mode 100644 index 00000000..93498ad5 --- /dev/null +++ b/test/regress/0161EB1E.test @@ -0,0 +1,15 @@ +bucket Assets:Checking +2011/04/25 Tom's Used Cars + Auto $ 5,500.00 + ; :nobudget: + +A Assets:Checking +2011/04/27 Book Store + Books $20.00 + +test reg +11-Apr-25 Tom's Used Cars Auto $ 5,500.00 $ 5,500.00 + Assets:Checking $ -5,500.00 0 +11-Apr-27 Book Store Books $ 20.00 $ 20.00 + Assets:Checking $ -20.00 0 +end test -- cgit v1.2.3 From 14dcb277778568b9c5b60612e4f696363db4de11 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 23 Oct 2012 13:07:39 -0700 Subject: Implemented Bug551 Automatic Transactions are cleared base on parent --- src/xact.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/xact.cc b/src/xact.cc index a54da81a..ec1d372c 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -780,6 +780,14 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) // the automated xact's one. post_t * new_post = new post_t(account, amt); new_post->copy_details(*post); + + // A Cleared transaction implies all of its automatic posting are cleared + // CPR 2012/10/23 + if(xact.state() == item_t::CLEARED){ + DEBUG("xact.extend.cleared", "CLEARED"); + new_post->set_state(item_t::CLEARED); + } + new_post->add_flags(ITEM_GENERATED); new_post->account = journal->register_account(account->fullname(), new_post, -- cgit v1.2.3 From 41cc9a7f3cb9cd4b1857b0209c59ef66929edf03 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 23 Oct 2012 14:10:19 -0700 Subject: Added filebase and filepath values 'filename' returns the complete path/filename of the file containg the current xact. This is inconvenient for some displays. filebase returns only the base name. For completeness added filepath as well. --- src/item.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/item.cc b/src/item.cc index 0630043b..24d03ba1 100644 --- a/src/item.cc +++ b/src/item.cc @@ -330,6 +330,21 @@ namespace { return NULL_VALUE; } + value_t get_filebase(item_t& item) { + if (item.pos) + return string_value(item.pos->pathname.filename().string()); + else + return NULL_VALUE; + } + + value_t get_filepath(item_t& item) { + if (item.pos) + return string_value(item.pos->pathname.parent_path().string()); + else + return NULL_VALUE; + } + + value_t get_beg_pos(item_t& item) { return item.pos ? long(item.pos->beg_pos) : 0L; } @@ -456,7 +471,12 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind, case 'f': if (name == "filename") return WRAP_FUNCTOR(get_wrapper<&get_pathname>); - break; + else if (name == "filebase") + return WRAP_FUNCTOR(get_wrapper<&get_filebase>); + else if (name == "filepath") + return WRAP_FUNCTOR(get_wrapper<&get_filepath>); + break; + break; case 'h': if (name == "has_tag") -- cgit v1.2.3 From 4b261f99bc56853b3468a8a1bb5b4af39ed67af5 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Thu, 25 Oct 2012 10:39:48 -0700 Subject: Fixes Bug 695, ledger ignores --init-file Handle --init-file as a special command option like the debug options. That wway we can have the argument captured before teh global scope is created. --- src/global.cc | 7 +++++++ src/global.h | 14 ++++++++++---- src/main.cc | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/global.cc b/src/global.cc index a718d6cb..3e83ba04 100644 --- a/src/global.cc +++ b/src/global.cc @@ -44,6 +44,7 @@ namespace ledger { static bool args_only = false; +std::string _init_file; global_scope_t::global_scope_t(char ** envp) { @@ -126,6 +127,8 @@ void global_scope_t::read_init() } TRACE_FINISH(init, 1); + } else { + throw_(parse_error, _f("Could not find specified init file %1%") % init_file); } } } @@ -473,6 +476,10 @@ void handle_debug_options(int argc, char * argv[]) _log_level = LOG_INFO; #endif } + else if (i + 1 < argc && std::strcmp(argv[i], "--init-file") == 0) { + _init_file = argv[i + 1]; + i++; + } else if (i + 1 < argc && std::strcmp(argv[i], "--debug") == 0) { #if DEBUG_ON _log_level = LOG_DEBUG; diff --git a/src/global.h b/src/global.h index f797ba01..d37043fc 100644 --- a/src/global.h +++ b/src/global.h @@ -46,6 +46,8 @@ namespace ledger { class session_t; class report_t; +extern std::string _init_file; + class global_scope_t : public noncopyable, public scope_t { shared_ptr session_ptr; @@ -151,10 +153,14 @@ See LICENSE file included with the distribution for details and disclaimer."); OPTION__ (global_scope_t, init_file_, // -i CTOR(global_scope_t, init_file_) { - if (const char * home_var = std::getenv("HOME")) - on(none, (path(home_var) / ".ledgerrc").string()); - else - on(none, path("./.ledgerrc").string()); + if(!_init_file.empty()) + // _init_file is filled during handle_debug_options + on(none, _init_file); + else + if (const char * home_var = std::getenv("HOME")) + on(none, (path(home_var) / ".ledgerrc").string()); + else + on(none, path("./.ledgerrc").string()); }); OPTION(global_scope_t, options); diff --git a/src/main.cc b/src/main.cc index a1ac0339..124efb5e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -59,6 +59,7 @@ int main(int argc, char * argv[], char * envp[]) // --debug CATEGORY ; turns on debug logging // --trace LEVEL ; turns on trace logging // --memory ; turns on memory usage tracing + // --init-file ; directs ledger to use a different init file handle_debug_options(argc, argv); #if VERIFY_ON IF_VERIFY() initialize_memory_tracing(); -- cgit v1.2.3 From b044a74bd34afdc27baf6241fe398690ff5e043a Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Thu, 25 Oct 2012 22:28:26 -0700 Subject: Bug 634 and 488, Corrected behavior of floor, and added ceiling This is only a partial fix for 634, since rounding is not fixed. --- src/amount.cc | 23 ++++++++++++++++++++--- src/amount.h | 9 +++++++++ src/balance.h | 11 +++++++++++ src/report.cc | 7 +++++++ src/report.h | 1 + src/value.cc | 23 +++++++++++++++++++++++ src/value.h | 7 +++++++ 7 files changed, 78 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/amount.cc b/src/amount.cc index 6ecb3558..4e658212 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -670,10 +670,27 @@ void amount_t::in_place_floor() _dup(); - std::ostringstream out; - stream_out_mpq(out, MP(quantity), precision_t(0), -1, GMP_RNDZ); + mpz_t quot; + mpz_init(quot); + mpz_fdiv_q(quot, mpq_numref(MP(quantity)), mpq_denref(MP(quantity))); + mpq_clear(MP(quantity)); + mpq_init(MP(quantity)); + mpq_set_num(MP(quantity), quot); +} + +void amount_t::in_place_ceiling() +{ + if (! quantity) + throw_(amount_error, _("Cannot ceiling an uninitialized amount")); - mpq_set_str(MP(quantity), out.str().c_str(), 10); + _dup(); + + mpz_t quot; + mpz_init(quot); + mpz_cdiv_q(quot, mpq_numref(MP(quantity)), mpq_denref(MP(quantity))); + mpq_clear(MP(quantity)); + mpq_init(MP(quantity)); + mpq_set_num(MP(quantity), quot); } void amount_t::in_place_unround() diff --git a/src/amount.h b/src/amount.h index 49027bb7..1b7d2101 100644 --- a/src/amount.h +++ b/src/amount.h @@ -364,6 +364,15 @@ public: } void in_place_floor(); + /** Yields an amount which has lost all of its extra precision, beyond what + the display precision of the commodity would have printed. */ + amount_t ceilinged() const { + amount_t temp(*this); + temp.in_place_ceiling(); + return temp; + } + void in_place_ceiling(); + /** Yields an amount whose display precision is never truncated, even though its commodity normally displays only rounded values. */ amount_t unrounded() const { diff --git a/src/balance.h b/src/balance.h index 230a4e2c..9635742d 100644 --- a/src/balance.h +++ b/src/balance.h @@ -345,6 +345,17 @@ public: pair.second.in_place_floor(); } + balance_t ceilinged() const { + balance_t temp(*this); + temp.in_place_ceiling(); + return temp; + } + void in_place_ceiling() { + foreach (amounts_map::value_type& pair, amounts) + pair.second.in_place_ceiling(); + } + + balance_t unrounded() const { balance_t temp(*this); temp.in_place_unround(); diff --git a/src/report.cc b/src/report.cc index 662386a4..dc5a0704 100644 --- a/src/report.cc +++ b/src/report.cc @@ -681,6 +681,11 @@ value_t report_t::fn_floor(call_scope_t& args) return args[0].floored(); } +value_t report_t::fn_ceiling(call_scope_t& args) +{ + return args[0].ceilinged(); +} + value_t report_t::fn_round(call_scope_t& args) { return args[0].rounded(); @@ -1335,6 +1340,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind, return WRAP_FUNCTOR(fn_cyan); else if (is_eq(p, "commodity")) return MAKE_FUNCTOR(report_t::fn_commodity); + else if (is_eq(p, "ceiling")) + return MAKE_FUNCTOR(report_t::fn_ceiling); break; case 'd': diff --git a/src/report.h b/src/report.h index 4a02843e..2eac61fe 100644 --- a/src/report.h +++ b/src/report.h @@ -174,6 +174,7 @@ public: value_t fn_unrounded(call_scope_t& scope); value_t fn_truncated(call_scope_t& scope); value_t fn_floor(call_scope_t& scope); + value_t fn_ceiling(call_scope_t& scope); value_t fn_round(call_scope_t& scope); value_t fn_unround(call_scope_t& scope); value_t fn_abs(call_scope_t& scope); diff --git a/src/value.cc b/src/value.cc index 1921d5a3..c57cff78 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1658,6 +1658,29 @@ void value_t::in_place_floor() throw_(value_error, _f("Cannot floor %1%") % label()); } +void value_t::in_place_ceiling() +{ + switch (type()) { + case INTEGER: + return; + case AMOUNT: + as_amount_lval().in_place_ceiling(); + return; + case BALANCE: + as_balance_lval().in_place_ceiling(); + return; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_ceiling(); + return; + default: + break; + } + + add_error_context(_f("While ceiling %1%:") % *this); + throw_(value_error, _f("Cannot ceiling %1%") % label()); +} + void value_t::in_place_unround() { switch (type()) { diff --git a/src/value.h b/src/value.h index ee3d414d..249f3d7f 100644 --- a/src/value.h +++ b/src/value.h @@ -457,6 +457,13 @@ public: } void in_place_floor(); + value_t ceilinged() const { + value_t temp(*this); + temp.in_place_ceiling(); + return temp; + } + void in_place_ceiling(); + value_t unrounded() const { value_t temp(*this); temp.in_place_unround(); -- cgit v1.2.3 From 10180f0fffd5dcb14df06617c17b1607a5818bfe Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Fri, 26 Oct 2012 13:33:27 -0700 Subject: Added "draft" and "lisp" command synonyms --- src/report.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/report.cc b/src/report.cc index dc5a0704..9e085a98 100644 --- a/src/report.cc +++ b/src/report.cc @@ -1592,7 +1592,10 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind, return POSTS_REPORTER(new report_commodities(*this)); } break; - + case 'd': + if (is_eq(p, "draft")) { + return WRAP_FUNCTOR(xact_command); + } case 'e': if (is_eq(p, "equity")) { HANDLER(generated).on("#equity"); @@ -1614,7 +1617,10 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind, return POSTS_REPORTER(new format_ptree(*this, format_ptree::FORMAT_JSON)); break; - + case 'l': + if (is_eq(p, "lisp")) + return POSTS_REPORTER(new format_emacs_posts(output_stream)); + break; case 'o': if (is_eq(p, "org")) return POSTS_REPORTER(new posts_to_org_table -- cgit v1.2.3 From 5c5c6463c74549cac0c5548ee9f5e314751f8e92 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Fri, 26 Oct 2012 15:46:10 -0700 Subject: Added missing break; statement in report.cc --- src/report.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/report.cc b/src/report.cc index 9e085a98..08365a6b 100644 --- a/src/report.cc +++ b/src/report.cc @@ -1596,6 +1596,7 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind, if (is_eq(p, "draft")) { return WRAP_FUNCTOR(xact_command); } + break; case 'e': if (is_eq(p, "equity")) { HANDLER(generated).on("#equity"); -- cgit v1.2.3 From 3b9b2cf908c27dff7b85511e9283119485f9439e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 31 Oct 2012 00:14:47 -0500 Subject: Corrected a typo --- src/textual.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/textual.cc b/src/textual.cc index 7f2f2a69..8a055251 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -490,9 +490,9 @@ void instance_t::default_commodity_directive(char * line) amt.commodity().add_flags(COMMODITY_KNOWN); } -void instance_t::default_account_directive(char * args) +void instance_t::default_account_directive(char * line) { - context.journal->bucket = top_account()->find_account(skip_ws(name)); + context.journal->bucket = top_account()->find_account(skip_ws(line)); context.journal->bucket->add_flags(ACCOUNT_KNOWN); } -- cgit v1.2.3 From ae5325f0a9aea13025d3fa6e6229f0b27171bd8c Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 31 Oct 2012 14:57:02 -0500 Subject: Guard against global_scope being NULL --- src/main.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cc b/src/main.cc index 124efb5e..a44506c9 100644 --- a/src/main.cc +++ b/src/main.cc @@ -214,7 +214,8 @@ int main(int argc, char * argv[], char * envp[]) } else #endif { - global_scope->quick_close(); + if (global_scope) + global_scope->quick_close(); INFO("Ledger ended"); // let global_scope leak! } -- cgit v1.2.3 From 8214a69e20aa6d5ef2dbb86ca670a02b013db0f1 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Tue, 6 Nov 2012 11:56:43 +0000 Subject: fix comment in display_filter_posts::output_rounding(post_t) slightly more detail in the case of zero display_amount and --empty not specified. --- src/filters.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/filters.cc b/src/filters.cc index f5694133..5e2bf983 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -530,9 +530,11 @@ bool display_filter_posts::output_rounding(post_t& post) } // Allow the posting to be displayed if: - // 1. It's display_amount would display as non-zero - // 2. The --empty option was specified - // 3. The account of the posting is + // 1. Its display_amount would display as non-zero, or + // 2. The --empty option was specified, or + // 3. a) The account of the posting is , and + // b) the revalued option is specified, and + // c) the --no-rounding option is not specified. if (post.account == revalued_account) { if (show_rounding) -- cgit v1.2.3 From a6d40ada1f33ebce5ed55ddd2d54a187a1f70c59 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Tue, 6 Nov 2012 12:01:16 +0000 Subject: right-justify amount_expr text in print report where possible --- src/print.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/print.cc b/src/print.cc index 79d83161..a4a0bc6f 100644 --- a/src/print.cc +++ b/src/print.cc @@ -203,9 +203,15 @@ namespace { (static_cast(account_width) - static_cast(name.length())); + std::size_t amount_width = + (report.HANDLED(amount_width_) ? + lexical_cast(report.HANDLER(amount_width_).str()) : + 12); string amt; if (post->amount_expr) { - amt = post->amount_expr->text(); + std::ostringstream amt_str; + justify(amt_str, post->amount_expr->text(), amount_width, true); + amt = amt_str.str(); } else if (count == 2 && index == 2 && post_has_simple_amount(*post) && @@ -218,11 +224,6 @@ namespace { // first. } else { - std::size_t amount_width = - (report.HANDLED(amount_width_) ? - lexical_cast(report.HANDLER(amount_width_).str()) : - 12); - std::ostringstream amt_str; value_t(post->amount).print(amt_str, static_cast(amount_width), -1, AMOUNT_PRINT_RIGHT_JUSTIFY | -- cgit v1.2.3 From 36f87f49d86e931bb99a226cd47721219ccd6301 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Mon, 6 Sep 2010 15:01:09 +0200 Subject: Add --time-colon option The --time-colon option will display the value for a seconds based commodity as real hours and minutes. For example 8100 seconds by default will be displayed as 2.25 whereas with the --time-colon option they will be displayed as 2:15. --- src/amount.cc | 23 +++++++++++++++++++++-- src/commodity.cc | 1 + src/commodity.h | 2 ++ src/session.cc | 4 +++- src/session.h | 5 +++++ 5 files changed, 32 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/amount.cc b/src/amount.cc index 4e658212..671215c2 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -195,7 +195,10 @@ namespace { for (const char * p = buf; *p; p++) { if (*p == '.') { - if (commodity_t::decimal_comma_by_default || + if (commodity_t::time_colon_by_default || + (comm && comm->has_flags(COMMODITY_STYLE_TIME_COLON))) + out << ':'; + else if (commodity_t::decimal_comma_by_default || (comm && comm->has_flags(COMMODITY_STYLE_DECIMAL_COMMA))) out << ','; else @@ -209,7 +212,10 @@ namespace { out << *p; if (integer_digits > 3 && --integer_digits % 3 == 0) { - if (commodity_t::decimal_comma_by_default || + if (commodity_t::time_colon_by_default || + (comm && comm->has_flags(COMMODITY_STYLE_TIME_COLON))) + out << ':'; + else if (commodity_t::decimal_comma_by_default || (comm && comm->has_flags(COMMODITY_STYLE_DECIMAL_COMMA))) out << '.'; else @@ -737,6 +743,16 @@ void amount_t::in_place_unreduce() } if (shifted) { + if ("h" == comm->symbol() && commodity_t::time_colon_by_default) { + amount_t floored = tmp.floored(); + amount_t precision = tmp - floored; + if (precision < 0.0) { + precision += 1.0; + floored -= 1.0; + } + tmp = floored + (precision * (comm->smaller()->number() / 100.0)); + } + *this = tmp; commodity_ = comm; } @@ -1090,6 +1106,9 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags) bool decimal_comma_style = (commodity_t::decimal_comma_by_default || commodity().has_flags(COMMODITY_STYLE_DECIMAL_COMMA)); + bool time_colon_style + = (commodity_t::time_colon_by_default || + commodity().has_flags(COMMODITY_STYLE_TIME_COLON)); new_quantity->prec = 0; diff --git a/src/commodity.cc b/src/commodity.cc index 05d465ca..ffeac10d 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -40,6 +40,7 @@ namespace ledger { bool commodity_t::decimal_comma_by_default = false; +bool commodity_t::time_colon_by_default = false; void commodity_t::add_price(const datetime_t& date, const amount_t& price, const bool reflexive) diff --git a/src/commodity.h b/src/commodity.h index ab496850..1d69b689 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -107,6 +107,7 @@ protected: #define COMMODITY_SAW_ANNOTATED 0x200 #define COMMODITY_SAW_ANN_PRICE_FLOAT 0x400 #define COMMODITY_SAW_ANN_PRICE_FIXATED 0x800 +#define COMMODITY_STYLE_TIME_COLON 0x1000 string symbol; optional graph_index; @@ -176,6 +177,7 @@ protected: public: static bool decimal_comma_by_default; + static bool time_colon_by_default; virtual ~commodity_t() { TRACE_DTOR(commodity_t); diff --git a/src/session.cc b/src/session.cc index b6153203..7072fb09 100644 --- a/src/session.cc +++ b/src/session.cc @@ -348,9 +348,11 @@ option_t * session_t::lookup_option(const char * p) case 's': OPT(strict); break; + case 't': + OPT(time_colon); + break; case 'v': OPT(value_expr_); - break; } return NULL; } diff --git a/src/session.h b/src/session.h index a0aba91b..74aeab5f 100644 --- a/src/session.h +++ b/src/session.h @@ -100,6 +100,7 @@ public: HANDLER(day_break).report(out); HANDLER(download).report(out); HANDLER(decimal_comma).report(out); + HANDLER(time_colon).report(out); HANDLER(file_).report(out); HANDLER(input_date_format_).report(out); HANDLER(explicit).report(out); @@ -130,6 +131,10 @@ public: commodity_t::decimal_comma_by_default = true; }); + OPTION_(session_t, time_colon, DO() { + commodity_t::time_colon_by_default = true; + }); + OPTION__ (session_t, price_exp_, // -Z CTOR(session_t, price_exp_) { value = "24"; }); -- cgit v1.2.3 From 29359f3a878c6017bb00f2aa8fcac91a2af5ddc5 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 12 Nov 2012 01:37:14 -0600 Subject: Account names in auto-xacts can be format strings --- src/xact.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/xact.cc b/src/xact.cc index ec1d372c..cac19a02 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -36,6 +36,7 @@ #include "account.h" #include "journal.h" #include "context.h" +#include "format.h" #include "pool.h" namespace ledger { @@ -775,6 +776,14 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) account = account->parent; account = account->find_account(fullname); } + else if (contains(fullname, "%")) { + format_t account_name(fullname); + std::ostringstream buf; + buf << account_name(bound_scope); + while (account->parent) + account = account->parent; + account = account->find_account(buf.str()); + } // Copy over details so that the resulting post is a mirror of // the automated xact's one. -- cgit v1.2.3 From 63712728e1e39557aa8ec35e1a4cf4e56c83e121 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 12 Nov 2012 02:29:10 -0600 Subject: Properly handle metadata tags on auto-postings --- src/textual.cc | 2 +- src/xact.cc | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/textual.cc b/src/textual.cc index 8a055251..6106914f 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -575,7 +575,7 @@ void instance_t::automated_xact_directive(char * line) item = ae.get(); // This is a trailing note, and possibly a metadata info tag - item->append_note(p + 1, *context.scope, true); + ae->append_note(p + 1, *context.scope, true); item->add_flags(ITEM_NOTE_ON_NEXT_LINE); item->pos->end_pos = context.curr_pos; item->pos->end_line++; diff --git a/src/xact.cc b/src/xact.cc index cac19a02..7888dadf 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -645,6 +645,18 @@ namespace { } } +static string apply_format(const string& str, scope_t& scope) +{ + if (contains(str, "%(")) { + format_t str_format(str); + std::ostringstream buf; + buf << str_format(scope); + return buf.str(); + } else { + return str; + } +} + void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) { posts_list initial_posts(xact.posts.begin(), xact.posts.end()); @@ -696,8 +708,9 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) if (deferred_notes) { foreach (deferred_tag_data_t& data, *deferred_notes) { if (data.apply_to_post == NULL) - initial_post->parse_tags(data.tag_data.c_str(), bound_scope, - data.overwrite_existing); + initial_post->append_note( + apply_format(data.tag_data, bound_scope).c_str(), + bound_scope, data.overwrite_existing); } } @@ -776,7 +789,7 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) account = account->parent; account = account->find_account(fullname); } - else if (contains(fullname, "%")) { + else if (contains(fullname, "%(")) { format_t account_name(fullname); std::ostringstream buf; buf << account_name(bound_scope); @@ -804,9 +817,11 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) if (deferred_notes) { foreach (deferred_tag_data_t& data, *deferred_notes) { - if (! data.apply_to_post || data.apply_to_post == post) - new_post->parse_tags(data.tag_data.c_str(), bound_scope, - data.overwrite_existing); + if (! data.apply_to_post || data.apply_to_post == post) { + new_post->append_note( + apply_format(data.tag_data, bound_scope).c_str(), + bound_scope, data.overwrite_existing); + } } } -- cgit v1.2.3 From 6a5d6a88cd626ee563b344657faec2ceb62b7f59 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Mon, 19 Nov 2012 23:00:58 +0100 Subject: Fix crash when accessing the transaction code via post.xact.code using python ledger would abort with the following error message: TypeError: No Python class registered for C++ class boost::optional The changes pass a CallPolicy to make_getter when adding the transaction code property for python, so that the correct to_python conversion is made. For details see: http://www.boost.org/doc/libs/1_52_0/libs/python/doc/v2/faq.html#topythonconversionfailed --- src/py_xact.cc | 6 ++++-- test/regress/xact_code.dat | 3 +++ test/regress/xact_code.py | 4 ++++ test/regress/xact_code_py.test | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 test/regress/xact_code.dat create mode 100644 test/regress/xact_code.py create mode 100644 test/regress/xact_code_py.test (limited to 'src') diff --git a/src/py_xact.cc b/src/py_xact.cc index 3d792c7b..96674207 100644 --- a/src/py_xact.cc +++ b/src/py_xact.cc @@ -119,8 +119,8 @@ void export_xact() .def("__str__", py_xact_to_string) .add_property("code", - make_getter(&xact_t::code), - make_setter(&xact_t::code)) + make_getter(&xact_t::code, return_value_policy()), + make_setter(&xact_t::code, return_value_policy())) .add_property("payee", make_getter(&xact_t::payee), make_setter(&xact_t::payee)) @@ -157,6 +157,8 @@ void export_xact() make_getter(&period_xact_t::period_string), make_setter(&period_xact_t::period_string)) ; + + register_optional_to_python(); } } // namespace ledger diff --git a/test/regress/xact_code.dat b/test/regress/xact_code.dat new file mode 100644 index 00000000..60956a23 --- /dev/null +++ b/test/regress/xact_code.dat @@ -0,0 +1,3 @@ +2012-11-10 (C0-d3) Payee + Assets:Checking € -12,45 + Expenses:Expenditure diff --git a/test/regress/xact_code.py b/test/regress/xact_code.py new file mode 100644 index 00000000..64abb17d --- /dev/null +++ b/test/regress/xact_code.py @@ -0,0 +1,4 @@ +import ledger + +for post in ledger.read_journal('test/regress/xact_code.dat').query('expenses'): + print post.xact.code diff --git a/test/regress/xact_code_py.test b/test/regress/xact_code_py.test new file mode 100644 index 00000000..c22158e0 --- /dev/null +++ b/test/regress/xact_code_py.test @@ -0,0 +1,3 @@ +test python test/regress/xact_code.py +C0-d3 +end test -- cgit v1.2.3 From 2ac996d9165f87754077a937eb69d765e139c05b Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 23 Nov 2012 16:54:03 -0600 Subject: Shorten debug comment --- src/post.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/post.h b/src/post.h index a9a44a79..c9aec6b2 100644 --- a/src/post.h +++ b/src/post.h @@ -83,7 +83,7 @@ public: const optional& _note = none) : item_t(_flags, _note), xact(NULL), account(_account), amount(_amount) { - TRACE_CTOR(post_t, "account_t *, const amount_t&, flags_t, const optional&"); + TRACE_CTOR(post_t, "account_t *, amount_t, flags_t, optional"); } post_t(const post_t& post) : item_t(post), -- cgit v1.2.3 From 67a598f6ff3b9b19b08af108c8bfe26064728457 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Mon, 7 Jan 2013 20:15:49 -0700 Subject: Bug551 fixed, commodities and accounts now sort Added two compare structs for std::map to use. I tried to override the < operator got a clean compile but map wasn't picking it up, I couldn't figure out why so I took the less elegant route. --- src/account.h | 7 +++++++ src/commodity.h | 7 +++++++ src/output.h | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/account.h b/src/account.h index a2fcb8de..3642ada0 100644 --- a/src/account.h +++ b/src/account.h @@ -308,6 +308,13 @@ std::ostream& operator<<(std::ostream& out, const account_t& account); void put_account(property_tree::ptree& pt, const account_t& acct, function pred); +//simple struct added to allow std::map to compare accounts in the accounts report +struct account_compare { + bool operator() (const account_t& lhs, const account_t& rhs){ + return (lhs.fullname().compare(rhs.fullname()) < 0); + } +}; + } // namespace ledger #endif // _ACCOUNT_H diff --git a/src/commodity.h b/src/commodity.h index ab496850..37b02e74 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -349,6 +349,13 @@ inline std::ostream& operator<<(std::ostream& out, const commodity_t& comm) { void put_commodity(property_tree::ptree& pt, const commodity_t& comm, bool commodity_details = false); +//simple struct to allow std::map to compare commodities names +struct commodity_compare { + bool operator() (const commodity_t* lhs, const commodity_t* rhs){ + return (lhs->symbol().compare(rhs->symbol()) < 0); + } +}; + } // namespace ledger #endif // _COMMODITY_H diff --git a/src/output.h b/src/output.h index 281f69b6..5ce9dc58 100644 --- a/src/output.h +++ b/src/output.h @@ -142,7 +142,7 @@ class report_accounts : public item_handler protected: report_t& report; - std::map accounts; + std::map accounts; typedef std::map::value_type accounts_pair; @@ -194,7 +194,7 @@ class report_commodities : public item_handler protected: report_t& report; - std::map commodities; + std::map commodities; typedef std::map::value_type commodities_pair; -- cgit v1.2.3 From 82ac7ef313ae8a8d9251706d66345efed6bf90ab Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 11 Jan 2013 00:10:30 -0600 Subject: Guard against a possible NULL --- src/filters.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/filters.cc b/src/filters.cc index 5e2bf983..7570809a 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -983,7 +983,8 @@ void interval_posts::flush() sort_posts_by_date()); // Determine the beginning interval by using the earliest post - if (! interval.find_period(all_posts.front()->date())) + if (all_posts.front() && + ! interval.find_period(all_posts.front()->date())) throw_(std::logic_error, _("Failed to find period for interval report")); // Walk the interval forward reporting all posts within each one -- cgit v1.2.3 From aba0a5ed2dc2dc91f61be32f4c12a5cf6bffd754 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 11 Jan 2013 07:08:51 -0600 Subject: Improvement to account alias expansion Aliases are now expanded not only if they occur by themselves, but also if they occur as the beginning of a multi-part account. Given the account should now be expanded to . --- src/journal.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/journal.cc b/src/journal.cc index e6c09125..f45b7527 100644 --- a/src/journal.cc +++ b/src/journal.cc @@ -127,8 +127,19 @@ account_t * journal_t::register_account(const string& name, post_t * post, // object. if (account_aliases.size() > 0) { accounts_map::const_iterator i = account_aliases.find(name); - if (i != account_aliases.end()) + if (i != account_aliases.end()) { result = (*i).second; + } else { + // only check the very first account for alias expansion, in case + // that can be expanded successfully + size_t colon = name.find(':'); + if(colon != string::npos) { + accounts_map::const_iterator i = account_aliases.find(name.substr(0, colon)); + if (i != account_aliases.end()) { + result = find_account((*i).second->fullname() + name.substr(colon)); + } + } + } } // Create the account object and associate it with the journal; this -- cgit v1.2.3 From 428490e917f1858acdcc3f70441353da2cb382c5 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Tue, 15 Jan 2013 00:23:25 +0100 Subject: fix for 'store absolute paths internally' `parent_path` was called on unprocessed path so neither `resolve_path` nor `filesystem::absolute` had any effect. --- src/context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/context.h b/src/context.h index 7373be39..9fe0613b 100644 --- a/src/context.h +++ b/src/context.h @@ -121,7 +121,7 @@ inline parse_context_t open_for_reading(const path& pathname, throw_(std::runtime_error, _f("Cannot read journal file %1%") % filename); - path parent(pathname.parent_path()); + path parent(filename.parent_path()); shared_ptr stream(new ifstream(filename)); parse_context_t context(stream, parent); context.pathname = filename; -- cgit v1.2.3 From 2b1cfd670681fe732daf81b4d0bb6eb4749eb240 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Tue, 15 Jan 2013 00:33:14 +0100 Subject: remove superfluous 'break' --- src/item.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/item.cc b/src/item.cc index 24d03ba1..362fac7f 100644 --- a/src/item.cc +++ b/src/item.cc @@ -476,7 +476,6 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind, else if (name == "filepath") return WRAP_FUNCTOR(get_wrapper<&get_filepath>); break; - break; case 'h': if (name == "has_tag") -- cgit v1.2.3 From 0a1ff035421d5f97675ad769a7fcdbc68399f3dc Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Tue, 8 Jan 2013 23:20:08 +0100 Subject: fix bug 788: behaviour of source_context for '-f -' `session_t::read_data` did not set context.pathname to `/dev/stdin` for the special case `-f -`. I chose to adjust `source_context` too as there is no sensible context if no file name is provided. --- src/error.cc | 2 +- src/session.cc | 1 + test/regress/BF3C1F82.test | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/regress/BF3C1F82.test (limited to 'src') diff --git a/src/error.cc b/src/error.cc index 58339db7..d7e92daa 100644 --- a/src/error.cc +++ b/src/error.cc @@ -84,7 +84,7 @@ string source_context(const path& file, const string& prefix) { const std::streamoff len = end_pos - pos; - if (! len || file == path("/dev/stdin")) + if (! len || file == path("/dev/stdin") || file.empty()) return _(""); assert(len > 0); diff --git a/src/session.cc b/src/session.cc index b6153203..a8bb628a 100644 --- a/src/session.cc +++ b/src/session.cc @@ -159,6 +159,7 @@ std::size_t session_t::read_data(const string& master_account) shared_ptr stream(new std::istringstream(buffer.str())); parsing_context.push(stream); + parsing_context.get_current().pathname = "/dev/stdin"; } else { parsing_context.push(pathname); } diff --git a/test/regress/BF3C1F82.test b/test/regress/BF3C1F82.test new file mode 100644 index 00000000..8d465f4d --- /dev/null +++ b/test/regress/BF3C1F82.test @@ -0,0 +1,12 @@ +; Check that error reporting works for "-f -" + +2012/02/30 * Test + a 1 + b +test -f - reg -> 1 +__ERROR__ +While parsing file "/dev/stdin", line 3: +While parsing transaction: + +Error: Day of month is not valid for year +end test -- cgit v1.2.3 From d922f4659570c87a06352b0da9d877f047ec442c Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Tue, 15 Jan 2013 23:30:17 +0100 Subject: fix bug 748: option aliases not recognized --- src/report.cc | 15 +++++++++++---- test/baseline/opt-aux-date.test | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/report.cc b/src/report.cc index 08365a6b..d4beaf2a 100644 --- a/src/report.cc +++ b/src/report.cc @@ -1089,6 +1089,7 @@ option_t * report_t::lookup_option(const char * p) else OPT(anon); else OPT_ALT(color, ansi); else OPT(auto_match); + else OPT(aux_date); else OPT(average); else OPT(account_width_); else OPT(amount_width_); @@ -1096,7 +1097,7 @@ option_t * report_t::lookup_option(const char * p) case 'b': OPT(balance_format_); else OPT(base); - else OPT_ALT(basis, cost); + else OPT(basis); else OPT_(begin_); else OPT(bold_if_); else OPT(budget); @@ -1105,6 +1106,7 @@ option_t * report_t::lookup_option(const char * p) break; case 'c': OPT(csv_format_); + else OPT_ALT(gain, change); else OPT(cleared); else OPT(collapse); else OPT(collapse_if_zero); @@ -1122,6 +1124,7 @@ option_t * report_t::lookup_option(const char * p) else OPT(dc); else OPT(depth_); else OPT(deviation); + else OPT_ALT(rich_data, detail); else OPT_(display_); else OPT(display_amount_); else OPT(display_total_); @@ -1146,7 +1149,7 @@ option_t * report_t::lookup_option(const char * p) else OPT_ALT(head_, first_); break; case 'g': - OPT_ALT(gain, change); + OPT(gain); else OPT(group_by_); else OPT(group_title_format_); else OPT(generated); @@ -1173,7 +1176,7 @@ option_t * report_t::lookup_option(const char * p) else OPT_ALT(tail_, last_); break; case 'm': - OPT_ALT(market, value); + OPT(market); else OPT(monthly); else OPT(meta_); else OPT(meta_width_); @@ -1203,6 +1206,7 @@ option_t * report_t::lookup_option(const char * p) else OPT(price); else OPT(prices_format_); else OPT(pricedb_format_); + else OPT(primary_date); else OPT(payee_width_); else OPT(prepend_format_); else OPT(prepend_width_); @@ -1220,7 +1224,7 @@ option_t * report_t::lookup_option(const char * p) else OPT(revalued); else OPT(revalued_only); else OPT(revalued_total_); - else OPT_ALT(rich_data, detail); + else OPT(rich_data); break; case 's': OPT(sort_); @@ -1247,6 +1251,9 @@ option_t * report_t::lookup_option(const char * p) else OPT(unrealized_losses_); else OPT(unround); break; + case 'v': + OPT_ALT(market, value); + break; case 'w': OPT(weekly); else OPT_(wide); diff --git a/test/baseline/opt-aux-date.test b/test/baseline/opt-aux-date.test index 9d1e73d0..495bb7e6 100644 --- a/test/baseline/opt-aux-date.test +++ b/test/baseline/opt-aux-date.test @@ -10,7 +10,7 @@ Expenses:Books $20.00 Assets:Cash -test reg --effective +test reg --aux-date 08-Jan-01 January Expenses:Books $10.00 $10.00 Assets:Cash $-10.00 0 08-Feb-01 End of January Expenses:Books $10.00 $10.00 -- cgit v1.2.3 From 3ed53b7b3c6fb3a82f863e07414372681aa92768 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Tue, 15 Jan 2013 00:31:12 +0100 Subject: whitespace cleanup --- src/amount.cc | 2 +- src/global.cc | 4 ++-- src/global.h | 6 +++--- src/journal.cc | 8 ++++---- src/xact.cc | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/amount.cc b/src/amount.cc index 4e658212..cba9a282 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -684,7 +684,7 @@ void amount_t::in_place_ceiling() throw_(amount_error, _("Cannot ceiling an uninitialized amount")); _dup(); - + mpz_t quot; mpz_init(quot); mpz_cdiv_q(quot, mpq_numref(MP(quantity)), mpq_denref(MP(quantity))); diff --git a/src/global.cc b/src/global.cc index 3e83ba04..bc172075 100644 --- a/src/global.cc +++ b/src/global.cc @@ -477,8 +477,8 @@ void handle_debug_options(int argc, char * argv[]) #endif } else if (i + 1 < argc && std::strcmp(argv[i], "--init-file") == 0) { - _init_file = argv[i + 1]; - i++; + _init_file = argv[i + 1]; + i++; } else if (i + 1 < argc && std::strcmp(argv[i], "--debug") == 0) { #if DEBUG_ON diff --git a/src/global.h b/src/global.h index d37043fc..dc6abd78 100644 --- a/src/global.h +++ b/src/global.h @@ -153,14 +153,14 @@ See LICENSE file included with the distribution for details and disclaimer."); OPTION__ (global_scope_t, init_file_, // -i CTOR(global_scope_t, init_file_) { - if(!_init_file.empty()) + if (!_init_file.empty()) // _init_file is filled during handle_debug_options on(none, _init_file); else if (const char * home_var = std::getenv("HOME")) - on(none, (path(home_var) / ".ledgerrc").string()); + on(none, (path(home_var) / ".ledgerrc").string()); else - on(none, path("./.ledgerrc").string()); + on(none, path("./.ledgerrc").string()); }); OPTION(global_scope_t, options); diff --git a/src/journal.cc b/src/journal.cc index f45b7527..68939be6 100644 --- a/src/journal.cc +++ b/src/journal.cc @@ -134,10 +134,10 @@ account_t * journal_t::register_account(const string& name, post_t * post, // that can be expanded successfully size_t colon = name.find(':'); if(colon != string::npos) { - accounts_map::const_iterator i = account_aliases.find(name.substr(0, colon)); - if (i != account_aliases.end()) { - result = find_account((*i).second->fullname() + name.substr(colon)); - } + accounts_map::const_iterator i = account_aliases.find(name.substr(0, colon)); + if (i != account_aliases.end()) { + result = find_account((*i).second->fullname() + name.substr(colon)); + } } } } diff --git a/src/xact.cc b/src/xact.cc index 7888dadf..7ac7a9e9 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -803,12 +803,12 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) post_t * new_post = new post_t(account, amt); new_post->copy_details(*post); - // A Cleared transaction implies all of its automatic posting are cleared + // A Cleared transaction implies all of its automatic posting are cleared // CPR 2012/10/23 - if(xact.state() == item_t::CLEARED){ - DEBUG("xact.extend.cleared", "CLEARED"); - new_post->set_state(item_t::CLEARED); - } + if (xact.state() == item_t::CLEARED) { + DEBUG("xact.extend.cleared", "CLEARED"); + new_post->set_state(item_t::CLEARED); + } new_post->add_flags(ITEM_GENERATED); new_post->account = -- cgit v1.2.3 From d1c96190e9549267782704eab991bf304d3f86e2 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 16 Jan 2013 18:10:30 -0600 Subject: Revert "fix bug 788: behaviour of source_context for '-f -'" This reverts commit 0a1ff035421d5f97675ad769a7fcdbc68399f3dc. --- src/error.cc | 2 +- src/session.cc | 1 - test/regress/BF3C1F82.test | 12 ------------ 3 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 test/regress/BF3C1F82.test (limited to 'src') diff --git a/src/error.cc b/src/error.cc index d7e92daa..58339db7 100644 --- a/src/error.cc +++ b/src/error.cc @@ -84,7 +84,7 @@ string source_context(const path& file, const string& prefix) { const std::streamoff len = end_pos - pos; - if (! len || file == path("/dev/stdin") || file.empty()) + if (! len || file == path("/dev/stdin")) return _(""); assert(len > 0); diff --git a/src/session.cc b/src/session.cc index a8bb628a..b6153203 100644 --- a/src/session.cc +++ b/src/session.cc @@ -159,7 +159,6 @@ std::size_t session_t::read_data(const string& master_account) shared_ptr stream(new std::istringstream(buffer.str())); parsing_context.push(stream); - parsing_context.get_current().pathname = "/dev/stdin"; } else { parsing_context.push(pathname); } diff --git a/test/regress/BF3C1F82.test b/test/regress/BF3C1F82.test deleted file mode 100644 index 8d465f4d..00000000 --- a/test/regress/BF3C1F82.test +++ /dev/null @@ -1,12 +0,0 @@ -; Check that error reporting works for "-f -" - -2012/02/30 * Test - a 1 - b -test -f - reg -> 1 -__ERROR__ -While parsing file "/dev/stdin", line 3: -While parsing transaction: - -Error: Day of month is not valid for year -end test -- cgit v1.2.3 From 9252c5f1f3d3e34998129be3f7e9f8521ae591f8 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 16 Jan 2013 18:14:34 -0600 Subject: Revert "Bug551 fixed, commodities and accounts now sort" This reverts commit 67a598f6ff3b9b19b08af108c8bfe26064728457. --- src/account.h | 7 ------- src/commodity.h | 7 ------- src/output.h | 4 ++-- 3 files changed, 2 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/account.h b/src/account.h index 3642ada0..a2fcb8de 100644 --- a/src/account.h +++ b/src/account.h @@ -308,13 +308,6 @@ std::ostream& operator<<(std::ostream& out, const account_t& account); void put_account(property_tree::ptree& pt, const account_t& acct, function pred); -//simple struct added to allow std::map to compare accounts in the accounts report -struct account_compare { - bool operator() (const account_t& lhs, const account_t& rhs){ - return (lhs.fullname().compare(rhs.fullname()) < 0); - } -}; - } // namespace ledger #endif // _ACCOUNT_H diff --git a/src/commodity.h b/src/commodity.h index 37b02e74..ab496850 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -349,13 +349,6 @@ inline std::ostream& operator<<(std::ostream& out, const commodity_t& comm) { void put_commodity(property_tree::ptree& pt, const commodity_t& comm, bool commodity_details = false); -//simple struct to allow std::map to compare commodities names -struct commodity_compare { - bool operator() (const commodity_t* lhs, const commodity_t* rhs){ - return (lhs->symbol().compare(rhs->symbol()) < 0); - } -}; - } // namespace ledger #endif // _COMMODITY_H diff --git a/src/output.h b/src/output.h index 5ce9dc58..281f69b6 100644 --- a/src/output.h +++ b/src/output.h @@ -142,7 +142,7 @@ class report_accounts : public item_handler protected: report_t& report; - std::map accounts; + std::map accounts; typedef std::map::value_type accounts_pair; @@ -194,7 +194,7 @@ class report_commodities : public item_handler protected: report_t& report; - std::map commodities; + std::map commodities; typedef std::map::value_type commodities_pair; -- cgit v1.2.3 From 3fe2ef59566ef679d9de58e5f9454b7443d9153a Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Thu, 17 Jan 2013 12:18:58 +0100 Subject: change handling of standard input For `-f /dev/stdin`, the `pathname` of the parsing context will be empty as for any other streamed input. `instance_t::include_directive` did not work as expected for `-f /dev/stdin` and relative file names. One would expect them to be relative to the current directory rather than `/dev`. This will lead to `While parsing file ""` messages. This could be adjusted to read `While parsing standard input`, but maybe it's not worth the special cases. This commit also fixes bug 788: behaviour of source_context for '-f -' --- src/error.cc | 2 +- src/item.cc | 4 ++-- src/session.cc | 2 +- test/regress/BF3C1F82-2.test | 12 ++++++++++++ test/regress/BF3C1F82.test | 19 +++++++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 test/regress/BF3C1F82-2.test create mode 100644 test/regress/BF3C1F82.test (limited to 'src') diff --git a/src/error.cc b/src/error.cc index 58339db7..8aa1d3d6 100644 --- a/src/error.cc +++ b/src/error.cc @@ -84,7 +84,7 @@ string source_context(const path& file, const string& prefix) { const std::streamoff len = end_pos - pos; - if (! len || file == path("/dev/stdin")) + if (! len || file.empty()) return _(""); assert(len > 0); diff --git a/src/item.cc b/src/item.cc index 362fac7f..4e2a487c 100644 --- a/src/item.cc +++ b/src/item.cc @@ -582,8 +582,8 @@ string item_context(const item_t& item, const string& desc) std::ostringstream out; - if (item.pos->pathname == path("/dev/stdin")) { - out << desc << _(" from standard input:"); + if (item.pos->pathname.empty()) { + out << desc << _(" from streamed input:"); return out.str(); } diff --git a/src/session.cc b/src/session.cc index b6153203..f047a540 100644 --- a/src/session.cc +++ b/src/session.cc @@ -143,7 +143,7 @@ std::size_t session_t::read_data(const string& master_account) } foreach (const path& pathname, HANDLER(file_).data_files) { - if (pathname == "-") { + if (pathname == "-" || pathname == "/dev/stdin") { // To avoid problems with stdin and pipes, etc., we read the entire // file in beforehand into a memory buffer, and then parcel it out // from there. diff --git a/test/regress/BF3C1F82-2.test b/test/regress/BF3C1F82-2.test new file mode 100644 index 00000000..453151ce --- /dev/null +++ b/test/regress/BF3C1F82-2.test @@ -0,0 +1,12 @@ +; Check that include directives are relative for "-f /dev/stdin" +include non-existent-ledger-file-BF3C1F82 +test -f - reg -> 1 +__ERROR__ +While parsing file "", line 2: +Error: File to include was not found: "./non-existent-ledger-file-BF3C1F82" +end test +test -f /dev/stdin reg -> 1 +__ERROR__ +While parsing file "", line 2: +Error: File to include was not found: "./non-existent-ledger-file-BF3C1F82" +end test diff --git a/test/regress/BF3C1F82.test b/test/regress/BF3C1F82.test new file mode 100644 index 00000000..50f4106f --- /dev/null +++ b/test/regress/BF3C1F82.test @@ -0,0 +1,19 @@ +; Check that error reporting works for "-f -" + +2012/02/30 * Test + a 1 + b +test -f - reg -> 1 +__ERROR__ +While parsing file "", line 3: +While parsing transaction: + +Error: Day of month is not valid for year +end test +test -f /dev/stdin reg -> 1 +__ERROR__ +While parsing file "", line 3: +While parsing transaction: + +Error: Day of month is not valid for year +end test -- cgit v1.2.3 From 3e72a51dc3d296c9f647efaf4cbfbbdcf4bf6df1 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 29 Jan 2013 09:42:10 -0700 Subject: Addes tags command and --values option Tags command reports all metadat tags in use. With the values option it reports tags and their values. --- src/output.cc | 28 ++++++++++++++++++++++++++++ src/output.h | 27 +++++++++++++++++++++++++++ src/report.cc | 20 ++++++++++---------- src/report.h | 2 ++ 4 files changed, 67 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/output.cc b/src/output.cc index f433f8d1..6ed7f861 100644 --- a/src/output.cc +++ b/src/output.cc @@ -318,6 +318,34 @@ void report_payees::operator()(post_t& post) (*i).second++; } +void report_tags::flush() +{ + std::ostream& out(report.output_stream); + + foreach (tags_pair& entry, tags) { + if (report.HANDLED(count)) + out << entry.second << ' '; + out << entry.first << '\n'; + } +} + +void report_tags::operator()(post_t& post) +{ + if(post.metadata){ + foreach (const item_t::string_map::value_type& data, *post.metadata){ + string tag=data.first; + if(report.HANDLED(values) && (data.second).first){ + tag+=": "+ (data.second).first.get().to_string(); + } + std::map::iterator i = tags.find(tag); + if (i == tags.end()) + tags.insert(tags_pair(tag, 1)); + else + (*i).second++; + } + } +} + void report_commodities::flush() { std::ostream& out(report.output_stream); diff --git a/src/output.h b/src/output.h index 281f69b6..9895cb44 100644 --- a/src/output.h +++ b/src/output.h @@ -189,6 +189,33 @@ public: } }; +class report_tags : public item_handler +{ +protected: + report_t& report; + + std::map tags; + + typedef std::map::value_type tags_pair; + +public: + report_tags(report_t& _report) : report(_report) { + TRACE_CTOR(report_tags, "report&"); + } + virtual ~report_tags() { + TRACE_DTOR(report_tags); + } + + virtual void flush(); + virtual void operator()(post_t& post); + + virtual void clear() { + tags.clear(); + item_handler::clear(); + } +}; + + class report_commodities : public item_handler { protected: diff --git a/src/report.cc b/src/report.cc index d4beaf2a..f7b71b94 100644 --- a/src/report.cc +++ b/src/report.cc @@ -1089,7 +1089,6 @@ option_t * report_t::lookup_option(const char * p) else OPT(anon); else OPT_ALT(color, ansi); else OPT(auto_match); - else OPT(aux_date); else OPT(average); else OPT(account_width_); else OPT(amount_width_); @@ -1097,7 +1096,7 @@ option_t * report_t::lookup_option(const char * p) case 'b': OPT(balance_format_); else OPT(base); - else OPT(basis); + else OPT_ALT(basis, cost); else OPT_(begin_); else OPT(bold_if_); else OPT(budget); @@ -1106,7 +1105,6 @@ option_t * report_t::lookup_option(const char * p) break; case 'c': OPT(csv_format_); - else OPT_ALT(gain, change); else OPT(cleared); else OPT(collapse); else OPT(collapse_if_zero); @@ -1124,7 +1122,6 @@ option_t * report_t::lookup_option(const char * p) else OPT(dc); else OPT(depth_); else OPT(deviation); - else OPT_ALT(rich_data, detail); else OPT_(display_); else OPT(display_amount_); else OPT(display_total_); @@ -1149,7 +1146,7 @@ option_t * report_t::lookup_option(const char * p) else OPT_ALT(head_, first_); break; case 'g': - OPT(gain); + OPT_ALT(gain, change); else OPT(group_by_); else OPT(group_title_format_); else OPT(generated); @@ -1176,7 +1173,7 @@ option_t * report_t::lookup_option(const char * p) else OPT_ALT(tail_, last_); break; case 'm': - OPT(market); + OPT_ALT(market, value); else OPT(monthly); else OPT(meta_); else OPT(meta_width_); @@ -1206,7 +1203,6 @@ option_t * report_t::lookup_option(const char * p) else OPT(price); else OPT(prices_format_); else OPT(pricedb_format_); - else OPT(primary_date); else OPT(payee_width_); else OPT(prepend_format_); else OPT(prepend_width_); @@ -1224,7 +1220,7 @@ option_t * report_t::lookup_option(const char * p) else OPT(revalued); else OPT(revalued_only); else OPT(revalued_total_); - else OPT(rich_data); + else OPT_ALT(rich_data, detail); break; case 's': OPT(sort_); @@ -1252,7 +1248,7 @@ option_t * report_t::lookup_option(const char * p) else OPT(unround); break; case 'v': - OPT_ALT(market, value); + OPT(values); break; case 'w': OPT(weekly); @@ -1670,7 +1666,11 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind, else if (is_eq(p, "select")) return WRAP_FUNCTOR(select_command); break; - + case 't': + if (is_eq(p, "tags")) { + return POSTS_REPORTER(new report_tags(*this)); + } + break; case 'x': if (is_eq(p, "xact")) return WRAP_FUNCTOR(xact_command); diff --git a/src/report.h b/src/report.h index 2eac61fe..b0044f60 100644 --- a/src/report.h +++ b/src/report.h @@ -358,6 +358,7 @@ public: HANDLER(account_width_).report(out); HANDLER(amount_width_).report(out); HANDLER(total_width_).report(out); + HANDLER(values).report(out); } option_t * lookup_option(const char * p); @@ -1043,6 +1044,7 @@ public: OPTION(report_t, account_width_); OPTION(report_t, amount_width_); OPTION(report_t, total_width_); + OPTION(report_t, values); }; template Date: Tue, 29 Jan 2013 10:03:47 -0700 Subject: Fixes bug 514. accounts and commodities output now sorts updated tests included. --- src/account.h | 7 +++++++ src/commodity.h | 7 +++++++ src/output.h | 4 ++-- test/baseline/cmd-accounts.test | 6 +++--- test/baseline/cmd-commodities.test | 4 ++-- test/baseline/opt-count.test | 6 +++--- 6 files changed, 24 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/account.h b/src/account.h index a2fcb8de..3642ada0 100644 --- a/src/account.h +++ b/src/account.h @@ -308,6 +308,13 @@ std::ostream& operator<<(std::ostream& out, const account_t& account); void put_account(property_tree::ptree& pt, const account_t& acct, function pred); +//simple struct added to allow std::map to compare accounts in the accounts report +struct account_compare { + bool operator() (const account_t& lhs, const account_t& rhs){ + return (lhs.fullname().compare(rhs.fullname()) < 0); + } +}; + } // namespace ledger #endif // _ACCOUNT_H diff --git a/src/commodity.h b/src/commodity.h index ab496850..37b02e74 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -349,6 +349,13 @@ inline std::ostream& operator<<(std::ostream& out, const commodity_t& comm) { void put_commodity(property_tree::ptree& pt, const commodity_t& comm, bool commodity_details = false); +//simple struct to allow std::map to compare commodities names +struct commodity_compare { + bool operator() (const commodity_t* lhs, const commodity_t* rhs){ + return (lhs->symbol().compare(rhs->symbol()) < 0); + } +}; + } // namespace ledger #endif // _COMMODITY_H diff --git a/src/output.h b/src/output.h index 281f69b6..5ce9dc58 100644 --- a/src/output.h +++ b/src/output.h @@ -142,7 +142,7 @@ class report_accounts : public item_handler protected: report_t& report; - std::map accounts; + std::map accounts; typedef std::map::value_type accounts_pair; @@ -194,7 +194,7 @@ class report_commodities : public item_handler protected: report_t& report; - std::map commodities; + std::map commodities; typedef std::map::value_type commodities_pair; diff --git a/test/baseline/cmd-accounts.test b/test/baseline/cmd-accounts.test index be6365fd..2f0310da 100644 --- a/test/baseline/cmd-accounts.test +++ b/test/baseline/cmd-accounts.test @@ -15,12 +15,12 @@ Assets:Testing123ÕßDone test accounts +Assets:AAA Assets:Bank -Equity:Opening balance +Assets:Testing123ÕßDone Assets:XXX -Assets:AAA Assets:♚ -Assets:Testing123ÕßDone +Equity:Opening balance end test test accounts assets:a diff --git a/test/baseline/cmd-commodities.test b/test/baseline/cmd-commodities.test index 0ce6f7a0..719b6798 100644 --- a/test/baseline/cmd-commodities.test +++ b/test/baseline/cmd-commodities.test @@ -15,10 +15,10 @@ Income:Rewards test commodities -GBP -AAA "AA2" "M&M" +AAA +GBP end test test commodities Assets:Rewards diff --git a/test/baseline/opt-count.test b/test/baseline/opt-count.test index 9c5495c8..7c935c7a 100644 --- a/test/baseline/opt-count.test +++ b/test/baseline/opt-count.test @@ -17,14 +17,14 @@ Assets:Cash -30.00 EUR test accounts --count -2 Expenses:Phone 4 Assets:Cash +2 Expenses:Phone 2 Expenses:Rent end test test commodities --count -4 GBP 4 EUR +4 GBP end test test payees --count @@ -33,8 +33,8 @@ test payees --count end test test commodities :rent --count -1 GBP 1 EUR +1 GBP end test test payees tag bnb --count -- cgit v1.2.3 From aba5c1aa465c6ad92839fc9259a6a21d2292192e Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 29 Jan 2013 10:30:18 -0700 Subject: Fixes bugs 705 and 862. Ledger now fails if init or pricedb files are specified on the command line but not found. --- src/global.cc | 53 +++++++++++++++++++++++++++++++++++++---------------- src/global.h | 6 +----- src/session.cc | 6 +++++- 3 files changed, 43 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/global.cc b/src/global.cc index bc172075..5fc10f02 100644 --- a/src/global.cc +++ b/src/global.cc @@ -107,32 +107,53 @@ global_scope_t::~global_scope_t() #endif } +void global_scope_t::parse_init(path init_file) +{ + TRACE_START(init, 1, "Read initialization file"); + + parse_context_stack_t parsing_context; + parsing_context.push(init_file); + parsing_context.get_current().journal = session().journal.get(); + parsing_context.get_current().scope = &report(); + + if (session().journal->read(parsing_context) > 0 || + session().journal->auto_xacts.size() > 0 || + session().journal->period_xacts.size() > 0) { + throw_(parse_error, _f("Transactions found in initialization file '%1%'") + % init_file); + } + + TRACE_FINISH(init, 1); +} + void global_scope_t::read_init() { + // if specified on the command line init_file_ is filled in + // global_scope_t::handle_debug_options. If it was specified on the command line + // fail is the file doesn't exist. If no init file was specified + // on the command-line then try the default values, but don't fail if there + // isn't one. + path init_file; if (HANDLED(init_file_)) { - path init_file(HANDLER(init_file_).str()); + init_file=HANDLER(init_file_).str(); if (exists(init_file)) { - TRACE_START(init, 1, "Read initialization file"); - - parse_context_stack_t parsing_context; - parsing_context.push(init_file); - parsing_context.get_current().journal = session().journal.get(); - parsing_context.get_current().scope = &report(); - - if (session().journal->read(parsing_context) > 0 || - session().journal->auto_xacts.size() > 0 || - session().journal->period_xacts.size() > 0) { - throw_(parse_error, _f("Transactions found in initialization file '%1%'") - % init_file); - } - - TRACE_FINISH(init, 1); + parse_init(init_file); } else { throw_(parse_error, _f("Could not find specified init file %1%") % init_file); } + } else { + if (const char * home_var = std::getenv("HOME")){ + init_file = (path(home_var) / ".ledgerrc"); + } else { + init_file = ("./.ledgerrc"); + } + } + if(exists(init_file)){ + parse_init(init_file); } } + char * global_scope_t::prompt_string() { static char prompt[32]; diff --git a/src/global.h b/src/global.h index dc6abd78..11459529 100644 --- a/src/global.h +++ b/src/global.h @@ -67,6 +67,7 @@ public: return _("global scope"); } + void parse_init(path init_file); void read_init(); void read_environment_settings(char * envp[]); strings_list read_command_arguments(scope_t& scope, strings_list args); @@ -156,11 +157,6 @@ See LICENSE file included with the distribution for details and disclaimer."); if (!_init_file.empty()) // _init_file is filled during handle_debug_options on(none, _init_file); - else - if (const char * home_var = std::getenv("HOME")) - on(none, (path(home_var) / ".ledgerrc").string()); - else - on(none, path("./.ledgerrc").string()); }); OPTION(global_scope_t, options); diff --git a/src/session.cc b/src/session.cc index f047a540..f9815c3f 100644 --- a/src/session.cc +++ b/src/session.cc @@ -98,8 +98,12 @@ std::size_t session_t::read_data(const string& master_account) acct = journal->find_account(master_account); optional price_db_path; - if (HANDLED(price_db_)) + if (HANDLED(price_db_)){ price_db_path = resolve_path(HANDLER(price_db_).str()); + if (!exists(price_db_path.get())){ + throw_(parse_error, _f("Could not find specified price file %1%") % price_db_path); + } + } if (HANDLED(explicit)) journal->force_checking = true; -- cgit v1.2.3 From 1b3dfa1297101fbdd0cbdab57377c40b3a1c3234 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 29 Jan 2013 11:26:43 -0700 Subject: Fixes regression error introduced by tags command patch Not sure how the changes to the options got into the repot.cc file, but this takes the changes out. --- src/report.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/report.cc b/src/report.cc index f7b71b94..80993515 100644 --- a/src/report.cc +++ b/src/report.cc @@ -1089,6 +1089,7 @@ option_t * report_t::lookup_option(const char * p) else OPT(anon); else OPT_ALT(color, ansi); else OPT(auto_match); + else OPT(aux_date); else OPT(average); else OPT(account_width_); else OPT(amount_width_); @@ -1096,7 +1097,7 @@ option_t * report_t::lookup_option(const char * p) case 'b': OPT(balance_format_); else OPT(base); - else OPT_ALT(basis, cost); + else OPT(basis); else OPT_(begin_); else OPT(bold_if_); else OPT(budget); @@ -1105,6 +1106,7 @@ option_t * report_t::lookup_option(const char * p) break; case 'c': OPT(csv_format_); + else OPT_ALT(gain, change); else OPT(cleared); else OPT(collapse); else OPT(collapse_if_zero); @@ -1122,6 +1124,7 @@ option_t * report_t::lookup_option(const char * p) else OPT(dc); else OPT(depth_); else OPT(deviation); + else OPT_ALT(rich_data, detail); else OPT_(display_); else OPT(display_amount_); else OPT(display_total_); @@ -1146,7 +1149,7 @@ option_t * report_t::lookup_option(const char * p) else OPT_ALT(head_, first_); break; case 'g': - OPT_ALT(gain, change); + OPT(gain); else OPT(group_by_); else OPT(group_title_format_); else OPT(generated); @@ -1173,7 +1176,7 @@ option_t * report_t::lookup_option(const char * p) else OPT_ALT(tail_, last_); break; case 'm': - OPT_ALT(market, value); + OPT(market); else OPT(monthly); else OPT(meta_); else OPT(meta_width_); @@ -1203,6 +1206,7 @@ option_t * report_t::lookup_option(const char * p) else OPT(price); else OPT(prices_format_); else OPT(pricedb_format_); + else OPT(primary_date); else OPT(payee_width_); else OPT(prepend_format_); else OPT(prepend_width_); @@ -1220,7 +1224,7 @@ option_t * report_t::lookup_option(const char * p) else OPT(revalued); else OPT(revalued_only); else OPT(revalued_total_); - else OPT_ALT(rich_data, detail); + else OPT(rich_data); break; case 's': OPT(sort_); @@ -1248,7 +1252,8 @@ option_t * report_t::lookup_option(const char * p) else OPT(unround); break; case 'v': - OPT(values); + OPT_ALT(market, value); + else OPT(values); break; case 'w': OPT(weekly); -- cgit v1.2.3 From 1903ff7c2ebdc2cccd4898fd98c28a0c4a74d5af Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 29 Jan 2013 14:10:08 -0700 Subject: Fixed problem finding the default priced file. Bug fix to detect badly specified priced files on the command line didn't handle the default correctly. --- src/session.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/session.cc b/src/session.cc index 632002d4..0f9cca22 100644 --- a/src/session.cc +++ b/src/session.cc @@ -62,12 +62,7 @@ void set_session_context(session_t * session) session_t::session_t() : flush_on_next_data_file(false), journal(new journal_t) { - if (const char * home_var = std::getenv("HOME")) - HANDLER(price_db_).on(none, (path(home_var) / ".pricedb").string()); - else - HANDLER(price_db_).on(none, path("./.pricedb").string()); - - parsing_context.push(); + parsing_context.push(); TRACE_CTOR(session_t, ""); } @@ -101,7 +96,13 @@ std::size_t session_t::read_data(const string& master_account) if (HANDLED(price_db_)){ price_db_path = resolve_path(HANDLER(price_db_).str()); if (!exists(price_db_path.get())){ - throw_(parse_error, _f("Could not find specified price file %1%") % price_db_path); + throw_(parse_error, _f("Could not find specified price-db file %1%") % price_db_path); + } + } else { + if (const char * home_var = std::getenv("HOME")){ + price_db_path = (path(home_var) / ".pricedb"); + } else { + price_db_path = ("./.ledgerrc"); } } -- cgit v1.2.3 From 0df13661686dfec66aa0d5a8dd88920e1e104fbc Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Wed, 30 Jan 2013 15:35:31 -0700 Subject: Bug 634 Added roundto function, optimized floor and ceiling Fixes Bug634 by adding roundto(amount, places). --- doc/ledger3.texi | 4 +++- src/amount.cc | 29 +++++++++++++++-------------- src/amount.h | 7 +++++++ src/balance.h | 11 +++++++++++ src/report.cc | 8 ++++++++ src/report.h | 1 + src/value.cc | 21 +++++++++++++++++++++ src/value.h | 7 +++++++ test/regress/25A099C9.test | 20 ++++++++++---------- 9 files changed, 83 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 377d740c..ee4c990b 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -7192,6 +7192,7 @@ Useful specifying a date in plain terms. For example, you could say @item @strong{Function} @tab @strong{Abbrev.} @tab @strong{Description} @item @code{amount_expr } @tab @code{} @tab @item @code{abs } @tab @code{} @tab --> U +@item @code{ceiling } @tab @code{} @tab Returns the next integer toward +infty @item @code{code} @tab @code{} @tab returns the transaction code, the string between the parenthesis after the date. @item @code{commodity } @tab @code{} @tab @item @code{display_amount } @tab @code{} @tab --> t @@ -7199,7 +7200,7 @@ Useful specifying a date in plain terms. For example, you could say @item @code{date } @tab @code{} @tab @item @code{format_date } @tab @code{} @tab @item @code{format } @tab @code{} @tab -@item @code{floor } @tab @code{} @tab +@item @code{floor } @tab @code{} @tab Returns the next integer toward -infty @item @code{get_at } @tab @code{} @tab @item @code{is_seq } @tab @code{} @tab @item @code{justify } @tab @code{} @tab @@ -7215,6 +7216,7 @@ Useful specifying a date in plain terms. For example, you could say @item @code{quoted } @tab @code{} @tab @item @code{quantity } @tab @code{} @tab @item @code{rounded } @tab @code{} @tab +@item @code{roundto } @tab @code{} @tab Returns value rounded to n digits. Does not affect formatting. @item @code{scrub } @tab @code{} @tab @item @code{strip --> S } @tab @code{} @tab @item @code{should_bold } @tab @code{} @tab diff --git a/src/amount.cc b/src/amount.cc index ee03827e..51e69290 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -30,6 +30,7 @@ */ #include +#include #include "amount.h" #include "commodity.h" @@ -672,31 +673,31 @@ void amount_t::in_place_truncate() void amount_t::in_place_floor() { if (! quantity) - throw_(amount_error, _("Cannot floor an uninitialized amount")); + throw_(amount_error, _("Cannot compute floor on an uninitialized amount")); _dup(); - mpz_t quot; - mpz_init(quot); - mpz_fdiv_q(quot, mpq_numref(MP(quantity)), mpq_denref(MP(quantity))); - mpq_clear(MP(quantity)); - mpq_init(MP(quantity)); - mpq_set_num(MP(quantity), quot); + mpz_fdiv_q(temp, mpq_numref(MP(quantity)), mpq_denref(MP(quantity))); + mpq_set_z(MP(quantity), temp); } void amount_t::in_place_ceiling() { if (! quantity) - throw_(amount_error, _("Cannot ceiling an uninitialized amount")); + throw_(amount_error, _("Cannot compute ceiling on an uninitialized amount")); _dup(); - mpz_t quot; - mpz_init(quot); - mpz_cdiv_q(quot, mpq_numref(MP(quantity)), mpq_denref(MP(quantity))); - mpq_clear(MP(quantity)); - mpq_init(MP(quantity)); - mpq_set_num(MP(quantity), quot); + mpz_cdiv_q(temp, mpq_numref(MP(quantity)), mpq_denref(MP(quantity))); + mpq_set_z(MP(quantity), temp); +} + +void amount_t::in_place_roundto(int places) +{ + if (! quantity) + throw_(amount_error, _("Cannot round an uninitialized amount")); + double x=ceil(mpq_get_d(MP(quantity))*pow(10, places) - 0.49999999) / pow(10, places); + mpq_set_d(MP(quantity), x); } void amount_t::in_place_unround() diff --git a/src/amount.h b/src/amount.h index 1b7d2101..5fc2ad2e 100644 --- a/src/amount.h +++ b/src/amount.h @@ -346,6 +346,13 @@ public: } void in_place_round(); + amount_t roundto(int places) const { + amount_t temp(*this); + temp.in_place_round(); + return temp; + } + void in_place_roundto(int places); + /** Yields an amount which has lost all of its extra precision, beyond what the display precision of the commodity would have printed. */ amount_t truncated() const { diff --git a/src/balance.h b/src/balance.h index 9635742d..f822e353 100644 --- a/src/balance.h +++ b/src/balance.h @@ -325,6 +325,17 @@ public: pair.second.in_place_round(); } + balance_t roundto(int places) const { + balance_t temp(*this); + temp.in_place_roundto(places); + return temp; + } + + void in_place_roundto(int places) { + foreach (amounts_map::value_type& pair, amounts) + pair.second.in_place_roundto(places); + } + balance_t truncated() const { balance_t temp(*this); temp.in_place_truncate(); diff --git a/src/report.cc b/src/report.cc index 80993515..d90d22e4 100644 --- a/src/report.cc +++ b/src/report.cc @@ -691,6 +691,12 @@ value_t report_t::fn_round(call_scope_t& args) return args[0].rounded(); } +value_t report_t::fn_roundto(call_scope_t& args) +{ + if(args.has(1)) + return args[0].roundto(args.get(1)); +} + value_t report_t::fn_unround(call_scope_t& args) { return args[0].unrounded(); @@ -1435,6 +1441,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind, return WRAP_FUNCTOR(fn_red); else if (is_eq(p, "round")) return MAKE_FUNCTOR(report_t::fn_round); + else if (is_eq(p, "roundto")) + return MAKE_FUNCTOR(report_t::fn_roundto); break; case 's': diff --git a/src/report.h b/src/report.h index b0044f60..6533d2f1 100644 --- a/src/report.h +++ b/src/report.h @@ -176,6 +176,7 @@ public: value_t fn_floor(call_scope_t& scope); value_t fn_ceiling(call_scope_t& scope); value_t fn_round(call_scope_t& scope); + value_t fn_roundto(call_scope_t& scope); value_t fn_unround(call_scope_t& scope); value_t fn_abs(call_scope_t& scope); value_t fn_justify(call_scope_t& scope); diff --git a/src/value.cc b/src/value.cc index c57cff78..3df8f3c7 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1612,6 +1612,27 @@ void value_t::in_place_round() throw_(value_error, _f("Cannot set rounding for %1%") % label()); } +void value_t::in_place_roundto(int places) +{ + DEBUG("amount.roundto", "=====> roundto places " << places); + switch (type()) { + case INTEGER: + return; + case AMOUNT: + as_amount_lval().in_place_roundto(places); + return; + case BALANCE: + as_balance_lval().in_place_roundto(places); + return; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_roundto(places); + return; + default: + break; + } +} + void value_t::in_place_truncate() { switch (type()) { diff --git a/src/value.h b/src/value.h index 249f3d7f..49d64ab6 100644 --- a/src/value.h +++ b/src/value.h @@ -443,6 +443,13 @@ public: } void in_place_round(); + value_t roundto(int places) const { + value_t temp(*this); + temp.in_place_roundto(places); + return temp; + } + void in_place_roundto(int places); + value_t truncated() const { value_t temp(*this); temp.in_place_truncate(); diff --git a/test/regress/25A099C9.test b/test/regress/25A099C9.test index fb362a4b..34c92c40 100644 --- a/test/regress/25A099C9.test +++ b/test/regress/25A099C9.test @@ -20,24 +20,24 @@ While parsing file "$sourcepath/src/amount.h", line 121: Error: Unexpected whitespace at beginning of line While parsing file "$sourcepath/src/amount.h", line 132: Error: Unexpected whitespace at beginning of line -While parsing file "$sourcepath/src/amount.h", line 711: +While parsing file "$sourcepath/src/amount.h", line 718: Error: Unexpected whitespace at beginning of line -While parsing file "$sourcepath/src/amount.h", line 741: +While parsing file "$sourcepath/src/amount.h", line 748: Error: Unexpected whitespace at beginning of line -While parsing file "$sourcepath/src/amount.h", line 749: +While parsing file "$sourcepath/src/amount.h", line 756: Error: Unexpected whitespace at beginning of line -While parsing file "$sourcepath/src/amount.h", line 752: +While parsing file "$sourcepath/src/amount.h", line 759: Error: Invalid date/time: line amount_t amoun -While parsing file "$sourcepath/src/amount.h", line 758: +While parsing file "$sourcepath/src/amount.h", line 765: Error: Invalid date/time: line string amount_ -While parsing file "$sourcepath/src/amount.h", line 764: +While parsing file "$sourcepath/src/amount.h", line 771: Error: Invalid date/time: line string amount_ -While parsing file "$sourcepath/src/amount.h", line 770: +While parsing file "$sourcepath/src/amount.h", line 777: Error: Invalid date/time: line string amount_ -While parsing file "$sourcepath/src/amount.h", line 776: -Error: Invalid date/time: line std::ostream& While parsing file "$sourcepath/src/amount.h", line 783: +Error: Invalid date/time: line std::ostream& +While parsing file "$sourcepath/src/amount.h", line 790: Error: Invalid date/time: line std::istream& -While parsing file "$sourcepath/src/amount.h", line 789: +While parsing file "$sourcepath/src/amount.h", line 796: Error: Unexpected whitespace at beginning of line end test -- cgit v1.2.3 From 2b245f823b0cab9aad74a5c0b59dc6de66dee21a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 30 Jan 2013 17:00:07 -0600 Subject: Added missing call to timelog.close() --- src/textual.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/textual.cc b/src/textual.cc index 6106914f..b19ce79a 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -282,6 +282,10 @@ void instance_t::parse() } } +#if defined(TIMELOG_SUPPORT) + timelog.close(); +#endif // TIMELOG_SUPPORT + TRACE_STOP(instance_parse, 1); } -- cgit v1.2.3 From 9e9d99e9187093b459525e3fd7e654d57000c3c4 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 31 Jan 2013 04:56:12 -0600 Subject: Removed an unnecessary if. Fixes #140 --- src/report.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/report.cc b/src/report.cc index d90d22e4..d0b64650 100644 --- a/src/report.cc +++ b/src/report.cc @@ -693,8 +693,7 @@ value_t report_t::fn_round(call_scope_t& args) value_t report_t::fn_roundto(call_scope_t& args) { - if(args.has(1)) - return args[0].roundto(args.get(1)); + return args[0].roundto(args.get(1)); } value_t report_t::fn_unround(call_scope_t& args) -- cgit v1.2.3 From 01b8416f240ab7070f62a9f38b9cd575d1fa6056 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Sat, 2 Feb 2013 09:44:31 -0700 Subject: Fix bug 795 858, printing "(null)" instead of empty string "" --- src/value.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/value.cc b/src/value.cc index 3df8f3c7..902987a7 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1847,7 +1847,7 @@ void value_t::print(std::ostream& _out, switch (type()) { case VOID: - out << "(null)"; + out << ""; break; case BOOLEAN: -- cgit v1.2.3 From 595a8afa44ad3f30995556fbee36ac16024e7c23 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Sat, 2 Feb 2013 15:59:46 -0700 Subject: Fixes bug 377. Ledger now complains if it is given only a directory as input. --- src/context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/context.h b/src/context.h index 9fe0613b..fd3575ab 100644 --- a/src/context.h +++ b/src/context.h @@ -117,7 +117,7 @@ inline parse_context_t open_for_reading(const path& pathname, #else filename = filesystem::complete(filename, cwd); #endif - if (! exists(filename)) + if (! exists(filename) || is_directory(filename)) throw_(std::runtime_error, _f("Cannot read journal file %1%") % filename); -- cgit v1.2.3 From 989f86974750ae4ae32645386d749e94e66eb27d Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 3 Feb 2013 08:26:56 -0600 Subject: Bump format parsing buffer to 64K --- src/format.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/format.cc b/src/format.cc index d29c87b3..14bb2430 100644 --- a/src/format.cc +++ b/src/format.cc @@ -129,7 +129,7 @@ format_t::element_t * format_t::parse_elements(const string& fmt, element_t * current = NULL; - char buf[1024]; + static char buf[65535]; char * q = buf; for (const char * p = fmt.c_str(); *p; p++) { -- cgit v1.2.3 From bc5563289cd838f1bb33b86706927fae2e0d670f Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 5 Feb 2013 00:08:42 -0600 Subject: Fixed bug with --day-break option --- src/timelog.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/timelog.cc b/src/timelog.cc index 9516ba17..acd8a4fa 100644 --- a/src/timelog.cc +++ b/src/timelog.cc @@ -169,10 +169,8 @@ void time_log_t::close() foreach (account_t * account, accounts) { DEBUG("timelog", "Clocking out from account " << account->fullname()); - clock_out_from_timelog(time_xacts, - time_xact_t(none, CURRENT_TIME(), account), - context); - context.count++; + context.count += clock_out_from_timelog + (time_xacts, time_xact_t(none, CURRENT_TIME(), account), context); } assert(time_xacts.empty()); } -- cgit v1.2.3 From 0951bcebef04a2933a7b6e3d93d5c23bea7c4dc9 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 18 Feb 2013 06:51:12 -0600 Subject: Bump copyright information to 2013 --- src/account.cc | 2 +- src/account.h | 2 +- src/amount.cc | 2 +- src/amount.h | 2 +- src/annotate.cc | 2 +- src/annotate.h | 2 +- src/archive.cc | 2 +- src/archive.h | 2 +- src/balance.cc | 2 +- src/balance.h | 2 +- src/chain.cc | 2 +- src/chain.h | 2 +- src/commodity.cc | 2 +- src/commodity.h | 2 +- src/compare.cc | 2 +- src/compare.h | 2 +- src/context.h | 2 +- src/convert.cc | 2 +- src/convert.h | 2 +- src/csv.cc | 2 +- src/csv.h | 2 +- src/draft.cc | 2 +- src/draft.h | 2 +- src/emacs.cc | 2 +- src/emacs.h | 2 +- src/error.cc | 2 +- src/error.h | 2 +- src/expr.cc | 2 +- src/expr.h | 2 +- src/exprbase.h | 2 +- src/filters.cc | 2 +- src/filters.h | 2 +- src/flags.h | 2 +- src/format.cc | 2 +- src/format.h | 2 +- src/generate.cc | 2 +- src/generate.h | 2 +- src/global.cc | 2 +- src/global.h | 4 ++-- src/history.cc | 2 +- src/history.h | 2 +- src/item.cc | 2 +- src/item.h | 2 +- src/iterators.cc | 2 +- src/iterators.h | 2 +- src/journal.cc | 2 +- src/journal.h | 2 +- src/lookup.cc | 2 +- src/lookup.h | 2 +- src/main.cc | 2 +- src/mask.cc | 2 +- src/mask.h | 2 +- src/op.cc | 2 +- src/op.h | 2 +- src/option.cc | 2 +- src/option.h | 2 +- src/org.cc | 2 +- src/org.h | 2 +- src/output.cc | 2 +- src/output.h | 2 +- src/parser.cc | 2 +- src/parser.h | 2 +- src/pool.cc | 2 +- src/pool.h | 2 +- src/post.cc | 2 +- src/post.h | 2 +- src/precmd.cc | 2 +- src/precmd.h | 2 +- src/predicate.h | 2 +- src/print.cc | 2 +- src/print.h | 2 +- src/pstream.h | 2 +- src/ptree.cc | 2 +- src/ptree.h | 2 +- src/py_account.cc | 2 +- src/py_amount.cc | 2 +- src/py_balance.cc | 2 +- src/py_commodity.cc | 2 +- src/py_expr.cc | 2 +- src/py_format.cc | 2 +- src/py_item.cc | 2 +- src/py_journal.cc | 2 +- src/py_post.cc | 2 +- src/py_session.cc | 2 +- src/py_times.cc | 2 +- src/py_utils.cc | 2 +- src/py_value.cc | 2 +- src/py_xact.cc | 2 +- src/pyfstream.h | 2 +- src/pyinterp.cc | 2 +- src/pyinterp.h | 2 +- src/pyledger.cc | 2 +- src/pyutils.h | 2 +- src/query.cc | 2 +- src/query.h | 2 +- src/quotes.cc | 2 +- src/quotes.h | 2 +- src/report.cc | 2 +- src/report.h | 2 +- src/scope.cc | 2 +- src/scope.h | 2 +- src/select.cc | 2 +- src/select.h | 2 +- src/session.cc | 2 +- src/session.h | 2 +- src/stats.cc | 2 +- src/stats.h | 2 +- src/stream.cc | 2 +- src/stream.h | 2 +- src/system.hh.in | 2 +- src/temps.cc | 2 +- src/temps.h | 2 +- src/textual.cc | 2 +- src/timelog.cc | 2 +- src/timelog.h | 2 +- src/times.cc | 2 +- src/times.h | 2 +- src/token.cc | 2 +- src/token.h | 2 +- src/unistring.h | 2 +- src/utils.cc | 2 +- src/utils.h | 2 +- src/value.cc | 2 +- src/value.h | 2 +- src/views.cc | 2 +- src/views.h | 2 +- src/xact.cc | 2 +- src/xact.h | 2 +- 128 files changed, 129 insertions(+), 129 deletions(-) (limited to 'src') diff --git a/src/account.cc b/src/account.cc index 8a5cdffa..7dcd5faa 100644 --- a/src/account.cc +++ b/src/account.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/account.h b/src/account.h index 3642ada0..7b53de15 100644 --- a/src/account.h +++ b/src/account.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/amount.cc b/src/amount.cc index 51e69290..88f2d124 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/amount.h b/src/amount.h index 5fc2ad2e..b70058ff 100644 --- a/src/amount.h +++ b/src/amount.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/annotate.cc b/src/annotate.cc index b7b6b5cb..12016868 100644 --- a/src/annotate.cc +++ b/src/annotate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/annotate.h b/src/annotate.h index 27deaad3..998f7c83 100644 --- a/src/annotate.h +++ b/src/annotate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/archive.cc b/src/archive.cc index caeaf965..6ac1c580 100644 --- a/src/archive.cc +++ b/src/archive.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/archive.h b/src/archive.h index ee4e9ccb..5c15a9fb 100644 --- a/src/archive.h +++ b/src/archive.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/balance.cc b/src/balance.cc index d9551670..f86d6561 100644 --- a/src/balance.cc +++ b/src/balance.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/balance.h b/src/balance.h index f822e353..a1ae51ef 100644 --- a/src/balance.h +++ b/src/balance.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/chain.cc b/src/chain.cc index 52d52f14..b2f6f203 100644 --- a/src/chain.cc +++ b/src/chain.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/chain.h b/src/chain.h index 15ae12ba..de7f68c7 100644 --- a/src/chain.h +++ b/src/chain.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/commodity.cc b/src/commodity.cc index ffeac10d..c7a893f1 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/commodity.h b/src/commodity.h index 82efac6a..a1988a3b 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/compare.cc b/src/compare.cc index e2a298c2..946cd835 100644 --- a/src/compare.cc +++ b/src/compare.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/compare.h b/src/compare.h index e1abbca1..4a91f49f 100644 --- a/src/compare.h +++ b/src/compare.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/context.h b/src/context.h index fd3575ab..e5457641 100644 --- a/src/context.h +++ b/src/context.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/convert.cc b/src/convert.cc index f0d8db06..38ef2c22 100644 --- a/src/convert.cc +++ b/src/convert.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/convert.h b/src/convert.h index de958108..17fb4505 100644 --- a/src/convert.h +++ b/src/convert.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/csv.cc b/src/csv.cc index c7b75712..2a3eb080 100644 --- a/src/csv.cc +++ b/src/csv.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/csv.h b/src/csv.h index 7d5098d2..94f7a328 100644 --- a/src/csv.h +++ b/src/csv.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/draft.cc b/src/draft.cc index a6f60520..6aef2f12 100644 --- a/src/draft.cc +++ b/src/draft.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/draft.h b/src/draft.h index 9023e6da..1cc362ba 100644 --- a/src/draft.h +++ b/src/draft.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/emacs.cc b/src/emacs.cc index 41c67cc6..9bfd1e4b 100644 --- a/src/emacs.cc +++ b/src/emacs.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/emacs.h b/src/emacs.h index a018ce68..368c4c4d 100644 --- a/src/emacs.h +++ b/src/emacs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/error.cc b/src/error.cc index 8aa1d3d6..acee85c9 100644 --- a/src/error.cc +++ b/src/error.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/error.h b/src/error.h index 9837fa4d..93d92109 100644 --- a/src/error.h +++ b/src/error.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/expr.cc b/src/expr.cc index dbe860bf..aa1e07d2 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/expr.h b/src/expr.h index 798e5bec..a5119c0b 100644 --- a/src/expr.h +++ b/src/expr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/exprbase.h b/src/exprbase.h index 4edf2a7a..88d6f118 100644 --- a/src/exprbase.h +++ b/src/exprbase.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/filters.cc b/src/filters.cc index 7570809a..9b8e4fc6 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/filters.h b/src/filters.h index b765f630..42ff2e5c 100644 --- a/src/filters.h +++ b/src/filters.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/flags.h b/src/flags.h index 77a2c4dd..d584e2d0 100644 --- a/src/flags.h +++ b/src/flags.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/format.cc b/src/format.cc index 14bb2430..e0f74616 100644 --- a/src/format.cc +++ b/src/format.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/format.h b/src/format.h index cc48bdda..38f567bd 100644 --- a/src/format.h +++ b/src/format.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/generate.cc b/src/generate.cc index bcbde9f1..2b471c87 100644 --- a/src/generate.cc +++ b/src/generate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/generate.h b/src/generate.h index 1b22004b..f171605b 100644 --- a/src/generate.h +++ b/src/generate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/global.cc b/src/global.cc index 5fc10f02..a4da6ead 100644 --- a/src/global.cc +++ b/src/global.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/global.h b/src/global.h index 11459529..c024dce2 100644 --- a/src/global.h +++ b/src/global.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -127,7 +127,7 @@ public: out << '-' << Ledger_VERSION_DATE; out << _(", the command-line accounting tool"); out << - _("\n\nCopyright (c) 2003-2012, John Wiegley. All rights reserved.\n\n\ + _("\n\nCopyright (c) 2003-2013, John Wiegley. All rights reserved.\n\n\ This program is made available under the terms of the BSD Public License.\n\ See LICENSE file included with the distribution for details and disclaimer."); out << std::endl; diff --git a/src/history.cc b/src/history.cc index 414fc15d..dde8c441 100644 --- a/src/history.cc +++ b/src/history.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/history.h b/src/history.h index b763cb0b..baefb333 100644 --- a/src/history.h +++ b/src/history.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/item.cc b/src/item.cc index 4e2a487c..896589e9 100644 --- a/src/item.cc +++ b/src/item.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/item.h b/src/item.h index 8b0a5225..b0670ac5 100644 --- a/src/item.h +++ b/src/item.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/iterators.cc b/src/iterators.cc index 0a053031..738f33be 100644 --- a/src/iterators.cc +++ b/src/iterators.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/iterators.h b/src/iterators.h index 53814666..3ece313c 100644 --- a/src/iterators.h +++ b/src/iterators.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/journal.cc b/src/journal.cc index 68939be6..c4c8fd98 100644 --- a/src/journal.cc +++ b/src/journal.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/journal.h b/src/journal.h index 5e0fa0e3..716e2910 100644 --- a/src/journal.h +++ b/src/journal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/lookup.cc b/src/lookup.cc index 9edc3bbc..2a602569 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/lookup.h b/src/lookup.h index ba64b0b5..ee80faac 100644 --- a/src/lookup.h +++ b/src/lookup.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/main.cc b/src/main.cc index a44506c9..accae197 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/mask.cc b/src/mask.cc index 18d482ed..56ef02d1 100644 --- a/src/mask.cc +++ b/src/mask.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/mask.h b/src/mask.h index 06bd0141..d46b3349 100644 --- a/src/mask.h +++ b/src/mask.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/op.cc b/src/op.cc index 87857049..15306f02 100644 --- a/src/op.cc +++ b/src/op.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/op.h b/src/op.h index 2a705ca0..bebfcbbd 100644 --- a/src/op.h +++ b/src/op.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/option.cc b/src/option.cc index 7fcc9e4d..256ee45b 100644 --- a/src/option.cc +++ b/src/option.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/option.h b/src/option.h index 642142aa..fe3e257b 100644 --- a/src/option.h +++ b/src/option.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/org.cc b/src/org.cc index 70427321..736260e6 100644 --- a/src/org.cc +++ b/src/org.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/org.h b/src/org.h index 0b34b610..8f9dcf81 100644 --- a/src/org.h +++ b/src/org.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/output.cc b/src/output.cc index 6ed7f861..77d28eed 100644 --- a/src/output.cc +++ b/src/output.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/output.h b/src/output.h index 44eca2d2..31afbd13 100644 --- a/src/output.h +++ b/src/output.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/parser.cc b/src/parser.cc index a17ad271..bcb23f48 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/parser.h b/src/parser.h index 9e6a59f4..8cc8027f 100644 --- a/src/parser.h +++ b/src/parser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/pool.cc b/src/pool.cc index 9f1aea9f..b9e64c4b 100644 --- a/src/pool.cc +++ b/src/pool.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/pool.h b/src/pool.h index 849b7a22..1bcb8b65 100644 --- a/src/pool.h +++ b/src/pool.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/post.cc b/src/post.cc index f23b81cb..c7435aec 100644 --- a/src/post.cc +++ b/src/post.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/post.h b/src/post.h index c9aec6b2..3206afdd 100644 --- a/src/post.h +++ b/src/post.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/precmd.cc b/src/precmd.cc index fe0836bc..e9c966e9 100644 --- a/src/precmd.cc +++ b/src/precmd.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/precmd.h b/src/precmd.h index 1c52d8a7..27925f42 100644 --- a/src/precmd.h +++ b/src/precmd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/predicate.h b/src/predicate.h index c670d6a4..6a1cc01c 100644 --- a/src/predicate.h +++ b/src/predicate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/print.cc b/src/print.cc index a4a0bc6f..f04f59d5 100644 --- a/src/print.cc +++ b/src/print.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/print.h b/src/print.h index 42bfc8b6..8d78e8cc 100644 --- a/src/print.h +++ b/src/print.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/pstream.h b/src/pstream.h index e9cddb4c..4886dc0b 100644 --- a/src/pstream.h +++ b/src/pstream.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/ptree.cc b/src/ptree.cc index 6fb840e0..1e271465 100644 --- a/src/ptree.cc +++ b/src/ptree.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/ptree.h b/src/ptree.h index b28f97d5..ac9e1060 100644 --- a/src/ptree.h +++ b/src/ptree.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_account.cc b/src/py_account.cc index 64a7ae54..fbd68140 100644 --- a/src/py_account.cc +++ b/src/py_account.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_amount.cc b/src/py_amount.cc index 0aa8fee8..50e16a70 100644 --- a/src/py_amount.cc +++ b/src/py_amount.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_balance.cc b/src/py_balance.cc index 2ae546f1..65e3c401 100644 --- a/src/py_balance.cc +++ b/src/py_balance.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_commodity.cc b/src/py_commodity.cc index b283efcc..44a45e33 100644 --- a/src/py_commodity.cc +++ b/src/py_commodity.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_expr.cc b/src/py_expr.cc index dd9df1f5..c680bab4 100644 --- a/src/py_expr.cc +++ b/src/py_expr.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_format.cc b/src/py_format.cc index 482eaf5b..43266b29 100644 --- a/src/py_format.cc +++ b/src/py_format.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_item.cc b/src/py_item.cc index 893ddcfa..02b978c5 100644 --- a/src/py_item.cc +++ b/src/py_item.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_journal.cc b/src/py_journal.cc index 50a52be9..7cce6b11 100644 --- a/src/py_journal.cc +++ b/src/py_journal.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_post.cc b/src/py_post.cc index 692542a0..6061d6ee 100644 --- a/src/py_post.cc +++ b/src/py_post.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_session.cc b/src/py_session.cc index f411d5e1..7e2f9e8a 100644 --- a/src/py_session.cc +++ b/src/py_session.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_times.cc b/src/py_times.cc index 17f9ec7e..599aa60c 100644 --- a/src/py_times.cc +++ b/src/py_times.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_utils.cc b/src/py_utils.cc index 45ffe545..dc572621 100644 --- a/src/py_utils.cc +++ b/src/py_utils.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_value.cc b/src/py_value.cc index b931f008..8b565661 100644 --- a/src/py_value.cc +++ b/src/py_value.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/py_xact.cc b/src/py_xact.cc index 96674207..0b07f582 100644 --- a/src/py_xact.cc +++ b/src/py_xact.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/pyfstream.h b/src/pyfstream.h index 18f28bc4..12bbecfd 100644 --- a/src/pyfstream.h +++ b/src/pyfstream.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/pyinterp.cc b/src/pyinterp.cc index 135a088b..3354d3e9 100644 --- a/src/pyinterp.cc +++ b/src/pyinterp.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/pyinterp.h b/src/pyinterp.h index 56f808c8..e961f4c0 100644 --- a/src/pyinterp.h +++ b/src/pyinterp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/pyledger.cc b/src/pyledger.cc index cf5e362e..ee7b99c9 100644 --- a/src/pyledger.cc +++ b/src/pyledger.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/pyutils.h b/src/pyutils.h index 406ca1ee..6bb9d0bd 100644 --- a/src/pyutils.h +++ b/src/pyutils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/query.cc b/src/query.cc index 07f724fd..209205ae 100644 --- a/src/query.cc +++ b/src/query.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/query.h b/src/query.h index fe52eb35..10820a59 100644 --- a/src/query.h +++ b/src/query.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/quotes.cc b/src/quotes.cc index e92af236..2df51ec1 100644 --- a/src/quotes.cc +++ b/src/quotes.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/quotes.h b/src/quotes.h index 56740e47..813bdfa3 100644 --- a/src/quotes.h +++ b/src/quotes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/report.cc b/src/report.cc index d0b64650..8bb38fb6 100644 --- a/src/report.cc +++ b/src/report.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/report.h b/src/report.h index 6533d2f1..5897e8f6 100644 --- a/src/report.h +++ b/src/report.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/scope.cc b/src/scope.cc index 9112040c..10ae45a9 100644 --- a/src/scope.cc +++ b/src/scope.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/scope.h b/src/scope.h index 4190f5bb..d6291439 100644 --- a/src/scope.h +++ b/src/scope.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/select.cc b/src/select.cc index afcfb351..b7e4c920 100644 --- a/src/select.cc +++ b/src/select.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/select.h b/src/select.h index 54883d22..346067a2 100644 --- a/src/select.h +++ b/src/select.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/session.cc b/src/session.cc index 0f9cca22..e5425a50 100644 --- a/src/session.cc +++ b/src/session.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/session.h b/src/session.h index 74aeab5f..21be3cc7 100644 --- a/src/session.h +++ b/src/session.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/stats.cc b/src/stats.cc index a12420b6..81d71a46 100644 --- a/src/stats.cc +++ b/src/stats.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/stats.h b/src/stats.h index 7b00fec8..5583e704 100644 --- a/src/stats.h +++ b/src/stats.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/stream.cc b/src/stream.cc index ce40bfcc..ad03ab77 100644 --- a/src/stream.cc +++ b/src/stream.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/stream.h b/src/stream.h index c317ebdf..bb63873a 100644 --- a/src/stream.h +++ b/src/stream.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/system.hh.in b/src/system.hh.in index e7411a5e..08a45a15 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/temps.cc b/src/temps.cc index 881077f6..b4778b49 100644 --- a/src/temps.cc +++ b/src/temps.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/temps.h b/src/temps.h index daa1493b..99110496 100644 --- a/src/temps.h +++ b/src/temps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/textual.cc b/src/textual.cc index b19ce79a..932bde84 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/timelog.cc b/src/timelog.cc index acd8a4fa..64017d50 100644 --- a/src/timelog.cc +++ b/src/timelog.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/timelog.h b/src/timelog.h index a902c084..1ce0be28 100644 --- a/src/timelog.h +++ b/src/timelog.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/times.cc b/src/times.cc index 167aac73..f9a6c279 100644 --- a/src/times.cc +++ b/src/times.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/times.h b/src/times.h index 9a0f21ff..ae4e4c75 100644 --- a/src/times.h +++ b/src/times.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/token.cc b/src/token.cc index 1c43af32..d0ec185b 100644 --- a/src/token.cc +++ b/src/token.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/token.h b/src/token.h index 01ff7ee9..51fa1d78 100644 --- a/src/token.h +++ b/src/token.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/unistring.h b/src/unistring.h index b2278796..eb38f8b1 100644 --- a/src/unistring.h +++ b/src/unistring.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/utils.cc b/src/utils.cc index e5faf184..2f592325 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/utils.h b/src/utils.h index 1b356e7c..c4d11636 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/value.cc b/src/value.cc index 902987a7..e8afac50 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/value.h b/src/value.h index 49d64ab6..93760234 100644 --- a/src/value.h +++ b/src/value.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/views.cc b/src/views.cc index 76d06370..2646e84b 100644 --- a/src/views.cc +++ b/src/views.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/views.h b/src/views.h index 7f769250..94bedda5 100644 --- a/src/views.h +++ b/src/views.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/xact.cc b/src/xact.cc index 7ac7a9e9..d33520b4 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/xact.h b/src/xact.h index c5ad3ad6..e59ead75 100644 --- a/src/xact.h +++ b/src/xact.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * Copyright (c) 2003-2013, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are -- cgit v1.2.3 From a875940a93848d4b18b5bed45049edc901ad07a2 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Fri, 8 Mar 2013 21:45:56 +0100 Subject: fix ledger xml output, remove ledger json command As the format used by property trees to represent valid JSON and that for valid XML is too different and given that there are more requests for valid XML output I decided to pursue a quick fix and remove the json command in favor of a working xml command. See bug #782, #909, recent discussion on mailing list. JSON support is postponed until I or someone else finds time to work on this or the python bindings are more stable. --- src/account.cc | 19 +++++++------------ src/amount.cc | 8 +++----- src/amount.h | 2 +- src/annotate.cc | 16 +++++----------- src/balance.cc | 6 ++---- src/commodity.cc | 6 ++---- src/item.cc | 9 ++++----- src/mask.h | 2 +- src/post.cc | 43 +++++++++++++++---------------------------- src/ptree.cc | 15 +++++++-------- src/ptree.h | 3 +-- src/report.cc | 5 ----- src/system.hh.in | 1 - src/times.h | 16 ++++------------ src/value.cc | 20 ++++++++++---------- src/xact.cc | 18 ++++++------------ 16 files changed, 68 insertions(+), 121 deletions(-) (limited to 'src') diff --git a/src/account.cc b/src/account.cc index 7dcd5faa..c3fc80f1 100644 --- a/src/account.cc +++ b/src/account.cc @@ -692,12 +692,10 @@ void account_t::xdata_t::details_t::update(post_t& post, } } -void put_account(property_tree::ptree& pt, const account_t& acct, +void put_account(property_tree::ptree& st, const account_t& acct, function pred) { if (pred(acct)) { - property_tree::ptree& st(pt.put("account", "")); - std::ostringstream buf; buf.width(sizeof(unsigned long) * 2); buf.fill('0'); @@ -709,18 +707,15 @@ void put_account(property_tree::ptree& pt, const account_t& acct, st.put("fullname", acct.fullname()); value_t total = acct.amount(); - if (! total.is_null()) { - property_tree::ptree& t(st.put("account-amount", "")); - put_value(t, total); - } + if (! total.is_null()) + put_value(st.put("account-amount", ""), total); + total = acct.total(); - if (! total.is_null()) { - property_tree::ptree& t(st.put("account-total", "")); - put_value(t, total); - } + if (! total.is_null()) + put_value(st.put("account-total", ""), total); foreach (const accounts_map::value_type& pair, acct.accounts) - put_account(st, *pair.second, pred); + put_account(st.add("account", ""), *pair.second, pred); } } diff --git a/src/amount.cc b/src/amount.cc index 88f2d124..55cbabeb 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -1320,13 +1320,11 @@ bool amount_t::valid() const return true; } -void put_amount(property_tree::ptree& pt, const amount_t& amt, - bool wrap, bool commodity_details) +void put_amount(property_tree::ptree& st, const amount_t& amt, + bool commodity_details) { - property_tree::ptree& st(wrap ? pt.put("amount", "") : pt); - if (amt.has_commodity()) - put_commodity(st, amt.commodity(), commodity_details); + put_commodity(st.put("commodity", ""), amt.commodity(), commodity_details); st.put("quantity", amt.quantity_string()); } diff --git a/src/amount.h b/src/amount.h index b70058ff..938d4b7b 100644 --- a/src/amount.h +++ b/src/amount.h @@ -793,7 +793,7 @@ inline std::istream& operator>>(std::istream& in, amount_t& amt) { } void put_amount(property_tree::ptree& pt, const amount_t& amt, - bool wrap = true, bool commodity_details = false); + bool commodity_details = false); } // namespace ledger diff --git a/src/annotate.cc b/src/annotate.cc index 12016868..8816a89c 100644 --- a/src/annotate.cc +++ b/src/annotate.cc @@ -216,19 +216,13 @@ void annotation_t::print(std::ostream& out, bool keep_base, out << " ((" << *value_expr << "))"; } -void put_annotation(property_tree::ptree& pt, const annotation_t& details) +void put_annotation(property_tree::ptree& st, const annotation_t& details) { - property_tree::ptree& st(pt.put("annotation", "")); + if (details.price) + put_amount(st.put("price", ""), *details.price); - if (details.price) { - property_tree::ptree& t(st.put("price", "")); - put_amount(t, *details.price, false); - } - - if (details.date) { - property_tree::ptree& t(st.put("date", "")); - put_date(t, *details.date, false); - } + if (details.date) + put_date(st.put("date", ""), *details.date); if (details.tag) st.put("tag", *details.tag); diff --git a/src/balance.cc b/src/balance.cc index f86d6561..b702cb7b 100644 --- a/src/balance.cc +++ b/src/balance.cc @@ -336,12 +336,10 @@ void balance_t::print(std::ostream& out, amount_printer.close(); } -void put_balance(property_tree::ptree& pt, const balance_t& bal) +void put_balance(property_tree::ptree& st, const balance_t& bal) { - property_tree::ptree& st(pt.put("balance", "")); - foreach (const balance_t::amounts_map::value_type& pair, bal.amounts) - put_amount(st, pair.second); + put_amount(st.add("amount", ""), pair.second); } } // namespace ledger diff --git a/src/commodity.cc b/src/commodity.cc index c7a893f1..535b31c9 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -497,11 +497,9 @@ bool commodity_t::compare_by_commodity::operator()(const amount_t * left, } } -void put_commodity(property_tree::ptree& pt, const commodity_t& comm, +void put_commodity(property_tree::ptree& st, const commodity_t& comm, bool commodity_details) { - property_tree::ptree& st(pt.put("commodity", "")); - std::string flags; if (! (comm.has_flags(COMMODITY_STYLE_SUFFIXED))) flags += 'P'; if (comm.has_flags(COMMODITY_STYLE_SEPARATED)) flags += 'S'; @@ -512,7 +510,7 @@ void put_commodity(property_tree::ptree& pt, const commodity_t& comm, st.put("symbol", comm.symbol()); if (commodity_details && comm.has_annotation()) - put_annotation(st, as_annotated_commodity(comm).details); + put_annotation(st.put("annotation", ""), as_annotated_commodity(comm).details); } } // namespace ledger diff --git a/src/item.cc b/src/item.cc index 896589e9..a29a3fd3 100644 --- a/src/item.cc +++ b/src/item.cc @@ -600,16 +600,15 @@ string item_context(const item_t& item, const string& desc) return out.str(); } -void put_metadata(property_tree::ptree& pt, const item_t::string_map& metadata) +void put_metadata(property_tree::ptree& st, const item_t::string_map& metadata) { - property_tree::ptree& st(pt.put("metadata", "")); foreach (const item_t::string_map::value_type& pair, metadata) { if (pair.second.first) { - property_tree::ptree& vt(st.put("pair", "")); - vt.put("key", pair.first); + property_tree::ptree& vt(st.add("value", "")); + vt.put(".key", pair.first); put_value(vt, *pair.second.first); } else { - st.put("tag", pair.first); + st.add("tag", pair.first); } } } diff --git a/src/mask.h b/src/mask.h index d46b3349..877a0011 100644 --- a/src/mask.h +++ b/src/mask.h @@ -151,7 +151,7 @@ inline std::ostream& operator<<(std::ostream& out, const mask_t& mask) { } inline void put_mask(property_tree::ptree& pt, const mask_t& mask) { - pt.put("mask", mask.str()); + pt.put_value(mask.str()); } } // namespace ledger diff --git a/src/post.cc b/src/post.cc index c7435aec..1a24429b 100644 --- a/src/post.cc +++ b/src/post.cc @@ -696,10 +696,8 @@ void extend_post(post_t& post, journal_t& journal) } } -void put_post(property_tree::ptree& pt, const post_t& post) +void put_post(property_tree::ptree& st, const post_t& post) { - property_tree::ptree& st(pt.put("posting", "")); - if (post.state() == item_t::CLEARED) st.put(".state", "cleared"); else if (post.state() == item_t::PENDING) @@ -710,14 +708,10 @@ void put_post(property_tree::ptree& pt, const post_t& post) if (post.has_flags(ITEM_GENERATED)) st.put(".generated", "true"); - if (post._date) { - property_tree::ptree& t(st.put("date", "")); - put_date(t, *post._date, false); - } - if (post._date_aux) { - property_tree::ptree& t(st.put("aux-date", "")); - put_date(t, *post._date_aux, false); - } + if (post._date) + put_date(st.put("date", ""), *post._date); + if (post._date_aux) + put_date(st.put("aux-date", ""), *post._date_aux); if (post.account) { property_tree::ptree& t(st.put("account", "")); @@ -736,34 +730,27 @@ void put_post(property_tree::ptree& pt, const post_t& post) if (post.has_xdata() && post.xdata().has_flags(POST_EXT_COMPOUND)) put_value(t, post.xdata().compound_value); else - put_amount(t, post.amount); + put_amount(t.put("amount", ""), post.amount); } - if (post.cost) { - property_tree::ptree& t(st.put("cost", "")); - put_amount(t, *post.cost, false); - } + if (post.cost) + put_amount(st.put("cost", ""), *post.cost); if (post.assigned_amount) { - if (post.has_flags(POST_CALCULATED)) { - property_tree::ptree& t(st.put("balance-assertion", "")); - put_amount(t, *post.assigned_amount, false); - } else { - property_tree::ptree& t(st.put("balance-assignment", "")); - put_amount(t, *post.assigned_amount, false); - } + if (post.has_flags(POST_CALCULATED)) + put_amount(st.put("balance-assertion", ""), *post.assigned_amount); + else + put_amount(st.put("balance-assignment", ""), *post.assigned_amount); } if (post.note) st.put("note", *post.note); if (post.metadata) - put_metadata(st, *post.metadata); + put_metadata(st.put("metadata", ""), *post.metadata); - if (post.xdata_ && ! post.xdata_->total.is_null()) { - property_tree::ptree& t(st.put("total", "")); - put_value(t, post.xdata_->total); - } + if (post.xdata_ && ! post.xdata_->total.is_null()) + put_value(st.put("total", ""), post.xdata_->total); } } // namespace ledger diff --git a/src/ptree.cc b/src/ptree.cc index 1e271465..1d2d4b26 100644 --- a/src/ptree.cc +++ b/src/ptree.cc @@ -61,28 +61,27 @@ void format_ptree::flush() property_tree::ptree& ct(pt.put("ledger.commodities", "")); foreach (const commodities_pair& pair, commodities) - put_commodity(ct, *pair.second, true); + put_commodity(ct.add("commodity", ""), *pair.second, true); property_tree::ptree& at(pt.put("ledger.accounts", "")); - put_account(at, *report.session.journal->master, account_visited_p); + put_account(at.add("account", ""), *report.session.journal->master, account_visited_p); property_tree::ptree& tt(pt.put("ledger.transactions", "")); foreach (const xact_t * xact, transactions) { - put_xact(tt, *xact); + property_tree::ptree& t(tt.add("transaction", "")); + put_xact(t, *xact); - property_tree::ptree& post_tree(tt.put("postings", "")); + property_tree::ptree& post_tree(t.put("postings", "")); foreach (const post_t * post, xact->posts) if (post->has_xdata() && post->xdata().has_flags(POST_EXT_VISITED)) - put_post(post_tree, *post); + put_post(post_tree.add("posting", ""), *post); } switch (format) { case FORMAT_XML: property_tree::write_xml(out, pt); - break; - case FORMAT_JSON: - property_tree::write_json(out, pt); + out << std::endl; break; } } diff --git a/src/ptree.h b/src/ptree.h index ac9e1060..154c8837 100644 --- a/src/ptree.h +++ b/src/ptree.h @@ -75,8 +75,7 @@ protected: public: enum format_t { - FORMAT_XML, - FORMAT_JSON + FORMAT_XML } format; format_ptree(report_t& _report, format_t _format = FORMAT_XML) diff --git a/src/report.cc b/src/report.cc index 8bb38fb6..29077f10 100644 --- a/src/report.cc +++ b/src/report.cc @@ -1628,11 +1628,6 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind, } break; - case 'j': - if (is_eq(p, "json")) - return POSTS_REPORTER(new format_ptree(*this, - format_ptree::FORMAT_JSON)); - break; case 'l': if (is_eq(p, "lisp")) return POSTS_REPORTER(new format_emacs_posts(output_stream)); diff --git a/src/system.hh.in b/src/system.hh.in index 08a45a15..ff7ea75b 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -204,7 +204,6 @@ typedef std::ostream::pos_type ostream_pos_type; #include #include -#include #include #include diff --git a/src/times.h b/src/times.h index ae4e4c75..4b89cc0c 100644 --- a/src/times.h +++ b/src/times.h @@ -111,20 +111,12 @@ std::string format_date(const date_t& when, void set_date_format(const char * format); void set_input_date_format(const char * format); -inline void put_datetime(property_tree::ptree& pt, const datetime_t& when, - bool wrap = true) { - if (wrap) - pt.put("datetime", format_datetime(when, FMT_WRITTEN)); - else - pt.put_value(format_datetime(when, FMT_WRITTEN)); +inline void put_datetime(property_tree::ptree& pt, const datetime_t& when) { + pt.put_value(format_datetime(when, FMT_WRITTEN)); } -inline void put_date(property_tree::ptree& pt, const date_t& when, - bool wrap = true) { - if (wrap) - pt.put("date", format_date(when, FMT_WRITTEN)); - else - pt.put_value(format_date(when, FMT_WRITTEN)); +inline void put_date(property_tree::ptree& pt, const date_t& when) { + pt.put_value(format_date(when, FMT_WRITTEN)); } struct date_traits_t diff --git a/src/value.cc b/src/value.cc index e8afac50..98e48c2f 100644 --- a/src/value.cc +++ b/src/value.cc @@ -2062,35 +2062,35 @@ void put_value(property_tree::ptree& pt, const value_t& value) { switch (value.type()) { case value_t::VOID: - pt.put("void", ""); + pt.add("void", ""); break; case value_t::BOOLEAN: - pt.put("bool", value.as_boolean() ? "true" : "false"); + pt.add("bool", value.as_boolean() ? "true" : "false"); break; case value_t::INTEGER: - pt.put("int", value.to_string()); + pt.add("int", value.to_string()); break; case value_t::AMOUNT: - put_amount(pt, value.as_amount()); + put_amount(pt.add("amount", ""), value.as_amount()); break; case value_t::BALANCE: - put_balance(pt, value.as_balance()); + put_balance(pt.add("balance", ""), value.as_balance()); break; case value_t::DATETIME: - put_datetime(pt, value.as_datetime()); + put_datetime(pt.add("datetime", ""), value.as_datetime()); break; case value_t::DATE: - put_date(pt, value.as_date()); + put_date(pt.add("date", ""), value.as_date()); break; case value_t::STRING: - pt.put("string", value.as_string()); + pt.add("string", value.as_string()); break; case value_t::MASK: - put_mask(pt, value.as_mask()); + put_mask(pt.add("mask", ""), value.as_mask()); break; case value_t::SEQUENCE: { - property_tree::ptree& st(pt.put("sequence", "")); + property_tree::ptree& st(pt.add("sequence", "")); foreach (const value_t& member, value.as_sequence()) put_value(st, member); break; diff --git a/src/xact.cc b/src/xact.cc index d33520b4..8aecf5d6 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -847,10 +847,8 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) } } -void put_xact(property_tree::ptree& pt, const xact_t& xact) +void put_xact(property_tree::ptree& st, const xact_t& xact) { - property_tree::ptree& st(pt.put("transaction", "")); - if (xact.state() == item_t::CLEARED) st.put(".state", "cleared"); else if (xact.state() == item_t::PENDING) @@ -859,14 +857,10 @@ void put_xact(property_tree::ptree& pt, const xact_t& xact) if (xact.has_flags(ITEM_GENERATED)) st.put(".generated", "true"); - if (xact._date) { - property_tree::ptree& t(st.put("date", "")); - put_date(t, *xact._date, false); - } - if (xact._date_aux) { - property_tree::ptree& t(st.put("aux-date", "")); - put_date(t, *xact._date_aux, false); - } + if (xact._date) + put_date(st.put("date", ""), *xact._date); + if (xact._date_aux) + put_date(st.put("aux-date", ""), *xact._date_aux); if (xact.code) st.put("code", *xact.code); @@ -877,7 +871,7 @@ void put_xact(property_tree::ptree& pt, const xact_t& xact) st.put("note", *xact.note); if (xact.metadata) - put_metadata(st, *xact.metadata); + put_metadata(st.put("metadata", ""), *xact.metadata); } } // namespace ledger -- cgit v1.2.3 From 44823d241f01c9cb2b891283f9e110f15aeebf9a Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Fri, 8 Mar 2013 23:16:31 +0100 Subject: indent output of ledger xml --- src/ptree.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ptree.cc b/src/ptree.cc index 1d2d4b26..e7afdcd1 100644 --- a/src/ptree.cc +++ b/src/ptree.cc @@ -80,7 +80,8 @@ void format_ptree::flush() switch (format) { case FORMAT_XML: - property_tree::write_xml(out, pt); + property_tree::xml_writer_settings indented(' ', 2); + property_tree::write_xml(out, pt, indented); out << std::endl; break; } -- cgit v1.2.3