From 117425305babfe40b8a964227297505fc3842a0f Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sat, 2 Mar 2019 15:01:44 +0800 Subject: [PATCH] [standard-reports] compact (directory-files) and remove regex use string-suffix? instead. --- .../standard-reports/standard-reports.scm | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/gnucash/report/standard-reports/standard-reports.scm b/gnucash/report/standard-reports/standard-reports.scm index 2c13ee09a5..0902bae421 100644 --- a/gnucash/report/standard-reports/standard-reports.scm +++ b/gnucash/report/standard-reports/standard-reports.scm @@ -87,23 +87,23 @@ ;; list of files in the directory (define (directory-files dir) - (if (file-exists? dir) - (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? fname) - (begin - (closedir dir-stream) - acc) - (loop (readdir dir-stream) - (if (regexp-exec fname-regexp fname) - (cons fname acc) - acc))))) - (begin - (gnc:warn "Can't access " dir ".\nEmpty list will be returned.") - '()))) + (cond + ((file-exists? dir) + (let ((dir-stream (opendir dir))) + (let loop ((fname (readdir dir-stream)) + (acc '())) + (cond + ((eof-object? fname) + (closedir dir-stream) + acc) + (else + (loop (readdir dir-stream) + (if (string-suffix? ".scm" fname) + (cons fname acc) + acc))))))) + (else + (gnc:warn "Can't access " dir ".\nEmpty list will be returned.") + '()))) ;; Process a list of files by removing the ".scm" suffix if it exists ;;