projects
/
ghc-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5522b14
)
fix hTell behaviour with Unicode Handles
author
Simon Marlow
<marlowsd@gmail.com>
Thu, 25 Nov 2010 12:18:31 +0000
(12:18 +0000)
committer
Simon Marlow
<marlowsd@gmail.com>
Thu, 25 Nov 2010 12:18:31 +0000
(12:18 +0000)
GHC/IO/Handle.hs
patch
|
blob
|
history
diff --git
a/GHC/IO/Handle.hs
b/GHC/IO/Handle.hs
index
bb45b15
..
ddf17e7
100644
(file)
--- a/
GHC/IO/Handle.hs
+++ b/
GHC/IO/Handle.hs
@@
-417,14
+417,17
@@
hTell handle =
posn <- IODevice.tell haDevice
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
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)
debugIO ("\nhGetPosn: (posn, real_posn) = " ++ show (posn, real_posn))
debugIO (" cbuf: " ++ summaryBuffer cbuf ++
" bbuf: " ++ summaryBuffer bbuf)