Ledger now builds without any significant warnings, except for one file. Some
of the warnings had to be temporarily disabled, but will be checked again once the code has moved into master.
This commit is contained in:
parent
ba02f0a450
commit
fd2e6c2502
8 changed files with 68 additions and 59 deletions
6
acprep
6
acprep
|
|
@ -68,7 +68,6 @@ BUILD_DIR=false
|
|||
# Warning flags
|
||||
CXXFLAGS="$CXXFLAGS -Wall -ansi -Winvalid-pch"
|
||||
CXXFLAGS="$CXXFLAGS -Wextra"
|
||||
#CXXFLAGS="$CXXFLAGS -Weffc++"
|
||||
CXXFLAGS="$CXXFLAGS -Wcast-align"
|
||||
CXXFLAGS="$CXXFLAGS -Wcast-qual"
|
||||
CXXFLAGS="$CXXFLAGS -Wconversion"
|
||||
|
|
@ -83,6 +82,11 @@ CXXFLAGS="$CXXFLAGS -Wsign-promo"
|
|||
CXXFLAGS="$CXXFLAGS -Wstrict-null-sentinel"
|
||||
CXXFLAGS="$CXXFLAGS -Wwrite-strings"
|
||||
|
||||
#CXXFLAGS="$CXXFLAGS -Weffc++"
|
||||
CXXFLAGS="$CXXFLAGS -Wno-unused"
|
||||
CXXFLAGS="$CXXFLAGS -Wno-shorten-64-to-32"
|
||||
CXXFLAGS="$CXXFLAGS -Wno-old-style-cast"
|
||||
CXXFLAGS="$CXXFLAGS -Wno-deprecated"
|
||||
|
||||
# The following are options to prepare a developer tree of Ledger for
|
||||
# building:
|
||||
|
|
|
|||
10
src/error.h
10
src/error.h
|
|
@ -48,7 +48,7 @@ inline void throw_func(const string& message) {
|
|||
extern std::ostringstream _ctxt_buffer;
|
||||
|
||||
#define add_error_context(msg) \
|
||||
((static_cast<unsigned long>(_ctxt_buffer.tellp()) == 0) ? \
|
||||
((long(_ctxt_buffer.tellp()) == 0) ? \
|
||||
(_ctxt_buffer << msg) : (_ctxt_buffer << std::endl << msg))
|
||||
|
||||
inline string error_context() {
|
||||
|
|
@ -63,11 +63,13 @@ inline string file_context(const path& file, std::size_t line) {
|
|||
return buf.str();
|
||||
}
|
||||
|
||||
inline string line_context(const string& line, long pos) {
|
||||
inline string line_context(const string& line, istream_pos_type pos) {
|
||||
std::ostringstream buf;
|
||||
buf << " " << line << std::endl << " ";
|
||||
long idx = pos < 0 ? line.length() - 1 : pos;
|
||||
for (int i = 0; i < idx; i++)
|
||||
istream_pos_type idx = (pos == istream_pos_type(0) ?
|
||||
istream_pos_type(line.length()) : pos);
|
||||
idx -= 1;
|
||||
for (istream_pos_type i = 0; i < idx; i += 1)
|
||||
buf << " ";
|
||||
buf << "^" << std::endl;
|
||||
return buf.str();
|
||||
|
|
|
|||
|
|
@ -210,8 +210,8 @@ format_t::element_t * format_t::parse_elements(const string& fmt)
|
|||
std::istringstream str(p);
|
||||
current->type = element_t::EXPR;
|
||||
current->expr.parse(str);
|
||||
current->expr.set_text(string(p, p + str.tellg()));
|
||||
p += str.tellg();
|
||||
current->expr.set_text(string(p, p + long(str.tellg())));
|
||||
p += long(str.tellg());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -763,7 +763,8 @@ bool expr_t::op_t::print(std::ostream& out, print_context_t& context) const
|
|||
bool found = false;
|
||||
|
||||
if (context.start_pos && this == context.op_to_find) {
|
||||
*context.start_pos = static_cast<unsigned long>(out.tellp()) - 1;
|
||||
*context.start_pos = out.tellp();
|
||||
*context.start_pos--;
|
||||
found = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
8
src/op.h
8
src/op.h
|
|
@ -278,15 +278,15 @@ public:
|
|||
scope_t& scope;
|
||||
const bool relaxed;
|
||||
const ptr_op_t& op_to_find;
|
||||
unsigned long * start_pos;
|
||||
unsigned long * end_pos;
|
||||
ostream_pos_type * start_pos;
|
||||
ostream_pos_type * end_pos;
|
||||
|
||||
// jww (2008-08-01): Is a scope needed here?
|
||||
print_context_t(scope_t& _scope,
|
||||
const bool _relaxed = false,
|
||||
const ptr_op_t& _op_to_find = ptr_op_t(),
|
||||
unsigned long * _start_pos = NULL,
|
||||
unsigned long * _end_pos = NULL)
|
||||
ostream_pos_type * _start_pos = NULL,
|
||||
ostream_pos_type * _end_pos = NULL)
|
||||
: scope(_scope), relaxed(_relaxed), op_to_find(_op_to_find),
|
||||
start_pos(_start_pos), end_pos(_end_pos) {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ expr_t::parser_t::parse(std::istream& in, const flags_t flags)
|
|||
catch (const std::exception& err) {
|
||||
add_error_context("While parsing value expression:\n");
|
||||
#if 0
|
||||
add_error_context(line_context(str, (long)in.tellg() - 1));
|
||||
add_error_context(line_context(str, in.tellg() - 1));
|
||||
#endif
|
||||
throw err;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,22 +144,22 @@ xact_t * parse_xact(char * line, account_t * account, entry_t * entry = NULL)
|
|||
|
||||
// Parse the account name
|
||||
|
||||
unsigned long account_beg = static_cast<unsigned long>(in.tellg());
|
||||
unsigned long account_end = account_beg;
|
||||
istream_pos_type account_beg = in.tellg();
|
||||
istream_pos_type account_end = account_beg;
|
||||
while (! in.eof()) {
|
||||
in.get(p);
|
||||
if (in.eof() || (std::isspace(p) &&
|
||||
(p == '\t' || in.peek() == EOF ||
|
||||
std::isspace(in.peek()))))
|
||||
break;
|
||||
account_end++;
|
||||
account_end += 1;
|
||||
}
|
||||
|
||||
if (account_beg == account_end)
|
||||
throw parse_error("No account was specified");
|
||||
|
||||
char * b = &line[account_beg];
|
||||
char * e = &line[account_end];
|
||||
char * b = &line[long(account_beg)];
|
||||
char * e = &line[long(account_end)];
|
||||
if ((*b == '[' && *(e - 1) == ']') ||
|
||||
(*b == '(' && *(e - 1) == ')')) {
|
||||
xact->add_flags(XACT_VIRTUAL);
|
||||
|
|
@ -198,7 +198,7 @@ xact_t * parse_xact(char * line, account_t * account, entry_t * entry = NULL)
|
|||
goto parse_assign;
|
||||
|
||||
try {
|
||||
unsigned long beg = static_cast<unsigned long>(in.tellg());
|
||||
istream_pos_type beg = in.tellg();
|
||||
|
||||
xact->amount_expr =
|
||||
parse_amount_expr(in, xact->amount, xact.get(),
|
||||
|
|
@ -217,8 +217,8 @@ xact_t * parse_xact(char * line, account_t * account, entry_t * entry = NULL)
|
|||
if (xact->amount_expr->is_constant())
|
||||
xact->amount_expr = expr_t();
|
||||
|
||||
unsigned long end = static_cast<unsigned long>(in.tellg());
|
||||
xact->amount_expr->set_text(string(line, beg, end - beg));
|
||||
istream_pos_type end = in.tellg();
|
||||
xact->amount_expr->set_text(string(line, long(beg), long(end - beg)));
|
||||
}
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
|
|
@ -251,7 +251,7 @@ xact_t * parse_xact(char * line, account_t * account, entry_t * entry = NULL)
|
|||
xact->cost = amount_t();
|
||||
|
||||
try {
|
||||
unsigned long beg = static_cast<unsigned long>(in.tellg());
|
||||
istream_pos_type beg = in.tellg();
|
||||
|
||||
xact->cost_expr =
|
||||
parse_amount_expr(in, *xact->cost, xact.get(),
|
||||
|
|
@ -259,13 +259,13 @@ xact_t * parse_xact(char * line, account_t * account, entry_t * entry = NULL)
|
|||
EXPR_PARSE_NO_ASSIGN);
|
||||
|
||||
if (xact->cost_expr) {
|
||||
unsigned long end = static_cast<unsigned long>(in.tellg());
|
||||
istream_pos_type end = in.tellg();
|
||||
if (per_unit)
|
||||
xact->cost_expr->set_text(string("@") +
|
||||
string(line, beg, end - beg));
|
||||
string(line, long(beg), long(end - beg)));
|
||||
else
|
||||
xact->cost_expr->set_text(string("@@") +
|
||||
string(line, beg, end - beg));
|
||||
string(line, long(beg), long(end - beg)));
|
||||
}
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
|
|
@ -316,7 +316,7 @@ xact_t * parse_xact(char * line, account_t * account, entry_t * entry = NULL)
|
|||
amount_t amt;
|
||||
|
||||
try {
|
||||
unsigned long beg = static_cast<unsigned long>(in.tellg());
|
||||
istream_pos_type beg = in.tellg();
|
||||
|
||||
optional<expr_t> total_expr =
|
||||
parse_amount_expr(in, amt, xact.get(), EXPR_PARSE_NO_MIGRATE);
|
||||
|
|
@ -329,9 +329,9 @@ xact_t * parse_xact(char * line, account_t * account, entry_t * entry = NULL)
|
|||
"XACT assign: parsed amt = " << amt);
|
||||
|
||||
if (total_expr) {
|
||||
unsigned long end = static_cast<unsigned long>(in.tellg());
|
||||
istream_pos_type end = in.tellg();
|
||||
total_expr->set_text(string("=") +
|
||||
string(line, beg, end - beg));
|
||||
string(line, long(beg), long(end - beg)));
|
||||
}
|
||||
|
||||
// jww (2008-08-02): Save total_expr somewhere!
|
||||
|
|
@ -397,7 +397,7 @@ xact_t * parse_xact(char * line, account_t * account, entry_t * entry = NULL)
|
|||
if (p == ';') {
|
||||
in.get(p);
|
||||
p = peek_next_nonws(in);
|
||||
xact->note = &line[static_cast<unsigned long>(in.tellg())];
|
||||
xact->note = &line[long(in.tellg())];
|
||||
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
||||
"Parsed a note '" << *xact->note << "'");
|
||||
|
||||
|
|
@ -426,7 +426,7 @@ xact_t * parse_xact(char * line, account_t * account, entry_t * entry = NULL)
|
|||
}
|
||||
catch (const std::exception& err) {
|
||||
add_error_context("While parsing transaction:\n");
|
||||
add_error_context(line_context(line, static_cast<unsigned long>(in.tellg()) - 1));
|
||||
add_error_context(line_context(line, in.tellg()));
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
|
@ -435,7 +435,7 @@ bool parse_xacts(std::istream& in,
|
|||
account_t * account,
|
||||
entry_base_t& entry,
|
||||
const string& kind,
|
||||
unsigned long beg_pos)
|
||||
istream_pos_type beg_pos)
|
||||
{
|
||||
TRACE_START(entry_xacts, 1, "Time spent parsing transactions:");
|
||||
|
||||
|
|
@ -471,7 +471,7 @@ bool parse_xacts(std::istream& in,
|
|||
}
|
||||
|
||||
entry_t * parse_entry(std::istream& in, char * line, account_t * master,
|
||||
textual_parser_t& parser, unsigned long& pos)
|
||||
textual_parser_t& parser, istream_pos_type& pos)
|
||||
{
|
||||
TRACE_START(entry_text, 1, "Time spent preparing entry text:");
|
||||
|
||||
|
|
@ -523,11 +523,11 @@ entry_t * parse_entry(std::istream& in, char * line, account_t * master,
|
|||
|
||||
TRACE_START(entry_details, 1, "Time spent parsing entry details:");
|
||||
|
||||
unsigned long end_pos;
|
||||
istream_pos_type end_pos;
|
||||
unsigned long beg_line = linenum;
|
||||
|
||||
while (! in.eof() && (in.peek() == ' ' || in.peek() == '\t')) {
|
||||
unsigned long beg_pos = static_cast<unsigned long>(in.tellg());
|
||||
istream_pos_type beg_pos = in.tellg();
|
||||
|
||||
line[0] = '\0';
|
||||
in.getline(line, MAX_LINE);
|
||||
|
|
@ -538,7 +538,8 @@ entry_t * parse_entry(std::istream& in, char * line, account_t * master,
|
|||
if (line[len - 1] == '\r')
|
||||
line[--len] = '\0';
|
||||
|
||||
end_pos = beg_pos + len + 1;
|
||||
end_pos = beg_pos;
|
||||
end_pos += len + 1;
|
||||
linenum++;
|
||||
|
||||
if (line[0] == ' ' || line[0] == '\t') {
|
||||
|
|
@ -705,8 +706,8 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
|||
|
||||
INFO("Parsing file '" << pathname.string() << "'");
|
||||
|
||||
unsigned long beg_pos = static_cast<unsigned long>(in.tellg());
|
||||
unsigned long end_pos;
|
||||
istream_pos_type beg_pos = in.tellg();
|
||||
istream_pos_type end_pos;
|
||||
unsigned long beg_line = linenum;
|
||||
|
||||
while (in.good() && ! in.eof()) {
|
||||
|
|
@ -719,7 +720,8 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
|||
if (line[len - 1] == '\r')
|
||||
line[--len] = '\0';
|
||||
|
||||
end_pos = beg_pos + len + 1;
|
||||
end_pos = beg_pos;
|
||||
end_pos += len + 1;
|
||||
linenum++;
|
||||
|
||||
switch (line[0]) {
|
||||
|
|
@ -864,8 +866,8 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
|||
}
|
||||
|
||||
auto_entry_t * ae = new auto_entry_t(skip_ws(line + 1));
|
||||
if (parse_xacts(in, account_stack.front(), *ae,
|
||||
"automated", end_pos)) {
|
||||
if (parse_xacts(in, account_stack.front(), *ae, "automated",
|
||||
end_pos)) {
|
||||
journal.auto_entries.push_back(ae);
|
||||
ae->src_idx = src_idx;
|
||||
ae->beg_pos = beg_pos;
|
||||
|
|
@ -905,8 +907,8 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
|||
if (word == "include") {
|
||||
push_variable<path> save_pathname(pathname);
|
||||
push_variable<unsigned int> save_src_idx(src_idx);
|
||||
push_variable<unsigned long> save_beg_pos(beg_pos);
|
||||
push_variable<unsigned long> save_end_pos(end_pos);
|
||||
push_variable<istream_pos_type> save_beg_pos(beg_pos);
|
||||
push_variable<istream_pos_type> save_end_pos(end_pos);
|
||||
push_variable<unsigned int> save_linenum(linenum);
|
||||
|
||||
pathname = p;
|
||||
|
|
@ -965,7 +967,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
|||
}
|
||||
|
||||
default: {
|
||||
unsigned long pos = beg_pos;
|
||||
istream_pos_type pos = beg_pos;
|
||||
TRACE_START(entries, 1, "Time spent handling entries:");
|
||||
if (entry_t * entry =
|
||||
parse_entry(in, line, account_stack.front(), *this, pos)) {
|
||||
|
|
@ -1079,7 +1081,7 @@ void write_textual_journal(journal_t& journal,
|
|||
auto_entries_list::iterator al = journal.auto_entries.begin();
|
||||
period_entries_list::iterator pl = journal.period_entries.begin();
|
||||
|
||||
unsigned long pos = 0;
|
||||
istream_pos_type pos = 0;
|
||||
|
||||
format_t hdr_fmt(write_hdr_format);
|
||||
boost::filesystem::ifstream in(found);
|
||||
|
|
@ -1111,11 +1113,11 @@ void write_textual_journal(journal_t& journal,
|
|||
|
||||
while (pos < base->end_pos) {
|
||||
in.get(c);
|
||||
pos = static_cast<unsigned long>(in.tellg()); // pos++;
|
||||
pos = in.tellg(); // pos++;
|
||||
}
|
||||
} else {
|
||||
in.get(c);
|
||||
pos = static_cast<unsigned long>(in.tellg()); // pos++;
|
||||
pos = in.tellg(); // pos++;
|
||||
out.put(c);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,12 +306,12 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags)
|
|||
|
||||
default: {
|
||||
amount_t temp;
|
||||
unsigned long pos = 0;
|
||||
istream_pos_type pos = 0;
|
||||
|
||||
// When in relaxed parsing mode, we want to migrate commodity
|
||||
// flags so that any precision specified by the user updates the
|
||||
// current maximum displayed precision.
|
||||
pos = static_cast<unsigned long>(in.tellg());
|
||||
pos = in.tellg();
|
||||
|
||||
amount_t::flags_t parse_flags = 0;
|
||||
if (pflags & EXPR_PARSE_NO_MIGRATE)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue