globs: * and ? should not match path-separator
parent
2b05f90c7b
commit
72de727d0e
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue