[commit: packages/haskeline] master: Remove more obsolete #if's (50f640e)
git at git.haskell.org
git at git.haskell.org
Tue Dec 13 19:21:30 UTC 2016
Repository : ssh://git@git.haskell.org/haskeline
On branch : master
Link : http://git.haskell.org/packages/haskeline.git/commitdiff/50f640e2992d80e43b107f93e51deb87cf80ae6e
>---------------------------------------------------------------
commit 50f640e2992d80e43b107f93e51deb87cf80ae6e
Author: Judah Jacobson <judah.jacobson at gmail.com>
Date: Wed Dec 23 22:42:00 2015 -0800
Remove more obsolete #if's
>---------------------------------------------------------------
50f640e2992d80e43b107f93e51deb87cf80ae6e
System/Console/Haskeline/Backend/Posix.hsc | 9 ------
System/Console/Haskeline/Directory.hsc | 50 ------------------------------
System/Console/Haskeline/Term.hs | 4 ---
3 files changed, 63 deletions(-)
diff --git a/System/Console/Haskeline/Backend/Posix.hsc b/System/Console/Haskeline/Backend/Posix.hsc
index a028629..18c6b20 100644
--- a/System/Console/Haskeline/Backend/Posix.hsc
+++ b/System/Console/Haskeline/Backend/Posix.hsc
@@ -35,7 +35,6 @@ import System.Console.Haskeline.Prefs
import System.Console.Haskeline.Backend.Posix.Encoder
-#if __GLASGOW_HASKELL__ >= 611
import GHC.IO.FD (fdFD)
import Data.Dynamic (cast)
import System.IO.Error
@@ -43,10 +42,6 @@ import GHC.IO.Exception
import GHC.IO.Handle.Types hiding (getState)
import GHC.IO.Handle.Internals
import System.Posix.Internals (FD)
-#else
-import GHC.IOBase(haFD,FD)
-import GHC.Handle (withHandle_)
-#endif
#if defined(USE_TERMIOS_H) || defined(__ANDROID__)
#include <termios.h>
@@ -81,7 +76,6 @@ ioctlLayout h = allocaBytes (#size struct winsize) $ \ws -> do
else return Nothing
unsafeHandleToFD :: Handle -> IO FD
-#if __GLASGOW_HASKELL__ >= 611
unsafeHandleToFD h =
withHandle_ "unsafeHandleToFd" h $ \Handle__{haDevice=dev} -> do
case cast dev of
@@ -89,9 +83,6 @@ unsafeHandleToFD h =
"unsafeHandleToFd" (Just h) Nothing)
"handle is not a file descriptor")
Just fd -> return (fdFD fd)
-#else
-unsafeHandleToFD h = withHandle_ "unsafeHandleToFd" h (return . haFD)
-#endif
envLayout :: IO (Maybe Layout)
envLayout = handle (\(_::IOException) -> return Nothing) $ do
diff --git a/System/Console/Haskeline/Directory.hsc b/System/Console/Haskeline/Directory.hsc
index 9eb0952..36f57fa 100644
--- a/System/Console/Haskeline/Directory.hsc
+++ b/System/Console/Haskeline/Directory.hsc
@@ -14,9 +14,7 @@ module System.Console.Haskeline.Directory(
import Foreign
import Foreign.C
import System.Win32.Types
-#if __GLASGOW_HASKELL__ >= 611
import qualified System.Directory
-#endif
#include <windows.h>
#include <shlobj.h>
@@ -62,59 +60,11 @@ doesDirectoryExist file = do
return $ attrs /= (#const INVALID_FILE_ATTRIBUTES)
&& (attrs .&. (#const FILE_ATTRIBUTE_DIRECTORY)) /= 0
-#if __GLASGOW_HASKELL__ >= 611
getHomeDirectory :: IO FilePath
getHomeDirectory = System.Directory.getHomeDirectory
-#else
-type HRESULT = #type HRESULT
-
-foreign import WINDOWS_CCONV "SHGetFolderPathW" c_SHGetFolderPath
- :: Ptr () -> CInt -> HANDLE -> DWORD -> LPTSTR -> IO HRESULT
-
-getHomeDirectory :: IO FilePath
-getHomeDirectory = allocaBytes ((#const MAX_PATH) * (#size TCHAR)) $ \pathPtr -> do
- result <- c_SHGetFolderPath nullPtr (#const CSIDL_PROFILE) nullPtr 0 pathPtr
-
- if result /= (#const S_OK)
- then return ""
- else peekCWString pathPtr
-#endif
#else
--- POSIX
--- On 7.2.1 and later, getDirectoryContents uses the locale encoding
--- But previous version don't, so we need to decode manually.
-#if __GLASGOW_HASKELL__ >= 701
import System.Directory
-#else
-import Data.ByteString.Char8 (pack, unpack)
-import qualified System.Directory as D
-import Control.Exception
-import System.Console.Haskeline.Backend.Posix.IConv
-
-getDirectoryContents :: FilePath -> IO [FilePath]
-getDirectoryContents path = do
- codeset <- getCodeset
- encoder <- openEncoder codeset
- decoder <- openDecoder codeset
- dirEnc <- fmap unpack (encoder path)
- filesEnc <- handle (\(_::IOException) -> return [])
- $ D.getDirectoryContents dirEnc
- mapM (decoder . pack) filesEnc
-
-doesDirectoryExist :: FilePath -> IO Bool
-doesDirectoryExist file = do
- codeset <- getCodeset
- encoder <- openEncoder codeset
- encoder file >>= D.doesDirectoryExist . unpack
-
-getHomeDirectory :: IO FilePath
-getHomeDirectory = do
- codeset <- getCodeset
- decoder <- openDecoder codeset
- handle (\(_::IOException) -> return "")
- $ D.getHomeDirectory >>= decoder . pack
-#endif
#endif
diff --git a/System/Console/Haskeline/Term.hs b/System/Console/Haskeline/Term.hs
index 9689a16..2b9c023 100644
--- a/System/Console/Haskeline/Term.hs
+++ b/System/Console/Haskeline/Term.hs
@@ -138,13 +138,9 @@ data Layout = Layout {width, height :: Int}
-- | Utility function since we're not using the new IO library yet.
hWithBinaryMode :: MonadException m => Handle -> m a -> m a
-#if __GLASGOW_HASKELL__ >= 611
hWithBinaryMode h = bracket (liftIO $ hGetEncoding h)
(maybe (return ()) (liftIO . hSetEncoding h))
. const . (liftIO (hSetBinaryMode h True) >>)
-#else
-hWithBinaryMode _ = id
-#endif
-- | Utility function for changing a property of a terminal for the duration of
-- a computation.
More information about the ghc-commits
mailing list