r384@user1022: johnw | 2007-06-08 00:08:53 -0400
Corrected several minor warnings
This commit is contained in:
parent
ec850814fd
commit
b7b4c07926
8 changed files with 71 additions and 72 deletions
31
acprep
31
acprep
|
|
@ -49,21 +49,22 @@ LDFLAGS="$LIBDIRS"
|
||||||
LOCAL=false
|
LOCAL=false
|
||||||
|
|
||||||
# Warning flags
|
# Warning flags
|
||||||
CXXFLAGS="$CXXFLAGS -Wall -Wextra -ansi"
|
CXXFLAGS="$CXXFLAGS -Wall -ansi"
|
||||||
CXXFLAGS="$CXXFLAGS -Weffc++"
|
#CXXFLAGS="$CXXFLAGS -Wextra"
|
||||||
CXXFLAGS="$CXXFLAGS -Wcast-align"
|
#CXXFLAGS="$CXXFLAGS -Weffc++"
|
||||||
CXXFLAGS="$CXXFLAGS -Wcast-qual"
|
#CXXFLAGS="$CXXFLAGS -Wcast-align"
|
||||||
CXXFLAGS="$CXXFLAGS -Wconversion"
|
#CXXFLAGS="$CXXFLAGS -Wcast-qual"
|
||||||
CXXFLAGS="$CXXFLAGS -Wfloat-equal"
|
#CXXFLAGS="$CXXFLAGS -Wconversion"
|
||||||
CXXFLAGS="$CXXFLAGS -Wmissing-field-initializers"
|
#CXXFLAGS="$CXXFLAGS -Wfloat-equal"
|
||||||
CXXFLAGS="$CXXFLAGS -Wno-endif-labels"
|
#CXXFLAGS="$CXXFLAGS -Wmissing-field-initializers"
|
||||||
CXXFLAGS="$CXXFLAGS -Wold-style-cast"
|
#CXXFLAGS="$CXXFLAGS -Wno-endif-labels"
|
||||||
CXXFLAGS="$CXXFLAGS -Woverloaded-virtual"
|
#CXXFLAGS="$CXXFLAGS -Wold-style-cast"
|
||||||
CXXFLAGS="$CXXFLAGS -Wshorten-64-to-32"
|
#CXXFLAGS="$CXXFLAGS -Woverloaded-virtual"
|
||||||
CXXFLAGS="$CXXFLAGS -Wsign-compare"
|
#CXXFLAGS="$CXXFLAGS -Wshorten-64-to-32"
|
||||||
CXXFLAGS="$CXXFLAGS -Wsign-promo"
|
#CXXFLAGS="$CXXFLAGS -Wsign-compare"
|
||||||
CXXFLAGS="$CXXFLAGS -Wstrict-null-sentinel"
|
#CXXFLAGS="$CXXFLAGS -Wsign-promo"
|
||||||
CXXFLAGS="$CXXFLAGS -Wwrite-strings"
|
#CXXFLAGS="$CXXFLAGS -Wstrict-null-sentinel"
|
||||||
|
#CXXFLAGS="$CXXFLAGS -Wwrite-strings"
|
||||||
|
|
||||||
|
|
||||||
while [ -n "$1" ]; do
|
while [ -n "$1" ]; do
|
||||||
|
|
|
||||||
|
|
@ -130,20 +130,16 @@ void transaction_node_t::parse_amount_expr(xpath_t::scope_t& scope,
|
||||||
|
|
||||||
// Parse the optional cost (@ PER-UNIT-COST, @@ TOTAL-COST)
|
// Parse the optional cost (@ PER-UNIT-COST, @@ TOTAL-COST)
|
||||||
|
|
||||||
unsigned int linenum = -1;
|
|
||||||
|
|
||||||
if (in.good() && ! in.eof()) {
|
if (in.good() && ! in.eof()) {
|
||||||
char c = peek_next_nonws(in);
|
char c = peek_next_nonws(in);
|
||||||
if (c == '@') {
|
if (c == '@') {
|
||||||
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
DEBUG("ledger.textual.parse", "Found a price indicator");
|
||||||
"Found a price indicator");
|
|
||||||
bool per_unit = true;
|
bool per_unit = true;
|
||||||
in.get(c);
|
in.get(c);
|
||||||
if (in.peek() == '@') {
|
if (in.peek() == '@') {
|
||||||
in.get(c);
|
in.get(c);
|
||||||
per_unit = false;
|
per_unit = false;
|
||||||
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
DEBUG("ledger.textual.parse", "And it's for a total price");
|
||||||
"And it's for a total price");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in.good() && ! in.eof()) {
|
if (in.good() && ! in.eof()) {
|
||||||
|
|
@ -179,22 +175,17 @@ void transaction_node_t::parse_amount_expr(xpath_t::scope_t& scope,
|
||||||
transaction->entry->code));
|
transaction->entry->code));
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
DEBUG("ledger.textual.parse", "Total cost is " << cost);
|
||||||
"Total cost is " << cost);
|
DEBUG("ledger.textual.parse", "Per-unit cost is " << per_unit_cost);
|
||||||
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
DEBUG("ledger.textual.parse", "Annotated amount is " << base_amount);
|
||||||
"Per-unit cost is " << per_unit_cost);
|
DEBUG("ledger.textual.parse", "Bare amount is " << base_amount.number());
|
||||||
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
|
||||||
"Annotated amount is " << base_amount);
|
|
||||||
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
|
||||||
"Bare amount is " << base_amount.number());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
amount->in_place_reduce();
|
amount->in_place_reduce();
|
||||||
|
|
||||||
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
DEBUG("ledger.textual.parse", "Reduced amount is " << *amount);
|
||||||
"Reduced amount is " << *amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void transaction_node_t::compile(xpath_t::scope_t& scope)
|
void transaction_node_t::compile(xpath_t::scope_t& scope)
|
||||||
|
|
|
||||||
|
|
@ -121,13 +121,14 @@ optional<node_t::nameid_t> document_t::lookup_name_id(const string& name) const
|
||||||
optional<node_t::nameid_t> document_t::lookup_builtin_id(const string& name)
|
optional<node_t::nameid_t> document_t::lookup_builtin_id(const string& name)
|
||||||
{
|
{
|
||||||
int first = 0;
|
int first = 0;
|
||||||
int last = (int)ledger_builtins_size;
|
int last = static_cast<int>(ledger_builtins_size);
|
||||||
|
|
||||||
while (first <= last) {
|
while (first <= last) {
|
||||||
int mid = (first + last) / 2; // compute mid point.
|
int mid = (first + last) / 2; // compute mid point.
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
if ((result = (int)name[0] - (int)ledger_builtins[mid][0]) == 0)
|
if ((result = (static_cast<int>(name[0]) -
|
||||||
|
static_cast<int>(ledger_builtins[mid][0]))) == 0)
|
||||||
result = std::strcmp(name.c_str(), ledger_builtins[mid]);
|
result = std::strcmp(name.c_str(), ledger_builtins[mid]);
|
||||||
|
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
|
|
|
||||||
|
|
@ -542,18 +542,22 @@ journal_t::~journal_t()
|
||||||
// be deleted.
|
// be deleted.
|
||||||
for (entries_list::iterator i = entries.begin();
|
for (entries_list::iterator i = entries.begin();
|
||||||
i != entries.end();
|
i != entries.end();
|
||||||
i++)
|
i++) {
|
||||||
if (! item_pool ||
|
if (! item_pool ||
|
||||||
((char *) *i) < item_pool || ((char *) *i) >= item_pool_end)
|
reinterpret_cast<char *>(*i) < item_pool ||
|
||||||
|
reinterpret_cast<char *>(*i) >= item_pool_end) {
|
||||||
checked_delete(*i);
|
checked_delete(*i);
|
||||||
else
|
} else {
|
||||||
(*i)->~entry_t();
|
(*i)->~entry_t();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto_entries_list::iterator i = auto_entries.begin();
|
for (auto_entries_list::iterator i = auto_entries.begin();
|
||||||
i != auto_entries.end();
|
i != auto_entries.end();
|
||||||
i++)
|
i++)
|
||||||
if (! item_pool ||
|
if (! item_pool ||
|
||||||
((char *) *i) < item_pool || ((char *) *i) >= item_pool_end)
|
reinterpret_cast<char *>(*i) < item_pool ||
|
||||||
|
reinterpret_cast<char *>(*i) >= item_pool_end)
|
||||||
checked_delete(*i);
|
checked_delete(*i);
|
||||||
else
|
else
|
||||||
(*i)->~auto_entry_t();
|
(*i)->~auto_entry_t();
|
||||||
|
|
@ -562,7 +566,8 @@ journal_t::~journal_t()
|
||||||
i != period_entries.end();
|
i != period_entries.end();
|
||||||
i++)
|
i++)
|
||||||
if (! item_pool ||
|
if (! item_pool ||
|
||||||
((char *) *i) < item_pool || ((char *) *i) >= item_pool_end)
|
reinterpret_cast<char *>(*i) < item_pool ||
|
||||||
|
reinterpret_cast<char *>(*i) >= item_pool_end)
|
||||||
checked_delete(*i);
|
checked_delete(*i);
|
||||||
else
|
else
|
||||||
(*i)->~period_entry_t();
|
(*i)->~period_entry_t();
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,14 @@ value_t report_t::abbrev(xml::xpath_t::call_scope_t& args)
|
||||||
|
|
||||||
elision_style_t style = session.elision_style;
|
elision_style_t style = session.elision_style;
|
||||||
if (args.size() == 3)
|
if (args.size() == 3)
|
||||||
style = (elision_style_t)args[2].as_long();
|
style = static_cast<elision_style_t>(args[2].as_long());
|
||||||
|
|
||||||
long abbrev_len = session.abbrev_length;
|
long abbrev_len = session.abbrev_length;
|
||||||
if (args.size() == 4)
|
if (args.size() == 4)
|
||||||
abbrev_len = args[3].as_long();
|
abbrev_len = args[3].as_long();
|
||||||
|
|
||||||
return value_t(abbreviate(str, wid, style, true, (int)abbrev_len), true);
|
return value_t(abbreviate(str, wid, style, true,
|
||||||
|
static_cast<int>(abbrev_len)), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t report_t::ftime(xml::xpath_t::call_scope_t& args)
|
value_t report_t::ftime(xml::xpath_t::call_scope_t& args)
|
||||||
|
|
|
||||||
|
|
@ -41,22 +41,22 @@ void value_t::storage_t::destroy()
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AMOUNT:
|
case AMOUNT:
|
||||||
((amount_t *)data)->~amount_t();
|
reinterpret_cast<amount_t *>(data)->~amount_t();
|
||||||
break;
|
break;
|
||||||
case BALANCE:
|
case BALANCE:
|
||||||
checked_delete(*(balance_t **)data);
|
checked_delete(*reinterpret_cast<balance_t **>(data));
|
||||||
break;
|
break;
|
||||||
case BALANCE_PAIR:
|
case BALANCE_PAIR:
|
||||||
checked_delete(*(balance_pair_t **)data);
|
checked_delete(*reinterpret_cast<balance_pair_t **>(data));
|
||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
((string *)data)->~string();
|
reinterpret_cast<string *>(data)->~string();
|
||||||
break;
|
break;
|
||||||
case SEQUENCE:
|
case SEQUENCE:
|
||||||
checked_delete(*(sequence_t **)data);
|
checked_delete(*reinterpret_cast<sequence_t **>(data));
|
||||||
break;
|
break;
|
||||||
case POINTER:
|
case POINTER:
|
||||||
((boost::any *)data)->~any();
|
reinterpret_cast<boost::any *>(data)->~any();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -73,11 +73,11 @@ void value_t::initialize()
|
||||||
|
|
||||||
true_value = new storage_t;
|
true_value = new storage_t;
|
||||||
true_value->type = BOOLEAN;
|
true_value->type = BOOLEAN;
|
||||||
*(bool *) true_value->data = true;
|
*reinterpret_cast<bool *>(true_value->data) = true;
|
||||||
|
|
||||||
false_value = new storage_t;
|
false_value = new storage_t;
|
||||||
false_value->type = BOOLEAN;
|
false_value->type = BOOLEAN;
|
||||||
*(bool *) false_value->data = false;
|
*reinterpret_cast<bool *>(false_value->data) = false;
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(sizeof(amount_t) >= sizeof(bool));
|
BOOST_STATIC_ASSERT(sizeof(amount_t) >= sizeof(bool));
|
||||||
BOOST_STATIC_ASSERT(sizeof(amount_t) >= sizeof(moment_t));
|
BOOST_STATIC_ASSERT(sizeof(amount_t) >= sizeof(moment_t));
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ void read_bool(std::istream& in, bool& num)
|
||||||
{
|
{
|
||||||
read_guard(in, 0x2005);
|
read_guard(in, 0x2005);
|
||||||
unsigned char val;
|
unsigned char val;
|
||||||
in.read((char *)&val, sizeof(val));
|
in.read(reinterpret_cast<char *>(&val), sizeof(val));
|
||||||
num = val == 1;
|
num = val == 1;
|
||||||
read_guard(in, 0x2006);
|
read_guard(in, 0x2006);
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +46,7 @@ void read_bool(std::istream& in, bool& num)
|
||||||
void read_bool(const char *& data, bool& num)
|
void read_bool(const char *& data, bool& num)
|
||||||
{
|
{
|
||||||
read_guard(data, 0x2005);
|
read_guard(data, 0x2005);
|
||||||
unsigned char val = *((unsigned char *) data);
|
const unsigned char val = *reinterpret_cast<const unsigned char *>(data);
|
||||||
data += sizeof(unsigned char);
|
data += sizeof(unsigned char);
|
||||||
num = val == 1;
|
num = val == 1;
|
||||||
read_guard(data, 0x2006);
|
read_guard(data, 0x2006);
|
||||||
|
|
@ -130,7 +130,7 @@ void write_bool(std::ostream& out, bool num)
|
||||||
{
|
{
|
||||||
write_guard(out, 0x2005);
|
write_guard(out, 0x2005);
|
||||||
unsigned char val = num ? 1 : 0;
|
unsigned char val = num ? 1 : 0;
|
||||||
out.write((char *)&val, sizeof(val));
|
out.write(reinterpret_cast<char *>(&val), sizeof(val));
|
||||||
write_guard(out, 0x2006);
|
write_guard(out, 0x2006);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,12 @@ namespace binary {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void read_number_nocheck(std::istream& in, T& num) {
|
inline void read_number_nocheck(std::istream& in, T& num) {
|
||||||
in.read((char *)&num, sizeof(num));
|
in.read(reinterpret_cast<char *>(&num), sizeof(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void read_number_nocheck(const char *& data, T& num) {
|
inline void read_number_nocheck(const char *& data, T& num) {
|
||||||
num = *((T *) data);
|
num = *reinterpret_cast<const T *>(data);
|
||||||
data += sizeof(T);
|
data += sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,14 +71,14 @@ inline T read_number_nocheck(const char *& data) {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void read_number(std::istream& in, T& num) {
|
inline void read_number(std::istream& in, T& num) {
|
||||||
read_guard(in, 0x2003);
|
read_guard(in, 0x2003);
|
||||||
in.read((char *)&num, sizeof(num));
|
in.read(reinterpret_cast<char *>(&num), sizeof(num));
|
||||||
read_guard(in, 0x2004);
|
read_guard(in, 0x2004);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void read_number(const char *& data, T& num) {
|
inline void read_number(const char *& data, T& num) {
|
||||||
read_guard(data, 0x2003);
|
read_guard(data, 0x2003);
|
||||||
num = *((T *) data);
|
num = *reinterpret_cast<const T *>(data);
|
||||||
data += sizeof(T);
|
data += sizeof(T);
|
||||||
read_guard(data, 0x2004);
|
read_guard(data, 0x2004);
|
||||||
}
|
}
|
||||||
|
|
@ -124,19 +124,19 @@ void read_long(std::istream& in, T& num)
|
||||||
unsigned char temp;
|
unsigned char temp;
|
||||||
if (len > 3) {
|
if (len > 3) {
|
||||||
read_number_nocheck(in, temp);
|
read_number_nocheck(in, temp);
|
||||||
num |= ((unsigned long)temp) << 24;
|
num |= static_cast<unsigned long>(temp) << 24;
|
||||||
}
|
}
|
||||||
if (len > 2) {
|
if (len > 2) {
|
||||||
read_number_nocheck(in, temp);
|
read_number_nocheck(in, temp);
|
||||||
num |= ((unsigned long)temp) << 16;
|
num |= static_cast<unsigned long>(temp) << 16;
|
||||||
}
|
}
|
||||||
if (len > 1) {
|
if (len > 1) {
|
||||||
read_number_nocheck(in, temp);
|
read_number_nocheck(in, temp);
|
||||||
num |= ((unsigned long)temp) << 8;
|
num |= static_cast<unsigned long>(temp) << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_number_nocheck(in, temp);
|
read_number_nocheck(in, temp);
|
||||||
num |= ((unsigned long)temp);
|
num |= static_cast<unsigned long>(temp);
|
||||||
|
|
||||||
read_guard(in, 0x2002);
|
read_guard(in, 0x2002);
|
||||||
}
|
}
|
||||||
|
|
@ -153,19 +153,19 @@ void read_long(const char *& data, T& num)
|
||||||
unsigned char temp;
|
unsigned char temp;
|
||||||
if (len > 3) {
|
if (len > 3) {
|
||||||
read_number_nocheck(data, temp);
|
read_number_nocheck(data, temp);
|
||||||
num |= ((unsigned long)temp) << 24;
|
num |= static_cast<unsigned long>(temp) << 24;
|
||||||
}
|
}
|
||||||
if (len > 2) {
|
if (len > 2) {
|
||||||
read_number_nocheck(data, temp);
|
read_number_nocheck(data, temp);
|
||||||
num |= ((unsigned long)temp) << 16;
|
num |= static_cast<unsigned long>(temp) << 16;
|
||||||
}
|
}
|
||||||
if (len > 1) {
|
if (len > 1) {
|
||||||
read_number_nocheck(data, temp);
|
read_number_nocheck(data, temp);
|
||||||
num |= ((unsigned long)temp) << 8;
|
num |= static_cast<unsigned long>(temp) << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_number_nocheck(data, temp);
|
read_number_nocheck(data, temp);
|
||||||
num |= ((unsigned long)temp);
|
num |= static_cast<unsigned long>(temp);
|
||||||
|
|
||||||
read_guard(data, 0x2002);
|
read_guard(data, 0x2002);
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +203,7 @@ inline string read_string(const char *& data) {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void write_number_nocheck(std::ostream& out, T num) {
|
inline void write_number_nocheck(std::ostream& out, T num) {
|
||||||
out.write((char *)&num, sizeof(num));
|
out.write(reinterpret_cast<char *>(&num), sizeof(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL >= ALPHA
|
#if DEBUG_LEVEL >= ALPHA
|
||||||
|
|
@ -216,7 +216,7 @@ inline void write_number_nocheck(std::ostream& out, T num) {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void write_number(std::ostream& out, T num) {
|
inline void write_number(std::ostream& out, T num) {
|
||||||
write_guard(out, 0x2003);
|
write_guard(out, 0x2003);
|
||||||
out.write((char *)&num, sizeof(num));
|
out.write(reinterpret_cast<char *>(&num), sizeof(num));
|
||||||
write_guard(out, 0x2004);
|
write_guard(out, 0x2004);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,29 +228,29 @@ void write_long(std::ostream& out, T num)
|
||||||
write_guard(out, 0x2001);
|
write_guard(out, 0x2001);
|
||||||
|
|
||||||
unsigned char len = 4;
|
unsigned char len = 4;
|
||||||
if (((unsigned long)num) < 0x00000100UL)
|
if (static_cast<unsigned long>(num) < 0x00000100UL)
|
||||||
len = 1;
|
len = 1;
|
||||||
else if (((unsigned long)num) < 0x00010000UL)
|
else if (static_cast<unsigned long>(num) < 0x00010000UL)
|
||||||
len = 2;
|
len = 2;
|
||||||
else if (((unsigned long)num) < 0x01000000UL)
|
else if (static_cast<unsigned long>(num) < 0x01000000UL)
|
||||||
len = 3;
|
len = 3;
|
||||||
write_number_nocheck<unsigned char>(out, len);
|
write_number_nocheck<unsigned char>(out, len);
|
||||||
|
|
||||||
unsigned char temp;
|
unsigned char temp;
|
||||||
if (len > 3) {
|
if (len > 3) {
|
||||||
temp = (((unsigned long)num) & 0xFF000000UL) >> 24;
|
temp = (static_cast<unsigned long>(num) & 0xFF000000UL) >> 24;
|
||||||
write_number_nocheck(out, temp);
|
write_number_nocheck(out, temp);
|
||||||
}
|
}
|
||||||
if (len > 2) {
|
if (len > 2) {
|
||||||
temp = (((unsigned long)num) & 0x00FF0000UL) >> 16;
|
temp = (static_cast<unsigned long>(num) & 0x00FF0000UL) >> 16;
|
||||||
write_number_nocheck(out, temp);
|
write_number_nocheck(out, temp);
|
||||||
}
|
}
|
||||||
if (len > 1) {
|
if (len > 1) {
|
||||||
temp = (((unsigned long)num) & 0x0000FF00UL) >> 8;
|
temp = (static_cast<unsigned long>(num) & 0x0000FF00UL) >> 8;
|
||||||
write_number_nocheck(out, temp);
|
write_number_nocheck(out, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
temp = (((unsigned long)num) & 0x000000FFUL);
|
temp = (static_cast<unsigned long>(num) & 0x000000FFUL);
|
||||||
write_number_nocheck(out, temp);
|
write_number_nocheck(out, temp);
|
||||||
|
|
||||||
write_guard(out, 0x2002);
|
write_guard(out, 0x2002);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue