From 71e08fde28fa335bdba2ec2150fd6663390bba5a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 18 Mar 2018 22:54:34 +0100 Subject: glob: Add an extra glob pattern compilation stage. * guix/glob.scm (compile-glob-pattern): Rename to... (string->sglob): ... this. (compile-sglob, string->compiled-sglob): New procedures. (glob-match?): Replace '?, 'range, and 'set with a single clause. * tests/glob.scm (test-compile-glob-pattern): Rename to... (test-string->sglob): ... this. Adjust accordingly. (test-glob-match): Use 'string->compiled-sglob' instead of 'compile-glob-pattern'. * gnu/build/linux-modules.scm (read-module-aliases): Use 'string->compiled-sglob' instead of 'compile-glob-pattern'. --- tests/glob.scm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/glob.scm b/tests/glob.scm index 71e2d3fce0..3134069789 100644 --- a/tests/glob.scm +++ b/tests/glob.scm @@ -23,14 +23,14 @@ (define-module (test-glob) (test-begin "glob") -(define-syntax test-compile-glob-pattern +(define-syntax test-string->sglob (syntax-rules (=>) ((_ pattern => result rest ...) (begin - (test-equal (format #f "compile-glob-pattern, ~s" pattern) + (test-equal (format #f "string->sglob, ~s" pattern) result - (compile-glob-pattern pattern)) - (test-compile-glob-pattern rest ...))) + (string->sglob pattern)) + (test-string->sglob rest ...))) ((_) #t))) @@ -39,14 +39,14 @@ (define-syntax test-glob-match ((_ (pattern-string matches strings ... (and not others ...)) rest ...) (begin (test-assert (format #f "glob-match? ~s" pattern-string) - (let ((pattern (compile-glob-pattern pattern-string))) + (let ((pattern (string->compiled-sglob pattern-string))) (and (glob-match? pattern strings) ... (not (glob-match? pattern others)) ...))) (test-glob-match rest ...))) ((_) #t))) -(test-compile-glob-pattern +(test-string->sglob "foo" => "foo" "?foo*" => '(? "foo" *) "foo[1-5]" => '("foo" (range #\1 #\5)) -- cgit v1.2.3