aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Interface
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-02-25 07:04:01 -0800
committerAlexander Biehl <alexbiehl@gmail.com>2018-02-25 16:04:01 +0100
commit7a36a41e154f9ff380b10584ec1a9f8bc4003be1 (patch)
treedd183b14c63add7519c42643bc6fdc6ff6c7b347 /haddock-api/src/Haddock/Interface
parentd66092ee99639de628dbc4fce8a9936875f47d8c (diff)
Fix file handle leak (#763) (#764)
Brought back some mistakenly deleted code for handling encoding and eager reading of files from e0ada1743cb722d2f82498a95b201f3ffb303137.
Diffstat (limited to 'haddock-api/src/Haddock/Interface')
-rw-r--r--haddock-api/src/Haddock/Interface/Create.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index a885b298..cac1e8b0 100644
--- a/haddock-api/src/Haddock/Interface/Create.hs
+++ b/haddock-api/src/Haddock/Interface/Create.hs
@@ -20,6 +20,7 @@
module Haddock.Interface.Create (createInterface) where
import Documentation.Haddock.Doc (metaDocAppend)
+import Documentation.Haddock.Utf8 as Utf8
import Haddock.Types
import Haddock.Options
import Haddock.GhcUtils
@@ -32,14 +33,15 @@ import Haddock.Backends.Hyperlinker.Parser as Hyperlinker
import Data.Bifunctor
import Data.Bitraversable
+import qualified Data.ByteString as BS
import qualified Data.Map as M
import Data.Map (Map)
import Data.List
import Data.Maybe
import Data.Ord
import Control.Applicative
+import Control.Exception (evaluate)
import Control.Monad
-import Control.DeepSeq
import Data.Traversable
import Avail hiding (avail)
@@ -1166,8 +1168,9 @@ mkTokenizedSrc :: DynFlags -> ModSummary -> RenamedSource -> IO [RichToken]
mkTokenizedSrc dflags ms src = do
-- make sure to read the whole file at once otherwise
-- we run out of file descriptors (see #495)
- file <- force <$> readFile (filepath)
- return $ Hyperlinker.enrich src (Hyperlinker.parse dflags filepath file)
+ rawSrc <- BS.readFile (msHsFilePath ms) >>= evaluate
+ let tokens = Hyperlinker.parse dflags filepath (Utf8.decodeUtf8 rawSrc)
+ return $ Hyperlinker.enrich src tokens
where
filepath = msHsFilePath ms