% ------------------------------------------------------------------------------
-% $Id: PrelIO.lhs,v 1.15 2000/07/25 15:20:10 simonmar Exp $
+% $Id: PrelIO.lhs,v 1.16 2000/11/07 10:42:56 simonmar Exp $
%
% (c) The University of Glasgow, 1992-2000
%
import PrelRead ( Read(..), readIO )
import PrelShow
import PrelMaybe ( Maybe(..) )
-import PrelAddr ( Addr(..), AddrOff(..), nullAddr, plusAddr )
+import PrelAddr ( Addr(..), nullAddr, plusAddr )
import PrelList ( concat, reverse, null )
import PrelPack ( unpackNBytesST, unpackNBytesAccST )
import PrelException ( ioError, catch, catchException, throw )
-- the handle.
withHandle handle $ \ handle_ -> do
case haType__ handle_ of
- ErrorHandle theError -> ioException theError
ClosedHandle -> ioe_closedHandle "hGetContents" handle
SemiClosedHandle -> ioe_closedHandle "hGetContents" handle
AppendHandle -> ioException not_readable_error
case mode of
NoBuffering -> return (handle_, (mode, nullAddr, 0))
_ -> case bufs of
- [] -> do buf <- allocMemory__ sz
+ [] -> do buf <- malloc sz
return (handle_, (mode, buf, sz))
(b:bs) -> return (handle_{ haBuffers__ = bs }, (mode, b, sz))
-- not flushing, and there's enough room in the buffer:
-- just copy the data in and update bufWPtr.
- else do memcpy (plusAddr fo_buf (AddrOff# fo_wptr)) buf count
+ else do memcpy (plusAddr fo_buf fo_wptr) buf count
setBufWPtr fo (fo_wptr + count)
handle_ <- freeBuffer handle_ buf sz
ok handle_
if (rc < 0) then constructErrorAndFail "commitBuffer"
else return ()
- else do memcpy (plusAddr fo_buf (AddrOff# new_wptr)) buf count
+ else do memcpy (plusAddr fo_buf new_wptr) buf count
setBufWPtr fo (new_wptr + count)
return ()