From 44b511b3c45bc6d6f4beab51ec0f09624845f109 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Wed, 9 Dec 2020 08:02:31 +0800 Subject: [PATCH] [report-utilities] don't use (ice-9 match) until guile-3.0 minimum (match) has a subtle bug which occurs in guile-2.2 causing this function to mishandle the second 'before-date?' conditional. When guile-3.0 is minimum this commit may be reverted. --- gnucash/report/report-utilities.scm | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gnucash/report/report-utilities.scm b/gnucash/report/report-utilities.scm index 5ec7f65f93..f48cbdf94a 100644 --- a/gnucash/report/report-utilities.scm +++ b/gnucash/report/report-utilities.scm @@ -412,24 +412,24 @@ ((date . rest) (define (before-date? s) (<= (to-date s) date)) (define (after-date? s) (< date (to-date s))) - (match splits + (cond - ;; end of splits, but still has dates. pad with last-result - ;; until end of dates. - (() (lp '() rest (cons last-result result) last-result)) + ;; end of splits, but still has dates. pad with last-result + ;; until end of dates. + ((null? splits) (lp '() rest (cons last-result result) last-result)) - ;; the next split is still before date. - ((and (_ (? before-date?) . _) (head . tail)) - (lp tail dates result (split->elt head))) + ;; the next split is still before date. + ((and (pair? (cdr splits)) (before-date? (cadr splits))) + (lp (cdr splits) dates result (split->elt (car splits)))) - ;; head split after date, accumulate previous result - (((? after-date?) . tail) - (lp splits rest (cons last-result result) last-result)) + ;; head split after date, accumulate previous result + ((after-date? (car splits)) + (lp splits rest (cons last-result result) last-result)) - ;; head split before date, next split after date, or end. - ((head . tail) - (let ((head-result (split->elt head))) - (lp tail rest (cons head-result result) head-result)))))))) + ;; head split before date, next split after date, or end. + (else + (let ((head-result (split->elt (car splits)))) + (lp (cdr splits) rest (cons head-result result) head-result)))))))) ;; This works similar as above but returns a commodity-collector, ;; thus takes care of children accounts with different currencies.