summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2020-06-23 13:30:33 +0200
committerBen Gamari <ben@smart-cactus.org>2020-07-15 16:41:04 -0400
commitaa4d84d556b39715ebc1a7860a620ec5a7d9beeb (patch)
treee946fee29dcbcd3b23fdea1c06461ecc27129a80
parent8e58e714e9a4b5fe77c4e71802cc4b9ad1998af3 (diff)
downloadhaskell-aa4d84d556b39715ebc1a7860a620ec5a7d9beeb.tar.gz
winio: flushCharReadBuffer shouldn't need to adjust offsets.
-rw-r--r--libraries/base/GHC/IO/Handle/Internals.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/libraries/base/GHC/IO/Handle/Internals.hs b/libraries/base/GHC/IO/Handle/Internals.hs
index f0a2cdac4b..120ae0ea66 100644
--- a/libraries/base/GHC/IO/Handle/Internals.hs
+++ b/libraries/base/GHC/IO/Handle/Internals.hs
@@ -596,11 +596,14 @@ flushCharReadBuffer Handle__{..} = do
(bbuf1,cbuf1) <- (streamEncode decoder) bbuf0
cbuf0{ bufL=0, bufR=0, bufSize = bufL cbuf0 }
- let bbuf2 = bbuf1 -- {bufOffset = bufOffset bbuf1 - fromIntegral (bufL bbuf1)}
- debugIO ("finished, bbuf=" ++ summaryBuffer bbuf2 ++
- " cbuf=" ++ summaryBuffer cbuf1)
-
- writeIORef haByteBuffer bbuf2
+ -- We should not need to update the offset here. The bytebuffer contains the
+ -- offset for the next read after it's used up. But this function only flushes
+ -- the char buffer.
+ -- let bbuf2 = bbuf1 -- {bufOffset = bufOffset bbuf1 - fromIntegral (bufL bbuf1)}
+ -- debugIO ("finished, bbuf=" ++ summaryBuffer bbuf2 ++
+ -- " cbuf=" ++ summaryBuffer cbuf1)
+
+ writeIORef haByteBuffer bbuf1
-- When flushing the byte read buffer, we seek backwards by the number