]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/globs/globs.factor
basis: use lint.vocabs tool to trim using lists
[factor.git] / basis / globs / globs.factor
index 3d9f7d857b548b103363d98a62cccd772cddcf13..3cb4ed094e0bbe0c608710b448063ef324b374bf 100644 (file)
@@ -1,18 +1,18 @@
 ! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays combinators combinators.short-circuit
-io.directories io.files io.files.info io.pathnames kernel locals
+io.directories io.files io.files.info io.pathnames kernel
 make peg.ebnf regexp regexp.combinators sequences strings system
-unicode ;
+unicode multiline ;
 IN: globs
 
 : not-path-separator ( -- sep )
-    os windows? R/ [^\\/\\]/ R/ [^\\/]/ ? ; foldable
+    os windows? R/ [^\/\\]/ R/ [^\/]/ ? ; foldable
 
 : wild-path-separator ( -- sep )
-    os windows? R/ [^\\/\\][\\/\\]|[^\\/\\]/ R/ [^\\/][\\/]|[^\\/]/ ? ; foldable
+    os windows? R/ [^\/\\][\/\\]|[^\/\\]/ R/ [^\/][\/]|[^\/]/ ? ; foldable
 
-EBNF: <glob>
+EBNF: <glob> [=[
 
 Character = "\\" .:c => [[ c 1string <literal> ]]
           | !(","|"}") . => [[ 1string <literal> ]]
@@ -45,7 +45,7 @@ End = !(.)
 
 Main = Concatenation End
 
-;EBNF
+]=]
 
 : glob-matches? ( input glob -- ? )
     [ >case-fold ] bi@ <glob> matches? ;
@@ -123,7 +123,7 @@ DEFER: glob%
 :: glob-literal% ( root globs -- )
     globs unclip :> ( remaining glob )
 
-    root glob append-path dup exists? [
+    root glob append-path dup file-exists? [
         remaining over file-info ?glob%
     ] [
         drop
@@ -156,4 +156,6 @@ DEFER: glob%
 PRIVATE>
 
 : glob ( glob -- files )
-    glob-path [ glob% ] { } make ;
+    glob-path [
+        [ 1array f swap ] when-empty glob%
+    ] { } make ;