-----------------------------------------------------------------------------
--- $Id: DriverUtil.hs,v 1.39 2003/08/20 15:07:57 simonmar Exp $
+-- $Id: DriverUtil.hs,v 1.43 2004/08/13 13:07:02 simonmar Exp $
--
-- Utils for the driver
--
--
-----------------------------------------------------------------------------
-module DriverUtil where
-
-#include "../includes/config.h"
+module DriverUtil (
+ getOptionsFromSource, softGetDirectoryContents,
+ createDirectoryHierarchy, doesDirNameExist, prefixUnderscore,
+ unknownFlagErr, unknownFlagsErr, missingArgErr,
+ later, handleDyn, handle,
+ split, add, addNoDups,
+ Suffix, splitFilename, getFileSuffix,
+ splitFilename3, remove_suffix, split_longest_prefix,
+ replaceFilenameSuffix, directoryOf, replaceFilenameDirectory,
+ remove_spaces, escapeSpaces,
+ ) where
+
+#include "../includes/ghcconfig.h"
#include "HsVersions.h"
import Util
catchJust ioErrors (look h `finally` hClose h)
(\e -> if isEOFError e then return [] else ioError e)
where
+
look h = do
l' <- hGetLine h
let l = remove_spaces l'
unknownFlagsErr :: [String] -> a
unknownFlagsErr fs = throwDyn (UsageError ("unrecognised flags: " ++ unwords fs))
-my_partition :: (a -> Maybe b) -> [a] -> ([(a,b)],[a])
-my_partition _ [] = ([],[])
-my_partition p (a:as)
- = let (bs,cs) = my_partition p as in
- case p a of
- Nothing -> (bs,a:cs)
- Just b -> ((a,b):bs,cs)
+missingArgErr :: String -> a
+missingArgErr f = throwDyn (UsageError ("missing argument for flag: " ++ f))
later = flip finally
remove_suffix :: Char -> String -> Suffix
remove_suffix c s
- | null pre = reverse suf
+ | null pre = s
| otherwise = reverse pre
where (suf,pre) = break (==c) (reverse s)