diff options
author | David Waern <david.waern@gmail.com> | 2011-06-10 01:35:31 +0000 |
---|---|---|
committer | David Waern <david.waern@gmail.com> | 2011-06-10 01:35:31 +0000 |
commit | ae5ed291f3c1550b0eda7bb0585ead327b5d967e (patch) | |
tree | 62cec94c894c7bc01221c007716aca2e2541dcce /src/Main.hs | |
parent | f5782ed0e979119a5ee3b48643b2161f06259774 (diff) |
Add git commits since switchover:
darcs format (followed by a conflict resolution):
commit 6f92cdd12d1354dfbd80f8323ca333bea700896a
Merge: f420cc4 28df3a1
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date: Thu May 19 17:54:34 2011 +0100
Merge remote branch 'origin/master' into ghc-generics
commit 28df3a119f770fdfe85c687dd73d5f6712b8e7d0
Author: Max Bolingbroke <batterseapower@hotmail.com>
Date: Sat May 14 22:37:02 2011 +0100
Unicode fix for getExecDir on Windows
commit 89813e729be8bce26765b95419a171a7826f6d70
Merge: 6df3a04 797ab27
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date: Mon May 9 11:55:17 2011 +0100
Merge branch 'ghc-new-co'
commit 6df3a040da3dbddee67c6e30a892f87e6b164383
Author: Ian Lynagh <igloo@earth.li>
Date: Sun May 8 17:05:50 2011 +0100
Follow changes in SDoc
commit f420cc48b9259f0b1afd2438b12f9a2bde57053d
Author: Jose Pedro Magalhaes <jpm@cs.uu.nl>
Date: Wed May 4 17:31:52 2011 +0200
Adapt haddock to the removal of HsNumTy and TypePat.
commit 797ab27bdccf39c73ccad374fea265f124cb52ea
Merge: 1d81436 5a91450
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date: Mon May 2 12:05:03 2011 +0100
Merge remote branch 'origin/master' into ghc-new-co
commit 1d8143659a81cf9611668348e33fd0775c7ab1d2
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date: Mon May 2 12:03:46 2011 +0100
Wibbles for ghc-new-co branch
commit 5a91450e2ea5a93c70bd3904b022445c9cc82488
Author: Ian Lynagh <igloo@earth.li>
Date: Fri Apr 22 00:51:56 2011 +0100
Follow defaultDynFlags change in GHC
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/Main.hs b/src/Main.hs index deb699f7..b49fc6e4 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -57,7 +57,7 @@ import Paths_haddock import GHC hiding (flags, verbosity) import Config import DynFlags hiding (flags, verbosity) -import Panic (handleGhcException) +import Panic (panic, handleGhcException) import Module @@ -393,7 +393,7 @@ getPrologue flags = [] -> return Nothing [filename] -> do str <- readFile filename - case parseParas (tokenise defaultDynFlags str + case parseParas (tokenise (defaultDynFlags (panic "No settings")) str (1,0) {- TODO: real position -}) of Nothing -> throwE $ "failed to parse haddock prologue from file: " ++ filename Just doc -> return (Just doc) @@ -416,18 +416,17 @@ getInTreeLibDir = do getExecDir :: IO (Maybe String) #if defined(mingw32_HOST_OS) -getExecDir = allocaArray len $ \buf -> do - ret <- getModuleFileName nullPtr buf len - if ret == 0 then - return Nothing - else do - s <- peekCString buf - return (Just (dropFileName s)) - where len = 2048 -- Plenty, PATH_MAX is 512 under Win32. - - -foreign import stdcall unsafe "GetModuleFileNameA" - getModuleFileName :: Ptr () -> CString -> Int -> IO Int32 +getExecDir = try_size 2048 -- plenty, PATH_MAX is 512 under Win32. + where + try_size size = allocaArray (fromIntegral size) $ \buf -> do + ret <- c_GetModuleFileName nullPtr buf size + case ret of + 0 -> return Nothing + _ | ret < size -> fmap (Just . dropFileName) $ peekCWString buf + | otherwise -> try_size (size * 2) + +foreign import stdcall unsafe "windows.h GetModuleFileNameW" + c_GetModuleFileName :: Ptr () -> CWString -> Word32 -> IO Word32 #else getExecDir = return Nothing #endif |