Skip to content

Commit 545ad29

Browse files
LysxiaBodigrim
authored andcommitted
Fix writeBlocks
1 parent ffca73d commit 545ad29

File tree

1 file changed

+4
-3
lines changed
  • src/Data/Text/Internal

1 file changed

+4
-3
lines changed

src/Data/Text/Internal/IO.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,12 @@ writeBlocks isCRLF h buf0 (Stream next0 s0 _len) = outer s0 buf0
262262
Done -> commit n False{-no flush-} True{-release-} >> return ()
263263
Skip s' -> inner s' n
264264
Yield x s'
265-
| isCRLF && x == '\n' && n + 1 < len -> do
265+
-- Leave room for two characters for CRLF decoding
266+
| n + 1 >= len -> commit n True{-needs flush-} False >>= outer s
267+
| x == '\n' && isCRLF -> do
266268
n1 <- writeCharBuf' raw len n '\r'
267269
writeCharBuf' raw len n1 '\n' >>= inner s'
268-
| n < len -> writeCharBuf' raw len n x >>= inner s'
269-
| otherwise -> commit n True{-needs flush-} False >>= outer s
270+
| otherwise -> writeCharBuf' raw len n x >>= inner s'
270271
commit = commitBuffer h raw len
271272

272273
-- | Only modifies the raw buffer and not the buffer attributes

0 commit comments

Comments
 (0)