X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FIO%2FHandle.hs;h=ddf17e7540782bc91f93b4377b90b32af87e12c2;hb=b99920eab7fba4e027fd39985840d4e854b8f923;hp=bb45b151f44d03f9a5b5f67447ea2aa42a8ad2b5;hpb=5522b142e24b9dbba21a9036746db20e78cf8f43;p=ghc-base.git diff --git a/GHC/IO/Handle.hs b/GHC/IO/Handle.hs index bb45b15..ddf17e7 100644 --- a/GHC/IO/Handle.hs +++ b/GHC/IO/Handle.hs @@ -417,14 +417,17 @@ hTell handle = posn <- IODevice.tell haDevice - cbuf <- readIORef haCharBuffer + -- we can't tell the real byte offset if there are buffered + -- Chars, so must flush first: + flushCharBuffer handle_ + bbuf <- readIORef haByteBuffer - let real_posn - | isWriteBuffer cbuf = posn + fromIntegral (bufR cbuf) - | otherwise = posn - fromIntegral (bufR cbuf - bufL cbuf) - - fromIntegral (bufR bbuf - bufL bbuf) + let real_posn + | isWriteBuffer bbuf = posn + fromIntegral (bufferElems bbuf) + | otherwise = posn - fromIntegral (bufferElems bbuf) + cbuf <- readIORef haCharBuffer debugIO ("\nhGetPosn: (posn, real_posn) = " ++ show (posn, real_posn)) debugIO (" cbuf: " ++ summaryBuffer cbuf ++ " bbuf: " ++ summaryBuffer bbuf)