Perform case-insensitive matching of path components in getBaseDir on Windows (Fixes...
authorNeil Mitchell <ndmitchell@gmail.com>
Wed, 5 Nov 2008 13:43:15 +0000 (13:43 +0000)
committerNeil Mitchell <ndmitchell@gmail.com>
Wed, 5 Nov 2008 13:43:15 +0000 (13:43 +0000)
compiler/main/SysTools.lhs

index 828530b..d1fd9f7 100644 (file)
@@ -844,16 +844,17 @@ getBaseDir = do let len = (2048::Int) -- plenty, PATH_MAX is 512 under Win32.
                                     return (Just (rootDir s))
   where
     rootDir s = case splitFileName $ normalise s of
-                (d, ghc_exe) | map toLower ghc_exe == "ghc.exe" ->
+                (d, ghc_exe) | lower ghc_exe == "ghc.exe" ->
                     case splitFileName $ takeDirectory d of
                     -- installed ghc.exe is in $topdir/bin/ghc.exe
-                    (d', "bin") -> takeDirectory d'
+                    (d', bin) | lower bin == "bin" -> takeDirectory d'
                     -- inplace ghc.exe is in $topdir/ghc/stage1-inplace/ghc.exe
-                    (d', x) | "-inplace" `isSuffixOf` x -> 
+                    (d', x) | "-inplace" `isSuffixOf` lower x -> 
                         takeDirectory d' </> ".."
                     _ -> fail
                 _ -> fail
         where fail = panic ("can't decompose ghc.exe path: " ++ show s)
+              lower = map toLower
 
 foreign import stdcall unsafe "GetModuleFileNameA"
   getModuleFileName :: Ptr () -> CString -> Int -> IO Int32