X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Futils%2FUtil.lhs;fp=ghc%2Fcompiler%2Futils%2FUtil.lhs;h=1598c124fe12b3c639dd0f9586afe245b0ccccd1;hb=be8b6cd519e181e2553ee48ef4a82b8d56a4e9b6;hp=0911dba84137a6c89acb40690a51be95ed35e426;hpb=de808d3b036673f29693f8380e1114c19d0d3493;p=ghc-hetmet.git diff --git a/ghc/compiler/utils/Util.lhs b/ghc/compiler/utils/Util.lhs index 0911dba..1598c12 100644 --- a/ghc/compiler/utils/Util.lhs +++ b/ghc/compiler/utils/Util.lhs @@ -70,6 +70,7 @@ module Util ( replaceFilenameSuffix, directoryOf, filenameOf, replaceFilenameDirectory, escapeSpaces, isPathSeparator, + parseSearchPath, normalisePath, platformPath, pgmPath, ) where @@ -950,6 +951,40 @@ isPathSeparator ch = ch == '/' #endif +-------------------------------------------------------------- +-- * Search path +-------------------------------------------------------------- + +-- | The function splits the given string to substrings +-- using the 'searchPathSeparator'. +parseSearchPath :: String -> [FilePath] +parseSearchPath path = split path + where + split :: String -> [String] + split s = + case rest' of + [] -> [chunk] + _:rest -> chunk : split rest + where + chunk = + case chunk' of +#ifdef mingw32_HOST_OS + ('\"':xs@(_:_)) | last xs == '\"' -> init xs +#endif + _ -> chunk' + + (chunk', rest') = break (==searchPathSeparator) s + +-- | A platform-specific character used to separate search path strings in +-- environment variables. The separator is a colon (\":\") on Unix and Macintosh, +-- and a semicolon (\";\") on the Windows operating system. +searchPathSeparator :: Char +#if mingw32_HOST_OS || mingw32_TARGET_OS +searchPathSeparator = ';' +#else +searchPathSeparator = ':' +#endif + ----------------------------------------------------------------------------- -- Convert filepath into platform / MSDOS form.