summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-01 18:33:46 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-01 18:33:46 -0400
commit59a080cdb6bafa6ab20cb20c1bf1f007ea64de84 (patch)
tree99ee6bdb62d3e3fdedfaa494723e4a48ec8ec6e4 /src
parent9f579902fb6b30cac426110dfd3faa55017b552b (diff)
downloadfork-ledger-59a080cdb6bafa6ab20cb20c1bf1f007ea64de84.tar.gz
fork-ledger-59a080cdb6bafa6ab20cb20c1bf1f007ea64de84.tar.bz2
fork-ledger-59a080cdb6bafa6ab20cb20c1bf1f007ea64de84.zip
Changed many uses of "unsigned long" to std::size_t.
Diffstat (limited to 'src')
-rw-r--r--src/account.h2
-rw-r--r--src/binary.cc2
-rw-r--r--src/cache.cc7
-rw-r--r--src/emacs.cc4
-rw-r--r--src/filters.h7
-rw-r--r--src/gnucash.cc6
-rw-r--r--src/item.h8
-rw-r--r--src/qif.cc2
-rw-r--r--src/quotes.h14
-rw-r--r--src/report.h2
-rw-r--r--src/session.h2
-rw-r--r--src/system.hh4
-rw-r--r--src/textual.cc6
-rw-r--r--src/textual.h2
-rw-r--r--src/utils.cc4
-rw-r--r--src/utils.h2
16 files changed, 39 insertions, 35 deletions
diff --git a/src/account.h b/src/account.h
index 0dba02e2..fa077bbc 100644
--- a/src/account.h
+++ b/src/account.h
@@ -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;
diff --git a/src/binary.cc b/src/binary.cc
index e55861b4..7c3f0809 100644
--- a/src/binary.cc
+++ b/src/binary.cc
@@ -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);
diff --git a/src/cache.cc b/src/cache.cc
index 4e546718..a085e9a3 100644
--- a/src/cache.cc
+++ b/src/cache.cc
@@ -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);
diff --git a/src/emacs.cc b/src/emacs.cc
index 1e8226d1..b63375b2 100644
--- a/src/emacs.cc
+++ b/src/emacs.cc
@@ -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 << "\"";
diff --git a/src/filters.h b/src/filters.h
index 32f71b5a..50e02a50 100644
--- a/src/filters.h
+++ b/src/filters.h
@@ -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);
diff --git a/src/gnucash.cc b/src/gnucash.cc
index 29528013..805be514 100644
--- a/src/gnucash.cc
+++ b/src/gnucash.cc
@@ -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 = "";
diff --git a/src/item.h b/src/item.h
index b4effb77..fab4458f 100644
--- a/src/item.h
+++ b/src/item.h
@@ -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;
diff --git a/src/qif.cc b/src/qif.cc
index b40a5591..07a29ca1 100644
--- a/src/qif.cc
+++ b/src/qif.cc
@@ -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) { \
diff --git a/src/quotes.h b/src/quotes.h
index 60eac63b..a18836f4 100644
--- a/src/quotes.h
+++ b/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);
diff --git a/src/report.h b/src/report.h
index 8ceed7a2..5323e352 100644
--- a/src/report.h
+++ b/src/report.h
@@ -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;
diff --git a/src/session.h b/src/session.h
index 5a05d42c..3723369d 100644
--- a/src/session.h
+++ b/src/session.h
@@ -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;
diff --git a/src/system.hh b/src/system.hh
index ab1b310f..d3fa4731 100644
--- a/src/system.hh
+++ b/src/system.hh
@@ -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)
diff --git a/src/textual.cc b/src/textual.cc
index 527d49af..2e252830 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -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
diff --git a/src/textual.h b/src/textual.h
index 4505d4ed..2ca5967d 100644
--- a/src/textual.h
+++ b/src/textual.h
@@ -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;
diff --git a/src/utils.cc b/src/utils.cc
index b1714879..253af4d2 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -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;
diff --git a/src/utils.h b/src/utils.h
index 39a8dc0e..510f8568 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -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) \