summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-10 08:16:26 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-10 08:16:26 -0400
commit7be17fd779db1ee2a20064bdf3b4a8f5da3eb968 (patch)
tree4408ceac022ed5370f2eb4b57408bbc7050697c4 /src
parent5aa1f8b6249a4d6d933b9ce1b2c79011439a04c6 (diff)
downloadfork-ledger-7be17fd779db1ee2a20064bdf3b4a8f5da3eb968.tar.gz
fork-ledger-7be17fd779db1ee2a20064bdf3b4a8f5da3eb968.tar.bz2
fork-ledger-7be17fd779db1ee2a20064bdf3b4a8f5da3eb968.zip
Corrections to the way error strings are generated
Diffstat (limited to 'src')
-rw-r--r--src/accum.cc6
-rw-r--r--src/accum.h4
-rw-r--r--src/error.cc1
-rw-r--r--src/error.h2
-rw-r--r--src/interactive.cc4
-rw-r--r--src/utils.cc2
6 files changed, 13 insertions, 6 deletions
diff --git a/src/accum.cc b/src/accum.cc
index 62e36deb..55f5f0a4 100644
--- a/src/accum.cc
+++ b/src/accum.cc
@@ -40,8 +40,6 @@ std::streamsize straccbuf::xsputn(const char * s, std::streamsize num)
if (index == 0) {
// The first item received is the format string
str = std::string(s, num);
- index++;
- return num;
}
else {
std::ostringstream buf;
@@ -68,9 +66,9 @@ std::streamsize straccbuf::xsputn(const char * s, std::streamsize num)
buf << std::string(s, num);
str = buf.str();
- index++;
- return num;
}
+ index++;
+ return num;
}
} // namespace ledger
diff --git a/src/accum.h b/src/accum.h
index 94e79948..cf74cb74 100644
--- a/src/accum.h
+++ b/src/accum.h
@@ -70,6 +70,8 @@ public:
}
void clear() {
+ std::ostream::clear();
+ buf.pubseekoff(0, ios_base::beg);
buf.str.clear();
buf.index = 0;
}
@@ -79,7 +81,7 @@ public:
}
};
-#define ACCUM(obj) (static_cast<straccstream&>(obj).str())
+#define ACCUM(obj) (static_cast<const straccstream&>(obj).str())
} // namespace ledger
diff --git a/src/error.cc b/src/error.cc
index cfc91ff1..4b3a7786 100644
--- a/src/error.cc
+++ b/src/error.cc
@@ -43,6 +43,7 @@ std::ostringstream _desc_buffer;
string error_context()
{
string context = _ctxt_buffer.str();
+ _ctxt_buffer.clear();
_ctxt_buffer.str("");
return context;
}
diff --git a/src/error.h b/src/error.h
index 0d33f020..b8b011eb 100644
--- a/src/error.h
+++ b/src/error.h
@@ -51,6 +51,7 @@ extern std::ostringstream _desc_buffer;
template <typename T>
inline void throw_func(const string& message) {
+ _desc_buffer.clear();
_desc_buffer.str("");
throw T(message);
}
@@ -62,6 +63,7 @@ inline void throw_func(const string& message) {
inline void warning_func(const string& message) {
std::cerr << "Warning: " << message << std::endl;
+ _desc_buffer.clear();
_desc_buffer.str("");
}
diff --git a/src/interactive.cc b/src/interactive.cc
index 9aeb5307..183a84fd 100644
--- a/src/interactive.cc
+++ b/src/interactive.cc
@@ -143,8 +143,10 @@ void interactive_t::verify_arguments() const
if (wrong_arg && optional && next_arg->is_null())
wrong_arg = false;
- if (wrong_arg)
+ if (wrong_arg) {
vlabel = next_arg->label();
+ break;
+ }
if (! dont_skip) {
if (is_seq) {
diff --git a/src/utils.cc b/src/utils.cc
index c3fecca0..b8acb3db 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -593,6 +593,7 @@ bool logger_func(log_level_t level)
}
*_log_stream << ' ' << _log_buffer.str() << std::endl;
+ _log_buffer.clear();
_log_buffer.str("");
return true;
@@ -663,6 +664,7 @@ void start_timer(const char * name, log_level_t lvl)
(*i).second.begin = TRUE_CURRENT_TIME();
(*i).second.active = true;
}
+ _log_buffer.clear();
_log_buffer.str("");
#if defined(VERIFY_ON)