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_YFLAGS = -d
|
||||||
AM_LFLAGS = -o $(LEX_OUTPUT_ROOT).c
|
AM_LFLAGS = -o $(LEX_OUTPUT_ROOT).c
|
||||||
|
|
||||||
WARNFLAGS = -Wall -Wextra -Wfloat-equal -Wno-endif-labels
|
WARNFLAGS = -Wall #-pedantic-errors
|
||||||
WARNFLAGS += -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion
|
#WARNFLAGS += -Wextra -Wfloat-equal -Wno-endif-labels -Wcast-qual
|
||||||
WARNFLAGS += -Wconversion -Wshorten-64-to-32 -Wsign-compare
|
#WARNFLAGS += -Wcast-align -Wwrite-strings -Wconversion -Wconversion
|
||||||
WARNFLAGS += -Wmissing-field-initializers -pedantic-errors
|
#WARNFLAGS += -Wshorten-64-to-32 -Wsign-compare -Weffc++ -Wsign-promo
|
||||||
WARNFLAGS += -Weffc++ -Wstrict-null-sentinel -Wold-style-cast
|
#WARNFLAGS += -Wmissing-field-initializers -Wstrict-null-sentinel
|
||||||
WARNFLAGS += -Woverloaded-virtual -Wsign-promo
|
#WARNFLAGS += -Wold-style-cast -Woverloaded-virtual
|
||||||
|
|
||||||
libledger_la_CPPFLAGS = -I$(top_builddir)/gdtoa -I$(srcdir)/gdtoa \
|
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_LDFLAGS = -release $(PACKAGE_VERSION)
|
||||||
|
|
||||||
libledger_la_SOURCES = \
|
libledger_la_SOURCES = \
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ protected:
|
||||||
position_t current_position;
|
position_t current_position;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual ~builder_t() {}
|
||||||
|
|
||||||
virtual void set_start_position(std::istream& in) {}
|
virtual void set_start_position(std::istream& in) {}
|
||||||
virtual void set_position(const position_t& position) {}
|
virtual void set_position(const position_t& position) {}
|
||||||
virtual position_t& position() { return current_position; }
|
virtual position_t& position() { return current_position; }
|
||||||
|
|
@ -134,11 +136,11 @@ public:
|
||||||
|
|
||||||
virtual node_t * end_node(const string& name,
|
virtual node_t * end_node(const string& name,
|
||||||
const optional<position_t>& end_pos = none) {
|
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,
|
virtual node_t * end_node(const node_t::nameid_t name_id,
|
||||||
const optional<position_t>& end_pos = none) {
|
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,
|
virtual node_t * end_node(const string& name,
|
||||||
const optional<position_t>& end_pos = none) {
|
const optional<position_t>& end_pos = none) {
|
||||||
outs << "</" << name << '>';
|
outs << "</" << name << '>';
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
virtual node_t * end_node(const node_t::nameid_t name_id,
|
virtual node_t * end_node(const node_t::nameid_t name_id,
|
||||||
const optional<position_t>& end_pos = none) {
|
const optional<position_t>& end_pos = none) {
|
||||||
end_node("hello", end_pos);
|
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");
|
throw_(std::logic_error, "Failed to fork child process");
|
||||||
}
|
}
|
||||||
else if (status == 0) { // child
|
else if (status == 0) { // child
|
||||||
const char *arg0;
|
|
||||||
|
|
||||||
// Duplicate pipe's reading end into stdin
|
// Duplicate pipe's reading end into stdin
|
||||||
status = dup2(pfd[0], STDIN_FILENO);
|
status = dup2(pfd[0], STDIN_FILENO);
|
||||||
if (status == -1)
|
if (status == -1)
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,7 @@ public:
|
||||||
|
|
||||||
virtual value_t to_value() const {
|
virtual value_t to_value() const {
|
||||||
throw_(std::logic_error, "Cannot convert parent node to a value");
|
throw_(std::logic_error, "Cannot convert parent node to a value");
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(std::ostream& out) const;
|
void print(std::ostream& out) const;
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ namespace {
|
||||||
#endif
|
#endif
|
||||||
scoped_ptr<xml::xpath_t::scope_t> args;
|
scoped_ptr<xml::xpath_t::scope_t> args;
|
||||||
if (arg) {
|
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));
|
args->args.push_back(value_t(arg, true));
|
||||||
}
|
}
|
||||||
opt(args.get());
|
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)
|
const char * arg)
|
||||||
{
|
{
|
||||||
op_bool_tuple opt(find_option(scope, name));
|
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);
|
process_option(opt.get<0>()->as_function(), scope, arg);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_environment(const char ** envp, const string& tag,
|
void process_environment(const char ** envp, const string& tag,
|
||||||
|
|
@ -137,8 +135,7 @@ void process_environment(const char ** envp, const string& tag,
|
||||||
#if 0
|
#if 0
|
||||||
try {
|
try {
|
||||||
#endif
|
#endif
|
||||||
if (! process_option(string(buf), scope, q + 1))
|
process_option(string(buf), scope, q + 1);
|
||||||
; //throw_(option_error, "unknown option");
|
|
||||||
#if 0
|
#if 0
|
||||||
}
|
}
|
||||||
catch (error * err) {
|
catch (error * err) {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
namespace ledger {
|
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);
|
const char * arg = NULL);
|
||||||
|
|
||||||
void process_environment(const char ** envp, const string& tag,
|
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;
|
date_format = moment_t::output_format;
|
||||||
|
|
||||||
return value_t(date.as_string(date_format), true);
|
return value_t(date.as_string(date_format), true);
|
||||||
|
#else
|
||||||
|
return NULL_VALUE;
|
||||||
#endif
|
#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) {
|
value_t option_eval(xml::xpath_t::scope_t * locals) {
|
||||||
eval(locals->args[0].as_string());
|
eval(locals->args[0].as_string());
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_amount(xml::xpath_t::scope_t * locals) {
|
value_t option_amount(xml::xpath_t::scope_t * locals) {
|
||||||
eval(string("t=") + locals->args[0].as_string());
|
eval(string("t=") + locals->args[0].as_string());
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
value_t option_total(xml::xpath_t::scope_t * locals) {
|
value_t option_total(xml::xpath_t::scope_t * locals) {
|
||||||
eval(string("T()=") + locals->args[0].as_string());
|
eval(string("T()=") + locals->args[0].as_string());
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_format(xml::xpath_t::scope_t * locals) {
|
value_t option_format(xml::xpath_t::scope_t * locals) {
|
||||||
format_string = locals->args[0].as_string();
|
format_string = locals->args[0].as_string();
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_raw(xml::xpath_t::scope_t * locals) {
|
value_t option_raw(xml::xpath_t::scope_t * locals) {
|
||||||
raw_mode = true;
|
raw_mode = true;
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_foo(xml::xpath_t::scope_t * locals) {
|
value_t option_foo(xml::xpath_t::scope_t * locals) {
|
||||||
std::cout << "This is foo" << std::endl;
|
std::cout << "This is foo" << std::endl;
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
value_t option_bar(xml::xpath_t::scope_t * locals) {
|
value_t option_bar(xml::xpath_t::scope_t * locals) {
|
||||||
std::cout << "This is bar: " << locals->args[0] << std::endl;
|
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
|
#if 0
|
||||||
value_t option_select(xml::xpath_t::scope_t * locals) {
|
value_t option_select(xml::xpath_t::scope_t * locals) {
|
||||||
transforms.push_back(new select_transform(locals->args[0].as_string()));
|
transforms.push_back(new select_transform(locals->args[0].as_string()));
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
value_t option_limit(xml::xpath_t::scope_t * locals) {
|
value_t option_limit(xml::xpath_t::scope_t * locals) {
|
||||||
string expr = (string("//xact[") +
|
string expr = (string("//xact[") +
|
||||||
locals->args[0].as_string() + "]");
|
locals->args[0].as_string() + "]");
|
||||||
transforms.push_back(new select_transform(expr));
|
transforms.push_back(new select_transform(expr));
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_remove(xml::xpath_t::scope_t * locals) {
|
value_t option_remove(xml::xpath_t::scope_t * locals) {
|
||||||
transforms.push_back(new remove_transform(locals->args[0].as_string()));
|
transforms.push_back(new remove_transform(locals->args[0].as_string()));
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_accounts(xml::xpath_t::scope_t * locals) {
|
value_t option_accounts(xml::xpath_t::scope_t * locals) {
|
||||||
transforms.push_back(new accounts_transform);
|
transforms.push_back(new accounts_transform);
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
value_t option_compact(xml::xpath_t::scope_t * locals) {
|
value_t option_compact(xml::xpath_t::scope_t * locals) {
|
||||||
transforms.push_back(new compact_transform);
|
transforms.push_back(new compact_transform);
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
value_t option_clean(xml::xpath_t::scope_t * locals) {
|
value_t option_clean(xml::xpath_t::scope_t * locals) {
|
||||||
transforms.push_back(new clean_transform);
|
transforms.push_back(new clean_transform);
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
value_t option_entries(xml::xpath_t::scope_t * locals) {
|
value_t option_entries(xml::xpath_t::scope_t * locals) {
|
||||||
transforms.push_back(new entries_transform);
|
transforms.push_back(new entries_transform);
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t option_split(xml::xpath_t::scope_t * locals) {
|
value_t option_split(xml::xpath_t::scope_t * locals) {
|
||||||
transforms.push_back(new split_transform);
|
transforms.push_back(new split_transform);
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
value_t option_merge(xml::xpath_t::scope_t * locals) {
|
value_t option_merge(xml::xpath_t::scope_t * locals) {
|
||||||
transforms.push_back(new merge_transform);
|
transforms.push_back(new merge_transform);
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -188,15 +188,22 @@ class session_t : public xml::xpath_t::scope_t
|
||||||
// Debug options
|
// Debug options
|
||||||
//
|
//
|
||||||
|
|
||||||
value_t option_trace_(xml::xpath_t::scope_t * locals) {}
|
value_t option_trace_(xml::xpath_t::scope_t * locals) {
|
||||||
value_t option_debug_(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 *) {
|
value_t option_verbose(xml::xpath_t::scope_t *) {
|
||||||
#if defined(LOGGING_ON)
|
#if defined(LOGGING_ON)
|
||||||
if (_log_level < LOG_INFO)
|
if (_log_level < LOG_INFO)
|
||||||
_log_level = LOG_INFO;
|
_log_level = LOG_INFO;
|
||||||
#endif
|
#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) {
|
value_t option_file_(xml::xpath_t::scope_t * locals) {
|
||||||
assert(locals->args.size() == 1);
|
assert(locals->args.size() == 1);
|
||||||
data_file = locals->args[0].as_string();
|
data_file = locals->args[0].as_string();
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#if defined(USE_BOOST_PYTHON)
|
#if defined(USE_BOOST_PYTHON)
|
||||||
value_t option_import_(xml::xpath_t::scope_t * locals) {
|
value_t option_import_(xml::xpath_t::scope_t * locals) {
|
||||||
python_import(optarg);
|
python_import(optarg);
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
value_t option_import_stdin(xml::xpath_t::scope_t * locals) {
|
value_t option_import_stdin(xml::xpath_t::scope_t * locals) {
|
||||||
python_eval(std::cin, PY_EVAL_MULTI);
|
python_eval(std::cin, PY_EVAL_MULTI);
|
||||||
|
return NULL_VALUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -561,6 +561,8 @@ std::ostream& operator<<(std::ostream& out, const value_t& val);
|
||||||
|
|
||||||
DECLARE_EXCEPTION(value_error);
|
DECLARE_EXCEPTION(value_error);
|
||||||
|
|
||||||
|
#define NULL_VALUE (value_t())
|
||||||
|
|
||||||
} // namespace ledger
|
} // namespace ledger
|
||||||
|
|
||||||
#endif // _VALUE_H
|
#endif // _VALUE_H
|
||||||
|
|
|
||||||
|
|
@ -1723,7 +1723,6 @@ bool xpath_t::op_t::print(std::ostream& out,
|
||||||
unsigned long * start_pos,
|
unsigned long * start_pos,
|
||||||
unsigned long * end_pos) const
|
unsigned long * end_pos) const
|
||||||
{
|
{
|
||||||
int arg_index = 0;
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if (start_pos && this == op_to_find) {
|
if (start_pos && this == op_to_find) {
|
||||||
|
|
@ -1737,6 +1736,9 @@ bool xpath_t::op_t::print(std::ostream& out,
|
||||||
case VALUE: {
|
case VALUE: {
|
||||||
const value_t& value(as_value());
|
const value_t& value(as_value());
|
||||||
switch (value.type()) {
|
switch (value.type()) {
|
||||||
|
case value_t::VOID:
|
||||||
|
out << "<VOID>";
|
||||||
|
break;
|
||||||
case value_t::BOOLEAN:
|
case value_t::BOOLEAN:
|
||||||
if (value)
|
if (value)
|
||||||
out << "1";
|
out << "1";
|
||||||
|
|
@ -2235,6 +2237,10 @@ void xpath_t::path_t::walk_elements(node_t& start,
|
||||||
check_element(*node, element, scope, index++, size, func);
|
check_element(*node, element, scope, index++, size, func);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (start.is_parent_node()) {
|
else if (start.is_parent_node()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue