diff options
-rw-r--r-- | Makefile.am | 14 | ||||
-rw-r--r-- | src/builder.h | 8 | ||||
-rw-r--r-- | src/main.cc | 2 | ||||
-rw-r--r-- | src/node.h | 1 | ||||
-rw-r--r-- | src/option.cc | 13 | ||||
-rw-r--r-- | src/option.h | 2 | ||||
-rw-r--r-- | src/report.cc | 2 | ||||
-rw-r--r-- | src/report.h | 16 | ||||
-rw-r--r-- | src/session.h | 16 | ||||
-rw-r--r-- | src/value.h | 2 | ||||
-rw-r--r-- | src/xpath.cc | 8 |
11 files changed, 60 insertions, 24 deletions
diff --git a/Makefile.am b/Makefile.am index 88deb7b1..21db24a1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,15 +22,15 @@ endif AM_YFLAGS = -d AM_LFLAGS = -o $(LEX_OUTPUT_ROOT).c -WARNFLAGS = -Wall -Wextra -Wfloat-equal -Wno-endif-labels -WARNFLAGS += -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -WARNFLAGS += -Wconversion -Wshorten-64-to-32 -Wsign-compare -WARNFLAGS += -Wmissing-field-initializers -pedantic-errors -WARNFLAGS += -Weffc++ -Wstrict-null-sentinel -Wold-style-cast -WARNFLAGS += -Woverloaded-virtual -Wsign-promo +WARNFLAGS = -Wall #-pedantic-errors +#WARNFLAGS += -Wextra -Wfloat-equal -Wno-endif-labels -Wcast-qual +#WARNFLAGS += -Wcast-align -Wwrite-strings -Wconversion -Wconversion +#WARNFLAGS += -Wshorten-64-to-32 -Wsign-compare -Weffc++ -Wsign-promo +#WARNFLAGS += -Wmissing-field-initializers -Wstrict-null-sentinel +#WARNFLAGS += -Wold-style-cast -Woverloaded-virtual libledger_la_CPPFLAGS = -I$(top_builddir)/gdtoa -I$(srcdir)/gdtoa \ - -I$(srcdir)/src #$(WARNFLAGS) + -I$(srcdir)/src $(WARNFLAGS) libledger_la_LDFLAGS = -release $(PACKAGE_VERSION) libledger_la_SOURCES = \ diff --git a/src/builder.h b/src/builder.h index 1952fe63..b1fae018 100644 --- a/src/builder.h +++ b/src/builder.h @@ -37,6 +37,8 @@ protected: position_t current_position; public: + virtual ~builder_t() {} + virtual void set_start_position(std::istream& in) {} virtual void set_position(const position_t& position) {} virtual position_t& position() { return current_position; } @@ -134,11 +136,11 @@ public: virtual node_t * end_node(const string& name, const optional<position_t>& end_pos = none) { - current = &*current->parent(); + return current = &*current->parent(); } virtual node_t * end_node(const node_t::nameid_t name_id, const optional<position_t>& end_pos = none) { - current = &*current->parent(); + return current = &*current->parent(); } }; @@ -236,10 +238,12 @@ public: virtual node_t * end_node(const string& name, const optional<position_t>& end_pos = none) { outs << "</" << name << '>'; + return NULL; } virtual node_t * end_node(const node_t::nameid_t name_id, const optional<position_t>& end_pos = none) { end_node("hello", end_pos); + return NULL; } }; diff --git a/src/main.cc b/src/main.cc index d50137b6..4fe41be2 100644 --- a/src/main.cc +++ b/src/main.cc @@ -216,8 +216,6 @@ static int read_and_report(ledger::report_t * report, int argc, char * argv[], throw_(std::logic_error, "Failed to fork child process"); } else if (status == 0) { // child - const char *arg0; - // Duplicate pipe's reading end into stdin status = dup2(pfd[0], STDIN_FILENO); if (status == -1) @@ -232,6 +232,7 @@ public: virtual value_t to_value() const { throw_(std::logic_error, "Cannot convert parent node to a value"); + return NULL_VALUE; } void print(std::ostream& out) const; diff --git a/src/option.cc b/src/option.cc index 607e22bd..6730748c 100644 --- a/src/option.cc +++ b/src/option.cc @@ -84,7 +84,8 @@ namespace { #endif scoped_ptr<xml::xpath_t::scope_t> args; if (arg) { - args.reset(new xml::xpath_t::scope_t(scope, xml::xpath_t::scope_t::ARGUMENT)); + args.reset(new xml::xpath_t::scope_t + (scope, xml::xpath_t::scope_t::ARGUMENT)); args->args.push_back(value_t(arg, true)); } opt(args.get()); @@ -102,15 +103,12 @@ namespace { } } -bool process_option(const string& name, xml::xpath_t::scope_t * scope, +void process_option(const string& name, xml::xpath_t::scope_t * scope, const char * arg) { op_bool_tuple opt(find_option(scope, name)); - if (opt.get<0>()) { + if (opt.get<0>()) process_option(opt.get<0>()->as_function(), scope, arg); - return true; - } - return false; } void process_environment(const char ** envp, const string& tag, @@ -137,8 +135,7 @@ void process_environment(const char ** envp, const string& tag, #if 0 try { #endif - if (! process_option(string(buf), scope, q + 1)) - ; //throw_(option_error, "unknown option"); + process_option(string(buf), scope, q + 1); #if 0 } catch (error * err) { diff --git a/src/option.h b/src/option.h index d4003343..0c9a35fd 100644 --- a/src/option.h +++ b/src/option.h @@ -36,7 +36,7 @@ namespace ledger { -bool process_option(const string& name, xml::xpath_t::scope_t * scope, +void process_option(const string& name, xml::xpath_t::scope_t * scope, const char * arg = NULL); void process_environment(const char ** envp, const string& tag, diff --git a/src/report.cc b/src/report.cc index 04ed2471..2dd881e2 100644 --- a/src/report.cc +++ b/src/report.cc @@ -79,6 +79,8 @@ value_t report_t::ftime(xml::xpath_t::scope_t * locals) date_format = moment_t::output_format; return value_t(date.as_string(date_format), true); +#else + return NULL_VALUE; #endif } diff --git a/src/report.h b/src/report.h index bf43e927..bf146eaf 100644 --- a/src/report.h +++ b/src/report.h @@ -94,28 +94,35 @@ class report_t : public xml::xpath_t::scope_t } value_t option_eval(xml::xpath_t::scope_t * locals) { eval(locals->args[0].as_string()); + return NULL_VALUE; } value_t option_amount(xml::xpath_t::scope_t * locals) { eval(string("t=") + locals->args[0].as_string()); + return NULL_VALUE; } value_t option_total(xml::xpath_t::scope_t * locals) { eval(string("T()=") + locals->args[0].as_string()); + return NULL_VALUE; } value_t option_format(xml::xpath_t::scope_t * locals) { format_string = locals->args[0].as_string(); + return NULL_VALUE; } value_t option_raw(xml::xpath_t::scope_t * locals) { raw_mode = true; + return NULL_VALUE; } value_t option_foo(xml::xpath_t::scope_t * locals) { std::cout << "This is foo" << std::endl; + return NULL_VALUE; } value_t option_bar(xml::xpath_t::scope_t * locals) { std::cout << "This is bar: " << locals->args[0] << std::endl; + return NULL_VALUE; } // @@ -125,35 +132,44 @@ class report_t : public xml::xpath_t::scope_t #if 0 value_t option_select(xml::xpath_t::scope_t * locals) { transforms.push_back(new select_transform(locals->args[0].as_string())); + return NULL_VALUE; } value_t option_limit(xml::xpath_t::scope_t * locals) { string expr = (string("//xact[") + locals->args[0].as_string() + "]"); transforms.push_back(new select_transform(expr)); + return NULL_VALUE; } value_t option_remove(xml::xpath_t::scope_t * locals) { transforms.push_back(new remove_transform(locals->args[0].as_string())); + return NULL_VALUE; } value_t option_accounts(xml::xpath_t::scope_t * locals) { transforms.push_back(new accounts_transform); + return NULL_VALUE; } value_t option_compact(xml::xpath_t::scope_t * locals) { transforms.push_back(new compact_transform); + return NULL_VALUE; } value_t option_clean(xml::xpath_t::scope_t * locals) { transforms.push_back(new clean_transform); + return NULL_VALUE; } value_t option_entries(xml::xpath_t::scope_t * locals) { transforms.push_back(new entries_transform); + return NULL_VALUE; } value_t option_split(xml::xpath_t::scope_t * locals) { transforms.push_back(new split_transform); + return NULL_VALUE; } value_t option_merge(xml::xpath_t::scope_t * locals) { transforms.push_back(new merge_transform); + return NULL_VALUE; } #endif diff --git a/src/session.h b/src/session.h index 6f7b5a12..e90a90d8 100644 --- a/src/session.h +++ b/src/session.h @@ -188,15 +188,22 @@ class session_t : public xml::xpath_t::scope_t // Debug options // - value_t option_trace_(xml::xpath_t::scope_t * locals) {} - value_t option_debug_(xml::xpath_t::scope_t * locals) {} + value_t option_trace_(xml::xpath_t::scope_t * locals) { + return NULL_VALUE; + } + value_t option_debug_(xml::xpath_t::scope_t * locals) { + return NULL_VALUE; + } - value_t option_verify(xml::xpath_t::scope_t *) {} + value_t option_verify(xml::xpath_t::scope_t *) { + return NULL_VALUE; + } value_t option_verbose(xml::xpath_t::scope_t *) { #if defined(LOGGING_ON) if (_log_level < LOG_INFO) _log_level = LOG_INFO; #endif + return NULL_VALUE; } // @@ -206,15 +213,18 @@ class session_t : public xml::xpath_t::scope_t value_t option_file_(xml::xpath_t::scope_t * locals) { assert(locals->args.size() == 1); data_file = locals->args[0].as_string(); + return NULL_VALUE; } #if 0 #if defined(USE_BOOST_PYTHON) value_t option_import_(xml::xpath_t::scope_t * locals) { python_import(optarg); + return NULL_VALUE; } value_t option_import_stdin(xml::xpath_t::scope_t * locals) { python_eval(std::cin, PY_EVAL_MULTI); + return NULL_VALUE; } #endif #endif diff --git a/src/value.h b/src/value.h index 3e67c248..fbe62dbf 100644 --- a/src/value.h +++ b/src/value.h @@ -561,6 +561,8 @@ std::ostream& operator<<(std::ostream& out, const value_t& val); DECLARE_EXCEPTION(value_error); +#define NULL_VALUE (value_t()) + } // namespace ledger #endif // _VALUE_H diff --git a/src/xpath.cc b/src/xpath.cc index 2a28956d..2a9ec1e5 100644 --- a/src/xpath.cc +++ b/src/xpath.cc @@ -1723,7 +1723,6 @@ bool xpath_t::op_t::print(std::ostream& out, unsigned long * start_pos, unsigned long * end_pos) const { - int arg_index = 0; bool found = false; if (start_pos && this == op_to_find) { @@ -1737,6 +1736,9 @@ bool xpath_t::op_t::print(std::ostream& out, case VALUE: { const value_t& value(as_value()); switch (value.type()) { + case value_t::VOID: + out << "<VOID>"; + break; case value_t::BOOLEAN: if (value) out << "1"; @@ -2235,6 +2237,10 @@ void xpath_t::path_t::walk_elements(node_t& start, check_element(*node, element, scope, index++, size, func); break; } + + default: + assert(false); + break; } } else if (start.is_parent_node()) { |