r19309 - gnucash/trunk/src/report/standard-reports - Improve the initial report loading code so that it loads only files ending with .scm.
Christian Stimming
cstim at code.gnucash.org
Sun Jun 27 14:56:56 EDT 2010
Author: cstim
Date: 2010-06-27 14:56:56 -0400 (Sun, 27 Jun 2010)
New Revision: 19309
Trac: http://svn.gnucash.org/trac/changeset/19309
Modified:
gnucash/trunk/src/report/standard-reports/standard-reports.scm
Log:
Improve the initial report loading code so that it loads only files ending with .scm.
This should avoid accidentally loading .scm~ backup files etc. The code
matches the filenames against the regexp "\.scm$", so the previous hand-
written comparison against "." and ".." is no longer necessary as those don't
match that regexp anyway.
Modified: gnucash/trunk/src/report/standard-reports/standard-reports.scm
===================================================================
--- gnucash/trunk/src/report/standard-reports/standard-reports.scm 2010-06-27 18:39:14 UTC (rev 19308)
+++ gnucash/trunk/src/report/standard-reports/standard-reports.scm 2010-06-27 18:56:56 UTC (rev 19309)
@@ -76,25 +76,25 @@
;; list of files in the directory
(define (directory-files dir)
- (let ((dir-stream (opendir dir)))
- (let loop ((new (readdir dir-stream))
+ (let ((fname-regexp (make-regexp "\.scm$")) ;; Regexp that matches the desired filenames
+ (dir-stream (opendir dir)))
+ (let loop ((fname (readdir dir-stream))
(acc '())
)
- (if (eof-object? new)
+ (if (eof-object? fname)
(begin
(closedir dir-stream)
acc
)
(loop (readdir dir-stream)
- (if (or (string=? "." new) ;;; ignore
- (string=? ".." new)) ;;; ignore
- acc
- (cons new acc)
- )
+ (if (regexp-exec fname-regexp fname)
+ (cons fname acc)
+ acc
+ )
)
)
- )
)
+ )
)
;; Process a list of files by removing the ".scm" suffix if it exists
More information about the gnucash-changes
mailing list