From 4681e58d7f3cda2a2ac6d05b6ec1a106f568e029 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 19 May 2012 19:32:40 -0500 Subject: Converted the Ledger build system to use CMake --- src/CMakeLists.txt | 261 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/account.cc | 4 +- src/account.h | 8 +- src/amount.cc | 14 +-- src/amount.h | 2 +- src/annotate.cc | 4 +- src/annotate.h | 6 +- src/archive.cc | 6 +- src/archive.h | 2 +- src/balance.h | 2 +- src/commodity.cc | 2 +- src/commodity.h | 6 +- src/draft.cc | 6 +- src/expr.h | 2 +- src/exprbase.h | 10 +- src/filters.cc | 10 +- src/filters.h | 2 +- src/flags.h | 4 +- src/format.cc | 6 +- src/global.cc | 20 ++-- src/global.h | 6 +- src/history.cc | 4 +- src/item.cc | 2 +- src/item.h | 4 +- src/iterators.cc | 4 +- src/journal.h | 4 +- src/lookup.cc | 10 +- src/main.cc | 20 ++-- src/mask.cc | 2 +- src/mask.h | 10 +- src/op.cc | 12 +-- src/op.h | 2 +- src/option.h | 2 +- src/output.cc | 2 +- src/parser.h | 4 +- src/pool.cc | 10 +- src/pool.h | 2 +- src/post.h | 2 +- src/predicate.h | 2 +- src/ptree.cc | 9 +- src/pyinterp.cc | 6 +- src/pyinterp.h | 2 +- src/pyutils.h | 2 +- src/quotes.cc | 2 +- src/report.cc | 4 +- src/report.h | 4 +- src/scope.h | 16 ++-- src/select.cc | 8 -- src/session.cc | 8 +- src/system.hh.in | 63 +++++++++++-- src/textual.cc | 17 +--- src/times.cc | 14 +-- src/times.h | 12 +-- src/utils.cc | 42 ++++----- src/utils.h | 57 +++++++----- src/value.cc | 4 +- src/value.h | 4 +- src/views.cc | 2 +- src/views.h | 2 +- src/xact.cc | 10 +- src/xact.h | 14 +-- 61 files changed, 541 insertions(+), 242 deletions(-) create mode 100644 src/CMakeLists.txt (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..6f44e1be --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,261 @@ +set(LEDGER_SOURCES + stats.cc + generate.cc + csv.cc + convert.cc + draft.cc + emacs.cc + org.cc + ptree.cc + print.cc + output.cc + precmd.cc + chain.cc + filters.cc + report.cc + views.cc + select.cc + session.cc + option.cc + lookup.cc + compare.cc + iterators.cc + timelog.cc + textual.cc + temps.cc + journal.cc + archive.cc + account.cc + xact.cc + post.cc + item.cc + format.cc + query.cc + scope.cc + expr.cc + op.cc + parser.cc + token.cc + value.cc + balance.cc + quotes.cc + history.cc + pool.cc + annotate.cc + commodity.cc + amount.cc + stream.cc + mask.cc + times.cc + error.cc + utils.cc) + +if(HAVE_BOOST_PYTHON) + list(APPEND LEDGER_SOURCES + py_account.cc + py_amount.cc + py_balance.cc + py_commodity.cc + py_expr.cc + py_format.cc + py_item.cc + py_journal.cc + py_post.cc + py_session.cc + py_times.cc + py_utils.cc + py_value.cc + py_xact.cc + pyinterp.cc + pyledger.cc) +endif() + +set(LEDGER_INCLUDES + account.h + amount.h + annotate.h + archive.h + balance.h + chain.h + commodity.h + compare.h + context.h + convert.h + csv.h + draft.h + emacs.h + error.h + expr.h + exprbase.h + filters.h + flags.h + format.h + generate.h + global.h + history.h + item.h + iterators.h + journal.h + lookup.h + mask.h + op.h + option.h + org.h + output.h + parser.h + pool.h + post.h + precmd.h + predicate.h + print.h + pstream.h + ptree.h + pyfstream.h + pyinterp.h + pyutils.h + query.h + quotes.h + report.h + scope.h + select.h + session.h + stats.h + stream.h + temps.h + timelog.h + times.h + token.h + unistring.h + utils.h + value.h + views.h + xact.h + ${PROJECT_BINARY_DIR}/system.hh) + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + if(CMAKE_CXX_COMPILER MATCHES "clang") + set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") + add_definitions( + -Weverything + -Wno-padded + -Wno-weak-vtables + -Wno-exit-time-destructors + -Wno-global-constructors + -Wno-switch-enum + -Wno-missing-prototypes + -Wno-missing-noreturn + -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") + + set_source_files_properties( + ${${_src_list}} PROPERTIES COMPILE_FLAGS "-include ${_header_filename}") + if(_other_srcs) + set_source_files_properties( + ${_other_srcs} PROPERTIES COMPILE_FLAGS "-include ${_header_filename}") + endif() + list(APPEND ${_src_list} ${_pch_filename}) + + set(_args ${CMAKE_CXX_FLAGS}) + list(APPEND _args ${CMAKE_CXX_FLAGS_DEBUG}) + list(APPEND _args "-x c++-header " ${_inc}) + list(APPEND _args -c ${_header_filename} -o ${_pch_filename}) + + get_directory_property(DIRINC INCLUDE_DIRECTORIES) + foreach(_inc ${DIRINC}) + list(APPEND _args "-isystem " ${_inc}) + endforeach(_inc ${DIRINC}) + + separate_arguments(_args) + + add_custom_command(OUTPUT ${_pch_filename} + COMMAND rm -f ${_pch_filename} + 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 + -ansi + -pedantic + -Wall + -Winvalid-pch + -Wextra + -Wcast-align + -Wcast-qual + -Wfloat-equal + -Wmissing-field-initializers + -Wno-endif-labels + -Wno-overloaded-virtual + -Wsign-compare + -Wsign-promo + -Wwrite-strings + -Wno-unused-parameter + -Wno-old-style-cast + -Wno-deprecated + -Wno-strict-aliasing) + + add_definitions(${GXX_WARNING_FLAGS}) + + macro(ADD_PCH_RULE _header_filename _src_list _other_srcs) + set(_gch_filename "${_header_filename}.gch") + + set_source_files_properties( + ${${_src_list}} PROPERTIES COMPILE_FLAGS "-Winvalid-pch") + if(_other_srcs) + set_source_files_properties( + ${_other_srcs} PROPERTIES COMPILE_FLAGS "-Winvalid-pch") + endif() + list(APPEND ${_src_list} ${_gch_filename}) + + set(_args ${CMAKE_CXX_FLAGS}) + list(APPEND _args ${CMAKE_CXX_FLAGS_DEBUG}) + list(APPEND _args ${GXX_WARNING_FLAGS}) + list(APPEND _args "-x c++-header " ${_inc}) + list(APPEND _args -c ${_header_filename} -o ${_gch_filename}) + + get_directory_property(DIRINC INCLUDE_DIRECTORIES) + foreach(_inc ${DIRINC}) + list(APPEND _args "-isystem " ${_inc}) + endforeach(_inc ${DIRINC}) + + separate_arguments(_args) + + add_custom_command(OUTPUT ${_gch_filename} + COMMAND rm -f ${_gch_filename} + 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) + endif() +else() + macro(ADD_PCH_RULE _header_filename _src_list _other_srcs) + endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs) +endif() + +add_pch_rule(${PROJECT_BINARY_DIR}/system.hh LEDGER_SOURCES main.cc global.cc) + +if(BUILD_LIBRARY) + add_library(libledger ${LEDGER_SOURCES} ${PROJECT_SOURCE_DIR}/lib/sha1.cpp) + set_target_properties(libledger PROPERTIES OUTPUT_NAME ledger) + + add_executable(ledger main.cc global.cc) + + install(TARGETS libledger DESTINATION lib) + install(FILES ${LEDGER_INCLUDES} DESTINATION include/ledger) +else() + add_executable(ledger + ${LEDGER_SOURCES} ${PROJECT_SOURCE_DIR}/lib/sha1.cpp main.cc global.cc) +endif() + +add_ledger_library_dependencies(ledger) + +install(TARGETS ledger DESTINATION bin) + +### CMakeLists.txt ends here diff --git a/src/account.cc b/src/account.cc index 11b918fa..72709f95 100644 --- a/src/account.cc +++ b/src/account.cc @@ -89,11 +89,11 @@ account_t * account_t::find_account(const string& acct_name, if (has_flags(ACCOUNT_GENERATED)) account->add_flags(ACCOUNT_GENERATED); -#if defined(DEBUG_ON) +#if DEBUG_ON std::pair result = #endif accounts.insert(accounts_map::value_type(first, account)); -#if defined(DEBUG_ON) +#if DEBUG_ON assert(result.second); #endif } else { diff --git a/src/account.h b/src/account.h index 1716102f..a2fcb8de 100644 --- a/src/account.h +++ b/src/account.h @@ -70,7 +70,7 @@ public: optional value_expr; mutable string _fullname; -#ifdef DOCUMENT_MODEL +#if DOCUMENT_MODEL mutable void * data; #endif @@ -80,7 +80,7 @@ public: : supports_flags<>(), scope_t(), parent(_parent), name(_name), note(_note), depth(static_cast(parent ? parent->depth + 1 : 0)) -#ifdef DOCUMENT_MODEL +#if DOCUMENT_MODEL , data(NULL) #endif { @@ -93,7 +93,7 @@ public: note(other.note), depth(other.depth), accounts(other.accounts) -#ifdef DOCUMENT_MODEL +#if DOCUMENT_MODEL , data(NULL) #endif { @@ -282,7 +282,7 @@ public: bool children_with_xdata() const; std::size_t children_with_flags(xdata_t::flags_t flags) const; -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/amount.cc b/src/amount.cc index 645b244b..9491efcd 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -93,7 +93,7 @@ struct amount_t::bigint_t : public supports_flags<> return true; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: friend class boost::serialization::access; @@ -120,7 +120,7 @@ namespace { { char * buf = NULL; try { -#if defined(DEBUG_ON) +#if DEBUG_ON IF_DEBUG("amount.convert") { char * tbuf = mpq_get_str(NULL, 10, quant); DEBUG("amount.convert", "Rational to convert = " << tbuf); @@ -247,7 +247,7 @@ void amount_t::initialize() // in terms of seconds, but reported as minutes or hours. if (commodity_t * commodity = commodity_pool_t::current_pool->create("s")) commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET); -#if !defined(NO_ASSERTS) +#if !NO_ASSERTS else assert(false); #endif @@ -255,7 +255,7 @@ void amount_t::initialize() // Add a "percentile" commodity if (commodity_t * commodity = commodity_pool_t::current_pool->create("%")) commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET); -#if !defined(NO_ASSERTS) +#if !NO_ASSERTS else assert(false); #endif @@ -730,7 +730,7 @@ amount_t::value(const datetime_t& moment, const commodity_t * in_terms_of) const { if (quantity) { -#if defined(DEBUG_ON) +#if DEBUG_ON DEBUG("commodity.price.find", "amount_t::value of " << commodity().symbol()); if (! moment.is_not_a_date_time()) @@ -1294,7 +1294,7 @@ void put_amount(property_tree::ptree& pt, const amount_t& amt, st.put("quantity", amt.quantity_string()); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION template void amount_t::serialize(Archive& ar, const unsigned int /* version */) @@ -1308,7 +1308,7 @@ void amount_t::serialize(Archive& ar, const unsigned int /* version */) } // namespace ledger -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION namespace boost { namespace serialization { diff --git a/src/amount.h b/src/amount.h index 5863381b..49027bb7 100644 --- a/src/amount.h +++ b/src/amount.h @@ -727,7 +727,7 @@ public: bool valid() const; -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/annotate.cc b/src/annotate.cc index b2df0d34..b7b6b5cb 100644 --- a/src/annotate.cc +++ b/src/annotate.cc @@ -186,7 +186,7 @@ void annotation_t::parse(std::istream& in) } } while (true); -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("amounts.commodities") && *this) { DEBUG("amounts.commodities", "Parsed commodity annotations: " << std::endl << *this); @@ -300,7 +300,7 @@ annotated_commodity_t::find_price(const commodity_t * commodity, } } -#if defined(DEBUG_ON) +#if DEBUG_ON if (target) DEBUG("commodity.price.find", "target commodity: " << target->symbol()); #endif diff --git a/src/annotate.h b/src/annotate.h index 1e62e2fa..27deaad3 100644 --- a/src/annotate.h +++ b/src/annotate.h @@ -108,7 +108,7 @@ struct annotation_t : public supports_flags<>, return true; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -163,7 +163,7 @@ struct keep_details_t } bool keep_any(const commodity_t& comm) const; -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -251,7 +251,7 @@ public: virtual void write_annotations(std::ostream& out, bool no_computed_annotations = false) const; -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: explicit annotated_commodity_t() : ptr(NULL) { TRACE_CTOR(annotated_commodity_t, ""); diff --git a/src/archive.cc b/src/archive.cc index 72ec0419..caeaf965 100644 --- a/src/archive.cc +++ b/src/archive.cc @@ -31,7 +31,7 @@ #include -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION #include "archive.h" #include "amount.h" @@ -116,7 +116,7 @@ bool archive_t::read_header() "Version number: " << std::hex << ARCHIVE_VERSION << std::dec); DEBUG("archive.journal", "Number of sources: " << sources.size()); -#if defined(DEBUG_ON) +#if DEBUG_ON foreach (const journal_t::fileinfo_t& i, sources) DEBUG("archive.journal", "Loaded source: " << *i.filename); #endif @@ -250,7 +250,7 @@ void archive_t::save(journal_t& journal) write_header_bits(stream); sources = journal.sources; -#if defined(DEBUG_ON) +#if DEBUG_ON foreach (const journal_t::fileinfo_t& i, sources) DEBUG("archive.journal", "Saving source: " << *i.filename); #endif diff --git a/src/archive.h b/src/archive.h index 4ce5e0e7..ee4e9ccb 100644 --- a/src/archive.h +++ b/src/archive.h @@ -74,7 +74,7 @@ public: void save(journal_t& journal); bool load(journal_t& journal); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/balance.h b/src/balance.h index 9a07084d..230a4e2c 100644 --- a/src/balance.h +++ b/src/balance.h @@ -573,7 +573,7 @@ public: return true; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/commodity.cc b/src/commodity.cc index 54459155..05d465ca 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -91,7 +91,7 @@ optional commodity_t::find_price_from_expr(expr_t& expr, const commodity_t * commodity, const datetime_t& moment) const { -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("commodity.price.find")) { ledger::_log_buffer << "valuation expr: "; expr.dump(ledger::_log_buffer); diff --git a/src/commodity.h b/src/commodity.h index 82be0ee8..ab496850 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -69,7 +69,7 @@ struct price_point_t return when == other.when && price == other.price; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -138,7 +138,7 @@ protected: TRACE_DTOR(commodity_t::base_t); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: base_t() { TRACE_CTOR(base_t, ""); @@ -314,7 +314,7 @@ public: bool operator()(const amount_t * left, const amount_t * right) const; }; -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: supports_flags temp_flags; diff --git a/src/draft.cc b/src/draft.cc index c5f37f42..a6f60520 100644 --- a/src/draft.cc +++ b/src/draft.cc @@ -276,7 +276,7 @@ xact_t * draft_t::insert(journal_t& journal) //added->code = matching->code; //added->note = matching->note; -#if defined(DEBUG_ON) +#if DEBUG_ON DEBUG("draft.xact", "Setting payee from match: " << added->payee); //if (added->code) // DEBUG("draft.xact", "Setting code from match: " << *added->code); @@ -381,14 +381,14 @@ xact_t * draft_t::insert(journal_t& journal) account_t * acct = NULL; if (! acct) { acct = journal.find_account_re(post.account_mask->str()); -#if defined(DEBUG_ON) +#if DEBUG_ON if (acct) DEBUG("draft.xact", "Found account as a regular expression"); #endif } if (! acct) { acct = journal.find_account(post.account_mask->str()); -#if defined(DEBUG_ON) +#if DEBUG_ON if (acct) DEBUG("draft.xact", "Found (or created) account by name"); #endif diff --git a/src/expr.h b/src/expr.h index 645b5cf9..798e5bec 100644 --- a/src/expr.h +++ b/src/expr.h @@ -107,7 +107,7 @@ public: virtual void print(std::ostream& out) const; virtual void dump(std::ostream& out) const; -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/exprbase.h b/src/exprbase.h index bea25320..4edf2a7a 100644 --- a/src/exprbase.h +++ b/src/exprbase.h @@ -156,22 +156,22 @@ public: result_type calc(scope_t& scope) { if (! compiled) { -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("expr.compile")) { DEBUG("expr.compile", "Before compilation:"); dump(*_log_stream); } -#endif // defined(DEBUG_ON) +#endif // DEBUG_ON DEBUG("expr.compile", "Compiling: " << str); compile(scope); -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("expr.compile")) { DEBUG("expr.compile", "After compilation:"); dump(*_log_stream); } -#endif // defined(DEBUG_ON) +#endif // DEBUG_ON } DEBUG("expr.calc", "Calculating: " << str); @@ -232,7 +232,7 @@ public: return calc(); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/filters.cc b/src/filters.cc index 9589958c..7f426bf3 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -909,14 +909,14 @@ void subtotal_posts::operator()(post_t& post) values_map::iterator i = values.find(acct->fullname()); if (i == values.end()) { -#if defined(DEBUG_ON) +#if DEBUG_ON std::pair result = #endif values.insert(values_pair (acct->fullname(), acct_value_t(acct, amount, post.has_flags(POST_VIRTUAL), post.has_flags(POST_MUST_BALANCE)))); -#if defined(DEBUG_ON) +#if DEBUG_ON assert(result.second); #endif } else { @@ -994,7 +994,7 @@ void interval_posts::flush() DEBUG("filters.interval", "Considering post " << post->date() << " = " << post->amount); -#if defined(DEBUG_ON) +#if DEBUG_ON DEBUG("filters.interval", "interval is:"); debug_interval(interval); #endif @@ -1269,7 +1269,7 @@ void budget_posts::report_budget_items(const date_t& date) begin = pair.first.start; } -#if defined(DEBUG_ON) +#if DEBUG_ON DEBUG("budget.generate", "begin = " << *begin); DEBUG("budget.generate", "date = " << date); if (pair.first.finish) @@ -1409,7 +1409,7 @@ void forecast_posts::flush() least = i; } -#if !defined(NO_ASSERTS) +#if !NO_ASSERTS if ((*least).first.finish) assert(*(*least).first.start < *(*least).first.finish); #endif diff --git a/src/filters.h b/src/filters.h index 1dad8852..b765f630 100644 --- a/src/filters.h +++ b/src/filters.h @@ -742,7 +742,7 @@ public: void report_subtotal(const date_interval_t& ival); -#if defined(DEBUG_ON) +#if DEBUG_ON void debug_interval(const date_interval_t& ival) { if (ival.start) DEBUG("filters.interval", "start = " << *ival.start); diff --git a/src/flags.h b/src/flags.h index e2046c08..77a2c4dd 100644 --- a/src/flags.h +++ b/src/flags.h @@ -91,7 +91,7 @@ public: _flags = static_cast(static_cast(_flags) & static_cast(~arg)); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: friend class boost::serialization::access; @@ -194,7 +194,7 @@ public: _flags.drop_flags(arg); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: friend class boost::serialization::access; diff --git a/src/format.cc b/src/format.cc index 18c7696d..d29c87b3 100644 --- a/src/format.cc +++ b/src/format.cc @@ -221,7 +221,7 @@ format_t::element_t * format_t::parse_elements(const string& fmt, static_cast(current->max_width) : -1); else if (keyword == "left") expr << (current->has_flags(ELEMENT_ALIGN_LEFT) ? "false" : "true"); -#if defined(DEBUG_ON) +#if DEBUG_ON else assert("Unrecognized format substitution keyword" == NULL); #endif @@ -538,7 +538,7 @@ string format_t::truncate(const unistring& ustr, // distributed, with the latter parts being longer than the // former, but with none shorter than account_abbrev_length. std::list lens; -#if defined(DEBUG_ON) +#if DEBUG_ON int index = 0; #endif for (std::list::iterator i = parts.begin(); @@ -595,7 +595,7 @@ string format_t::truncate(const unistring& ustr, std::size_t overflow_at_start = overflow; DEBUG("format.abbrev", "Overflow starting at " << overflow << " chars"); -#if defined(DEBUG_ON) +#if DEBUG_ON index = 0; #endif std::size_t counter = lens.size(); diff --git a/src/global.cc b/src/global.cc index 285fdea3..a718d6cb 100644 --- a/src/global.cc +++ b/src/global.cc @@ -32,7 +32,7 @@ #include #include "global.h" -#if defined(HAVE_BOOST_PYTHON) +#if HAVE_BOOST_PYTHON #include "pyinterp.h" #else #include "session.h" @@ -49,7 +49,7 @@ global_scope_t::global_scope_t(char ** envp) { epoch = CURRENT_TIME(); -#if defined(HAVE_BOOST_PYTHON) +#if HAVE_BOOST_PYTHON if (! python_session.get()) { python_session.reset(new ledger::python_interpreter_t); session_ptr = python_session; @@ -101,7 +101,7 @@ global_scope_t::~global_scope_t() // Otherwise, let it all leak because we're about to exit anyway. IF_VERIFY() set_session_context(NULL); -#if defined(HAVE_BOOST_PYTHON) +#if HAVE_BOOST_PYTHON python_session.reset(); #endif } @@ -399,13 +399,13 @@ global_scope_t::read_command_arguments(scope_t& scope, strings_list args) void global_scope_t::normalize_session_options() { -#if defined(LOGGING_ON) +#if LOGGING_ON INFO("Initialization file is " << HANDLER(init_file_).str()); INFO("Price database is " << session().HANDLER(price_db_).str()); foreach (const path& pathname, session().HANDLER(file_).data_files) INFO("Journal file is " << pathname.string()); -#endif // defined(LOGGING_ON) +#endif // LOGGING_ON } expr_t::func_t global_scope_t::look_for_precommand(scope_t& scope, @@ -455,7 +455,7 @@ void handle_debug_options(int argc, char * argv[]) args_only = true; } else if (std::strcmp(argv[i], "--verify-memory") == 0) { -#if defined(VERIFY_ON) +#if VERIFY_ON verify_enabled = true; _log_level = LOG_DEBUG; @@ -463,25 +463,25 @@ void handle_debug_options(int argc, char * argv[]) #endif } else if (std::strcmp(argv[i], "--verify") == 0) { -#if defined(VERIFY_ON) +#if VERIFY_ON verify_enabled = true; #endif } else if (std::strcmp(argv[i], "--verbose") == 0 || std::strcmp(argv[i], "-v") == 0) { -#if defined(LOGGING_ON) +#if LOGGING_ON _log_level = LOG_INFO; #endif } else if (i + 1 < argc && std::strcmp(argv[i], "--debug") == 0) { -#if defined(DEBUG_ON) +#if DEBUG_ON _log_level = LOG_DEBUG; _log_category = argv[i + 1]; i++; #endif } else if (i + 1 < argc && std::strcmp(argv[i], "--trace") == 0) { -#if defined(TRACING_ON) +#if TRACING_ON _log_level = LOG_TRACE; try { _trace_level = boost::lexical_cast(argv[i + 1]); diff --git a/src/global.h b/src/global.h index 5786bb89..f797ba01 100644 --- a/src/global.h +++ b/src/global.h @@ -118,7 +118,11 @@ public: void show_version_info(std::ostream& out) { out << - "Ledger " << ledger::version << _(", the command-line accounting tool"); + "Ledger " << Ledger_VERSION_MAJOR << '.' << Ledger_VERSION_MINOR << '.' + << Ledger_VERSION_PATCH; + if (Ledger_VERSION_DATE != 0) + out << '-' << Ledger_VERSION_DATE; + out << _(", the command-line accounting tool"); out << _("\n\nCopyright (c) 2003-2012, John Wiegley. All rights reserved.\n\n\ This program is made available under the terms of the BSD Public License.\n\ diff --git a/src/history.cc b/src/history.cc index d94ec647..556abd26 100644 --- a/src/history.cc +++ b/src/history.cc @@ -67,7 +67,7 @@ public: template bool operator()(const Edge& e) const { -#if defined(DEBUG_ON) +#if DEBUG_ON DEBUG("history.find", " reftime = " << reftime); if (! oldest.is_not_a_date_time()) { DEBUG("history.find", " oldest = " << oldest); @@ -239,7 +239,7 @@ commodity_history_t::find_price(const commodity_t& source, FNameMap namemap(get(vertex_name, fg)); DEBUG("history.find", "sv commodity = " << get(namemap, sv)->symbol()); -#if defined(DEBUG_ON) +#if DEBUG_ON if (source.has_flags(COMMODITY_PRIMARY)) DEBUG("history.find", "sv commodity is primary"); #endif diff --git a/src/item.cc b/src/item.cc index 5dc62096..0630043b 100644 --- a/src/item.cc +++ b/src/item.cc @@ -45,7 +45,7 @@ bool item_t::has_tag(const string& tag, bool) const return false; } string_map::const_iterator i = metadata->find(tag); -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("item.meta")) { if (i == metadata->end()) DEBUG("item.meta", "Item does not have this tag"); diff --git a/src/item.h b/src/item.h index 582abc46..8b0a5225 100644 --- a/src/item.h +++ b/src/item.h @@ -79,7 +79,7 @@ struct position_t return *this; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -223,7 +223,7 @@ public: bool valid() const; -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/iterators.cc b/src/iterators.cc index 7cc1291a..0a053031 100644 --- a/src/iterators.cc +++ b/src/iterators.cc @@ -203,7 +203,7 @@ void sorted_accounts_iterator::push_back(account_t& account) accounts_list.back().end(), compare_items(sort_cmp)); -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("accounts.sorted")) { foreach (account_t * acct, accounts_list.back()) DEBUG("accounts.sorted", @@ -236,7 +236,7 @@ void sorted_accounts_iterator::sort_accounts(account_t& account, std::stable_sort(deque.begin(), deque.end(), compare_items(sort_cmp)); -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("accounts.sorted")) { foreach (account_t * acct, deque) DEBUG("accounts.sorted", "Account: " << acct->fullname()); diff --git a/src/journal.h b/src/journal.h index 1f9cf3af..5e0fa0e3 100644 --- a/src/journal.h +++ b/src/journal.h @@ -99,7 +99,7 @@ public: TRACE_DTOR(journal_t::fileinfo_t); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -208,7 +208,7 @@ public: private: std::size_t read_textual(parse_context_stack_t& context); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/lookup.cc b/src/lookup.cc index 6f0c33ea..9edc3bbc 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -67,7 +67,7 @@ lookup_probable_account(const string& ident, { scorecard_t scores; -#if !defined(HAVE_BOOST_REGEX_UNICODE) +#if !HAVE_BOOST_REGEX_UNICODE string lident = ident; to_lower(lident); unistring lowered_ident(lident); @@ -78,7 +78,7 @@ lookup_probable_account(const string& ident, DEBUG("lookup.account", "Looking up identifier '" << lowered_ident.extract() << "'"); -#if defined(DEBUG_ON) +#if DEBUG_ON if (ref_account != NULL) DEBUG("lookup.account", " with reference account: " << ref_account->fullname()); @@ -100,7 +100,7 @@ lookup_probable_account(const string& ident, break; } -#if !defined(HAVE_BOOST_REGEX_UNICODE) +#if !HAVE_BOOST_REGEX_UNICODE string payee = xact->payee; to_lower(payee); unistring value_key(payee); @@ -187,7 +187,7 @@ lookup_probable_account(const string& ident, addend++; #if 0 -#if !defined(HAVE_BOOST_REGEX_UNICODE) +#if !HAVE_BOOST_REGEX_UNICODE if (pos == 0 || (pos > 0 && !std::isalnum(value_key[pos - 1]))) addend++; #else @@ -268,7 +268,7 @@ lookup_probable_account(const string& ident, } if (account_usage.size() > 0) { -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("lookup.account")) { foreach (const account_use_pair& value, account_usage) { DEBUG("lookup.account", diff --git a/src/main.cc b/src/main.cc index b309255b..99f7451e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -37,7 +37,7 @@ using namespace ledger; -#ifdef HAVE_BOOST_PYTHON +#if HAVE_BOOST_PYTHON namespace ledger { extern char * argv0; } @@ -47,7 +47,7 @@ int main(int argc, char * argv[], char * envp[]) { int status = 1; -#ifdef HAVE_BOOST_PYTHON +#if HAVE_BOOST_PYTHON argv0 = argv[0]; #endif @@ -60,7 +60,7 @@ int main(int argc, char * argv[], char * envp[]) // --trace LEVEL ; turns on trace logging // --memory ; turns on memory usage tracing handle_debug_options(argc, argv); -#if defined(VERIFY_ON) +#if VERIFY_ON IF_VERIFY() initialize_memory_tracing(); #endif @@ -77,7 +77,7 @@ int main(int argc, char * argv[], char * envp[]) std::signal(SIGPIPE, sigpipe_handler); #endif -#if defined(HAVE_GETTEXT) +#if HAVE_GETTEXT ::textdomain("ledger"); #endif @@ -127,7 +127,7 @@ int main(int argc, char * argv[], char * envp[]) bool exit_loop = false; -#ifdef HAVE_LIBEDIT +#ifdef HAVE_EDIT rl_readline_name = const_cast("Ledger"); #if 0 @@ -152,7 +152,7 @@ int main(int argc, char * argv[], char * envp[]) add_history(expansion); } -#else // HAVE_LIBEDIT +#else // HAVE_EDIT while (! std::cin.eof()) { std::cout << global_scope->prompt_string(); @@ -161,7 +161,7 @@ int main(int argc, char * argv[], char * envp[]) char * p = skip_ws(line); -#endif // HAVE_LIBEDIT +#endif // HAVE_EDIT check_for_signal(); @@ -172,7 +172,7 @@ int main(int argc, char * argv[], char * envp[]) global_scope->execute_command_wrapper(split_arguments(p), true); } -#ifdef HAVE_LIBEDIT +#if HAVE_EDIT if (expansion) std::free(expansion); std::free(p); @@ -202,12 +202,12 @@ int main(int argc, char * argv[], char * envp[]) // up everything by closing the session and deleting the session object, and // then shutting down the memory tracing subsystem. Otherwise, let it all // leak because we're about to exit anyway. -#if defined(VERIFY_ON) +#if VERIFY_ON IF_VERIFY() { checked_delete(global_scope); INFO("Ledger ended (Boost/libstdc++ may still hold memory)"); -#if defined(VERIFY_ON) +#if VERIFY_ON shutdown_memory_tracing(); #endif } else diff --git a/src/mask.cc b/src/mask.cc index afb68ca0..18d482ed 100644 --- a/src/mask.cc +++ b/src/mask.cc @@ -43,7 +43,7 @@ mask_t::mask_t(const string& pat) : expr() mask_t& mask_t::operator=(const string& pat) { -#if defined(HAVE_BOOST_REGEX_UNICODE) +#if HAVE_BOOST_REGEX_UNICODE expr = boost::make_u32regex(pat.c_str(), boost::regex::perl | boost::regex::icase); #else expr.assign(pat.c_str(), boost::regex::perl | boost::regex::icase); diff --git a/src/mask.h b/src/mask.h index 78124d06..06bd0141 100644 --- a/src/mask.h +++ b/src/mask.h @@ -45,7 +45,7 @@ #define _MASK_H #include "utils.h" -#if defined(HAVE_BOOST_REGEX_UNICODE) +#if HAVE_BOOST_REGEX_UNICODE #include "unistring.h" #endif @@ -54,7 +54,7 @@ namespace ledger { class mask_t { public: -#if defined(HAVE_BOOST_REGEX_UNICODE) +#if HAVE_BOOST_REGEX_UNICODE boost::u32regex expr; #else boost::regex expr; @@ -83,7 +83,7 @@ public: } bool match(const string& text) const { -#if defined(HAVE_BOOST_REGEX_UNICODE) +#if HAVE_BOOST_REGEX_UNICODE DEBUG("mask.match", "Matching: \"" << text << "\" =~ /" << str() << "/ = " << (boost::u32regex_search(text, expr) ? "true" : "false")); @@ -102,7 +102,7 @@ public: string str() const { if (! empty()) { -#if defined(HAVE_BOOST_REGEX_UNICODE) +#if HAVE_BOOST_REGEX_UNICODE assert(sizeof(boost::uint32_t) == sizeof(UChar32)); unistring ustr; std::basic_string expr_str = expr.str(); @@ -125,7 +125,7 @@ public: return true; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/op.cc b/src/op.cc index 6ba921e5..87857049 100644 --- a/src/op.cc +++ b/src/op.cc @@ -93,7 +93,7 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope, const int depth, unique_ptr bound_scope; expr_t::ptr_op_t result; -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("expr.compile")) { for (int i = 0; i < depth; i++) ledger::_log_buffer << '.'; @@ -114,12 +114,12 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope, const int depth, // Identifier references are first looked up at the point of // definition, and then at the point of every use if they could // not be found there. -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("expr.compile")) { DEBUG("expr.compile", "Found definition:"); def->dump(*_log_stream, 0); } -#endif // defined(DEBUG_ON) +#endif // DEBUG_ON result = copy(def); } else if (left()) { @@ -219,7 +219,7 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope, const int depth, } } -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("expr.compile")) { for (int i = 0; i < depth; i++) ledger::_log_buffer << '.'; @@ -253,7 +253,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth) value_t result; -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("expr.calc")) { for (int i = 0; i < depth; i++) ledger::_log_buffer << '.'; @@ -415,7 +415,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth) throw_(calc_error, _f("Unexpected expr node '%1%'") % op_context(this)); } -#if defined(DEBUG_ON) +#if DEBUG_ON if (SHOW_DEBUG("expr.calc")) { for (int i = 0; i < depth; i++) ledger::_log_buffer << '.'; diff --git a/src/op.h b/src/op.h index 973ba67f..2a705ca0 100644 --- a/src/op.h +++ b/src/op.h @@ -315,7 +315,7 @@ private: value_t calc_cons(scope_t& scope, ptr_op_t * locus, const int depth); value_t calc_seq(scope_t& scope, ptr_op_t * locus, const int depth); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/option.h b/src/option.h index 80be69c4..642142aa 100644 --- a/src/option.h +++ b/src/option.h @@ -95,7 +95,7 @@ public: if (wants_arg) { out << " = "; out.width(42); - out << value; + out << std::left << value; } else { out.width(45); out << ' '; diff --git a/src/output.cc b/src/output.cc index 742000bd..f433f8d1 100644 --- a/src/output.cc +++ b/src/output.cc @@ -208,7 +208,7 @@ format_accounts::mark_accounts(account_t& account, const bool flat) to_display += i.second; } -#if defined(DEBUG_ON) +#if DEBUG_ON DEBUG("account.display", "Considering account: " << account.fullname()); if (account.has_xflags(ACCOUNT_EXT_VISITED)) DEBUG("account.display", " it was visited itself"); diff --git a/src/parser.h b/src/parser.h index db16a919..9e6a59f4 100644 --- a/src/parser.h +++ b/src/parser.h @@ -65,7 +65,7 @@ class expr_t::parser_t : public noncopyable return lookahead; } -#if !defined(NO_ASSERTS) +#if !NO_ASSERTS void push_token(const token_t& tok) const { assert(&tok == &lookahead); use_lookahead = true; @@ -74,7 +74,7 @@ class expr_t::parser_t : public noncopyable void push_token(const token_t&) const { use_lookahead = true; } -#endif // !defined(NO_ASSERTS) +#endif // !NO_ASSERTS void push_token() const { use_lookahead = true; } diff --git a/src/pool.cc b/src/pool.cc index 61b5bef2..9f1aea9f 100644 --- a/src/pool.cc +++ b/src/pool.cc @@ -69,11 +69,11 @@ commodity_t * commodity_pool_t::create(const string& symbol) DEBUG("pool.commodities", "Creating commodity '" << symbol << "'"); -#if defined(DEBUG_ON) +#if DEBUG_ON std::pair result = #endif commodities.insert(commodities_map::value_type(symbol, commodity)); -#if defined(DEBUG_ON) +#if DEBUG_ON assert(result.second); #endif @@ -206,13 +206,13 @@ commodity_pool_t::create(commodity_t& comm, << "symbol " << commodity->base_symbol() << std::endl << details); -#if defined(DEBUG_ON) +#if DEBUG_ON std::pair result = #endif annotated_commodities.insert(annotated_commodities_map::value_type (annotated_commodities_map::key_type (comm.base_symbol(), details), commodity)); -#if defined(DEBUG_ON) +#if DEBUG_ON assert(result.second); #endif @@ -243,7 +243,7 @@ commodity_pool_t::exchange(const amount_t& amount, { DEBUG("commodity.prices.add", "exchange: " << amount << " for " << cost); DEBUG("commodity.prices.add", "exchange: is-per-unit = " << is_per_unit); -#if defined(DEBUG_ON) +#if DEBUG_ON if (moment) DEBUG("commodity.prices.add", "exchange: moment = " << *moment); if (tag) diff --git a/src/pool.h b/src/pool.h index eb630781..849b7a22 100644 --- a/src/pool.h +++ b/src/pool.h @@ -132,7 +132,7 @@ public: const bool add_prices = true, const optional& moment = none); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/post.h b/src/post.h index efdd63ab..a9a44a79 100644 --- a/src/post.h +++ b/src/post.h @@ -250,7 +250,7 @@ public: } }; -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/predicate.h b/src/predicate.h index 7d58dc2f..c670d6a4 100644 --- a/src/predicate.h +++ b/src/predicate.h @@ -91,7 +91,7 @@ public: true); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/ptree.cc b/src/ptree.cc index db523e99..6fb840e0 100644 --- a/src/ptree.cc +++ b/src/ptree.cc @@ -54,7 +54,10 @@ void format_ptree::flush() property_tree::ptree pt; - pt.put("ledger..version", VERSION); + pt.put("ledger..version", + lexical_cast((Ledger_VERSION_MAJOR << 16) | + (Ledger_VERSION_MINOR << 8) | + Ledger_VERSION_PATCH)); property_tree::ptree& ct(pt.put("ledger.commodities", "")); foreach (const commodities_pair& pair, commodities) @@ -67,11 +70,11 @@ void format_ptree::flush() foreach (const xact_t * xact, transactions) { put_xact(tt, *xact); - property_tree::ptree& post_t(tt.put("postings", "")); + property_tree::ptree& post_tree(tt.put("postings", "")); foreach (const post_t * post, xact->posts) if (post->has_xdata() && post->xdata().has_flags(POST_EXT_VISITED)) - put_post(post_t, *post); + put_post(post_tree, *post); } switch (format) { diff --git a/src/pyinterp.cc b/src/pyinterp.cc index 3c864910..135a088b 100644 --- a/src/pyinterp.cc +++ b/src/pyinterp.cc @@ -166,7 +166,7 @@ void python_interpreter_t::hack_system_paths() python::list paths(sys_dict["path"]); -#if defined(DEBUG_ON) +#if DEBUG_ON bool path_initialized = false; #endif int n = python::extract(paths.attr("__len__")()); @@ -189,13 +189,13 @@ void python_interpreter_t::hack_system_paths() throw_(std::runtime_error, _("Python failed to initialize (couldn't find ledger)")); } -#if defined(DEBUG_ON) +#if DEBUG_ON path_initialized = true; #endif break; } } -#if defined(DEBUG_ON) +#if DEBUG_ON if (! path_initialized) DEBUG("python.init", "Ledger failed to find 'ledger/__init__.py' on the PYTHONPATH"); diff --git a/src/pyinterp.h b/src/pyinterp.h index 556b1563..56f808c8 100644 --- a/src/pyinterp.h +++ b/src/pyinterp.h @@ -34,7 +34,7 @@ #include "session.h" -#if defined(HAVE_BOOST_PYTHON) +#if HAVE_BOOST_PYTHON namespace ledger { diff --git a/src/pyutils.h b/src/pyutils.h index 2c7dfaeb..a34eee00 100644 --- a/src/pyutils.h +++ b/src/pyutils.h @@ -180,7 +180,7 @@ namespace boost { namespace python { BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(T,expr, pytype) \ BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(T,expr) -#if !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) +#if !HAVE_CXX11 && (VERIFY_ON || HAVE_BOOST_PYTHON) BOOST_PYTHON_TO_PYTHON_BY_VALUE(ledger::string, ::PyUnicode_FromEncodedObject(::PyString_FromString(x.c_str()), "UTF-8", NULL), &PyUnicode_Type) #endif diff --git a/src/quotes.cc b/src/quotes.cc index c33e0826..e92af236 100644 --- a/src/quotes.cc +++ b/src/quotes.cc @@ -43,7 +43,7 @@ commodity_quote_from_script(commodity_t& commodity, const commodity_t * exchange_commodity) { DEBUG("commodity.download", "downloading quote for symbol " << commodity.symbol()); -#if defined(DEBUG_ON) +#if DEBUG_ON if (exchange_commodity) DEBUG("commodity.download", " in terms of commodity " << exchange_commodity->symbol()); diff --git a/src/report.cc b/src/report.cc index d6e6f150..662386a4 100644 --- a/src/report.cc +++ b/src/report.cc @@ -57,7 +57,7 @@ void report_t::normalize_options(const string& verb) // Patch up some of the reporting options based on what kind of // command it was. -#ifdef HAVE_ISATTY +#if HAVE_ISATTY if (! HANDLED(force_color)) { if (! HANDLED(no_color) && isatty(STDOUT_FILENO)) HANDLER(color).on("?normalize"); @@ -480,7 +480,7 @@ void report_t::commodities_report(post_handler_ptr handler) pass_down_posts(handler, *walker); } catch (...) { -#if defined(VERIFY_ON) +#if VERIFY_ON IF_VERIFY() { // If --verify was used, clean up the posts_commodities_iterator. // Otherwise, just leak like a sieve. diff --git a/src/report.h b/src/report.h index 085cfa48..0f4fc103 100644 --- a/src/report.h +++ b/src/report.h @@ -659,7 +659,7 @@ public: OPTION(report_t, equity); OPTION(report_t, exact); - OPTION_(report_t, exchange_, DO_() { // -X + OPTION_(report_t, exchange_, DO_(str) { // -X // Using -X implies -V. The main difference is that now // HANDLER(exchange_) contains the name of a commodity, which // is accessed via the "exchange" value expression function. @@ -784,7 +784,7 @@ public: OPTION(report_t, output_); // -o -#ifdef HAVE_ISATTY +#if HAVE_ISATTY OPTION__ (report_t, pager_, CTOR(report_t, pager_) { diff --git a/src/scope.h b/src/scope.h index c43d73d6..4190f5bb 100644 --- a/src/scope.h +++ b/src/scope.h @@ -84,7 +84,7 @@ struct symbol_t return kind == sym.kind || name == sym.name; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -128,7 +128,7 @@ public: return false; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -185,7 +185,7 @@ public: return NULL; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -234,7 +234,7 @@ public: return child_scope_t::lookup(kind, name); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -311,7 +311,7 @@ public: virtual string description() { if (parent) return parent->description(); -#if !defined(NO_ASSERTS) +#if !NO_ASSERTS else assert(false); #endif @@ -324,7 +324,7 @@ public: virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, const string& name); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -366,7 +366,7 @@ public: return required; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION protected: explicit context_scope_t() { TRACE_CTOR(context_scope_t, ""); @@ -481,7 +481,7 @@ public: return args.size() == 0; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION protected: explicit call_scope_t() : depth(0) { TRACE_CTOR(call_scope_t, ""); diff --git a/src/select.cc b/src/select.cc index 20a78701..afcfb351 100644 --- a/src/select.cc +++ b/src/select.cc @@ -178,12 +178,8 @@ value_t select_command(call_scope_t& args) lexical_cast(report.HANDLER(meta_width_).str()) : 10); - bool saw_date = false; bool saw_payee = false; bool saw_account = false; - bool saw_amount = false; - bool saw_total = false; - bool saw_meta = false; std::size_t cols_needed = 0; foreach (const value_t& column, columns.to_sequence()) { @@ -191,7 +187,6 @@ value_t select_command(call_scope_t& args) if (get_principal_identifiers(as_expr(column), ident)) { if (ident == "date" || ident == "aux_date") { cols_needed += date_width + 1; - saw_date = true; } else if (ident == "payee") { cols_needed += payee_width + 1; @@ -203,15 +198,12 @@ value_t select_command(call_scope_t& args) } else if (ident == "amount") { cols_needed += amount_width + 1; - saw_amount = true; } else if (ident == "total") { cols_needed += total_width + 1; - saw_total = true; } else { cols_needed += meta_width + 1; - saw_meta = true; } } } diff --git a/src/session.cc b/src/session.cc index 9a77d341..b6153203 100644 --- a/src/session.cc +++ b/src/session.cc @@ -117,7 +117,7 @@ std::size_t session_t::read_data(const string& master_account) else if (HANDLED(value_expr_)) journal->value_expr = HANDLER(value_expr_).str(); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION optional cache; if (HANDLED(cache_) && master_account.empty()) cache = archive_t(HANDLED(cache_).str()); @@ -179,7 +179,7 @@ std::size_t session_t::read_data(const string& master_account) << "] == journal->xacts.size() [" << journal->xacts.size() << "]"); assert(xact_count == journal->xacts.size()); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION if (cache && cache->should_save(*journal.get())) cache->save(*journal.get()); } @@ -201,14 +201,14 @@ journal_t * session_t::read_journal_files() if (HANDLED(master_account_)) master_account = HANDLER(master_account_).str(); -#if defined(DEBUG_ON) +#if DEBUG_ON std::size_t count = #endif read_data(master_account); INFO_FINISH(journal); -#if defined(DEBUG_ON) +#if DEBUG_ON INFO("Found " << count << " transactions"); #endif diff --git a/src/system.hh.in b/src/system.hh.in index fd019ba7..e81dfc00 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -41,7 +41,48 @@ * None of these header files (with the exception of acconf.h, when * configure is re-run) are expected to change. */ -#include "config.h" + +#ifndef _SYSTEM_HH +#define _SYSTEM_HH + +//#warning("Loading system.hh. This should occur only once!") + +/*------------------------------------------------------------------------*/ +/* Application configuration */ +/*------------------------------------------------------------------------*/ + +#define Ledger_VERSION_MAJOR @Ledger_VERSION_MAJOR@ +#define Ledger_VERSION_MINOR @Ledger_VERSION_MINOR@ +#define Ledger_VERSION_PATCH @Ledger_VERSION_PATCH@ +#define Ledger_VERSION_DATE @Ledger_VERSION_DATE@ + +#define HAVE_CXX11 @HAVE_CXX11@ + +#define HAVE_LANGINFO_H @HAVE_LANGINFO_H@ +#define HAVE_EDIT @HAVE_EDIT@ +#define HAVE_GETTEXT @HAVE_GETTEXT@ + +#define HAVE_ACCESS @HAVE_ACCESS@ +#define HAVE_REALPATH @HAVE_REALPATH@ +#define HAVE_GETPWUID @HAVE_GETPWUID@ +#define HAVE_GETPWNAM @HAVE_GETPWNAM@ +#define HAVE_ISATTY @HAVE_ISATTY@ + +#define HAVE_UNIX_PIPES @HAVE_UNIX_PIPES@ + +#define HAVE_BOOST_PYTHON @HAVE_BOOST_PYTHON@ +#define HAVE_BOOST_REGEX_UNICODE @HAVE_BOOST_REGEX_UNICODE@ +#define HAVE_BOOST_SERIALIZATION 0 + +#define DEBUG_MODE @DEBUG_MODE@ +#define NDEBUG @NDEBUG@ + +#define DOCUMENT_MODEL 0 +#define REDUCE_TO_INTEGER 0 + +/*------------------------------------------------------------------------*/ +/* System includes */ +/*------------------------------------------------------------------------*/ #if defined(__GNUG__) && __GNUG__ < 3 #define _XOPEN_SOURCE @@ -109,11 +150,11 @@ typedef std::ostream::pos_type ostream_pos_type; #else #include #endif -#if defined(HAVE_GETPWUID) || defined(HAVE_GETPWNAM) +#if HAVE_GETPWUID || HAVE_GETPWNAM #include #endif -#if defined(HAVE_UNIX_PIPES) +#if HAVE_UNIX_PIPES #include #include #endif @@ -123,7 +164,7 @@ typedef std::ostream::pos_type ostream_pos_type; #include "sha1.h" #include "utf8.h" -#if defined(HAVE_LIBEDIT) +#if HAVE_EDIT #include #endif @@ -147,7 +188,6 @@ typedef std::ostream::pos_type ostream_pos_type; #include #endif -#include #include #include @@ -155,6 +195,7 @@ typedef std::ostream::pos_type ostream_pos_type; #include #include +#include #include #include @@ -179,7 +220,7 @@ typedef std::ostream::pos_type ostream_pos_type; #include #include -#if defined(HAVE_BOOST_REGEX_UNICODE) +#if HAVE_BOOST_REGEX_UNICODE #include #else #include @@ -193,8 +234,8 @@ typedef std::ostream::pos_type ostream_pos_type; #include #include -#if defined(HAVE_GETTEXT) -#include "gettext.h" +#if HAVE_GETTEXT +#include #define _(str) gettext(str) #define _f(str) boost::format(gettext(str)) #else @@ -202,7 +243,7 @@ typedef std::ostream::pos_type ostream_pos_type; #define _f(str) boost::format(str) #endif -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION #include #include @@ -282,7 +323,7 @@ void serialize(Archive& ar, istream_pos_type& pos, const unsigned int) #endif // HAVE_BOOST_SERIALIZATION -#if defined(HAVE_BOOST_PYTHON) +#if HAVE_BOOST_PYTHON #include @@ -296,3 +337,5 @@ void serialize(Archive& ar, istream_pos_type& pos, const unsigned int) #include #endif // HAVE_BOOST_PYTHON + +#endif // _SYSTEM_HH diff --git a/src/textual.cc b/src/textual.cc index 1665d4dd..a5ae2f68 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -40,7 +40,7 @@ #include "query.h" #include "pstream.h" #include "pool.h" -#if defined(HAVE_BOOST_PYTHON) +#if HAVE_BOOST_PYTHON #include "pyinterp.h" #endif @@ -126,7 +126,7 @@ namespace { return (in.good() && ! in.eof() && (in.peek() == ' ' || in.peek() == '\t')); } -#if defined(HAVE_BOOST_PYTHON) +#if HAVE_BOOST_PYTHON bool peek_blank_line() { return (in.good() && ! in.eof() && (in.peek() == '\n' || in.peek() == '\r')); @@ -221,15 +221,6 @@ namespace { DEBUG("textual.parse", "Parsed an amount expression"); -#if defined(DEBUG_ENABLED) - DEBUG_IF("textual.parse") { - if (_debug_stream) { - ledger::dump_value_expr(*_debug_stream, expr); - *_debug_stream << std::endl; - } - } -#endif - if (expr) { if (amount_expr) *amount_expr = expr; @@ -835,7 +826,7 @@ void instance_t::apply_account_directive(char * line) { if (account_t * acct = top_account()->find_account(line)) apply_stack.push_front(application_t("account", acct)); -#if !defined(NO_ASSERTS) +#if !NO_ASSERTS else assert("Failed to create account" == NULL); #endif @@ -1168,7 +1159,7 @@ void instance_t::comment_directive(char * line) } } -#if defined(HAVE_BOOST_PYTHON) +#if HAVE_BOOST_PYTHON void instance_t::import_directive(char * line) { diff --git a/src/times.cc b/src/times.cc index 6bf2af82..167aac73 100644 --- a/src/times.cc +++ b/src/times.cc @@ -122,7 +122,7 @@ namespace { datetime_t when; input_stream >> when; -#if defined(DEBUG_ON) +#if DEBUG_ON if (when.is_not_a_date_time()) DEBUG("times.parse", "Failed to parse date/time '" << str << "' using pattern '" << fmt_str << "'"); @@ -157,7 +157,7 @@ namespace { date_t when; input_stream >> when; -#if defined(DEBUG_ON) +#if DEBUG_ON if (when.is_not_a_date()) DEBUG("times.parse", "Failed to parse date '" << str << "' using pattern '" << fmt_str << "'"); @@ -346,7 +346,7 @@ date_t date_specifier_t::begin() const month_type the_month = month ? *month : date_t::month_type(1); day_type the_day = day ? *day : date_t::day_type(1); -#if !defined(NO_ASSERTS) +#if !NO_ASSERTS if (day) assert(! wday); else if (wday) @@ -1259,7 +1259,7 @@ date_t date_duration_t::find_nearest(const date_t& date, skip_quantum_t skip) void date_interval_t::stabilize(const optional& date) { -#if defined(DEBUG_ON) +#if DEBUG_ON if (date) DEBUG("times.interval", "stabilize: with date = " << *date); #endif @@ -1280,7 +1280,7 @@ void date_interval_t::stabilize(const optional& date) optional initial_start = start ? start : begin(); optional initial_finish = finish ? finish : end(); -#if defined(DEBUG_ON) +#if DEBUG_ON if (initial_start) DEBUG("times.interval", "stabilize: initial_start = " << *initial_start); @@ -1333,7 +1333,7 @@ void date_interval_t::stabilize(const optional& date) DEBUG("times.interval", "stabilize: finish reset to initial finish"); } -#if defined(DEBUG_ON) +#if DEBUG_ON if (start) DEBUG("times.interval", "stabilize: final start = " << *start); if (finish) @@ -1403,7 +1403,7 @@ bool date_interval_t::find_period(const date_t& date, DEBUG("times.interval", "date = " << date); DEBUG("times.interval", "scan = " << scan); DEBUG("times.interval", "end_of_scan = " << end_of_scan); -#if defined(DEBUG_ON) +#if DEBUG_ON if (finish) DEBUG("times.interval", "finish = " << *finish); else diff --git a/src/times.h b/src/times.h index d6ab542d..9a0f21ff 100644 --- a/src/times.h +++ b/src/times.h @@ -162,7 +162,7 @@ struct date_traits_t has_day == traits.has_day); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -256,7 +256,7 @@ struct date_duration_t static date_t find_nearest(const date_t& date, skip_quantum_t skip); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -352,7 +352,7 @@ public: return out.str(); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -429,7 +429,7 @@ public: return out.str(); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -499,7 +499,7 @@ public: return out.str(); } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -599,7 +599,7 @@ public: void dump(std::ostream& out); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/utils.cc b/src/utils.cc index d8cba61e..d32eef5a 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -38,7 +38,7 @@ * Assertions */ -#if defined(ASSERTS_ON) +#if ASSERTS_ON namespace ledger { @@ -64,7 +64,7 @@ void debug_assert(const string& reason, * Verification (basically, very slow asserts) */ -#if defined(VERIFY_ON) +#if VERIFY_ON namespace ledger { @@ -489,7 +489,7 @@ void report_memory(std::ostream& out, bool report_all) namespace ledger { -#if !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) +#if !HAVE_CXX11 && (VERIFY_ON || HAVE_BOOST_PYTHON) string::string() : std::string() { TRACE_CTOR(string, ""); @@ -527,7 +527,7 @@ string::~string() throw() { TRACE_DTOR(string); } -#endif // !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) +#endif // !HAVE_CXX11 && (VERIFY_ON || HAVE_BOOST_PYTHON) string empty_string(""); @@ -589,7 +589,7 @@ strings_list split_arguments(const char * line) * Logging */ -#if defined(LOGGING_ON) +#if LOGGING_ON namespace ledger { @@ -597,7 +597,7 @@ log_level_t _log_level = LOG_WARN; std::ostream * _log_stream = &std::cerr; std::ostringstream _log_buffer; -#if defined(TRACING_ON) +#if TRACING_ON uint8_t _trace_level; #endif @@ -610,7 +610,7 @@ void logger_func(log_level_t level) logger_has_run = true; logger_start = TRUE_CURRENT_TIME(); -#if defined(VERIFY_ON) +#if VERIFY_ON IF_VERIFY() *_log_stream << " TIME OBJSZ MEMSZ" << std::endl; #endif @@ -620,7 +620,7 @@ void logger_func(log_level_t level) << (TRUE_CURRENT_TIME() - logger_start).total_milliseconds() << "ms"; -#if defined(VERIFY_ON) +#if VERIFY_ON IF_VERIFY() { *_log_stream << std::right << std::setw(6) << std::setprecision(3); stream_memory_size(*_log_stream, current_objects_size()); @@ -656,12 +656,12 @@ void logger_func(log_level_t level) } // namespace ledger -#if defined(DEBUG_ON) +#if DEBUG_ON namespace ledger { optional _log_category; -#if defined(HAVE_BOOST_REGEX_UNICODE) +#if HAVE_BOOST_REGEX_UNICODE optional _log_category_re; #else optional _log_category_re; @@ -686,7 +686,7 @@ struct __maybe_enable_debugging { * Timers (allows log xacts to specify cumulative time spent) */ -#if defined(LOGGING_ON) && defined(TIMERS_ON) +#if LOGGING_ON && defined(TIMERS_ON) namespace ledger { @@ -710,7 +710,7 @@ static timer_map timers; void start_timer(const char * name, log_level_t lvl) { -#if defined(VERIFY_ON) +#if VERIFY_ON bool tracing_active = memory_tracing_active; memory_tracing_active = false; #endif @@ -726,14 +726,14 @@ void start_timer(const char * name, log_level_t lvl) _log_buffer.clear(); _log_buffer.str(""); -#if defined(VERIFY_ON) +#if VERIFY_ON memory_tracing_active = tracing_active; #endif } void stop_timer(const char * name) { -#if defined(VERIFY_ON) +#if VERIFY_ON bool tracing_active = memory_tracing_active; memory_tracing_active = false; #endif @@ -744,21 +744,21 @@ void stop_timer(const char * name) (*i).second.spent += TRUE_CURRENT_TIME() - (*i).second.begin; (*i).second.active = false; -#if defined(VERIFY_ON) +#if VERIFY_ON memory_tracing_active = tracing_active; #endif } void finish_timer(const char * name) { -#if defined(VERIFY_ON) +#if VERIFY_ON bool tracing_active = memory_tracing_active; memory_tracing_active = false; #endif timer_map::iterator i = timers.find(name); if (i == timers.end()) { -#if defined(VERIFY_ON) +#if VERIFY_ON memory_tracing_active = tracing_active; #endif return; @@ -787,7 +787,7 @@ void finish_timer(const char * name) timers.erase(i); -#if defined(VERIFY_ON) +#if VERIFY_ON memory_tracing_active = tracing_active; #endif } @@ -820,8 +820,6 @@ void sigpipe_handler(int) namespace ledger { -const string version = PACKAGE_VERSION; - path expand_path(const path& pathname) { if (pathname.empty()) @@ -833,7 +831,7 @@ path expand_path(const path& pathname) if (path_string.length() == 1 || pos == 1) { pfx = std::getenv("HOME"); -#ifdef HAVE_GETPWUID +#if HAVE_GETPWUID if (! pfx) { // Punt. We're trying to expand ~/, but HOME isn't set struct passwd * pw = getpwuid(getuid()); @@ -842,7 +840,7 @@ path expand_path(const path& pathname) } #endif } -#ifdef HAVE_GETPWNAM +#if HAVE_GETPWNAM else { string user(path_string, 1, pos == string::npos ? string::npos : pos - 1); diff --git a/src/utils.h b/src/utils.h index 7f5242d9..cbcfb131 100644 --- a/src/utils.h +++ b/src/utils.h @@ -51,15 +51,23 @@ #define TIMERS_ON 1 -#if defined(DEBUG_MODE) +#if DEBUG_MODE +#define NO_ASSERTS 0 #define VERIFY_ON 1 #define TRACING_ON 1 #define DEBUG_ON 1 -#elif defined(NDEBUG) +#elif NDEBUG #define NO_ASSERTS 1 //#define NO_LOGGING 1 +#define VERIFY_ON 0 +#define TRACING_ON 0 +#define DEBUG_ON 0 #else +#define NO_ASSERTS 0 #define TRACING_ON 1 // use --trace X to enable +#define VERIFY_ON 0 +#define TRACING_ON 0 +#define DEBUG_ON 0 #endif /*@}*/ @@ -72,7 +80,7 @@ namespace ledger { using namespace boost; -#if !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) +#if !HAVE_CXX11 && (VERIFY_ON || HAVE_BOOST_PYTHON) class string; #else typedef std::string string; @@ -93,11 +101,11 @@ namespace ledger { } #if BOOST_FILESYSTEM_VERSION == 3 -#if !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) +#if !HAVE_CXX11 && (VERIFY_ON || HAVE_BOOST_PYTHON) namespace boost { namespace filesystem3 { namespace path_traits { template<> struct is_pathable { static const bool value = true; }; }}} -#endif // defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON) +#endif // VERIFY_ON || HAVE_BOOST_PYTHON #endif // BOOST_FILESYSTEM_VERSION == 3 /*@}*/ @@ -111,10 +119,10 @@ template<> struct is_pathable { static const bool value = true; #undef assert #endif -#if ! defined(NO_ASSERTS) +#if ! NO_ASSERTS #define ASSERTS_ON 1 #endif -#if defined(ASSERTS_ON) +#if ASSERTS_ON namespace ledger { void debug_assert(const string& reason, const string& func, @@ -138,7 +146,7 @@ namespace ledger { */ /*@{*/ -#if defined(VERIFY_ON) +#if VERIFY_ON namespace ledger { @@ -193,7 +201,7 @@ void report_memory(std::ostream& out, bool report_all = false); namespace ledger { -#if !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) +#if !HAVE_CXX11 && (VERIFY_ON || HAVE_BOOST_PYTHON) class string : public std::string { @@ -215,7 +223,7 @@ public: string(const char * str, size_type x, size_type y); ~string() throw(); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -272,7 +280,7 @@ inline bool operator!=(const char* __lhs, const string& __rhs) inline bool operator!=(const string& __lhs, const char* __rhs) { return __lhs.compare(__rhs) != 0; } -#endif // !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) +#endif // !HAVE_CXX11 && (VERIFY_ON || HAVE_BOOST_PYTHON) extern string empty_string; @@ -312,7 +320,7 @@ inline string operator+(const char * left, const string& right) { #if ! defined(NO_LOGGING) #define LOGGING_ON 1 #endif -#if defined(LOGGING_ON) +#if LOGGING_ON namespace ledger { @@ -340,7 +348,7 @@ void logger_func(log_level_t level); #define LOGGER(cat) \ static const char * const _this_category = cat -#if defined(TRACING_ON) +#if TRACING_ON extern uint8_t _trace_level; @@ -358,10 +366,10 @@ extern uint8_t _trace_level; #endif // TRACING_ON -#if defined(DEBUG_ON) +#if DEBUG_ON extern optional _log_category; -#if defined(HAVE_BOOST_REGEX_UNICODE) +#if HAVE_BOOST_REGEX_UNICODE extern optional _log_category_re; #else extern optional _log_category_re; @@ -371,7 +379,7 @@ inline bool category_matches(const char * cat) { if (_log_category) { if (! _log_category_re) { _log_category_re = -#if defined(HAVE_BOOST_REGEX_UNICODE) +#if HAVE_BOOST_REGEX_UNICODE boost::make_u32regex(_log_category->c_str(), boost::regex::perl | boost::regex::icase); #else @@ -379,7 +387,7 @@ inline bool category_matches(const char * cat) { boost::regex::perl | boost::regex::icase); #endif } -#if defined(HAVE_BOOST_REGEX_UNICODE) +#if HAVE_BOOST_REGEX_UNICODE return boost::u32regex_search(cat, *_log_category_re); #else return boost::regex_search(cat, *_log_category_re); @@ -467,7 +475,7 @@ inline bool category_matches(const char * cat) { */ /*@{*/ -#if defined(LOGGING_ON) && defined(TIMERS_ON) +#if LOGGING_ON && TIMERS_ON namespace ledger { @@ -475,7 +483,7 @@ void start_timer(const char * name, log_level_t lvl); void stop_timer(const char * name); void finish_timer(const char * name); -#if defined(TRACING_ON) +#if TRACING_ON #define TRACE_START(name, lvl, msg) \ (SHOW_TRACE(lvl) ? \ ((ledger::_log_buffer << msg), \ @@ -490,7 +498,7 @@ void finish_timer(const char * name); #define TRACE_FINISH(name, lvl) #endif -#if defined(DEBUG_ON) +#if DEBUG_ON #define DEBUG_START(name, cat, msg) \ (SHOW_DEBUG(cat) ? \ ((ledger::_log_buffer << msg), \ @@ -575,11 +583,10 @@ inline void check_for_signal() { */ /*@{*/ -#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__ -#define foreach(x, y) for (x : y) -#define unique_ptr std::unique_ptr -#else #define foreach BOOST_FOREACH +#if HAVE_CXX11 +using std::unique_ptr; +#else #define unique_ptr std::auto_ptr #endif @@ -592,7 +599,7 @@ inline T& downcast(U& object) { path resolve_path(const path& pathname); -#ifdef HAVE_REALPATH +#if HAVE_REALPATH extern "C" char * realpath(const char *, char resolved_path[]); #endif diff --git a/src/value.cc b/src/value.cc index 832460ce..1921d5a3 100644 --- a/src/value.cc +++ b/src/value.cc @@ -256,7 +256,7 @@ value_t::sequence_t value_t::to_sequence() const void value_t::in_place_simplify() { -#if defined(DEBUG_ON) +#if DEBUG_ON LOGGER("value.simplify"); #endif @@ -273,7 +273,7 @@ void value_t::in_place_simplify() DEBUG_("as an amount it looks like: " << *this); } -#ifdef REDUCE_TO_INTEGER // this is off by default +#if REDUCE_TO_INTEGER // this is off by default if (is_amount() && ! as_amount().has_commodity() && as_amount().fits_in_long()) { DEBUG_("Reducing amount to integer"); diff --git a/src/value.h b/src/value.h index 74c015ec..ee3d414d 100644 --- a/src/value.h +++ b/src/value.h @@ -228,7 +228,7 @@ public: type = VOID; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -952,7 +952,7 @@ public: */ bool valid() const; -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ diff --git a/src/views.cc b/src/views.cc index bbd58ce2..76d06370 100644 --- a/src/views.cc +++ b/src/views.cc @@ -29,7 +29,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef DOCUMENT_MODEL +#if DOCUMENT_MODEL #include diff --git a/src/views.h b/src/views.h index 22bc1dd5..7f769250 100644 --- a/src/views.h +++ b/src/views.h @@ -44,7 +44,7 @@ #include "utils.h" -#ifdef DOCUMENT_MODEL +#if DOCUMENT_MODEL #include "scope.h" #include "item.h" diff --git a/src/xact.cc b/src/xact.cc index 0e7e7e00..b5cb2a38 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -65,7 +65,7 @@ xact_base_t::~xact_base_t() void xact_base_t::add_post(post_t * post) { -#if !defined(NO_ASSERTS) +#if !NO_ASSERTS // You can add temporary postings to transactions, but not real postings to // temporary transactions. if (! post->has_flags(ITEM_TEMP)) @@ -197,7 +197,7 @@ bool xact_base_t::finalize() } VERIFY(balance.valid()); -#if defined(DEBUG_ON) +#if DEBUG_ON DEBUG("xact.finalize", "initial balance = " << balance); DEBUG("xact.finalize", "balance is " << balance.label()); if (balance.is_balance()) @@ -488,7 +488,7 @@ bool xact_base_t::verify() xact_t::xact_t(const xact_t& e) : xact_base_t(e), code(e.code), payee(e.payee) -#ifdef DOCUMENT_MODEL +#if DOCUMENT_MODEL , data(NULL) #endif { @@ -739,7 +739,7 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) else amt = post_amount; -#if defined(DEBUG_ON) +#if DEBUG_ON IF_DEBUG("xact.extend") { DEBUG("xact.extend", "Initial post on line " << initial_post->pos->beg_line << ": " @@ -760,7 +760,7 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context) if (amt.keep_precision()) DEBUG("xact.extend", " amt precision is kept"); } -#endif // defined(DEBUG_ON) +#endif // DEBUG_ON account_t * account = post->account; string fullname = account->fullname(); diff --git a/src/xact.h b/src/xact.h index 52e434e0..c5ad3ad6 100644 --- a/src/xact.h +++ b/src/xact.h @@ -88,7 +88,7 @@ public: return true; } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -109,12 +109,12 @@ public: optional code; string payee; -#ifdef DOCUMENT_MODEL +#if DOCUMENT_MODEL mutable void * data; #endif xact_t() -#ifdef DOCUMENT_MODEL +#if DOCUMENT_MODEL : data(NULL) #endif { @@ -143,7 +143,7 @@ public: virtual bool valid() const; -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -177,7 +177,7 @@ public: : tag_data(_tag_data), overwrite_existing(_overwrite_existing), apply_to_post(NULL) {} -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ deferred_tag_data_t() : apply_to_post(NULL) {} @@ -237,7 +237,7 @@ private: virtual void extend_xact(xact_base_t& xact, parse_context_t& context); -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ @@ -285,7 +285,7 @@ class period_xact_t : public xact_base_t } } -#if defined(HAVE_BOOST_SERIALIZATION) +#if HAVE_BOOST_SERIALIZATION private: /** Serialization. */ -- cgit v1.2.3