summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2015-08-06 19:38:39 -0700
committerCraig Earls <enderw88@gmail.com>2015-08-06 19:38:39 -0700
commit0e82bd0d63bd0a6e9a9c77f0ef55e332b357368c (patch)
treefea3628fe67824069641f517a659cd88287ffdfc /src
parent254d82e5eb123feaf87e3f7096a1f8389bac60b3 (diff)
parent3c2d228ddc74b75122b07a87bbd06263092a9661 (diff)
downloadfork-ledger-0e82bd0d63bd0a6e9a9c77f0ef55e332b357368c.tar.gz
fork-ledger-0e82bd0d63bd0a6e9a9c77f0ef55e332b357368c.tar.bz2
fork-ledger-0e82bd0d63bd0a6e9a9c77f0ef55e332b357368c.zip
Merge commit '3c2d228ddc74b75122b07a87bbd06263092a9661' into next
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/account.h6
-rw-r--r--src/emacs.h2
-rw-r--r--src/filters.cc2
-rw-r--r--src/history.cc2
-rw-r--r--src/item.h6
-rw-r--r--src/iterators.cc2
-rw-r--r--src/parser.h2
-rw-r--r--src/pool.h4
-rw-r--r--src/post.h6
-rw-r--r--src/pyinterp.h2
-rw-r--r--src/select.cc2
-rw-r--r--src/session.cc83
-rw-r--r--src/strptime.cc2
-rw-r--r--src/times.h6
-rw-r--r--src/value.cc4
-rw-r--r--src/value.h2
-rw-r--r--src/views.h2
-rw-r--r--src/wcwidth.cc2
19 files changed, 71 insertions, 79 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a368d378..65e58edb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -152,7 +152,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
-Wno-unused-parameter
-Wno-c++98-compat
-fno-limit-debug-info)
-
+
macro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
set(_pch_filename "${_header_filename}.pch")
@@ -188,7 +188,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${_args}
DEPENDS ${_header_filename})
endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
-
+
elseif(CMAKE_CXX_COMPILER MATCHES "g\\+\\+")
set(GXX_WARNING_FLAGS
-pedantic
@@ -210,7 +210,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
-Wno-strict-aliasing)
add_definitions(${GXX_WARNING_FLAGS})
-
+
macro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
set(_gch_filename "${_header_filename}.gch")
@@ -247,7 +247,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${_args}
DEPENDS ${_header_filename})
endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
-
+
else()
macro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
@@ -273,6 +273,9 @@ if (BUILD_LIBRARY)
add_executable(ledger main.cc global.cc)
target_link_libraries(ledger libledger)
+ if (CMAKE_SYSTEM_NAME STREQUAL Darwin AND HAVE_BOOST_PYTHON)
+ target_link_libraries(ledger ${PYTHON_LIBRARIES})
+ endif()
install(TARGETS libledger DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${LEDGER_INCLUDES}
@@ -294,7 +297,7 @@ print(s.get_python_lib(True, prefix=''))"
if (PYTHON_SITE_PACKAGES)
if (WIN32 AND NOT CYGWIN)
set(_ledger_python_module_name "ledger.pyd")
- elseif(CMAKE_HOST_APPLE)
+ elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(_ledger_python_module_name "ledger.so")
else()
set(_ledger_python_module_name "ledger${CMAKE_SHARED_LIBRARY_SUFFIX}")
diff --git a/src/account.h b/src/account.h
index 7fae93e1..7de4e560 100644
--- a/src/account.h
+++ b/src/account.h
@@ -261,11 +261,7 @@ public:
mutable optional<xdata_t> xdata_;
bool has_xdata() const {
-#if BOOST_VERSION >= 105600
- return xdata_ != NULL;
-#else
- return xdata_;
-#endif
+ return static_cast<bool>(xdata_);
}
void clear_xdata();
xdata_t& xdata() {
diff --git a/src/emacs.h b/src/emacs.h
index fef7a882..b89ce9f4 100644
--- a/src/emacs.h
+++ b/src/emacs.h
@@ -72,7 +72,7 @@ public:
out.flush();
}
virtual void operator()(post_t& post);
- virtual string escape_string(string raw);
+ virtual string escape_string(string raw);
};
} // namespace ledger
diff --git a/src/filters.cc b/src/filters.cc
index 2f97a0e5..b6530c04 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -707,7 +707,7 @@ namespace {
insert_prices_in_map(price_map_t& _all_prices)
: all_prices(_all_prices) {}
- void operator()(datetime_t& date, const amount_t& price) {
+ void operator()(const datetime_t& date, const amount_t& price) {
all_prices.insert(price_map_t::value_type(date, price));
}
};
diff --git a/src/history.cc b/src/history.cc
index e3c459f3..8772d18c 100644
--- a/src/history.cc
+++ b/src/history.cc
@@ -475,7 +475,7 @@ commodity_history_impl_t::find_price(const commodity_t& source,
#endif
vertex_descriptor v = tv;
- for (vertex_descriptor u = predecessorMap[v];
+ for (vertex_descriptor u = predecessorMap[v];
u != v;
v = u, u = predecessorMap[v])
{
diff --git a/src/item.h b/src/item.h
index ba812175..dbba53a8 100644
--- a/src/item.h
+++ b/src/item.h
@@ -174,11 +174,7 @@ public:
static bool use_aux_date;
virtual bool has_date() const {
-#if BOOST_VERSION >= 105600
- return _date != NULL;
-#else
- return _date;
-#endif
+ return static_cast<bool>(_date);
}
virtual date_t date() const {
diff --git a/src/iterators.cc b/src/iterators.cc
index 21bec5d9..0225e210 100644
--- a/src/iterators.cc
+++ b/src/iterators.cc
@@ -96,7 +96,7 @@ namespace {
TRACE_DTOR(create_price_xact);
}
- void operator()(datetime_t& date, const amount_t& price) {
+ void operator()(const datetime_t& date, const amount_t& price) {
xact_t * xact;
string symbol = price.commodity().symbol();
diff --git a/src/parser.h b/src/parser.h
index e46fc719..25c4a7e3 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -118,7 +118,7 @@ public:
ptr_op_t parse(std::istream& in,
const parse_flags_t& flags = PARSE_DEFAULT,
- const optional<string>& original_string = NULL);
+ const optional<string>& original_string = boost::none);
};
} // namespace ledger
diff --git a/src/pool.h b/src/pool.h
index 2e9d93f1..fcc54b86 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -78,8 +78,8 @@ public:
commodity_t * default_commodity;
bool keep_base; // --base
- optional<path> price_db; // --price-db=
- long quote_leeway; // --leeway=
+ optional<path> price_db; // --price-db=
+ long quote_leeway; // --leeway=
bool get_quotes; // --download
function<optional<price_point_t>
diff --git a/src/post.h b/src/post.h
index 0fb45e90..5f22fa3c 100644
--- a/src/post.h
+++ b/src/post.h
@@ -205,11 +205,7 @@ public:
mutable optional<xdata_t> xdata_;
bool has_xdata() const {
-#if BOOST_VERSION >= 105600
- return xdata_ != NULL;
-#else
- return xdata_;
-#endif
+ return static_cast<bool>(xdata_);
}
void clear_xdata() {
xdata_ = none;
diff --git a/src/pyinterp.h b/src/pyinterp.h
index 32becbf6..fe86573a 100644
--- a/src/pyinterp.h
+++ b/src/pyinterp.h
@@ -77,7 +77,7 @@ public:
if (name != "__main__")
main_module->define_global(name, mod->module_object);
return mod;
- }
+ }
python_interpreter_t() : session_t(), is_initialized(false) {
TRACE_CTOR(python_interpreter_t, "");
diff --git a/src/select.cc b/src/select.cc
index 81800f16..1141df04 100644
--- a/src/select.cc
+++ b/src/select.cc
@@ -396,7 +396,7 @@ value_t select_command(call_scope_t& args)
#if 0
query_t query;
keep_details_t keeper(true, true, true);
- expr_t::ptr_op_t expr =
+ expr_t::ptr_op_t expr =
query.parse_args(string_value(arg).to_sequence(), keeper, false, true);
report.HANDLER(limit_).on("#select", query.get_query(query_t::QUERY_LIMIT));
#else
diff --git a/src/session.cc b/src/session.cc
index 7736023d..b4fb4eb8 100644
--- a/src/session.cc
+++ b/src/session.cc
@@ -127,47 +127,14 @@ std::size_t session_t::read_data(const string& master_account)
if (HANDLED(value_expr_))
journal->value_expr = HANDLER(value_expr_).str();
- if (price_db_path) {
- if (exists(*price_db_path)) {
- parsing_context.push(*price_db_path);
- parsing_context.get_current().journal = journal.get();
- try {
- if (journal->read(parsing_context) > 0)
- throw_(parse_error, _("Transactions not allowed in price history file"));
- }
- catch (...) {
- parsing_context.pop();
- throw;
- }
- parsing_context.pop();
- }
- }
-
- foreach (const path& pathname, HANDLER(file_).data_files) {
- if (pathname == "-" || pathname == "/dev/stdin") {
- // To avoid problems with stdin and pipes, etc., we read the entire
- // file in beforehand into a memory buffer, and then parcel it out
- // from there.
- std::ostringstream buffer;
-
- while (std::cin.good() && ! std::cin.eof()) {
- char line[8192];
- std::cin.read(line, 8192);
- std::streamsize count = std::cin.gcount();
- buffer.write(line, count);
- }
- buffer.flush();
-
- shared_ptr<std::istream> stream(new std::istringstream(buffer.str()));
- parsing_context.push(stream);
- } else {
- parsing_context.push(pathname);
- }
+ if (price_db_path) {
+ if (exists(*price_db_path)) {
+ parsing_context.push(*price_db_path);
parsing_context.get_current().journal = journal.get();
- parsing_context.get_current().master = acct;
try {
- xact_count += journal->read(parsing_context);
+ if (journal->read(parsing_context) > 0)
+ throw_(parse_error, _("Transactions not allowed in price history file"));
}
catch (...) {
parsing_context.pop();
@@ -175,10 +142,44 @@ std::size_t session_t::read_data(const string& master_account)
}
parsing_context.pop();
}
+ }
+
+ foreach (const path& pathname, HANDLER(file_).data_files) {
+ if (pathname == "-" || pathname == "/dev/stdin") {
+ // To avoid problems with stdin and pipes, etc., we read the entire
+ // file in beforehand into a memory buffer, and then parcel it out
+ // from there.
+ std::ostringstream buffer;
+
+ while (std::cin.good() && ! std::cin.eof()) {
+ char line[8192];
+ std::cin.read(line, 8192);
+ std::streamsize count = std::cin.gcount();
+ buffer.write(line, count);
+ }
+ buffer.flush();
+
+ shared_ptr<std::istream> stream(new std::istringstream(buffer.str()));
+ parsing_context.push(stream);
+ } else {
+ parsing_context.push(pathname);
+ }
+
+ parsing_context.get_current().journal = journal.get();
+ parsing_context.get_current().master = acct;
+ try {
+ xact_count += journal->read(parsing_context);
+ }
+ catch (...) {
+ parsing_context.pop();
+ throw;
+ }
+ parsing_context.pop();
+ }
- DEBUG("ledger.read", "xact_count [" << xact_count
- << "] == journal->xacts.size() [" << journal->xacts.size() << "]");
- assert(xact_count == journal->xacts.size());
+ DEBUG("ledger.read", "xact_count [" << xact_count
+ << "] == journal->xacts.size() [" << journal->xacts.size() << "]");
+ assert(xact_count == journal->xacts.size());
if (populated_data_files)
HANDLER(file_).data_files.clear();
diff --git a/src/strptime.cc b/src/strptime.cc
index b64af96b..b31954f4 100644
--- a/src/strptime.cc
+++ b/src/strptime.cc
@@ -85,7 +85,7 @@ static char* _strptime(const char *s, const char *format, struct tm *tm) {
if (tm->tm_wday == -1) return NULL;
s += len;
break;
-
+
// month name.
case 'b':
case 'B':
diff --git a/src/times.h b/src/times.h
index 421d1462..e1a9e847 100644
--- a/src/times.h
+++ b/src/times.h
@@ -500,11 +500,7 @@ public:
void stabilize(const optional<date_t>& date = none);
bool is_valid() const {
-#if BOOST_VERSION >= 105600
- return start != NULL;
-#else
- return start;
-#endif
+ return static_cast<bool>(start);
}
/** Find the current or next period containing date. Returns false if
diff --git a/src/value.cc b/src/value.cc
index 2737add9..4ea7c7a8 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -341,6 +341,10 @@ value_t& value_t::operator+=(const value_t& val)
}
switch (type()) {
+ case VOID:
+ *this = value_t(val);
+ return *this;
+
case DATETIME:
switch (val.type()) {
case INTEGER:
diff --git a/src/value.h b/src/value.h
index 810d34f9..c9084e03 100644
--- a/src/value.h
+++ b/src/value.h
@@ -435,7 +435,7 @@ public:
return temp;
}
void in_place_roundto(int places);
-
+
value_t truncated() const {
value_t temp(*this);
temp.in_place_truncate();
diff --git a/src/views.h b/src/views.h
index 2be3d978..603b28da 100644
--- a/src/views.h
+++ b/src/views.h
@@ -235,7 +235,7 @@ public:
optional<string> note() const {
return ptr()->note;
}
-
+
bool has_tag(const string& tag) const {
return ptr()->has_tag(tag);
}
diff --git a/src/wcwidth.cc b/src/wcwidth.cc
index c23f83d7..75cd76be 100644
--- a/src/wcwidth.cc
+++ b/src/wcwidth.cc
@@ -195,7 +195,7 @@ int mk_wcwidth(boost::uint32_t ucs)
/* if we arrive here, ucs is not a combining or C0/C1 control character */
- return 1 +
+ return 1 +
(ucs >= 0x1100 &&
(ucs <= 0x115f || /* Hangul Jamo init. consonants */
ucs == 0x2329 || ucs == 0x232a ||