gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Sun Nov 1 20:11:41 EST 2020
Updated via https://github.com/Gnucash/gnucash/commit/e7a3ec56 (commit)
via https://github.com/Gnucash/gnucash/commit/7e6cb470 (commit)
via https://github.com/Gnucash/gnucash/commit/8628ffa9 (commit)
via https://github.com/Gnucash/gnucash/commit/6637d6d2 (commit)
via https://github.com/Gnucash/gnucash/commit/a10c0840 (commit)
via https://github.com/Gnucash/gnucash/commit/25e4efc2 (commit)
from https://github.com/Gnucash/gnucash/commit/5ced4174 (commit)
commit e7a3ec56318d8a6a7cdcae4cfc618de3b1863847
Merge: 5ced41746 7e6cb470f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Nov 2 09:08:53 2020 +0800
Merge branch 'maint-797989' into maint #807
* Introduce gnc:string-locale<? and gnc:string-locale>?
* Deprecates a few engine.scm functions
* Fix sorting to be locale-sensitive where possible
commit 7e6cb470f160b55c694a6676a594774c25fb3d1b
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Oct 27 21:51:00 2020 +0800
Bug 797989 - Sorting columns by alphabet with non-ASCII characters
use gnc:string-locale for string sorting
diff --git a/gnucash/gnome/report-menus.scm b/gnucash/gnome/report-menus.scm
index c230ed08e..4eb08fa28 100644
--- a/gnucash/gnome/report-menus.scm
+++ b/gnucash/gnome/report-menus.scm
@@ -65,7 +65,7 @@
(gnc-main-window-open-report
(gnc:make-report report-guid) window))))))
(sort (filter (compose gnc:report-template-in-menu? cdr) *template-items*)
- (lambda (a b) (string>? (car a) (car b))))))
+ (lambda (a b) (gnc:string-locale>? (car a) (car b))))))
(define (gnc:report-menu-setup)
(define asset-liability-menu
diff --git a/gnucash/import-export/qif-imp/qif-dialog-utils.scm b/gnucash/import-export/qif-imp/qif-dialog-utils.scm
index ad6aa53f9..abddb2e84 100644
--- a/gnucash/import-export/qif-imp/qif-dialog-utils.scm
+++ b/gnucash/import-export/qif-imp/qif-dialog-utils.scm
@@ -412,8 +412,8 @@
(set! retval
(sort retval
(lambda (a b)
- (string<? (qif-map-entry:qif-name a)
- (qif-map-entry:qif-name b)))))
+ (gnc:string-locale<? (qif-map-entry:qif-name a)
+ (qif-map-entry:qif-name b)))))
retval))
@@ -532,8 +532,8 @@
;; sort by qif account name
(set! retval (sort retval
(lambda (a b)
- (string<? (qif-map-entry:qif-name a)
- (qif-map-entry:qif-name b)))))
+ (gnc:string-locale<? (qif-map-entry:qif-name a)
+ (qif-map-entry:qif-name b)))))
retval))
;; this one's like the other display builders, it just looks at the
@@ -624,8 +624,8 @@
;; sort by qif memo/payee name
(set! retval (sort retval
(lambda (a b)
- (string<? (qif-map-entry:qif-name a)
- (qif-map-entry:qif-name b)))))
+ (gnc:string-locale<? (qif-map-entry:qif-name a)
+ (qif-map-entry:qif-name b)))))
retval))
@@ -826,7 +826,7 @@
#f acct-hash)
(if (not (null? names))
- (sort names string<?)
+ (sort names gnc:string-locale<?)
#f)))
;; this is used within the dialog to get a list of all the new
@@ -867,7 +867,7 @@
(loop (car tree-left) (cdr tree-left))
(set! newtree (cons (cvt-to-tree path new?)
newtree))))))
- (sort newtree (lambda (a b) (string<? (car a) (car b))))))))
+ (sort newtree (lambda (a b) (gnc:string-locale<? (car a) (car b))))))))
(let ((accts '())
diff --git a/gnucash/report/html-acct-table.scm b/gnucash/report/html-acct-table.scm
index 7871e4581..ae18decef 100644
--- a/gnucash/report/html-acct-table.scm
+++ b/gnucash/report/html-acct-table.scm
@@ -528,14 +528,14 @@
;; some useful predicates to export
(define (gnc:account-code-less-p a b)
- (string<? (xaccAccountGetCode a)
- (xaccAccountGetCode b)))
+ (gnc:string-locale<? (xaccAccountGetCode a)
+ (xaccAccountGetCode b)))
(define (gnc:account-name-less-p a b)
- (string<? (xaccAccountGetName a)
- (xaccAccountGetName b)))
+ (gnc:string-locale<? (xaccAccountGetName a)
+ (xaccAccountGetName b)))
(define (gnc:account-path-less-p a b)
- (string<? (gnc-account-get-full-name a)
- (gnc-account-get-full-name b)))
+ (gnc:string-locale<? (gnc-account-get-full-name a)
+ (gnc-account-get-full-name b)))
(define (gnc:html-acct-table-add-accounts! acct-table accounts)
diff --git a/gnucash/report/html-style-sheet.scm b/gnucash/report/html-style-sheet.scm
index afd3322d9..1d0d4dff0 100644
--- a/gnucash/report/html-style-sheet.scm
+++ b/gnucash/report/html-style-sheet.scm
@@ -201,14 +201,14 @@
(define (gnc:get-html-style-sheets)
(sort (map cdr (hash-map->list cons *gnc:_style-sheets_*))
(lambda (a b)
- (string<? (gnc:html-style-sheet-name a)
- (gnc:html-style-sheet-name b)))))
+ (gnc:string-locale<? (gnc:html-style-sheet-name a)
+ (gnc:html-style-sheet-name b)))))
(define (gnc:get-html-templates)
(sort (map cdr (hash-map->list cons *gnc:_style-sheet-templates_*))
(lambda (a b)
- (string<? (gnc:html-style-sheet-template-name a)
- (gnc:html-style-sheet-template-name b)))))
+ (gnc:string-locale<? (gnc:html-style-sheet-template-name a)
+ (gnc:html-style-sheet-template-name b)))))
(define (gnc:html-style-sheet-find tname)
(hash-ref *gnc:_style-sheets_* tname))
diff --git a/gnucash/report/report-core.scm b/gnucash/report/report-core.scm
index fe596f568..649bdc1b3 100644
--- a/gnucash/report/report-core.scm
+++ b/gnucash/report/report-core.scm
@@ -777,7 +777,8 @@ not found.")))
(lambda (k v p) (if (gnc:report-template-in-menu? v) (cons v p) p))
'() *gnc:_report-templates_*)
(lambda (a b)
- (string<? (gnc:report-template-name a) (gnc:report-template-name b))))))
+ (gnc:string-locale<? (gnc:report-template-name a)
+ (gnc:report-template-name b))))))
(define-public (gnc:cmdline-report-show report port)
(let ((templates (reportname->templates report)))
diff --git a/gnucash/report/report-utilities.scm b/gnucash/report/report-utilities.scm
index 405af4d02..d3eb1d69d 100644
--- a/gnucash/report/report-utilities.scm
+++ b/gnucash/report/report-utilities.scm
@@ -138,8 +138,8 @@
(sort-and-delete-duplicates
(map xaccAccountGetCommodity accounts)
(lambda (a b)
- (string<? (gnc-commodity-get-unique-name a)
- (gnc-commodity-get-unique-name b)))
+ (gnc:string-locale<? (gnc-commodity-get-unique-name a)
+ (gnc-commodity-get-unique-name b)))
gnc-commodity-equiv)))
diff --git a/gnucash/report/reports/standard/account-piecharts.scm b/gnucash/report/reports/standard/account-piecharts.scm
index 19d30067d..42f4a4669 100644
--- a/gnucash/report/reports/standard/account-piecharts.scm
+++ b/gnucash/report/reports/standard/account-piecharts.scm
@@ -209,12 +209,12 @@ balance at a given time"))
(cond
((eq? sort-method 'acct-code)
(lambda (a b)
- (string<? (xaccAccountGetCode (cadr a))
- (xaccAccountGetCode (cadr b)))))
+ (gnc:string-locale<? (xaccAccountGetCode (cadr a))
+ (xaccAccountGetCode (cadr b)))))
((eq? sort-method 'alphabetical)
(lambda (a b)
- (string<? (display-name-accounts show-fullname? (cadr a))
- (display-name-accounts show-fullname? (cadr b)))))
+ (gnc:string-locale<? (display-name-accounts show-fullname? (cadr a))
+ (display-name-accounts show-fullname? (cadr b)))))
(else
(lambda (a b) (> (car a) (car b))))))
@@ -223,12 +223,12 @@ balance at a given time"))
(cond
((eq? sort-method 'acct-code)
(lambda (a b)
- (string<? (gnc-commodity-get-mnemonic (cadr a))
- (gnc-commodity-get-mnemonic (cadr b)))))
+ (gnc:string-locale<? (gnc-commodity-get-mnemonic (cadr a))
+ (gnc-commodity-get-mnemonic (cadr b)))))
((eq? sort-method 'alphabetical)
(lambda (a b)
- (string<? (display-name-security show-fullname? (cadr a))
- (display-name-security show-fullname? (cadr b)))))
+ (gnc:string-locale<? (display-name-security show-fullname? (cadr a))
+ (display-name-security show-fullname? (cadr b)))))
(else
(lambda (a b) (> (car a) (car b))))))
diff --git a/gnucash/report/reports/standard/category-barchart.scm b/gnucash/report/reports/standard/category-barchart.scm
index a8523b2e4..fc85be08c 100644
--- a/gnucash/report/reports/standard/category-barchart.scm
+++ b/gnucash/report/reports/standard/category-barchart.scm
@@ -479,14 +479,14 @@ developing over time"))
((alphabetical)
(lambda (a b)
(if show-fullname?
- (string<? (gnc-account-get-full-name (car a))
- (gnc-account-get-full-name (car b)))
- (string<? (xaccAccountGetName (car a))
- (xaccAccountGetName (car b))))))
+ (gnc:string-locale<? (gnc-account-get-full-name (car a))
+ (gnc-account-get-full-name (car b)))
+ (gnc:string-locale<? (xaccAccountGetName (car a))
+ (xaccAccountGetName (car b))))))
((acct-code)
(lambda (a b)
- (string<? (xaccAccountGetCode (car a))
- (xaccAccountGetCode (car b)))))
+ (gnc:string-locale<? (xaccAccountGetCode (car a))
+ (xaccAccountGetCode (car b)))))
((amount)
(lambda (a b)
(> (gnc:gnc-monetary-amount (apply gnc:monetary+ (cadr a)))
diff --git a/gnucash/report/reports/standard/customer-summary.scm b/gnucash/report/reports/standard/customer-summary.scm
index d89986e65..1f2f9aa0e 100644
--- a/gnucash/report/reports/standard/customer-summary.scm
+++ b/gnucash/report/reports/standard/customer-summary.scm
@@ -406,7 +406,9 @@
;; Stable-sort the sortingtable according to column, then
;; stable-sort according to currency. This results in group-by
;; currency then sort by columns.
- (let* ((str-op (if (eq? sort-order 'descend) string>? string<?))
+ (let* ((str-op (if (eq? sort-order 'descend)
+ gnc:string-locale>?
+ gnc:string-locale<?))
(op (if (eq? sort-order 'descend) > <)))
(define (<? key)
(case key
@@ -421,7 +423,7 @@
(else (str-op (vector-ref a 0) (vector-ref b 0))))))
;; currency sorting always alphabetical a-z
((currency)
- (lambda (a b) (string<?
+ (lambda (a b) (gnc:string-locale<?
(gnc-commodity-get-mnemonic (vector-ref a 1))
(gnc-commodity-get-mnemonic (vector-ref b 1)))))
((markup)
diff --git a/gnucash/report/reports/standard/new-aging.scm b/gnucash/report/reports/standard/new-aging.scm
index fadfb6864..f983a680c 100644
--- a/gnucash/report/reports/standard/new-aging.scm
+++ b/gnucash/report/reports/standard/new-aging.scm
@@ -218,7 +218,7 @@ exist but have no suitable transactions."))
(match-let* (((own1 aging1 aging-total1) a)
((own2 aging2 aging-total2) b)
(increasing? (eq? sort-order 'increasing))
- (op-str (if increasing? string<? string>?))
+ (op-str (if increasing? gnc:string-locale<? gnc:string-locale>?))
(op-num (if increasing? < >)))
(case sort-by
((name) (op-str (gncOwnerGetName own1) (gncOwnerGetName own2)))
diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm
index 894505083..5e6d5fe0e 100644
--- a/gnucash/report/trep-engine.scm
+++ b/gnucash/report/trep-engine.scm
@@ -2089,7 +2089,7 @@ warning will be removed in GnuCash 5.0"))
(value-of-X (comparator-function split-X))
(value-of-Y (comparator-function split-Y))
(op (if (string? value-of-X)
- (if ascend? string<? string>?)
+ (if ascend? gnc:string-locale<? gnc:string-locale>?)
(if ascend? < >))))
(and value-of-X (op value-of-X value-of-Y))))
@@ -2245,7 +2245,7 @@ warning will be removed in GnuCash 5.0"))
(when subtotal-table?
(let* ((generic<?
(lambda (a b)
- (cond ((string? (car a)) (string<? (car a) (car b)))
+ (cond ((string? (car a)) (gnc:string-locale<? (car a) (car b)))
((number? (car a)) (< (car a) (car b)))
(else (gnc:error "unknown sortvalue")))))
(list-of-rows
commit 8628ffa957b0e9446a6ff62df2cfd949a2107172
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Oct 30 19:54:06 2020 +0800
3/3 [engine.scm] deprecate scheme utility functions
diff --git a/bindings/guile/engine.scm b/bindings/guile/engine.scm
index da91cf47c..6b74ed3b5 100644
--- a/bindings/guile/engine.scm
+++ b/bindings/guile/engine.scm
@@ -81,20 +81,24 @@
;; A few account related utility functions which used to be in engine-utilities.scm
(define (gnc:account-map-descendants thunk account)
+ (issue-deprecation-warning "gnc:account-map-descendants is deprecated.")
(let ((descendants (or (gnc-account-get-descendants-sorted account) '())))
(map thunk descendants)))
(define (gnc:account-map-children thunk account)
+ (issue-deprecation-warning "gnc:account-map-children is deprecated.")
(let ((children (or (gnc-account-get-children-sorted account) '())))
(map thunk children)))
;; account related functions
;; helper for sorting of account list
(define (account-full-name<? a b)
+ (issue-deprecation-warning "account-full-name<? is deprecated. use gnc:account-full-name<? instead.")
(string<? (gnc-account-get-full-name a) (gnc-account-get-full-name b)))
;; return maximum depth over accounts and their children, if any
(define (accounts-get-children-depth accounts)
+ (issue-deprecation-warning "accounts-get-children-depth is deprecated. use gnc:accounts-get-children-depth instead.")
(apply max
(map (lambda (acct)
(let ((acct-depth (gnc-account-get-current-depth acct)))
commit 6637d6d2101c1113a001fbf8d4f0fad1fc5f51c9
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Oct 30 19:53:49 2020 +0800
2/3 [taxtxf] inline single-use scheme function from engine.scm
diff --git a/gnucash/report/reports/locale-specific/de_DE/taxtxf.scm b/gnucash/report/reports/locale-specific/de_DE/taxtxf.scm
index cd2fd5faf..7048ee854 100644
--- a/gnucash/report/reports/locale-specific/de_DE/taxtxf.scm
+++ b/gnucash/report/reports/locale-specific/de_DE/taxtxf.scm
@@ -471,9 +471,8 @@
(txf-special-split? (gnc:account-get-txf-code account)))
(+ gen 1) ; Est Fed Tax has a extra generation
gen) ; no kids, return input
- (apply max (gnc:account-map-children
- (lambda (x) (num-generations x (+ 1 gen)))
- account))))
+ (apply max (map (lambda (x) (num-generations x (1+ gen)))
+ (or (gnc-account-get-children-sorted account) '())))))
(gnc:report-starting reportname)
(let* ((from-value (gnc:date-option-absolute-time
commit a10c084022bca8e47755ebe50eccbfd0fca1b298
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Oct 30 19:52:42 2020 +0800
1/3 [report-utilities][API] copy funcs engine.scm to report-utilities.scm
The following copied from similarly named functions in libgnucash
gnc:account-full-name<?
gnc:accounts-get-children-depth
diff --git a/gnucash/report/report-utilities.scm b/gnucash/report/report-utilities.scm
index 2571a52df..405af4d02 100644
--- a/gnucash/report/report-utilities.scm
+++ b/gnucash/report/report-utilities.scm
@@ -56,6 +56,18 @@
(let ((type (xaccAccountGetType account)))
(member type (list ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL))))
+;; account related functions
+;; helper for sorting of account list
+(define (gnc:account-full-name<? a b)
+ (gnc:string-locale<? (gnc-account-get-full-name a) (gnc-account-get-full-name b)))
+
+(define (gnc:accounts-get-children-depth accounts)
+ (1- (apply max
+ (map (lambda (acct)
+ (+ (gnc-account-get-current-depth acct)
+ (gnc-account-get-tree-depth acct)))
+ accounts))))
+
;; True if the account is of type income or expense
(define (gnc:account-is-inc-exp? account)
diff --git a/gnucash/report/report.scm b/gnucash/report/report.scm
index 8444da85c..44956efe2 100644
--- a/gnucash/report/report.scm
+++ b/gnucash/report/report.scm
@@ -672,6 +672,8 @@
(export gnc:account-has-shares?)
(export gnc:account-is-stock?)
(export gnc:account-is-inc-exp?)
+(export gnc:account-full-name<?)
+(export gnc:accounts-get-children-depth)
(export gnc:filter-accountlist-type)
(export gnc:decompose-accountlist)
(export gnc:account-get-type-string-plural)
diff --git a/gnucash/report/reports/standard/budget.scm b/gnucash/report/reports/standard/budget.scm
index 8a7e7942e..9da3133ad 100644
--- a/gnucash/report/reports/standard/budget.scm
+++ b/gnucash/report/reports/standard/budget.scm
@@ -717,7 +717,7 @@
(else
(let* ((tree-depth (if (eq? display-depth 'all)
- (accounts-get-children-depth accounts)
+ (gnc:accounts-get-children-depth accounts)
display-depth))
(to-period-val (lambda (v)
(inexact->exact
@@ -732,7 +732,7 @@
(list 'zero-balance-mode
(if show-zb-accts? 'show-leaf-acct 'omit-leaf-acct))
(list 'report-budget budget)))
- (accounts (sort accounts account-full-name<?))
+ (accounts (sort accounts gnc:account-full-name<?))
(accumulate? (get-option gnc:pagename-general optname-accumulate))
(acct-table (gnc:make-html-acct-table/env/accts env accounts))
(footnotes (make-footnote-collector))
diff --git a/gnucash/report/reports/standard/cash-flow.scm b/gnucash/report/reports/standard/cash-flow.scm
index 2379e1885..1dd900e6f 100644
--- a/gnucash/report/reports/standard/cash-flow.scm
+++ b/gnucash/report/reports/standard/cash-flow.scm
@@ -158,7 +158,7 @@
(accounts (if show-subaccts?
(gnc:accounts-and-all-descendants accounts)
accounts))
- (accounts (sort accounts account-full-name<?)))
+ (accounts (sort accounts gnc:account-full-name<?)))
(define (add-accounts-flow accounts accounts-alist)
(let loop ((accounts accounts)
@@ -193,7 +193,7 @@
(if (not (null? accounts))
(let* ((tree-depth (if (equal? display-depth 'all)
- (accounts-get-children-depth accounts)
+ (gnc:accounts-get-children-depth accounts)
display-depth))
(account-disp-list
(map
@@ -242,12 +242,12 @@
(cons 'to-report-currency to-report-currency)))))
(let ((money-in-accounts (sort
(cdr (assq 'money-in-accounts result))
- account-full-name<?))
+ gnc:account-full-name<?))
(money-in-alist (cdr (assq 'money-in-alist result)))
(money-in-collector (cdr (assq 'money-in-collector result)))
(money-out-accounts (sort
(cdr (assq 'money-out-accounts result))
- account-full-name<?))
+ gnc:account-full-name<?))
(money-out-alist (cdr (assq 'money-out-alist result)))
(money-out-collector (cdr (assq 'money-out-collector result))))
commit 25e4efc2b7d788b6f0b61ea0a523d8cc6e572004
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Oct 28 21:42:31 2020 +0800
[core-utils.scm][API] gnc:string-locale<? gnc:string-locale>?
locale-sensitive string-sorting functions -- currently mirrors guile's
(ice-9 i18n) functions -- may be modified to call C code if guile code
is not reliable.
diff --git a/bindings/guile/core-utils.scm b/bindings/guile/core-utils.scm
index 32179f149..c08643cf1 100644
--- a/bindings/guile/core-utils.scm
+++ b/bindings/guile/core-utils.scm
@@ -28,12 +28,15 @@
#:export (N_
G_
C_
+ gnc:string-locale<?
+ gnc:string-locale>?
gnc:version))
;; Guile 2 needs to find the symbols from the extension at compile time already
(eval-when (compile load eval expand)
(load-extension "libgnucash-guile" "gnc_guile_bindings_init"))
(use-modules (sw_core_utils))
+(use-modules (ice-9 i18n))
;; Export the swig-wrapped symbols in the public interface of this module
(module-use! (module-public-interface (current-module))
@@ -54,3 +57,6 @@
(define-public (_ x)
(issue-deprecation-warning "Using _ to call gettext is disallowed in guile-3 and will be removed in the future. Use G_ instead.")
(gnc:gettext x))))
+
+(define gnc:string-locale<? string-locale<?)
+(define gnc:string-locale>? string-locale>?)
Summary of changes:
bindings/guile/core-utils.scm | 6 ++++++
bindings/guile/engine.scm | 4 ++++
gnucash/gnome/report-menus.scm | 2 +-
gnucash/import-export/qif-imp/qif-dialog-utils.scm | 16 ++++++++--------
gnucash/report/html-acct-table.scm | 12 ++++++------
gnucash/report/html-style-sheet.scm | 8 ++++----
gnucash/report/report-core.scm | 3 ++-
gnucash/report/report-utilities.scm | 16 ++++++++++++++--
gnucash/report/report.scm | 2 ++
gnucash/report/reports/locale-specific/de_DE/taxtxf.scm | 5 ++---
gnucash/report/reports/standard/account-piecharts.scm | 16 ++++++++--------
gnucash/report/reports/standard/budget.scm | 4 ++--
gnucash/report/reports/standard/cash-flow.scm | 8 ++++----
gnucash/report/reports/standard/category-barchart.scm | 12 ++++++------
gnucash/report/reports/standard/customer-summary.scm | 6 ++++--
gnucash/report/reports/standard/new-aging.scm | 2 +-
gnucash/report/trep-engine.scm | 4 ++--
17 files changed, 76 insertions(+), 50 deletions(-)
More information about the gnucash-changes
mailing list