aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Haddock/Lex.x3
-rw-r--r--src/Main.hs4
2 files changed, 5 insertions, 2 deletions
diff --git a/src/Haddock/Lex.x b/src/Haddock/Lex.x
index f65aee8c..b9ebe688 100644
--- a/src/Haddock/Lex.x
+++ b/src/Haddock/Lex.x
@@ -34,6 +34,7 @@ import Data.Char
import Data.Word (Word8)
import Numeric
import System.IO.Unsafe
+import Debug.Trace
}
$ws = $white # \n
@@ -181,7 +182,7 @@ tokenise dflags str (line, col) = let toks = go (posn, '\n', eofHack str) para i
go inp@(pos, _, str) sc =
case alexScan inp sc of
AlexEOF -> []
- AlexError _ -> error "lexical error"
+ AlexError _ -> []
AlexSkip inp' _ -> go inp' sc
AlexToken inp'@(pos',_,_) len act -> act pos (take len str) sc (\sc -> go inp' sc) dflags
diff --git a/src/Main.hs b/src/Main.hs
index 7d83866a..4f0784eb 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -57,6 +57,7 @@ import Paths_haddock
import GHC hiding (flags, verbosity)
import Config
import DynFlags hiding (flags, verbosity)
+import StaticFlags (saveStaticFlagGlobals, restoreStaticFlagGlobals)
import Panic (panic, handleGhcException)
import Module
@@ -295,7 +296,7 @@ dumpInterfaceFile path ifaces homeLinks = writeInterfaceFile path ifaceFile
-- | Start a GHC session with the -haddock flag set. Also turn off
-- compilation and linking. Then run the given 'Ghc' action.
withGhc :: String -> [String] -> (DynFlags -> Ghc a) -> IO a
-withGhc libDir flags ghcActs = do
+withGhc libDir flags ghcActs = saveStaticFlagGlobals >>= \savedFlags -> do
-- TODO: handle warnings?
(restFlags, _) <- parseStaticFlags (map noLoc flags)
runGhc (Just libDir) $ do
@@ -313,6 +314,7 @@ withGhc libDir flags ghcActs = do
-- dynamic or static linking at all!
_ <- setSessionDynFlags dynflags'''
ghcActs dynflags'''
+ `finally` restoreStaticFlagGlobals savedFlags
where
parseGhcFlags :: Monad m => DynFlags -> [Located String]
-> [String] -> m DynFlags