diff options
author | Joey Hess <joey@kitenet.net> | 2011-01-29 23:47:10 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-01-29 23:56:40 -0400 |
commit | 6d3df8a0833fdef290b76681e8ba85ec94b76e36 (patch) | |
tree | 0bb9f96e9562d27786826d3e644a326c63b6b265 /Command.hs | |
parent | c64b50a0ce725df2d5317b7ae4918b61aafa25ee (diff) |
more pure code refactoring
Diffstat (limited to 'Command.hs')
-rw-r--r-- | Command.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Command.hs b/Command.hs index 298234fa0..e54add707 100644 --- a/Command.hs +++ b/Command.hs @@ -184,17 +184,20 @@ filterFiles l = do if null exclude then return l' else do - let regexp = compile (toregex exclude) [] + let regexp = compile (wildsRegex exclude) [] return $ filter (notExcluded regexp) l' where notState f = not $ stateDir `isPrefixOf` f notExcluded r f = case match r f [] of Nothing -> True Just _ -> False - toregex exclude = "^(" ++ toregex' exclude "" ++ ")" - toregex' [] c = c - toregex' (w:ws) "" = toregex' ws (wildToRegex w) - toregex' (w:ws) c = toregex' ws (c ++ "|" ++ wildToRegex w) + +wildsRegex :: [String] -> String +wildsRegex ws = "^(" ++ wildsRegex' ws "" ++ ")" +wildsRegex' :: [String] -> String -> String +wildsRegex' [] c = c +wildsRegex' (w:ws) "" = wildsRegex' ws (wildToRegex w) +wildsRegex' (w:ws) c = wildsRegex' ws (c ++ "|" ++ wildToRegex w) {- filter out symlinks -} notSymlink :: FilePath -> IO Bool |