Corrected problem with uninitialized value_t's.
This commit is contained in:
parent
8a2b87e6e1
commit
8cdc8008c3
11 changed files with 60 additions and 24 deletions
14
Makefile.am
14
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 = \
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
16
src/report.h
16
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue