From 972562421eeb5c62ed407630f5cd574a796de747 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 14 Feb 2019 20:59:27 +0800 Subject: [PATCH] [engine-utilities] deprecate split utility functions These functions are obsolete with srfi-1 --- libgnucash/engine/engine-utilities.scm | 21 +++++++++++---------- libgnucash/engine/engine.scm | 11 ++++------- libgnucash/engine/test/test-split.scm | 1 + 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/libgnucash/engine/engine-utilities.scm b/libgnucash/engine/engine-utilities.scm index 83b363e86b..cc692ff1bf 100644 --- a/libgnucash/engine/engine-utilities.scm +++ b/libgnucash/engine/engine-utilities.scm @@ -93,33 +93,34 @@ (hashx-set! account-hash account-assoc table account value)) ;; Splits -(export split-same?) -(export split-in-list?) - +(export split-same?) ;deprecated +(export split-in-list?) ;deprecated (define (split-same? s1 s2) + (issue-deprecation-warning "split-same? is deprecated. use equal? instead.") (or (eq? s1 s2) (string=? (gncSplitGetGUID s1) (gncSplitGetGUID s2)))) - (define split-in-list? (lambda (split splits) + (issue-deprecation-warning "split-in-list? is deprecated. use member instead.") (cond ((null? splits) #f) ((split-same? (car splits) split) #t) (else (split-in-list? split (cdr splits)))))) - -;; Split hashtable. Because we do gncSplitGetGUID so often, it -;; turns out to be a bit quicker to store a (hash, split) pair -;; instead of just the split. (define (split-assoc split alist) + (issue-deprecation-warning "split-assoc is deprecated. use assoc instead") (find (lambda (pair) (split-same? (cdr split) (cdr (car pair)))) alist)) (define (split-hash split size) + (issue-deprecation-warning "split-hash is deprecated. \ +internal function -- no srfi-1 equivalent") (remainder (car split) size)) - (define (split-hashtable-ref table split) + (issue-deprecation-warning "split-hashtable-ref is deprecated. \ +use assoc-ref instead.") (hashx-ref split-hash split-assoc table (cons (string-hash (gncSplitGetGUID split)) split))) - (define (split-hashtable-set! table split value) + (issue-deprecation-warning "split-hashtable-set! is deprecated. \ +use assoc-set! instead") (hashx-set! split-hash split-assoc table (cons (string-hash (gncSplitGetGUID split)) split) value)) diff --git a/libgnucash/engine/engine.scm b/libgnucash/engine/engine.scm index b3023a3f1d..0c9ace487b 100644 --- a/libgnucash/engine/engine.scm +++ b/libgnucash/engine/engine.scm @@ -73,13 +73,10 @@ (export account-hashtable-ref) (export account-hashtable-set!) -(export split-same?) -(export split-in-list?) - -(export split-same?) -(export split-in-list?) -(export split-hashtable-ref) -(export split-hashtable-set!) +(export split-same?) ;deprecated +(export split-in-list?) ;deprecated +(export split-hashtable-ref) ;deprecated +(export split-hashtable-set!) ;deprecated (export gnc:split-structure) (export gnc:make-split-scm) diff --git a/libgnucash/engine/test/test-split.scm b/libgnucash/engine/test/test-split.scm index 96713c44df..e5f53a6ef0 100644 --- a/libgnucash/engine/test/test-split.scm +++ b/libgnucash/engine/test/test-split.scm @@ -11,6 +11,7 @@ (test test-split-in-list?)) (define (test-split-in-list?) + ;; this test suite tests deprecated functions. (let* ((env (create-test-env)) (today (current-time)) (account-alist (env-create-test-accounts env))