Changed many uses of "unsigned long" to std::size_t.
This commit is contained in:
parent
9f579902fb
commit
59a080cdb6
16 changed files with 39 additions and 35 deletions
|
|
@ -64,7 +64,7 @@ typedef std::map<const string, account_t *> accounts_map;
|
|||
class account_t : public scope_t
|
||||
{
|
||||
public:
|
||||
typedef unsigned long ident_t;
|
||||
typedef std::size_t ident_t;
|
||||
|
||||
account_t * parent;
|
||||
string name;
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ void write_string(std::ostream& out, const string& str)
|
|||
{
|
||||
write_guard(out, 0x3001);
|
||||
|
||||
unsigned long len = str.length();
|
||||
std::size_t len = str.length();
|
||||
if (len > 255) {
|
||||
assert(len < 65536);
|
||||
write_number_nocheck<unsigned char>(out, 0xff);
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ void read_xact(const char *& data, xact_t * xact)
|
|||
xact->add_flags(XACT_BULK_ALLOC);
|
||||
read_string(data, xact->note);
|
||||
|
||||
// jww (2009-02-01): Use istream_pos_type
|
||||
xact->beg_pos = read_long<unsigned long>(data);
|
||||
read_long(data, xact->beg_line);
|
||||
xact->end_pos = read_long<unsigned long>(data);
|
||||
|
|
@ -249,7 +250,7 @@ commodity_t::base_t * read_commodity_base(const char *& data)
|
|||
commodity->note = str;
|
||||
|
||||
read_number(data, commodity->precision);
|
||||
unsigned long flags;
|
||||
commodity_t::base_t::flags_t flags;
|
||||
read_number(data, flags);
|
||||
commodity->set_flags(flags);
|
||||
|
||||
|
|
@ -320,9 +321,9 @@ void write_commodity_base_extra(std::ostream& out,
|
|||
#endif
|
||||
|
||||
if (! commodity->history) {
|
||||
write_long<unsigned long>(out, 0);
|
||||
write_long<std::size_t>(out, 0);
|
||||
} else {
|
||||
write_long<unsigned long>(out, commodity->history->prices.size());
|
||||
write_long<std::size_t>(out, commodity->history->prices.size());
|
||||
foreach (commodity_t::history_map::value_type& pair,
|
||||
commodity->history->prices) {
|
||||
write_number(out, pair.first);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ void format_emacs_xacts::write_entry(entry_t& entry)
|
|||
break;
|
||||
}
|
||||
|
||||
out << (static_cast<unsigned long>(entry.beg_line) + 1) << " ";
|
||||
out << (static_cast<std::size_t>(entry.beg_line) + 1) << " ";
|
||||
|
||||
tm when = gregorian::to_tm(*entry.date());
|
||||
std::time_t date = std::mktime(&when); // jww (2008-04-20): Is this GMT or local?
|
||||
|
|
@ -79,7 +79,7 @@ void format_emacs_xacts::operator()(xact_t& xact)
|
|||
out << "\n";
|
||||
}
|
||||
|
||||
out << " (" << (static_cast<unsigned long>(xact.beg_line) + 1) << " ";
|
||||
out << " (" << (static_cast<std::size_t>(xact.beg_line) + 1) << " ";
|
||||
out << "\"" << xact.reported_account()->fullname() << "\" \""
|
||||
<< xact.amount << "\"";
|
||||
|
||||
|
|
|
|||
|
|
@ -783,16 +783,15 @@ class budget_xacts : public generate_xacts
|
|||
#define BUDGET_BUDGETED 0x01
|
||||
#define BUDGET_UNBUDGETED 0x02
|
||||
|
||||
unsigned short flags;
|
||||
uint_least8_t flags;
|
||||
|
||||
budget_xacts();
|
||||
|
||||
public:
|
||||
budget_xacts(xact_handler_ptr handler,
|
||||
unsigned long _flags = BUDGET_BUDGETED)
|
||||
uint_least8_t _flags = BUDGET_BUDGETED)
|
||||
: generate_xacts(handler), flags(_flags) {
|
||||
TRACE_CTOR(budget_xacts,
|
||||
"xact_handler_ptr, unsigned long");
|
||||
TRACE_CTOR(budget_xacts, "xact_handler_ptr, uint_least8_t");
|
||||
}
|
||||
virtual ~budget_xacts() throw() {
|
||||
TRACE_DTOR(budget_xacts);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ static XML_Parser parser;
|
|||
static path pathname;
|
||||
static std::size_t src_idx;
|
||||
static istream_pos_type beg_pos;
|
||||
static unsigned long beg_line;
|
||||
static std::size_t beg_line;
|
||||
|
||||
static xact_t::state_t curr_state;
|
||||
|
||||
|
|
@ -425,14 +425,14 @@ std::size_t gnucash_parser_t::parse(std::istream& in,
|
|||
in.getline(buf, BUFSIZ - 1);
|
||||
std::strcat(buf, "\n");
|
||||
if (! XML_Parse(parser, buf, std::strlen(buf), in.eof())) {
|
||||
//unsigned long line = XML_GetCurrentLineNumber(parser) - offset++;
|
||||
//std::size_t line = XML_GetCurrentLineNumber(parser) - offset++;
|
||||
const char * msg = XML_ErrorString(XML_GetErrorCode(parser));
|
||||
XML_ParserFree(parser);
|
||||
throw parse_error(msg);
|
||||
}
|
||||
|
||||
if (! have_error.empty()) {
|
||||
//unsigned long line = XML_GetCurrentLineNumber(parser) - offset++;
|
||||
//std::size_t line = XML_GetCurrentLineNumber(parser) - offset++;
|
||||
parse_error err(have_error);
|
||||
std::cerr << "Error: " << err.what() << std::endl;
|
||||
have_error = "";
|
||||
|
|
|
|||
|
|
@ -73,10 +73,14 @@ public:
|
|||
optional<string> note;
|
||||
|
||||
unsigned short src_idx;
|
||||
istream_pos_type full_beg_pos;
|
||||
std::size_t full_beg_line;
|
||||
istream_pos_type beg_pos;
|
||||
unsigned long beg_line;
|
||||
std::size_t beg_line;
|
||||
istream_pos_type end_pos;
|
||||
unsigned long end_line;
|
||||
std::size_t end_line;
|
||||
istream_pos_type full_end_pos;
|
||||
std::size_t full_end_line;
|
||||
|
||||
static bool use_effective_date;
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ std::size_t qif_parser_t::parse(std::istream& in,
|
|||
linenum = 1;
|
||||
|
||||
istream_pos_type beg_pos = 0;
|
||||
unsigned long beg_line = 0;
|
||||
std::size_t beg_line = 0;
|
||||
|
||||
#define SET_BEG_POS_AND_LINE() \
|
||||
if (! beg_line) { \
|
||||
|
|
|
|||
14
src/quotes.h
14
src/quotes.h
|
|
@ -58,19 +58,19 @@ namespace ledger {
|
|||
*/
|
||||
class quotes_by_script : public noncopyable, public commodity_t::base_t::updater_t
|
||||
{
|
||||
string price_db;
|
||||
unsigned long pricing_leeway;
|
||||
bool& cache_dirty;
|
||||
string price_db;
|
||||
std::size_t pricing_leeway;
|
||||
bool& cache_dirty;
|
||||
|
||||
quotes_by_script();
|
||||
|
||||
public:
|
||||
quotes_by_script(path _price_db,
|
||||
unsigned long _pricing_leeway,
|
||||
bool& _cache_dirty)
|
||||
quotes_by_script(path _price_db,
|
||||
std::size_t _pricing_leeway,
|
||||
bool& _cache_dirty)
|
||||
: price_db(_price_db), pricing_leeway(_pricing_leeway),
|
||||
cache_dirty(_cache_dirty) {
|
||||
TRACE_CTOR(quotes_by_script, "path, unsigned long, bool&");
|
||||
TRACE_CTOR(quotes_by_script, "path, std::size_t, bool&");
|
||||
}
|
||||
~quotes_by_script() throw() {
|
||||
TRACE_DTOR(quotes_by_script);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public:
|
|||
expr_t total_expr;
|
||||
expr_t display_total;
|
||||
|
||||
unsigned long budget_flags;
|
||||
uint_least8_t budget_flags;
|
||||
|
||||
long head_entries;
|
||||
long tail_entries;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public:
|
|||
string prices_format;
|
||||
string pricesdb_format;
|
||||
|
||||
unsigned long pricing_leeway;
|
||||
std::size_t pricing_leeway;
|
||||
|
||||
bool download_quotes;
|
||||
bool use_cache;
|
||||
|
|
|
|||
|
|
@ -95,8 +95,8 @@ namespace std {
|
|||
}
|
||||
}
|
||||
|
||||
typedef unsigned long istream_pos_type;
|
||||
typedef unsigned long ostream_pos_type;
|
||||
typedef std::size_t istream_pos_type;
|
||||
typedef std::size_t ostream_pos_type;
|
||||
|
||||
#else // ! (defined(__GNUG__) && __GNUG__ < 3)
|
||||
|
||||
|
|
|
|||
|
|
@ -1068,7 +1068,7 @@ entry_t * textual_parser_t::instance_t::parse_entry(std::istream& in,
|
|||
TRACE_START(entry_details, 1, "Time spent parsing entry details:");
|
||||
|
||||
istream_pos_type end_pos;
|
||||
unsigned long beg_line = linenum;
|
||||
std::size_t beg_line = linenum;
|
||||
|
||||
while (! in.eof() && (in.peek() == ' ' || in.peek() == '\t')) {
|
||||
istream_pos_type beg_pos = in.tellg();
|
||||
|
|
@ -1127,8 +1127,8 @@ void write_textual_journal(journal_t& journal,
|
|||
const string& write_hdr_format,
|
||||
std::ostream& out)
|
||||
{
|
||||
unsigned long index = 0;
|
||||
path found;
|
||||
std::size_t index = 0;
|
||||
path found;
|
||||
|
||||
// jww (2009-01-29): This function currently doesn't work
|
||||
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ protected:
|
|||
std::size_t linenum;
|
||||
std::size_t src_idx;
|
||||
istream_pos_type beg_pos;
|
||||
std::size_t beg_line;
|
||||
istream_pos_type end_pos;
|
||||
unsigned long beg_line;
|
||||
std::size_t count;
|
||||
std::size_t errors;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ DECLARE_EXCEPTION(assertion_failed, std::logic_error);
|
|||
void debug_assert(const string& reason,
|
||||
const string& func,
|
||||
const string& file,
|
||||
unsigned long line)
|
||||
std::size_t line)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
buf << "Assertion failed in \"" << file << "\", line " << line
|
||||
|
|
@ -458,7 +458,7 @@ static ptime logger_start;
|
|||
|
||||
bool logger_func(log_level_t level)
|
||||
{
|
||||
unsigned long appender = 0;
|
||||
std::size_t appender = 0;
|
||||
|
||||
if (! logger_has_run) {
|
||||
logger_has_run = true;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ namespace ledger {
|
|||
|
||||
namespace ledger {
|
||||
void debug_assert(const string& reason, const string& func,
|
||||
const string& file, unsigned long line);
|
||||
const string& file, std::size_t line);
|
||||
}
|
||||
|
||||
#define assert(x) \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue