From: Simon Marlow Date: Thu, 22 Jun 2006 14:44:46 +0000 (+0000) Subject: default to NoBuffering on Windows for a read/write text file X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=f4ed1a81084c267c6f36bec7f8100b6a4b62253f;p=haskell-directory.git default to NoBuffering on Windows for a read/write text file Fixes (works around) #679 --- diff --git a/GHC/Handle.hs b/GHC/Handle.hs index 52bf8cd..8f5fe18 100644 --- a/GHC/Handle.hs +++ b/GHC/Handle.hs @@ -973,6 +973,17 @@ mkStdHandle fd filepath ha_type buf bmode = do mkFileHandle :: FD -> Bool -> FilePath -> HandleType -> Bool -> IO Handle mkFileHandle fd is_stream filepath ha_type binary = do (buf, bmode) <- getBuffer fd (initBufferState ha_type) + +#ifdef mingw32_HOST_OS + -- On Windows, if this is a read/write handle and we are in text mode, + -- turn off buffering. We don't correctly handle the case of switching + -- from read mode to write mode on a buffered text-mode handle, see bug + -- #679. + bmode <- case ha_type of + ReadWriteHandle | not binary -> return NoBuffering + _other -> return bmode +#endif + spares <- newIORef BufferListNil newFileHandle filepath (handleFinalizer filepath) (Handle__ { haFD = fd,