aboutsummaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-11 11:47:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-11 11:47:53 -0400
commit69cb6af4b7f6b16a69734d75ef5583bd2797c173 (patch)
tree2342a1c3b8ced54e0cde32afce963d643294a718 /Limit.hs
parent3ce402a4c63e4ac04ab788cfd3ad8ea964b402ef (diff)
Now uses the Haskell Glob library, rather than pcre-light, avoiding the need to install libpcre. Currently done only for Cabal or when the Makefile is made to use -DWITH_GLOB
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/Limit.hs b/Limit.hs
index 85cce4f44..16e555bed 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -12,7 +12,9 @@ module Limit where
import Data.Time.Clock.POSIX
import qualified Data.Set as S
import qualified Data.Map as M
-#ifndef WITH_ANDROID
+#ifdef WITH_GLOB
+import System.FilePath.Glob (simplify, compile, match)
+#else
import Text.Regex.PCRE.Light.Char8
import System.Path.WildMatch
#endif
@@ -85,10 +87,12 @@ limitExclude :: MkLimit
limitExclude glob = Right $ const $ return . not . matchglob glob
matchglob :: String -> Annex.FileInfo -> Bool
-#ifdef WITH_ANDROID
-matchglob _ _ = error "glob matching not supported"
-#else
matchglob glob (Annex.FileInfo { Annex.matchFile = f }) =
+#ifdef WITH_GLOB
+ match pattern f
+ where
+ pattern = simplify $ compile glob
+#else
isJust $ match cregex f []
where
cregex = compile regex []