summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-04 06:02:00 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-04 06:02:00 -0400
commitb848ace76866188701a6a704a9531c4eeb2bc71a (patch)
tree6fdb3e1cf8a8239c89c03907447a08402bef391b /src
parentf16a5382ed9a9750c69595e5752f80e39cf7a4b8 (diff)
downloadfork-ledger-b848ace76866188701a6a704a9531c4eeb2bc71a.tar.gz
fork-ledger-b848ace76866188701a6a704a9531c4eeb2bc71a.tar.bz2
fork-ledger-b848ace76866188701a6a704a9531c4eeb2bc71a.zip
Allow opt -NDEBUG build to complete without warnings
Diffstat (limited to 'src')
-rw-r--r--src/amount.cc4
-rw-r--r--src/exprbase.h4
-rw-r--r--src/filters.cc2
-rw-r--r--src/global.cc2
-rw-r--r--src/op.cc2
-rw-r--r--src/parser.h6
-rw-r--r--src/py_utils.cc2
-rw-r--r--src/textual.cc10
-rw-r--r--src/times.cc2
-rw-r--r--src/utils.h8
-rw-r--r--src/xact.cc2
11 files changed, 40 insertions, 4 deletions
diff --git a/src/amount.cc b/src/amount.cc
index 2837178c..7eb94442 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -240,14 +240,18 @@ 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)
else
assert(false);
+#endif
// 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)
else
assert(false);
+#endif
is_initialized = true;
}
diff --git a/src/exprbase.h b/src/exprbase.h
index 0dbf3bff..cf81a0a7 100644
--- a/src/exprbase.h
+++ b/src/exprbase.h
@@ -155,17 +155,21 @@ public:
result_type calc(scope_t& scope)
{
if (! compiled) {
+#if defined(DEBUG_ON)
if (SHOW_DEBUG("expr.compile")) {
DEBUG("expr.compile", "Before compilation:");
dump(*_log_stream);
}
+#endif // defined(DEBUG_ON)
compile(scope);
+#if defined(DEBUG_ON)
if (SHOW_DEBUG("expr.compile")) {
DEBUG("expr.compile", "After compilation:");
dump(*_log_stream);
}
+#endif // defined(DEBUG_ON)
}
return real_calc(scope);
diff --git a/src/filters.cc b/src/filters.cc
index 70a46e8e..b5f9983a 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -1166,8 +1166,10 @@ void forecast_posts::flush()
}
date_t& begin = *(*least).first.start;
+#if !defined(NO_ASSERTS)
if ((*least).first.finish)
assert(begin < *(*least).first.finish);
+#endif
// If the next date in the series for this periodic posting is more than 5
// years beyond the last valid post we generated, drop it from further
diff --git a/src/global.cc b/src/global.cc
index 170509b0..35651ddb 100644
--- a/src/global.cc
+++ b/src/global.cc
@@ -391,11 +391,13 @@ global_scope_t::read_command_arguments(scope_t& scope, strings_list args)
void global_scope_t::normalize_session_options()
{
+#if defined(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)
}
expr_t::func_t global_scope_t::look_for_precommand(scope_t& scope,
diff --git a/src/op.cc b/src/op.cc
index df222802..ca720535 100644
--- a/src/op.cc
+++ b/src/op.cc
@@ -78,10 +78,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 (SHOW_DEBUG("expr.compile")) {
DEBUG("expr.compile", "Found definition:");
def->dump(*_log_stream, 0);
}
+#endif // defined(DEBUG_ON)
return copy(def);
}
else if (left()) {
diff --git a/src/parser.h b/src/parser.h
index aab48830..2693fc79 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -61,10 +61,16 @@ class expr_t::parser_t : public noncopyable
return lookahead;
}
+#if !defined(NO_ASSERTS)
void push_token(const token_t& tok) const {
assert(&tok == &lookahead);
use_lookahead = true;
}
+#else
+ void push_token(const token_t&) const {
+ use_lookahead = true;
+ }
+#endif // !defined(NO_ASSERTS)
void push_token() const {
use_lookahead = true;
}
diff --git a/src/py_utils.cc b/src/py_utils.cc
index 4b364e5d..952416cc 100644
--- a/src/py_utils.cc
+++ b/src/py_utils.cc
@@ -115,8 +115,10 @@ struct string_from_python
utf8::unchecked::utf16to8(value, value + size, std::back_inserter(str));
else if (sizeof(Py_UNICODE) == 4) // UTF-32
utf8::unchecked::utf32to8(value, value + size, std::back_inserter(str));
+#if !defined(NO_ASSERTS)
else
assert(! "Py_UNICODE has an unexpected size");
+#endif
if (value == 0) throw_error_already_set();
void* storage =
diff --git a/src/textual.cc b/src/textual.cc
index 9a49edd4..85b1a14b 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -695,8 +695,10 @@ void instance_t::master_account_directive(char * line)
{
if (account_t * acct = context.top_account()->find_account(line))
context.state_stack.push_front(acct);
+#if !defined(NO_ASSERTS)
else
assert(! "Failed to create account");
+#endif
}
void instance_t::end_directive(char * kind)
@@ -763,8 +765,12 @@ void instance_t::payee_mapping_directive(char * line)
(payee_mapping_t(mask_t(regex), payee));
while (peek_whitespace_line()) {
+#if defined(NO_ASSERTS)
+ read_line(line);
+#else
std::streamsize len = read_line(line);
assert(len > 0);
+#endif
regex = skip_ws(line);
if (! *regex)
@@ -786,8 +792,12 @@ void instance_t::account_mapping_directive(char * line)
context.top_account()->find_account(account_name)));
while (peek_whitespace_line()) {
+#if defined(NO_ASSERTS)
+ read_line(line);
+#else
std::streamsize len = read_line(line);
assert(len > 0);
+#endif
payee_regex = skip_ws(line);
if (! *payee_regex)
diff --git a/src/times.cc b/src/times.cc
index a7906aee..60e8e7cc 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -333,10 +333,12 @@ date_t date_specifier_t::begin(const optional_year& current_year) 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 (day)
assert(! wday);
else if (wday)
assert(! day);
+#endif
// jww (2009-11-16): Handle wday. If a month is set, find the most recent
// wday in that month; if the year is set, then in that year.
diff --git a/src/utils.h b/src/utils.h
index a0c3f49f..24f424b7 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -434,8 +434,8 @@ void finish_timer(const char * name);
(SHOW_TRACE(lvl) ? ledger::finish_timer(#name) : ((void)0))
#else
#define TRACE_START(name, lvl, msg)
-#define TRACE_STOP(name)
-#define TRACE_FINISH(name)
+#define TRACE_STOP(name, lvl)
+#define TRACE_FINISH(name, lvl)
#endif
#if defined(DEBUG_ON)
@@ -474,8 +474,8 @@ void finish_timer(const char * name);
#else // ! (LOGGING_ON && TIMERS_ON)
#define TRACE_START(lvl, msg, name)
-#define TRACE_STOP(name)
-#define TRACE_FINISH(name)
+#define TRACE_STOP(name, lvl)
+#define TRACE_FINISH(name, lvl)
#define DEBUG_START(name, msg)
#define DEBUG_START_(name, cat, msg)
diff --git a/src/xact.cc b/src/xact.cc
index 569e5869..6c10ac04 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -62,10 +62,12 @@ xact_base_t::~xact_base_t()
void xact_base_t::add_post(post_t * post)
{
+#if !defined(NO_ASSERTS)
// You can add temporary postings to transactions, but not real postings to
// temporary transactions.
if (! post->has_flags(ITEM_TEMP))
assert(! has_flags(ITEM_TEMP));
+#endif
posts.push_back(post);
}