~ chicken-core (chicken-5) 034909215a9215496ba9e9430e12c24a5b86c1f0


commit 034909215a9215496ba9e9430e12c24a5b86c1f0
Author:     Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Wed May 1 14:20:58 2013 +0200
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Thu May 2 10:30:08 2013 +0200

    Change test argument to find-files conversion to check for procedure and otherwise pass it to irregex, so that anything accepted by the irregex constructor is also allowed as a test (previously, SRE expressions were not accepted)
    
    Signed-off-by: felix <felix@call-with-current-continuation.org>

diff --git a/NEWS b/NEWS
index d5ac72b1..06eec3ce 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@
   - write and pp now correctly use escape sequences for control characters
      (thanks to Florian Zumbiehl)
   - posix: memory-mapped file support for Windows (thanks to "rivo")
+  - posix: find-file's test argument now also accepts SRE forms.
 
 - Runtime system
   - Special events in poll() are now handled, avoiding hangs in threaded apps.
diff --git a/manual/Unit posix b/manual/Unit posix
index 3f59078f..fe0e057b 100644
--- a/manual/Unit posix	
+++ b/manual/Unit posix	
@@ -1239,20 +1239,21 @@ These variables contain error codes as returned by {{errno}}.
 Recursively traverses the contents of {{DIRECTORY}} (which should be a
 string) and invokes the procedure {{action}} for all files in which
 the procedure {{test}} is true.  {{test}} may be a procedure of one
-argument or a regular-expression string that will be matched with a
-full pathname using {{irregex-match}}.  {{action}} should be a
-procedure of two arguments: the currently encountered file and the
-result of the previous invocation of {{action}}, or, if this is the
-first invocation, the value of {{seed}}. {{test}} defaults to
-{{(constantly #t)}}, {{action}} defaults to {{cons}}, {{seed}}
-defaults to {{()}}.  {{limit}} should be a procedure of one argument
-that is called for each nested directory and which should return true,
-if that directory is to be traversed recursively. {{limit}} may also
-be an exact integer that gives the maximum recursion depth. For
-example, a depth of {{0}} means that only files in the top-level,
-specified directory are to be traversed. In this case, all nested
-directories are ignored.  {{limit}} may also be {{#f}} (the default),
-which is equivalent to {{(constantly #t)}}. 
+argument or an irregex object, regex string or SRE expression that
+will be matched with a full pathname using {{irregex-match}}.
+{{action}} should be a procedure of two arguments: the currently
+encountered file and the result of the previous invocation of
+{{action}}, or, if this is the first invocation, the value of
+{{seed}}. {{test}} defaults to {{(constantly #t)}}, {{action}}
+defaults to {{cons}}, {{seed}} defaults to {{()}}.  {{limit}} should
+be a procedure of one argument that is called for each nested
+directory and which should return true, if that directory is to be
+traversed recursively. {{limit}} may also be an exact integer that
+gives the maximum recursion depth. For example, a depth of {{0}} means
+that only files in the top-level, specified directory are to be
+traversed. In this case, all nested directories are ignored.
+{{limit}} may also be {{#f}} (the default), which is equivalent to
+{{(constantly #t)}}.
 
 If {{dotfiles}} is given and true, then files starting with a "{{.}}"
 character will not be ignored (but note that "{{.}}" and "{{..}}"  are
diff --git a/posix-common.scm b/posix-common.scm
index 1f7c4b33..78669d14 100644
--- a/posix-common.scm
+++ b/posix-common.scm
@@ -399,10 +399,10 @@ EOF
 		  ((fixnum? limit) (lambda _ (fx< depth limit)))
 		  (else limit) ) )
 	   (pproc
-	    (if (or (string? pred) (irregex? pred))
+	    (if (procedure? pred)
+		pred
 		(let ((pred (irregex pred))) ; force compilation
-		  (lambda (x) (irregex-match pred x)))
-		pred) ) )
+		  (lambda (x) (irregex-match pred x))) ) ) )
       (let loop ((fs (glob (make-pathname dir (if dot "?*" "*"))))
 		 (r id) )
 	(if (null? fs)
Trap