AUDIT: r16949 - gnucash/trunk/src/import-export/qif-import - Fixes bug 360058 by rewriting qif-import:get-account-name to avoid use
Charles Day
cedayiv at cvs.gnucash.org
Thu Feb 21 16:09:39 EST 2008
Author: cedayiv
Date: 2008-02-21 16:09:39 -0500 (Thu, 21 Feb 2008)
New Revision: 16949
Trac: http://svn.gnucash.org/trac/changeset/16949
Modified:
gnucash/trunk/src/import-export/qif-import/qif-dialog-utils.scm
Log:
Fixes bug 360058 by rewriting qif-import:get-account-name to avoid use
of regular expressions. The new algorithm is simpler and faster anyway.
BP
Modified: gnucash/trunk/src/import-export/qif-import/qif-dialog-utils.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-dialog-utils.scm 2008-02-21 17:13:22 UTC (rev 16948)
+++ gnucash/trunk/src/import-export/qif-import/qif-dialog-utils.scm 2008-02-21 21:09:39 UTC (rev 16949)
@@ -6,8 +6,6 @@
;;; Bill Gribble <grib at billgribble.com> 20 Feb 2000
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(use-modules (ice-9 regex))
-
(define (default-stock-acct brokerage security)
(string-append brokerage (gnc-get-account-separator-string) security))
@@ -561,23 +559,21 @@
(qif-xtn:set-from-acct! xtn new-acct-name)))
(qif-file:xtns qif-file)))
-(define qif-import:account-name-regexp #f)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; qif-import:get-account-name
+;;
+;; Given an account name, return the rightmost subaccount.
+;; For example, given the account name "foo:bar", "bar" is
+;; returned (assuming the account separator is ":").
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
(define (qif-import:get-account-name fullname)
- (if (not qif-import:account-name-regexp)
- (let* ((rstr ":([^:]+)$|^([^:]+)$")
- (newstr (regexp-substitute/global
- #f ":" rstr 'pre (gnc-get-account-separator-string) 'post)))
-
- (set! qif-import:account-name-regexp (make-regexp newstr))))
-
- (let ((match (regexp-exec qif-import:account-name-regexp fullname)))
- (if match
- (begin
- (let ((substr (match:substring match 1)))
- (if substr
- substr
- (match:substring match 2))))
+ (let ((lastsep (string-rindex fullname
+ (string-ref (gnc-get-account-separator-string)
+ 0))))
+ (if lastsep
+ (substring fullname (+ lastsep 1))
fullname)))
More information about the gnucash-changes
mailing list