]> gitweb.factorcode.org Git - factor.git/commitdiff
globs: * and ? should not match path-separator
authorJoe Groff <arcata@gmail.com>
Sat, 13 Feb 2010 21:35:04 +0000 (13:35 -0800)
committerJoe Groff <arcata@gmail.com>
Sat, 13 Feb 2010 21:35:04 +0000 (13:35 -0800)
basis/globs/globs-tests.factor
basis/globs/globs.factor

index bdc0623d5413eb591589a8f35420f59b8c356d26..eceb6bab7b6e671ccd5e1f13eecc7777b36ec19e 100644 (file)
@@ -1,4 +1,4 @@
-USING: tools.test globs ;
+USING: tools.test globs io.pathnames ;
 IN: globs.tests
 
 [ f ] [ "abd" "fdf" glob-matches? ] unit-test
@@ -17,3 +17,8 @@ IN: globs.tests
 [ f ] [ "foo." "*.{xml,txt}" glob-matches? ] unit-test
 [ t ] [ "foo." "*.{,xml,txt}" glob-matches? ] unit-test
 [ t ] [ "foo.{" "*.{" glob-matches? ] unit-test
+
+[ f ] [ "foo" "bar" append-path "*" glob-matches? ] unit-test
+[ t ] [ "foo" "bar" append-path "*" "*" append-path glob-matches? ] unit-test
+[ f ] [ "foo" "bar" append-path "foo?bar" glob-matches? ] unit-test
+[ t ] [ "foo" "bar" append-path "fo?" "bar" append-path glob-matches? ] unit-test
index cac7fd9a2ff8056387fe96ca2c09f5585f543cbf..47c8fca5284bada119806fff7e401ee258ee6f09 100644 (file)
@@ -1,9 +1,12 @@
 ! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences kernel regexp.combinators strings unicode.case
-peg.ebnf regexp arrays ;
+USING: sequences io.pathnames kernel regexp.combinators
+strings unicode.case peg.ebnf regexp arrays ;
 IN: globs
 
+: not-path-separator ( -- sep )
+    "[^" path-separator "]" 3append <regexp> ; foldable
+
 EBNF: <glob>
 
 Character = "\\" .:c => [[ c 1string <literal> ]]
@@ -24,8 +27,8 @@ CharClass = "^"?:n Ranges:e => [[ e <or> n [ <not> ] when ]]
 AlternationBody = Concatenation:c "," AlternationBody:a => [[ a c prefix ]]
                 | Concatenation => [[ 1array ]]
 
-Element = "*" => [[ R/ .*/ ]]
-        | "?" => [[ R/ ./ ]]
+Element = "*" => [[ not-path-separator <zero-or-more> ]]
+        | "?" => [[ not-path-separator ]]
         | "[" CharClass:c "]" => [[ c ]]
         | "{" AlternationBody:b "}" => [[ b <or> ]]
         | Character