summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1f35ed0)
- fix one case where it was blocking when it shouldn't
- a couple of error-message tweaks
hGetBufSome :: Handle -> Ptr a -> Int -> IO Int
hGetBufSome h ptr count
| count == 0 = return 0
hGetBufSome :: Handle -> Ptr a -> Int -> IO Int
hGetBufSome h ptr count
| count == 0 = return 0
- | count < 0 = illegalBufferSize h "hGetBuf" count
+ | count < 0 = illegalBufferSize h "hGetBufSome" count
- wantReadableHandle_ "hGetBuf" h $ \ h_@Handle__{..} -> do
+ wantReadableHandle_ "hGetBufSome" h $ \ h_@Handle__{..} -> do
flushCharReadBuffer h_
buf@Buffer{ bufSize=sz } <- readIORef haByteBuffer
if isEmptyBuffer buf
flushCharReadBuffer h_
buf@Buffer{ bufSize=sz } <- readIORef haByteBuffer
if isEmptyBuffer buf
if r == 0
then return 0
else do writeIORef haByteBuffer buf'
if r == 0
then return 0
else do writeIORef haByteBuffer buf'
- bufReadNBNonEmpty h_ buf' (castPtr ptr) 0 count
+ bufReadNBNonEmpty h_ buf' (castPtr ptr) 0 (min r count)
+ -- new count is (min r count), so
+ -- that bufReadNBNonEmpty will not
+ -- issue another read.
else
bufReadNBEmpty h_ buf (castPtr ptr) 0 count
else
bufReadNBEmpty h_ buf (castPtr ptr) 0 count