[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 15:09:24 UTC 2010
The following commit has been merged in the master branch:
commit 5adef131fb65a026c946b9cc84a72f044a8723dc
Author: John Goerzen <jgoerzen at complete.org>
Date: Sat Apr 8 02:43:50 2006 +0100
Compilation fixes
diff --git a/MissingH/List.hs b/MissingH/List.hs
index d741948..04775c1 100644
--- a/MissingH/List.hs
+++ b/MissingH/List.hs
@@ -89,7 +89,7 @@ endswith = isSuffixOf
{- | Returns true if the given list contains any of the elements in the search
list. -}
hasAny :: Eq a => [a] -- ^ List of elements to look for
- -> a -- ^ List to search
+ -> [a] -- ^ List to search
-> Bool -- ^ Result
hasAny [] _ = False -- An empty search list: always false
hasAny _ [] = False -- An empty list to scan: always false
diff --git a/MissingH/Path/Glob.hs b/MissingH/Path/Glob.hs
index 320dac9..556a7cf 100644
--- a/MissingH/Path/Glob.hs
+++ b/MissingH/Path/Glob.hs
@@ -35,6 +35,9 @@ module MissingH.Path.Glob(glob, vGlob) where
import MissingH.List
import System.IO
import MissingH.IO.HVFS
+import MissingH.Path.FilePath
+import Control.Exception
+import MissingH.Path.WildMatch
hasWild = hasAny "*?["
@@ -47,24 +50,24 @@ that component of the pattern also begins with a dot.
In MissingH, this function is defined as:
>glob = vGlob SystemFS -}
-glob :: FilePath -> IO ()
+glob :: FilePath -> IO [FilePath]
glob = vGlob SystemFS
{- | Like 'glob', but works on both the system ("real") and HVFS virtual
filesystems. -}
-vGlob :: HVFS a => a -> FilePath -> IO ()
+vGlob :: HVFS a => a -> FilePath -> IO [FilePath]
vGlob fs fn =
- if not hasWild fn -- Don't try globbing if there are no wilds
+ if not (hasWild fn) -- Don't try globbing if there are no wilds
then do de <- vDoesExist fs fn
if de
then return [fn]
else return []
else expandGlob fs fn -- It's there
-expandGlob :: HVFS a => a -> FilePath -> IO ()
-exnapdGlob fs fn =
+expandGlob :: HVFS a => a -> FilePath -> IO [FilePath]
+expandGlob fs fn =
case dirname of
- "." -> runGlob "." basename
+ "." -> runGlob fs "." basename
_ -> do dirlist <- if hasWild dirname
then expandGlob fs dirname
else return [dirname]
@@ -77,25 +80,22 @@ exnapdGlob fs fn =
where (dirname, basename) = splitFileName fn
expandWildBase :: FilePath -> IO [FilePath]
expandWildBase dname =
- do dirglobs <- runGlob dname basename
- return (map \globfn -> dname ++ "/" ++ globfn) dirglobs
+ do dirglobs <- runGlob fs dname basename
+ return $ map (\globfn -> dname ++ "/" ++ globfn) dirglobs
expandNormalBase :: FilePath -> IO [FilePath]
expandNormalBase dname =
- do isdir <- vDoesDirectoryExist dname
+ do isdir <- vDoesDirectoryExist fs dname
if (basename /= "." && basename /= "") || isdir
then return [dname ++ "/" ++ basename]
else return []
-runGlob :: HVFS a => a -> FilePath -> IO ()
+runGlob :: HVFS a => a -> FilePath -> FilePath -> IO [FilePath]
runGlob fs "" patt = runGlob fs "." patt
runGlob fs dirname patt =
- case tryJust ioErrors (vGetDirectoryContents fs dirname) of
- Left _ -> []
- Right names -> let matches = return . filter . wildCheckCase $ names
- in if head patt == '.'
- then matches
- else filter (\x -> head x /= '.') matches
-
-
-
-
\ No newline at end of file
+ do r <- tryJust ioErrors (vGetDirectoryContents fs dirname)
+ case r of
+ Left _ -> return []
+ Right names -> let matches = filter (wildCheckCase patt) $ names
+ in if head patt == '.'
+ then return matches
+ else return $ filter (\x -> head x /= '.') matches
diff --git a/MissingH/Path/WildMatch.hs b/MissingH/Path/WildMatch.hs
index 0d72237..59b0b68 100644
--- a/MissingH/Path/WildMatch.hs
+++ b/MissingH/Path/WildMatch.hs
@@ -99,6 +99,5 @@ convwild (x:xs) = escapeRe [x] ++ convwild xs
convpat :: String -> String
convpat ('\\':xs) = "\\\\" ++ convpat xs
-convpat (']':xs) = ']' ++ convwild xs
+convpat (']':xs) = ']' : convwild xs
convpat (x:xs) = x : convpat xs
-
\ No newline at end of file
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list