From 3cb941fc1deb59a07be690b7ebb1b45da189f7d2 Mon Sep 17 00:00:00 2001 From: Neil Mitchell Date: Wed, 5 Nov 2008 13:43:15 +0000 Subject: [PATCH] Perform case-insensitive matching of path components in getBaseDir on Windows (Fixes bug 2743) --- compiler/main/SysTools.lhs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs index 828530b..d1fd9f7 100644 --- a/compiler/main/SysTools.lhs +++ b/compiler/main/SysTools.lhs @@ -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 -- 1.7.10.4