From b63dd16156c2b960c859e8147ab39b25243ee04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 27 Oct 2023 16:14:41 +0200 Subject: Replace regex with simpler string check. --- module/hnh/module-introspection/all-modules.scm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'module/hnh') 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)))) -- cgit v1.2.3