summaryrefslogtreecommitdiff
path: root/src/error.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-08-10 02:52:38 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-08-10 02:52:38 -0400
commitfd2e6c25024eefa5dfc36bed892360451862cb88 (patch)
tree4fb09cea0a20569fca59eedd73896e92b10565ad /src/error.h
parentba02f0a45036a1f9c64cd56533990d3284bcc4cf (diff)
downloadfork-ledger-fd2e6c25024eefa5dfc36bed892360451862cb88.tar.gz
fork-ledger-fd2e6c25024eefa5dfc36bed892360451862cb88.tar.bz2
fork-ledger-fd2e6c25024eefa5dfc36bed892360451862cb88.zip
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.
Diffstat (limited to 'src/error.h')
-rw-r--r--src/error.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/error.h b/src/error.h
index fafef08e..253bcdbf 100644
--- a/src/error.h
+++ b/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();