From: simonmar Date: Tue, 31 Jul 2001 11:59:08 +0000 (+0000) Subject: [project @ 2001-07-31 11:59:08 by simonmar] X-Git-Tag: nhc98-1-18-release~1213 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=5dad5fb64d44eb53a5db829f50311e998ea7b72c;p=haskell-directory.git [project @ 2001-07-31 11:59:08 by simonmar] merge fptools/ghc/lib/std/PrelHandle.hsc rev. 1.11 --- diff --git a/GHC/Handle.hsc b/GHC/Handle.hsc index c613d43..cc10334 100644 --- a/GHC/Handle.hsc +++ b/GHC/Handle.hsc @@ -4,7 +4,7 @@ #undef DEBUG -- ----------------------------------------------------------------------------- --- $Id: Handle.hsc,v 1.1 2001/06/28 14:15:03 simonmar Exp $ +-- $Id: Handle.hsc,v 1.2 2001/07/31 11:59:08 simonmar Exp $ -- -- (c) The University of Glasgow, 1994-2001 -- @@ -22,9 +22,11 @@ module GHC.Handle ( stdin, stdout, stderr, IOMode(..), IOModeEx(..), openFile, openFileEx, openFd, - hClose, hFileSize, hIsEOF, isEOF, hLookAhead, hSetBuffering, hSetBinaryMode, + hFileSize, hIsEOF, isEOF, hLookAhead, hSetBuffering, hSetBinaryMode, hFlush, + hClose, hClose_help, + HandlePosn(..), hGetPosn, hSetPosn, SeekMode(..), hSeek, @@ -115,9 +117,7 @@ but we might want to revisit this in the future --SDM ]. {-# INLINE withHandle #-} withHandle :: String -> Handle -> (Handle__ -> IO (Handle__,a)) -> IO a withHandle fun h@(FileHandle m) act = withHandle' fun h m act -withHandle fun h@(DuplexHandle r w) act = do - withHandle' fun h r act - withHandle' fun h w act +withHandle fun h@(DuplexHandle m _) act = withHandle' fun h m act withHandle' fun h m act = block $ do @@ -747,8 +747,9 @@ hClose h@(DuplexHandle r w) = do haType = ClosedHandle } -hClose' h m = - withHandle__' "hClose" h m $ \ handle_ -> do +hClose' h m = withHandle__' "hClose" h m $ hClose_help + +hClose_help handle_ = case haType handle_ of ClosedHandle -> return handle_ _ -> do @@ -1146,18 +1147,20 @@ hIsTerminalDevice handle = do #ifdef _WIN32 hSetBinaryMode handle bin = - withHandle "hSetBinaryMode" handle $ \ handle_ -> + withAllHandles__ "hSetBinaryMode" handle $ \ handle_ -> do let flg | bin = (#const O_BINARY) | otherwise = (#const O_TEXT) throwErrnoIfMinus1_ "hSetBinaryMode" (setmode (fromIntegral (haFD handle_)) flg) - return (handle_{haIsBin=bin}, ()) + return handle_{haIsBin=bin} + return () foreign import "setmode" setmode :: CInt -> CInt -> IO CInt #else -hSetBinaryMode handle bin = - withHandle "hSetBinaryMode" handle $ \ handle_ -> - return (handle_{haIsBin=bin}, ()) +hSetBinaryMode handle bin = do + withAllHandles__ "hSetBinaryMode" handle $ \ handle_ -> + return handle_{haIsBin=bin} + return () #endif -- -----------------------------------------------------------------------------