Skip to content

Commit fd9c873

Browse files
LysxiaBodigrim
authored andcommitted
Fix unpack_nl
1 parent 545ad29 commit fd9c873

File tree

1 file changed

+2
-1
lines changed
  • src/Data/Text/Internal

1 file changed

+2
-1
lines changed

src/Data/Text/Internal/IO.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ unpack !buf !r !w
112112
| otherwise = Yield (ix i) (i+1)
113113
ix i = inlinePerformIO $ peekElemOff pbuf i
114114

115+
-- Variant of 'unpack' with CRLF decoding. If there is a trailing '\r', leave it in the buffer.
115116
unpack_nl :: RawCharBuffer -> Int -> Int -> IO (Text, Int)
116117
unpack_nl !buf !r !w
117118
| charSize /= 4 = sizeError "unpack_nl"
@@ -130,7 +131,7 @@ unpack_nl !buf !r !w
130131
in if i' < w
131132
then if ix i' == '\n'
132133
then Yield '\n' (i+2)
133-
else Yield '\n' i'
134+
else Yield '\r' i'
134135
else Done
135136
| otherwise = Yield c (i+1)
136137
where c = ix i

0 commit comments

Comments
 (0)