diff options
-rw-r--r-- | README | 4 | ||||
-rwxr-xr-x | acprep | 2 | ||||
-rw-r--r-- | amount.cc | 3 | ||||
-rw-r--r-- | binary.cc | 4 | ||||
-rw-r--r-- | config.cc | 2 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | configure.lt | 4 | ||||
-rw-r--r-- | format.cc | 3 | ||||
-rw-r--r-- | ledger.el | 24 | ||||
-rw-r--r-- | main.cc | 3 | ||||
-rw-r--r-- | parser.cc | 2 | ||||
-rw-r--r-- | walk.cc | 16 | ||||
-rw-r--r-- | walk.h | 6 |
13 files changed, 52 insertions, 25 deletions
@@ -37,7 +37,7 @@ Mailing List and IRC ==================== If you need help on how to use Ledger, or run into problems, you can -just the Ledger mailing list at the following Web address: +join the Ledger mailing list at the following Web address: https://lists.sourceforge.net/lists/listinfo/ledger-discuss @@ -54,4 +54,4 @@ passed to the configure script. This means you can interact with your Ledger data from Python, making it easy to write custom reports. This feature is mostly undocumented in version 2.0, although main.py -is offered as a working example. +is a working example. @@ -29,7 +29,7 @@ elif [ "$1" = "--flat-opt" ]; then CXXFLAGS="-fomit-frame-pointer -fastf -mcpu=7450" elif [ "$1" = "--safe-opt" ]; then ./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" \ - CXXFLAGS="-fomit-frame-pointer -fastf -mcpu=7450 -DDEBUG_LEVEL=1" \ + CXXFLAGS="-fomit-frame-pointer -fastf -mcpu=7450 -fPIC -DDEBUG_LEVEL=1" \ --enable-python elif [ "$1" = "--perf" ]; then ./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" CXXFLAGS="-g -pg" @@ -620,6 +620,9 @@ std::string amount_t::quantity_string() const } mpz_set(rquotient, remainder); + if (mpz_sgn(quotient) == 0 && mpz_sgn(rquotient) == 0) + return "0"; + if (negative) out << "-"; @@ -371,7 +371,7 @@ unsigned int read_binary_journal(std::istream& in, // Read in the accounts account_t::ident_t a_count = read_binary_number<account_t::ident_t>(data); - accounts = accounts_next = new (account_t *)[a_count]; + accounts = accounts_next = new account_t *[a_count]; journal->master = read_binary_account(data, master); // Allocate the memory needed for the entries and transactions in @@ -400,7 +400,7 @@ unsigned int read_binary_journal(std::istream& in, // Read in the commodities commodity_t::ident_t c_count = read_binary_number<commodity_t::ident_t>(data); - commodities = commodities_next = new (commodity_t *)[c_count]; + commodities = commodities_next = new commodity_t *[c_count]; for (commodity_t::ident_t i = 0; i < c_count; i++) { commodity_t * commodity = read_binary_commodity(data); std::pair<commodities_map::iterator, bool> result @@ -11,6 +11,8 @@ #include <cstdlib> #ifdef WIN32 #include <io.h> +#else +#include <unistd.h> #endif namespace ledger { diff --git a/configure.in b/configure.in index 4d568016..ea5881e0 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(ledger, 2.0, johnw@newartisans.com) -AM_INIT_AUTOMAKE(ledger, 2.0) +AC_INIT(ledger, 2.02, johnw@newartisans.com) +AM_INIT_AUTOMAKE(ledger, 2.02) AC_CONFIG_SRCDIR([main.cc]) AC_CONFIG_HEADER([acconf.h]) diff --git a/configure.lt b/configure.lt index 2eedb0e4..59a3406b 100644 --- a/configure.lt +++ b/configure.lt @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(ledger, 2.0, johnw@newartisans.com) -AM_INIT_AUTOMAKE(ledger, 2.0) +AC_INIT(ledger, 2.02, johnw@newartisans.com) +AM_INIT_AUTOMAKE(ledger, 2.02) AC_CONFIG_SRCDIR([main.cc]) AC_CONFIG_HEADER([acconf.h]) @@ -682,8 +682,7 @@ void print_entry(std::ostream& out, const entry_t& entry) formatter); formatter.flush(); - clear_transactions_xdata(); - clear_accounts_xdata(); + clear_all_xdata(); } bool disp_subaccounts_p(const account_t& account, @@ -92,12 +92,25 @@ mark desc))))) (forward-line)))) +(defun ledger-time-less-p (t1 t2) + "Say whether time value T1 is less than time value T2." + (or (< (car t1) (car t2)) + (and (= (car t1) (car t2)) + (< (nth 1 t1) (nth 1 t2))))) + +(defun ledger-time-subtract (t1 t2) + "Subtract two time values. +Return the difference in the format of a time value." + (let ((borrow (< (cadr t1) (cadr t2)))) + (list (- (car t1) (car t2) (if borrow 1 0)) + (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2))))) + (defun ledger-find-slot (moment) (catch 'found (ledger-iterate-entries (function (lambda (start date mark desc) - (if (time-less-p moment date) + (if (ledger-time-less-p moment date) (throw 'found t))))))) (defun ledger-add-entry (entry-text) @@ -159,6 +172,8 @@ (shell-command (format "%s -f %s %s" ledger-binary-path buffer-file-name command))) +(defvar ledger-mode-abbrev-table) + (define-derived-mode ledger-mode text-mode "Ledger" "A mode for editing ledger data files." (set (make-local-variable 'comment-start) ";") @@ -179,7 +194,7 @@ (function (lambda (start date mark desc) (when (and (or all-p (not mark)) - (time-less-p after-date date)) + (ledger-time-less-p after-date date)) (forward-line) (setq total 0.0) (while (looking-at @@ -202,6 +217,7 @@ entries)) (defvar ledger-reconcile-text "Reconcile") +(defvar ledger-reconcile-mode-abbrev-table) (define-derived-mode ledger-reconcile-mode text-mode 'ledger-reconcile-text "A mode for reconciling ledger entries." @@ -256,8 +272,8 @@ (defun ledger-reconcile (account &optional days) (interactive "sAccount to reconcile: \nnBack how far (default 30 days): ") - (let* ((then (time-subtract (current-time) - (seconds-to-time (* (or days 30) 24 60 60)))) + (let* ((then (ledger-time-subtract + (current-time) (seconds-to-time (* (or days 30) 24 60 60)))) (items (save-excursion (goto-char (point-min)) (ledger-parse-entries account t then))) @@ -382,8 +382,7 @@ def vmax(d, val):\n\ #if DEBUG_LEVEL >= BETA - clear_transactions_xdata(); - clear_accounts_xdata(); + clear_all_xdata(); if (! config.output_file.empty()) delete out; @@ -4,6 +4,8 @@ #include <fstream> #ifdef WIN32 #include <io.h> +#else +#include <unistd.h> #endif namespace ledger { @@ -342,28 +342,27 @@ void interval_transactions::report_subtotal(const std::time_t moment) void interval_transactions::operator()(transaction_t& xact) { - if ((interval.begin && - std::difftime(xact.entry->date, interval.begin) < 0) || - (interval.end && - std::difftime(xact.entry->date, interval.end) >= 0)) + const std::time_t date = xact.entry->date; + + if ((interval.begin && std::difftime(date, interval.begin) < 0) || + (interval.end && std::difftime(date, interval.end) >= 0)) return; if (interval) { if (! started) { if (! interval.begin) - interval.start(xact.entry->date); + interval.start(date); start = interval.begin; started = true; } std::time_t quant = interval.increment(interval.begin); - if (std::difftime(xact.entry->date, quant) >= 0) { + if (std::difftime(date, quant) >= 0) { if (last_xact) report_subtotal(quant); std::time_t temp; - while (std::difftime(xact.entry->date, - temp = interval.increment(quant)) >= 0) { + while (std::difftime(date, temp = interval.increment(quant)) >= 0) { if (quant == temp) break; quant = temp; @@ -1077,6 +1076,7 @@ void export_walk() def("account_has_xdata", account_has_xdata); def("account_xdata", account_xdata, return_internal_reference<1>()); def("clear_accounts_xdata", clear_accounts_xdata); + def("clear_all_xdata", clear_all_xdata); class_< account_handler_t, item_handler_wrap<account_t> > ("AccountHandler") @@ -568,8 +568,14 @@ void walk_accounts(account_t& account, void walk_accounts(account_t& account, item_handler<account_t>& handler, const std::string& sort_string); + void clear_accounts_xdata(); +inline void clear_all_xdata() { + clear_transactions_xdata(); + clear_accounts_xdata(); +} + ////////////////////////////////////////////////////////////////////// void walk_commodities(commodities_map& commodities, |