Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove some CPPery for old, no-longer-supported versions of GHC

  • Loading branch information...
commit 15fd935568e266100d2a8c8f7ca830874ed39f80 1 parent 75f9254
@igfoo igfoo authored
View
21 Cabal/Distribution/Compat/CopyFile.hs
@@ -22,12 +22,10 @@ import Control.Exception
( bracket, bracketOnError )
import Distribution.Compat.Exception
( catchIO )
-#if __GLASGOW_HASKELL__ >= 608
import Distribution.Compat.Exception
( throwIOIO )
import System.IO.Error
( ioeSetLocation )
-#endif
import System.Directory
( renameFile, removeFile )
import Distribution.Compat.TempFile
@@ -41,22 +39,13 @@ import Foreign
#endif /* __GLASGOW_HASKELL__ */
#ifndef mingw32_HOST_OS
-#if __GLASGOW_HASKELL__ >= 611
import System.Posix.Internals (withFilePath)
-#else
-import Foreign.C (withCString)
-#endif
import System.Posix.Types
( FileMode )
import System.Posix.Internals
( c_chmod )
-#if __GLASGOW_HASKELL__ >= 608
import Foreign.C
( throwErrnoPathIfMinus1_ )
-#else
-import Foreign.C
- ( throwErrnoIfMinus1_ )
-#endif
#endif /* mingw32_HOST_OS */
copyOrdinaryFile, copyExecutableFile :: FilePath -> FilePath -> IO ()
@@ -70,17 +59,9 @@ setFileExecutable path = setFileMode path 0o755 -- file perms -rwxr-xr-x
setFileMode :: FilePath -> FileMode -> IO ()
setFileMode name m =
-#if __GLASGOW_HASKELL__ >= 611
withFilePath name $ \s -> do
-#else
- withCString name $ \s -> do
-#endif
-#if __GLASGOW_HASKELL__ >= 608
throwErrnoPathIfMinus1_ "setFileMode" name (c_chmod s m)
#else
- throwErrnoIfMinus1_ name (c_chmod s m)
-#endif
-#else
setFileOrdinary _ = return ()
setFileExecutable _ = return ()
#endif
@@ -91,9 +72,7 @@ copyFile :: FilePath -> FilePath -> IO ()
#ifdef __GLASGOW_HASKELL__
copyFile fromFPath toFPath =
copy
-#if __GLASGOW_HASKELL__ >= 608
`catchIO` (\ioe -> throwIOIO (ioeSetLocation ioe "copyFile"))
-#endif
where copy = bracket (openBinaryFile fromFPath ReadMode) hClose $ \hFrom ->
bracketOnError openTmp cleanTmp $ \(tmpFPath, hTmp) ->
do allocaBytes bufferSize $ copyContents hFrom hTmp
View
2  Cabal/Distribution/Compat/Exception.hs
@@ -5,7 +5,7 @@
{-# OPTIONS_NHC98 -cpp #-}
{-# OPTIONS_JHC -fcpp #-}
-#if !(defined(__HUGS__) || (defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 610))
+#if !defined(__HUGS__)
#define NEW_EXCEPTION
#endif
View
24 Cabal/Distribution/Compat/TempFile.hs
@@ -28,17 +28,9 @@ import Data.Bits ((.|.))
import System.Posix.Internals (c_open, c_close, o_CREAT, o_EXCL, o_RDWR,
o_BINARY, o_NONBLOCK, o_NOCTTY)
import System.IO.Error (isAlreadyExistsError)
-#if __GLASGOW_HASKELL__ >= 611
import System.Posix.Internals (withFilePath)
-#else
-import Foreign.C (withCString)
-#endif
import Foreign.C (CInt)
-#if __GLASGOW_HASKELL__ >= 611
import GHC.IO.Handle.FD (fdToHandle)
-#else
-import GHC.Handle (fdToHandle)
-#endif
import Distribution.Compat.Exception (onException, tryIO)
#endif
import Foreign.C (getErrno, errnoToIOError)
@@ -128,10 +120,6 @@ openNewBinaryFile dir template = do
oflags = rw_flags .|. o_EXCL .|. o_BINARY
-#if __GLASGOW_HASKELL__ < 611
- withFilePath = withCString
-#endif
-
findTempName x = do
fd <- withFilePath filepath $ \ f ->
c_open f oflags 0o666
@@ -145,17 +133,7 @@ openNewBinaryFile dir template = do
-- TODO: We want to tell fdToHandle what the filepath is,
-- as any exceptions etc will only be able to report the
-- fd currently
- h <-
-#if __GLASGOW_HASKELL__ >= 609
- fdToHandle fd
-#elif __GLASGOW_HASKELL__ <= 606 && defined(mingw32_HOST_OS)
- -- fdToHandle is borked on Windows with ghc-6.6.x
- openFd (fromIntegral fd) Nothing False filepath
- ReadWriteMode True
-#else
- fdToHandle (fromIntegral fd)
-#endif
- `onException` c_close fd
+ h <- fdToHandle fd `onException` c_close fd
return (filepath, h)
where
filename = prefix ++ show x ++ suffix
View
32 Cabal/Distribution/PackageDescription/Configuration.hs
@@ -91,11 +91,6 @@ import Data.Map ( Map, fromListWith, toList )
import qualified Data.Map as Map
import Data.Monoid
-#if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ < 606)
-import qualified Text.Read as R
-import qualified Text.Read.Lex as L
-#endif
-
------------------------------------------------------------------------------
-- | Simplify the condition and return its free variables.
@@ -315,34 +310,7 @@ resolveWithFlags dom os arch impl constrs trees checkDeps =
-- | A map of dependencies. Newtyped since the default monoid instance is not
-- appropriate. The monoid instance uses 'intersectVersionRanges'.
newtype DependencyMap = DependencyMap { unDependencyMap :: Map PackageName VersionRange }
-#if !defined(__GLASGOW_HASKELL__) || (__GLASGOW_HASKELL__ >= 606)
deriving (Show, Read)
-#else
--- The Show/Read instance for Data.Map in ghc-6.4 is useless
--- so we have to re-implement it here:
-instance Show DependencyMap where
- showsPrec d (DependencyMap m) =
- showParen (d > 10) (showString "DependencyMap" . shows (M.toList m))
-
-instance Read DependencyMap where
- readPrec = parens $ R.prec 10 $ do
- R.Ident "DependencyMap" <- R.lexP
- xs <- R.readPrec
- return (DependencyMap (M.fromList xs))
- where parens :: R.ReadPrec a -> R.ReadPrec a
- parens p = optional
- where
- optional = p R.+++ mandatory
- mandatory = paren optional
-
- paren :: R.ReadPrec a -> R.ReadPrec a
- paren p = do L.Punc "(" <- R.lexP
- x <- R.reset p
- L.Punc ")" <- R.lexP
- return x
-
- readListPrec = R.readListPrecDefault
-#endif
instance Monoid DependencyMap where
mempty = DependencyMap Map.empty
View
2  Cabal/Distribution/Simple/InstallDirs.hs
@@ -77,7 +77,7 @@ import Data.Maybe (fromMaybe)
import Data.Monoid (Monoid(..))
import System.Directory (getAppUserDataDirectory)
import System.FilePath ((</>), isPathSeparator, pathSeparator)
-#if __HUGS__ || __GLASGOW_HASKELL__ > 606
+#if defined(__HUGS__) || defined(__GLASGOW_HASKELL__)
import System.FilePath (dropDrive)
#endif
View
6 Cabal/Distribution/Simple/Utils.hs
@@ -171,7 +171,7 @@ import System.IO
import System.IO.Error as IO.Error
( isDoesNotExistError, isAlreadyExistsError
, ioeSetFileName, ioeGetFileName, ioeGetErrorString )
-#if !(defined(__HUGS__) || (defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 608))
+#if !defined(__HUGS__)
import System.IO.Error
( ioeSetLocation, ioeGetLocation )
#endif
@@ -231,7 +231,7 @@ dieWithLocation filename lineno msg =
. flip ioeSetFileName (normalise filename)
$ userError msg
where
-#if defined(__HUGS__) || (defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 608)
+#if defined(__HUGS__)
setLocation _ err = err
#else
setLocation Nothing err = err
@@ -254,7 +254,7 @@ topHandler prog = catchIO prog handle
file = case ioeGetFileName ioe of
Nothing -> ""
Just path -> path ++ location ++ ": "
-#if defined(__HUGS__) || (defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 608)
+#if defined(__HUGS__)
location = ""
#else
location = case ioeGetLocation ioe of
Please sign in to comment.
Something went wrong with that request. Please try again.