X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fmain%2FDriverUtil.hs;h=b8796c1244d11479e1c90c924dcece7cacfec684;hb=423d477bfecd490de1449c59325c8776f91d7aac;hp=d8fe68c2b20be52a115e958c371f275ed2f263c0;hpb=4be58768d4974fd1bddae44f12a0fde1f7fe6b30;p=ghc-hetmet.git diff --git a/ghc/compiler/main/DriverUtil.hs b/ghc/compiler/main/DriverUtil.hs index d8fe68c..b8796c1 100644 --- a/ghc/compiler/main/DriverUtil.hs +++ b/ghc/compiler/main/DriverUtil.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $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 -- @@ -7,9 +7,19 @@ -- ----------------------------------------------------------------------------- -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 @@ -38,6 +48,7 @@ getOptionsFromSource file 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' @@ -101,13 +112,8 @@ unknownFlagErr f = throwDyn (UsageError ("unrecognised flag: " ++ f)) 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 @@ -170,7 +176,7 @@ splitFilename3 str 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)