@@ -97,15 +97,16 @@ hGetContents h = do
97 return (hh'{haType=ClosedHandle},T.concat ts)
97 return (hh'{haType=ClosedHandle},T.concat ts)
99 readAll hh@Handle__{..} = do
99 readAll hh@Handle__{..} = do
100− buf <- readIORef haCharBuffer
101 let readChunks = do
100 let readChunks = do
102− t <- readChunk hh buf
101+ t <- readChunk hh =<< readIORef haCharBuffer
103− (hh',ts) <- readAll hh
102+ (hh',ts) <- readChunks
104 return (hh', t:ts)
103 return (hh', t:ts)
105 readChunks `catch` \e -> do
104 readChunks `catch` \e -> do
106 (hh', _) <- hClose_help hh
105 (hh', _) <- hClose_help hh
107 if isEOFError e
106 if isEOFError e
108+ buf <- readIORef haCharBuffer
108− then return $ if isEmptyBuffer buf
109+ return $ if isEmptyBuffer buf
109 then (hh', [])
110 then (hh', [])
110 else (hh', [T.singleton '\r'])
111 else (hh', [T.singleton '\r'])
111 else throw (augmentIOError e "hGetContents" h)
112 else throw (augmentIOError e "hGetContents" h)