on master help sign in
Preserve invariant in lazy I/O hGetLine

--HG-- extra : convert_revision : 3411e8b88508906cf6f12daeddd9ff7c45fd3d6f

commite8ade8936a5eab54074b95c7459ca272606c9629 authorBryan O'Sullivan <bos@serpentine.com> dateSun 29 Aug 2010, 07:48 (16 years ago) parentbb3c24c
1 file changed+2−2
Data/Text/IO/Internal.hs+2−2
Data/Text/IO/Internal.hs+2−2
@@ -72,8 +72,8 @@ hGetLineLoop hh@Handle__{..} ts buf@Buffer{ bufL=r0, bufR=w, bufRaw=raw0 } = do
7272 let pre | isEmptyBuffer buf1 = T.empty
7373 | otherwise = T.singleton '\r'
7474 writeIORef haCharBuffer buf1{ bufL=0, bufR=0 }
75− let str = reverse $ pre:t:ts
76− if all T.null str
75+ let str = reverse . filter (not . T.null) $ pre:t:ts
76+ if null str
7777 then ioe_EOF
7878 else return str
7979 Just new_buf -> hGetLineLoop hh (t:ts) new_buf