aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-10-27 16:14:41 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-11-06 00:46:25 +0100
commitb63dd16156c2b960c859e8147ab39b25243ee04d (patch)
treef4ed3926bbe2a8c9a314f5ce64c91c251dee0de6
parentFix sort*! test. (diff)
downloadcalp-b63dd16156c2b960c859e8147ab39b25243ee04d.tar.gz
calp-b63dd16156c2b960c859e8147ab39b25243ee04d.tar.xz
Replace regex with simpler string check.
-rw-r--r--module/hnh/module-introspection/all-modules.scm15
1 files changed, 9 insertions, 6 deletions
diff --git a/module/hnh/module-introspection/all-modules.scm b/module/hnh/module-introspection/all-modules.scm
index 4b224d2f..753d5019 100644
--- a/module/hnh/module-introspection/all-modules.scm
+++ b/module/hnh/module-introspection/all-modules.scm
@@ -1,5 +1,4 @@
(define-module (hnh module-introspection all-modules)
- :use-module (ice-9 regex)
:use-module (srfi srfi-1)
:use-module (ice-9 ftw)
:use-module (ice-9 match)
@@ -21,14 +20,18 @@
;; (define (fs-find proc dir)
;; (filter proc (fs-find-base dir)))
-(define* (all-files-under-directory dir extension)
- (define extension-rx ((@ (texinfo string-utils) escape-special-chars)
- extension "[](){}+*?.^$" #\\))
- (define re (make-regexp (string-append extension-rx "$")))
+(define (string-ends-with? string tail)
+ (and (>= (string-length string)
+ (string-length tail))
+ (string=? tail
+ (substring string
+ (- (string-length string)
+ (string-length tail))))))
+(define* (all-files-under-directory dir extension)
(map car
(filter (match-lambda ((filename _ 'regular)
- (and (regexp-exec re filename)
+ (and (string-ends-with? filename extension)
(not (file-hidden? filename))))
(_ #f))
(fs-find dir))))