summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/annotate.cc2
-rw-r--r--src/error.cc2
-rw-r--r--src/main.cc2
-rw-r--r--src/pyinterp.cc8
-rw-r--r--src/session.cc3
-rw-r--r--src/textual.cc20
-rw-r--r--src/timelog.cc11
-rw-r--r--src/timelog.h14
-rw-r--r--src/token.cc2
-rw-r--r--src/utils.h6
10 files changed, 53 insertions, 17 deletions
diff --git a/src/annotate.cc b/src/annotate.cc
index 093837fe..8ba46f4f 100644
--- a/src/annotate.cc
+++ b/src/annotate.cc
@@ -42,7 +42,7 @@ void annotation_t::parse(std::istream& in)
{
do {
istream_pos_type pos = in.tellg();
- if (pos == -1)
+ if (static_cast<int>(pos) < 0)
return;
char buf[256];
diff --git a/src/error.cc b/src/error.cc
index 39ac63ea..c6309702 100644
--- a/src/error.cc
+++ b/src/error.cc
@@ -51,7 +51,7 @@ string error_context()
string file_context(const path& file, const std::size_t line)
{
std::ostringstream buf;
- buf << "\"" << file << "\", line " << line << ": ";
+ buf << '"' << file.string() << "\", line " << line << ": ";
return buf.str();
}
diff --git a/src/main.cc b/src/main.cc
index ef611f51..820f920d 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -67,7 +67,9 @@ int main(int argc, char * argv[], char * envp[])
// Initialize global Boost/C++ environment
std::ios::sync_with_stdio(false);
+#if BOOST_VERSION < 104600
filesystem::path::default_name_check(filesystem::portable_posix_name);
+#endif
std::signal(SIGINT, sigint_handler);
#ifndef WIN32
diff --git a/src/pyinterp.cc b/src/pyinterp.cc
index 8052f6a4..e0801604 100644
--- a/src/pyinterp.cc
+++ b/src/pyinterp.cc
@@ -137,7 +137,7 @@ void python_interpreter_t::hack_system_paths()
int n = python::extract<int>(paths.attr("__len__")());
for (int i = 0; i < n; i++) {
python::extract<std::string> str(paths[i]);
- path pathname(str);
+ path pathname(str());
DEBUG("python.interp", "sys.path = " << pathname);
if (exists(pathname / "ledger" / "__init__.py")) {
@@ -202,9 +202,15 @@ object python_interpreter_t::import_option(const string& str)
paths.insert(0, file.parent_path().string());
sys_dict["path"] = paths;
+#if BOOST_VERSION >= 104600
+ string name = file.filename().string();
+ if (contains(name, ".py"))
+ name = file.stem().string();
+#else
string name = file.filename();
if (contains(name, ".py"))
name = file.stem();
+#endif
#else // BOOST_VERSION >= 103700
paths.insert(0, file.branch_path().string());
sys_dict["path"] = paths;
diff --git a/src/session.cc b/src/session.cc
index 96aa98d4..fdb0ad1d 100644
--- a/src/session.cc
+++ b/src/session.cc
@@ -129,7 +129,6 @@ std::size_t session_t::read_data(const string& master_account)
buffer.flush();
std::istringstream buf_in(buffer.str());
-
xact_count += journal->read(buf_in, "/dev/stdin", acct);
journal->sources.push_back(journal_t::fileinfo_t());
} else {
@@ -137,6 +136,8 @@ std::size_t session_t::read_data(const string& master_account)
}
}
+ DEBUG("ledger.read", "xact_count [" << xact_count
+ << "] == journal->xacts.size() [" << journal->xacts.size() << "]");
assert(xact_count == journal->xacts.size());
#if defined(HAVE_BOOST_SERIALIZATION)
diff --git a/src/textual.cc b/src/textual.cc
index 5bcbf86b..26de6f9e 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -68,7 +68,9 @@ namespace {
parse_context_t(journal_t& _journal, scope_t& _scope)
: journal(_journal), scope(_scope), timelog(journal, scope),
- strict(false), count(0), errors(0), sequence(1) {}
+ strict(false), count(0), errors(0), sequence(1) {
+ timelog.context_count = &count;
+ }
bool front_is_account() {
return state_stack.front().type() == typeid(account_t *);
@@ -86,6 +88,10 @@ namespace {
return boost::get<account_t *>(state);
return NULL;
}
+
+ void close() {
+ timelog.close();
+ }
};
class instance_t : public noncopyable, public scope_t
@@ -723,7 +729,11 @@ void instance_t::include_directive(char * line)
mask_t glob;
#if BOOST_VERSION >= 103700
path parent_path = filename.parent_path();
+#if BOOST_VERSION >= 104600
+ glob.assign_glob('^' + filename.filename().string() + '$');
+#else
glob.assign_glob('^' + filename.filename() + '$');
+#endif
#else // BOOST_VERSION >= 103700
path parent_path = filename.branch_path();
glob.assign_glob('^' + filename.leaf() + '$');
@@ -742,7 +752,11 @@ void instance_t::include_directive(char * line)
#endif
{
#if BOOST_VERSION >= 103700
+#if BOOST_VERSION >= 104600
+ string base = (*iter).path().string();
+#else
string base = (*iter).filename();
+#endif
#else // BOOST_VERSION >= 103700
string base = (*iter).leaf();
#endif // BOOST_VERSION >= 103700
@@ -1136,7 +1150,7 @@ post_t * instance_t::parse_post(char * line,
if (context.strict && ! post->account->has_flags(ACCOUNT_KNOWN)) {
if (post->_state == item_t::UNCLEARED)
warning_(_("\"%1\", line %2: Unknown account '%3'")
- << pathname << linenum << post->account->fullname());
+ << pathname.string() << linenum << post->account->fullname());
post->account->add_flags(ACCOUNT_KNOWN);
}
@@ -1171,7 +1185,7 @@ post_t * instance_t::parse_post(char * line,
! post->amount.commodity().has_flags(COMMODITY_KNOWN)) {
if (post->_state == item_t::UNCLEARED)
warning_(_("\"%1\", line %2: Unknown commodity '%3'")
- << pathname << linenum << post->amount.commodity());
+ << pathname.string() << linenum << post->amount.commodity());
post->amount.commodity().add_flags(COMMODITY_KNOWN);
}
diff --git a/src/timelog.cc b/src/timelog.cc
index 698e2420..ee9a0b6c 100644
--- a/src/timelog.cc
+++ b/src/timelog.cc
@@ -117,21 +117,22 @@ namespace {
}
} // unnamed namespace
-time_log_t::~time_log_t()
+void time_log_t::close()
{
- TRACE_DTOR(time_log_t);
-
if (! time_xacts.empty()) {
std::list<account_t *> accounts;
foreach (time_xact_t& time_xact, time_xacts)
accounts.push_back(time_xact.account);
- foreach (account_t * account, accounts)
+ foreach (account_t * account, accounts) {
+ DEBUG("timelog", "Clocking out from account " << account->fullname());
clock_out_from_timelog(time_xacts,
time_xact_t(none, CURRENT_TIME(), account),
journal, scope);
-
+ if (context_count)
+ (*context_count)++;
+ }
assert(time_xacts.empty());
}
}
diff --git a/src/timelog.h b/src/timelog.h
index 92b80edc..020ae4f2 100644
--- a/src/timelog.h
+++ b/src/timelog.h
@@ -83,21 +83,27 @@ public:
}
};
-class time_log_t
+class time_log_t : public boost::noncopyable
{
std::list<time_xact_t> time_xacts;
journal_t& journal;
scope_t& scope;
public:
+ std::size_t * context_count;
+
time_log_t(journal_t& _journal, scope_t& _scope)
- : journal(_journal), scope(_scope) {
- TRACE_CTOR(time_log_t, "journal_t&, scope_t&");
+ : journal(_journal), scope(_scope), context_count(NULL) {
+ TRACE_CTOR(time_log_t, "journal_t&, scope_t&, std::size&");
+ }
+ ~time_log_t() {
+ TRACE_DTOR(time_log_t);
}
- ~time_log_t();
void clock_in(time_xact_t event);
void clock_out(time_xact_t event);
+
+ void close();
};
} // namespace ledger
diff --git a/src/token.cc b/src/token.cc
index 7bfaf162..735f5825 100644
--- a/src/token.cc
+++ b/src/token.cc
@@ -402,7 +402,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
assert(in.good());
assert(! in.eof());
- assert(in.tellg() != -1);
+ assert(static_cast<int>(in.tellg()) != -1);
// When in relaxed parsing mode, we want to migrate commodity flags
// so that any precision specified by the user updates the current
diff --git a/src/utils.h b/src/utils.h
index af75514c..ad9b0562 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -92,6 +92,12 @@ namespace ledger {
typedef boost::filesystem::filesystem_error filesystem_error;
}
+#if BOOST_FILESYSTEM_VERSION == 3
+namespace boost { namespace filesystem3 { namespace path_traits {
+template<> struct is_pathable<ledger::string> { static const bool value = true; };
+}}}
+#endif
+
/*@}*/
/**