aboutsummaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-08 15:29:01 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-08 15:29:01 -0400
commit556b5d9fb7f313b035aff2cff5ee54b9727c71b9 (patch)
treee7051836d32800f2c09ef084576935f7c8809cb2 /Limit.hs
parent626960cd383b620fc06a485e9b6d1f4b475fe0e8 (diff)
Switch from using regex-compat to regex-tdfa, as the C regex library is rather buggy.
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/Limit.hs b/Limit.hs
index 1d02decbe..e43b640da 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -13,7 +13,8 @@ import Data.Time.Clock.POSIX
import qualified Data.Set as S
import qualified Data.Map as M
import System.Path.WildMatch
-import Text.Regex
+import Text.Regex.TDFA
+import Text.Regex.TDFA.String
import Common.Annex
import qualified Annex
@@ -83,12 +84,17 @@ limitExclude :: MkLimit
limitExclude glob = Right $ const $ return . not . matchglob glob
{- Could just use wildCheckCase, but this way the regex is only compiled
- - once. -}
+ - once. Also, we use regex-TDFA because it's less buggy in its support
+ - of non-unicode characters. -}
matchglob :: String -> Annex.FileInfo -> Bool
matchglob glob (Annex.FileInfo { Annex.matchFile = f }) =
- isJust $ matchRegex cregex f
+ case cregex of
+ Right r -> case execute r f of
+ Right (Just _) -> True
+ _ -> False
+ Left _ -> error $ "failed to compile regex: " ++ regex
where
- cregex = mkRegex regex
+ cregex = compile defaultCompOpt defaultExecOpt regex
regex = '^':wildToRegex glob
{- Adds a limit to skip files not believed to be present