From 71f1adad647d5ec4f2e69970543758d7f49f1340 Mon Sep 17 00:00:00 2001 From: "johannes@debussy" Date: Tue, 5 Nov 2013 14:56:13 +0100 Subject: first try for implementing --depth for register --- src/filters.cc | 32 +++++++++++++++++++++++++------- src/filters.h | 32 ++++++++++++++------------------ 2 files changed, 39 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/filters.cc b/src/filters.cc index fadd5b5a..02f0e79b 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -449,13 +449,16 @@ void collapse_posts::report_subtotal() DEBUG("filters.collapse", "earliest date = " << earliest_date); DEBUG("filters.collapse", "latest date = " << latest_date); - handle_value(/* value= */ subtotal, - /* account= */ totals_account, - /* xact= */ &xact, - /* temps= */ temps, - /* handler= */ handler, - /* date= */ latest_date, - /* act_date_p= */ false); + foreach (post_t * post, component_posts) { + handle_value(/* value= */ subtotal, + /* account= */ find_totals_account(post->account), + /* xact= */ &xact, + /* temps= */ temps, + /* handler= */ handler, + /* date= */ latest_date, + /* act_date_p= */ false); + } + } component_posts.clear(); @@ -466,6 +469,21 @@ void collapse_posts::report_subtotal() count = 0; } +account_t* collapse_posts::find_totals_account(account_t* account) +{ + unsigned short depth=2; + if(account->depth==depth) + { + string name=account->fullname(); + account_t*& acc = totals_accounts[name]; + if(acc==NULL) + acc= &temps.create_account(name); + return acc; + } + //recurse + return find_totals_account(account->parent); +} + void collapse_posts::operator()(post_t& post) { // If we've reached a new xact, report on the subtotal diff --git a/src/filters.h b/src/filters.h index f256707b..f05ddaa1 100644 --- a/src/filters.h +++ b/src/filters.h @@ -421,18 +421,18 @@ public: class collapse_posts : public item_handler { - expr_t& amount_expr; - predicate_t display_predicate; - predicate_t only_predicate; - value_t subtotal; - std::size_t count; - xact_t * last_xact; - post_t * last_post; - temporaries_t temps; - account_t * totals_account; - bool only_collapse_if_zero; - std::list component_posts; - report_t& report; + expr_t& amount_expr; + predicate_t display_predicate; + predicate_t only_predicate; + value_t subtotal; + std::size_t count; + xact_t * last_xact; + post_t * last_post; + temporaries_t temps; + std::map totals_accounts; + bool only_collapse_if_zero; + std::list component_posts; + report_t& report; collapse_posts(); @@ -448,17 +448,13 @@ public: only_predicate(_only_predicate), count(0), last_xact(NULL), last_post(NULL), only_collapse_if_zero(_only_collapse_if_zero), report(_report) { - create_accounts(); TRACE_CTOR(collapse_posts, "post_handler_ptr, ..."); } virtual ~collapse_posts() { TRACE_DTOR(collapse_posts); handler.reset(); } - - void create_accounts() { - totals_account = &temps.create_account(_("")); - } + account_t* find_totals_account(account_t* account); virtual void flush() { report_subtotal(); @@ -480,7 +476,7 @@ public: last_post = NULL; temps.clear(); - create_accounts(); + totals_accounts.clear(); component_posts.clear(); item_handler::clear(); -- cgit v1.2.3 From a2d29dda5f514b84b503037195ca8a79a7969f7d Mon Sep 17 00:00:00 2001 From: "johannes@debussy" Date: Tue, 5 Nov 2013 15:58:52 +0100 Subject: first implementation of --depth for register --- src/filters.cc | 27 ++++++++++++--------------- src/filters.h | 31 +++++++++++++++++-------------- 2 files changed, 29 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/filters.cc b/src/filters.cc index 02f0e79b..f7321438 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -448,10 +448,10 @@ void collapse_posts::report_subtotal() DEBUG("filters.collapse", "Pseudo-xact date = " << *xact._date); DEBUG("filters.collapse", "earliest date = " << earliest_date); DEBUG("filters.collapse", "latest date = " << latest_date); - - foreach (post_t * post, component_posts) { - handle_value(/* value= */ subtotal, - /* account= */ find_totals_account(post->account), + + foreach (totals_map::value_type& pat, totals) { + handle_value(/* value= */ pat.second, + /* account= */ &temps.create_account(pat.first), /* xact= */ &xact, /* temps= */ temps, /* handler= */ handler, @@ -461,6 +461,7 @@ void collapse_posts::report_subtotal() } + totals.clear(); component_posts.clear(); last_xact = NULL; @@ -469,19 +470,14 @@ void collapse_posts::report_subtotal() count = 0; } -account_t* collapse_posts::find_totals_account(account_t* account) +value_t& collapse_posts::find_totals(account_t* account) { - unsigned short depth=2; + unsigned short depth=3; if(account->depth==depth) - { - string name=account->fullname(); - account_t*& acc = totals_accounts[name]; - if(acc==NULL) - acc= &temps.create_account(name); - return acc; - } - //recurse - return find_totals_account(account->parent); + return totals[account->fullname()]; + + //else recurse + return find_totals(account->parent); } void collapse_posts::operator()(post_t& post) @@ -493,6 +489,7 @@ void collapse_posts::operator()(post_t& post) report_subtotal(); post.add_to_value(subtotal, amount_expr); + post.add_to_value(find_totals(post.account), amount_expr); component_posts.push_back(&post); diff --git a/src/filters.h b/src/filters.h index f05ddaa1..d6e1b6fc 100644 --- a/src/filters.h +++ b/src/filters.h @@ -421,18 +421,21 @@ public: class collapse_posts : public item_handler { - expr_t& amount_expr; - predicate_t display_predicate; - predicate_t only_predicate; - value_t subtotal; - std::size_t count; - xact_t * last_xact; - post_t * last_post; - temporaries_t temps; - std::map totals_accounts; - bool only_collapse_if_zero; - std::list component_posts; - report_t& report; + + typedef std::map totals_map; + + expr_t& amount_expr; + predicate_t display_predicate; + predicate_t only_predicate; + value_t subtotal; + std::size_t count; + xact_t * last_xact; + post_t * last_post; + temporaries_t temps; + totals_map totals; + bool only_collapse_if_zero; + std::list component_posts; + report_t& report; collapse_posts(); @@ -454,7 +457,7 @@ public: TRACE_DTOR(collapse_posts); handler.reset(); } - account_t* find_totals_account(account_t* account); + value_t& find_totals(account_t* account); virtual void flush() { report_subtotal(); @@ -476,7 +479,7 @@ public: last_post = NULL; temps.clear(); - totals_accounts.clear(); + totals.clear(); component_posts.clear(); item_handler::clear(); -- cgit v1.2.3 From 658029d39f8594c7f3bf75fb8f7ca9fb2081b473 Mon Sep 17 00:00:00 2001 From: "johannes@debussy" Date: Tue, 5 Nov 2013 16:13:37 +0100 Subject: first implementation of --depth for register --- src/filters.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/filters.cc b/src/filters.cc index f7321438..2b4fe1bf 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -473,6 +473,10 @@ void collapse_posts::report_subtotal() value_t& collapse_posts::find_totals(account_t* account) { unsigned short depth=3; + + if(depth==0) + return totals[_("")]; + if(account->depth==depth) return totals[account->fullname()]; -- cgit v1.2.3 From cb39ea25080a65ebc67d42d24f9de72c7b49bea2 Mon Sep 17 00:00:00 2001 From: tripun Date: Mon, 18 Aug 2014 23:23:58 +0530 Subject: add case for addition to void --- src/value.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/value.cc b/src/value.cc index 70a8ab43..2c62f4e1 100644 --- a/src/value.cc +++ b/src/value.cc @@ -341,6 +341,10 @@ value_t& value_t::operator+=(const value_t& val) } switch (type()) { + case VOID: + *this = value_t(val); + return *this; + case DATETIME: switch (val.type()) { case INTEGER: -- cgit v1.2.3 From 249527c985a9580a5a17ceab8f4488b855a8569c Mon Sep 17 00:00:00 2001 From: "Tim D. Smith" Date: Sat, 9 May 2015 20:01:32 -0700 Subject: link ledger executable to Python Since the ledger executable embeds the Python interpreter, it does need an explicit link to a Python framework on OS X after all. --- src/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a368d378..570a6592 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -273,6 +273,9 @@ if (BUILD_LIBRARY) add_executable(ledger main.cc global.cc) target_link_libraries(ledger libledger) + if (APPLE AND HAVE_BOOST_PYTHON) + target_link_libraries(ledger ${PYTHON_LIBRARIES}) + endif() install(TARGETS libledger DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${LEDGER_INCLUDES} -- cgit v1.2.3 From bcaca24de4264f89a94069701361988007e22e58 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 27 Jul 2015 20:37:16 +0100 Subject: Convert boost::optional objects to bool explicitly. Fixes #417. --- src/account.h | 6 +----- src/item.h | 6 +----- src/parser.h | 2 +- src/post.h | 6 +----- src/times.h | 6 +----- 5 files changed, 5 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/account.h b/src/account.h index 7fae93e1..7de4e560 100644 --- a/src/account.h +++ b/src/account.h @@ -261,11 +261,7 @@ public: mutable optional xdata_; bool has_xdata() const { -#if BOOST_VERSION >= 105600 - return xdata_ != NULL; -#else - return xdata_; -#endif + return static_cast(xdata_); } void clear_xdata(); xdata_t& xdata() { diff --git a/src/item.h b/src/item.h index ba812175..dbba53a8 100644 --- a/src/item.h +++ b/src/item.h @@ -174,11 +174,7 @@ public: static bool use_aux_date; virtual bool has_date() const { -#if BOOST_VERSION >= 105600 - return _date != NULL; -#else - return _date; -#endif + return static_cast(_date); } virtual date_t date() const { diff --git a/src/parser.h b/src/parser.h index e46fc719..25c4a7e3 100644 --- a/src/parser.h +++ b/src/parser.h @@ -118,7 +118,7 @@ public: ptr_op_t parse(std::istream& in, const parse_flags_t& flags = PARSE_DEFAULT, - const optional& original_string = NULL); + const optional& original_string = boost::none); }; } // namespace ledger diff --git a/src/post.h b/src/post.h index 0fb45e90..5f22fa3c 100644 --- a/src/post.h +++ b/src/post.h @@ -205,11 +205,7 @@ public: mutable optional xdata_; bool has_xdata() const { -#if BOOST_VERSION >= 105600 - return xdata_ != NULL; -#else - return xdata_; -#endif + return static_cast(xdata_); } void clear_xdata() { xdata_ = none; diff --git a/src/times.h b/src/times.h index 421d1462..e1a9e847 100644 --- a/src/times.h +++ b/src/times.h @@ -500,11 +500,7 @@ public: void stabilize(const optional& date = none); bool is_valid() const { -#if BOOST_VERSION >= 105600 - return start != NULL; -#else - return start; -#endif + return static_cast(start); } /** Find the current or next period containing date. Returns false if -- cgit v1.2.3 From a1cb25ad2d9a98ea9ec0bb3ee27fe3cde6046434 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Sun, 10 May 2015 13:41:26 +0200 Subject: fix build for boost 1.58 --- src/filters.cc | 2 +- src/iterators.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/filters.cc b/src/filters.cc index 2f97a0e5..b6530c04 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -707,7 +707,7 @@ namespace { insert_prices_in_map(price_map_t& _all_prices) : all_prices(_all_prices) {} - void operator()(datetime_t& date, const amount_t& price) { + void operator()(const datetime_t& date, const amount_t& price) { all_prices.insert(price_map_t::value_type(date, price)); } }; diff --git a/src/iterators.cc b/src/iterators.cc index 21bec5d9..0225e210 100644 --- a/src/iterators.cc +++ b/src/iterators.cc @@ -96,7 +96,7 @@ namespace { TRACE_DTOR(create_price_xact); } - void operator()(datetime_t& date, const amount_t& price) { + void operator()(const datetime_t& date, const amount_t& price) { xact_t * xact; string symbol = price.commodity().symbol(); -- cgit v1.2.3 From d0fba947ade223dfa351c49ac15c6939c35b5f89 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Tue, 28 Jul 2015 20:55:56 +0200 Subject: [cmake] Use CMAKE_SYSTEM_NAME to test the platform. APPLE and CMAKE_HOST_APPLE only check the host system, whereas CMAKE_SYSTEM_NAME checks the target system when cross-compiling. --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index 6166780c..3c8c36ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,7 +225,7 @@ macro(add_ledger_library_dependencies _target) target_link_libraries(${_target} ${INTL_LIB}) endif() if (HAVE_BOOST_PYTHON) - if(APPLE) + if(CMAKE_SYSTEM_NAME STREQUAL Darwin) # Don't link directly to a Python framework on OS X, to avoid segfaults # when the module is imported from a different interpreter target_link_libraries(${_target} ${Boost_LIBRARIES}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 570a6592..8ed6e51a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -273,7 +273,7 @@ if (BUILD_LIBRARY) add_executable(ledger main.cc global.cc) target_link_libraries(ledger libledger) - if (APPLE AND HAVE_BOOST_PYTHON) + if (CMAKE_SYSTEM_NAME STREQUAL Darwin AND HAVE_BOOST_PYTHON) target_link_libraries(ledger ${PYTHON_LIBRARIES}) endif() @@ -297,7 +297,7 @@ print(s.get_python_lib(True, prefix=''))" if (PYTHON_SITE_PACKAGES) if (WIN32 AND NOT CYGWIN) set(_ledger_python_module_name "ledger.pyd") - elseif(CMAKE_HOST_APPLE) + elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(_ledger_python_module_name "ledger.so") else() set(_ledger_python_module_name "ledger${CMAKE_SHARED_LIBRARY_SUFFIX}") -- cgit v1.2.3 From 76f057c14c1ab3255478ba9e8f305bf961f8ed71 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 30 Jul 2015 14:05:53 -0700 Subject: Re-indent some code that was indented incorrectly --- src/session.cc | 83 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/session.cc b/src/session.cc index 7736023d..b4fb4eb8 100644 --- a/src/session.cc +++ b/src/session.cc @@ -127,47 +127,14 @@ std::size_t session_t::read_data(const string& master_account) if (HANDLED(value_expr_)) journal->value_expr = HANDLER(value_expr_).str(); - if (price_db_path) { - if (exists(*price_db_path)) { - parsing_context.push(*price_db_path); - parsing_context.get_current().journal = journal.get(); - try { - if (journal->read(parsing_context) > 0) - throw_(parse_error, _("Transactions not allowed in price history file")); - } - catch (...) { - parsing_context.pop(); - throw; - } - parsing_context.pop(); - } - } - - foreach (const path& pathname, HANDLER(file_).data_files) { - 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. - std::ostringstream buffer; - - while (std::cin.good() && ! std::cin.eof()) { - char line[8192]; - std::cin.read(line, 8192); - std::streamsize count = std::cin.gcount(); - buffer.write(line, count); - } - buffer.flush(); - - shared_ptr stream(new std::istringstream(buffer.str())); - parsing_context.push(stream); - } else { - parsing_context.push(pathname); - } + if (price_db_path) { + if (exists(*price_db_path)) { + parsing_context.push(*price_db_path); parsing_context.get_current().journal = journal.get(); - parsing_context.get_current().master = acct; try { - xact_count += journal->read(parsing_context); + if (journal->read(parsing_context) > 0) + throw_(parse_error, _("Transactions not allowed in price history file")); } catch (...) { parsing_context.pop(); @@ -175,10 +142,44 @@ std::size_t session_t::read_data(const string& master_account) } parsing_context.pop(); } + } + + foreach (const path& pathname, HANDLER(file_).data_files) { + 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. + std::ostringstream buffer; + + while (std::cin.good() && ! std::cin.eof()) { + char line[8192]; + std::cin.read(line, 8192); + std::streamsize count = std::cin.gcount(); + buffer.write(line, count); + } + buffer.flush(); + + shared_ptr stream(new std::istringstream(buffer.str())); + parsing_context.push(stream); + } else { + parsing_context.push(pathname); + } + + parsing_context.get_current().journal = journal.get(); + parsing_context.get_current().master = acct; + try { + xact_count += journal->read(parsing_context); + } + catch (...) { + parsing_context.pop(); + throw; + } + parsing_context.pop(); + } - DEBUG("ledger.read", "xact_count [" << xact_count - << "] == journal->xacts.size() [" << journal->xacts.size() << "]"); - assert(xact_count == journal->xacts.size()); + DEBUG("ledger.read", "xact_count [" << xact_count + << "] == journal->xacts.size() [" << journal->xacts.size() << "]"); + assert(xact_count == journal->xacts.size()); if (populated_data_files) HANDLER(file_).data_files.clear(); -- cgit v1.2.3 From 5bb4f2f593f34e6ce7f98bb59d5c0d30c5e377fb Mon Sep 17 00:00:00 2001 From: thdox Date: Fri, 27 Jun 2014 21:17:57 +0200 Subject: untabify --- src/emacs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/emacs.h b/src/emacs.h index fef7a882..b89ce9f4 100644 --- a/src/emacs.h +++ b/src/emacs.h @@ -72,7 +72,7 @@ public: out.flush(); } virtual void operator()(post_t& post); - virtual string escape_string(string raw); + virtual string escape_string(string raw); }; } // namespace ledger -- cgit v1.2.3 From a24910b3740b572db15fda4bd574222090e16d79 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 4 Aug 2015 14:47:44 -0700 Subject: Whitespace cleanup --- src/CMakeLists.txt | 8 ++++---- src/filters.cc | 6 +++--- src/filters.h | 2 +- src/history.cc | 2 +- src/pool.h | 4 ++-- src/pyinterp.h | 2 +- src/select.cc | 2 +- src/strptime.cc | 2 +- src/value.h | 2 +- src/views.h | 2 +- src/wcwidth.cc | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ed6e51a..65e58edb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -152,7 +152,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") -Wno-unused-parameter -Wno-c++98-compat -fno-limit-debug-info) - + macro(ADD_PCH_RULE _header_filename _src_list _other_srcs) set(_pch_filename "${_header_filename}.pch") @@ -188,7 +188,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${_args} DEPENDS ${_header_filename}) endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs) - + elseif(CMAKE_CXX_COMPILER MATCHES "g\\+\\+") set(GXX_WARNING_FLAGS -pedantic @@ -210,7 +210,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") -Wno-strict-aliasing) add_definitions(${GXX_WARNING_FLAGS}) - + macro(ADD_PCH_RULE _header_filename _src_list _other_srcs) set(_gch_filename "${_header_filename}.gch") @@ -247,7 +247,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${_args} DEPENDS ${_header_filename}) endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs) - + else() macro(ADD_PCH_RULE _header_filename _src_list _other_srcs) endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs) diff --git a/src/filters.cc b/src/filters.cc index d9fb64b0..ef713f1f 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -448,7 +448,7 @@ void collapse_posts::report_subtotal() DEBUG("filters.collapse", "Pseudo-xact date = " << *xact._date); DEBUG("filters.collapse", "earliest date = " << earliest_date); DEBUG("filters.collapse", "latest date = " << latest_date); - + foreach (totals_map::value_type& pat, totals) { handle_value(/* value= */ pat.second, /* account= */ &temps.create_account(pat.first), @@ -476,10 +476,10 @@ value_t& collapse_posts::find_totals(account_t* account) if(depth==0) return totals[_("")]; - + if(account->depth==depth) return totals[account->fullname()]; - + //else recurse return find_totals(account->parent); } diff --git a/src/filters.h b/src/filters.h index 9b745235..e3dc19d8 100644 --- a/src/filters.h +++ b/src/filters.h @@ -423,7 +423,7 @@ class collapse_posts : public item_handler { typedef std::map totals_map; - + expr_t& amount_expr; predicate_t display_predicate; predicate_t only_predicate; diff --git a/src/history.cc b/src/history.cc index e3c459f3..8772d18c 100644 --- a/src/history.cc +++ b/src/history.cc @@ -475,7 +475,7 @@ commodity_history_impl_t::find_price(const commodity_t& source, #endif vertex_descriptor v = tv; - for (vertex_descriptor u = predecessorMap[v]; + for (vertex_descriptor u = predecessorMap[v]; u != v; v = u, u = predecessorMap[v]) { diff --git a/src/pool.h b/src/pool.h index 2e9d93f1..fcc54b86 100644 --- a/src/pool.h +++ b/src/pool.h @@ -78,8 +78,8 @@ public: commodity_t * default_commodity; bool keep_base; // --base - optional price_db; // --price-db= - long quote_leeway; // --leeway= + optional price_db; // --price-db= + long quote_leeway; // --leeway= bool get_quotes; // --download function diff --git a/src/pyinterp.h b/src/pyinterp.h index 32becbf6..fe86573a 100644 --- a/src/pyinterp.h +++ b/src/pyinterp.h @@ -77,7 +77,7 @@ public: if (name != "__main__") main_module->define_global(name, mod->module_object); return mod; - } + } python_interpreter_t() : session_t(), is_initialized(false) { TRACE_CTOR(python_interpreter_t, ""); diff --git a/src/select.cc b/src/select.cc index 81800f16..1141df04 100644 --- a/src/select.cc +++ b/src/select.cc @@ -396,7 +396,7 @@ value_t select_command(call_scope_t& args) #if 0 query_t query; keep_details_t keeper(true, true, true); - expr_t::ptr_op_t expr = + expr_t::ptr_op_t expr = query.parse_args(string_value(arg).to_sequence(), keeper, false, true); report.HANDLER(limit_).on("#select", query.get_query(query_t::QUERY_LIMIT)); #else diff --git a/src/strptime.cc b/src/strptime.cc index b64af96b..b31954f4 100644 --- a/src/strptime.cc +++ b/src/strptime.cc @@ -85,7 +85,7 @@ static char* _strptime(const char *s, const char *format, struct tm *tm) { if (tm->tm_wday == -1) return NULL; s += len; break; - + // month name. case 'b': case 'B': diff --git a/src/value.h b/src/value.h index 810d34f9..c9084e03 100644 --- a/src/value.h +++ b/src/value.h @@ -435,7 +435,7 @@ public: return temp; } void in_place_roundto(int places); - + value_t truncated() const { value_t temp(*this); temp.in_place_truncate(); diff --git a/src/views.h b/src/views.h index 2be3d978..603b28da 100644 --- a/src/views.h +++ b/src/views.h @@ -235,7 +235,7 @@ public: optional note() const { return ptr()->note; } - + bool has_tag(const string& tag) const { return ptr()->has_tag(tag); } diff --git a/src/wcwidth.cc b/src/wcwidth.cc index c23f83d7..75cd76be 100644 --- a/src/wcwidth.cc +++ b/src/wcwidth.cc @@ -195,7 +195,7 @@ int mk_wcwidth(boost::uint32_t ucs) /* if we arrive here, ucs is not a combining or C0/C1 control character */ - return 1 + + return 1 + (ucs >= 0x1100 && (ucs <= 0x115f || /* Hangul Jamo init. consonants */ ucs == 0x2329 || ucs == 0x232a || -- cgit v1.2.3 From 69de980aebf83e83971eb2b791e8676a0141f00a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 4 Aug 2015 14:54:06 -0700 Subject: Revert "--depth for register" --- doc/ledger3.texi | 2 +- src/filters.cc | 33 +++++++-------------------------- src/filters.h | 13 +++++++------ 3 files changed, 15 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 4dc3f48f..62869a29 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -7740,7 +7740,7 @@ The market value of a posting or an account, without its children. The net gain (market value minus cost basis), for a posting or an account, without its children. It is the same as @samp{v-b}. -@item depth +@item l The depth (``level'') of an account. If an account has one parent, its depth is one. diff --git a/src/filters.cc b/src/filters.cc index fd30c966..2f97a0e5 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -448,20 +448,16 @@ void collapse_posts::report_subtotal() DEBUG("filters.collapse", "Pseudo-xact date = " << *xact._date); DEBUG("filters.collapse", "earliest date = " << earliest_date); DEBUG("filters.collapse", "latest date = " << latest_date); - - foreach (totals_map::value_type& pat, totals) { - handle_value(/* value= */ pat.second, - /* account= */ &temps.create_account(pat.first), - /* xact= */ &xact, - /* temps= */ temps, - /* handler= */ handler, - /* date= */ latest_date, - /* act_date_p= */ false); - } + handle_value(/* value= */ subtotal, + /* account= */ totals_account, + /* xact= */ &xact, + /* temps= */ temps, + /* handler= */ handler, + /* date= */ latest_date, + /* act_date_p= */ false); } - totals.clear(); component_posts.clear(); last_xact = NULL; @@ -470,20 +466,6 @@ void collapse_posts::report_subtotal() count = 0; } -value_t& collapse_posts::find_totals(account_t* account) -{ - unsigned short depth=3; - - if(depth==0) - return totals[_("")]; - - if(account->depth==depth) - return totals[account->fullname()]; - - //else recurse - return find_totals(account->parent); -} - void collapse_posts::operator()(post_t& post) { // If we've reached a new xact, report on the subtotal @@ -493,7 +475,6 @@ void collapse_posts::operator()(post_t& post) report_subtotal(); post.add_to_value(subtotal, amount_expr); - post.add_to_value(find_totals(post.account), amount_expr); component_posts.push_back(&post); diff --git a/src/filters.h b/src/filters.h index 9b745235..1404b38e 100644 --- a/src/filters.h +++ b/src/filters.h @@ -421,9 +421,6 @@ public: class collapse_posts : public item_handler { - - typedef std::map totals_map; - expr_t& amount_expr; predicate_t display_predicate; predicate_t only_predicate; @@ -432,7 +429,7 @@ class collapse_posts : public item_handler xact_t * last_xact; post_t * last_post; temporaries_t temps; - totals_map totals; + account_t * totals_account; bool only_collapse_if_zero; std::list component_posts; report_t& report; @@ -451,13 +448,17 @@ public: only_predicate(_only_predicate), count(0), last_xact(NULL), last_post(NULL), only_collapse_if_zero(_only_collapse_if_zero), report(_report) { + create_accounts(); TRACE_CTOR(collapse_posts, "post_handler_ptr, ..."); } virtual ~collapse_posts() { TRACE_DTOR(collapse_posts); handler.reset(); } - value_t& find_totals(account_t* account); + + void create_accounts() { + totals_account = &temps.create_account(_("")); + } virtual void flush() { report_subtotal(); @@ -479,7 +480,7 @@ public: last_post = NULL; temps.clear(); - totals.clear(); + create_accounts(); component_posts.clear(); item_handler::clear(); -- cgit v1.2.3