diff options
author | Ian Lynagh <igloo@earth.li> | 2010-02-26 22:39:31 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2010-02-26 22:39:31 +0000 |
commit | d78b2eb70ee84d83833be14e855d5e3d72356892 (patch) | |
tree | 46b1ec8d939660bce5c614c60434a476a39c3df3 /utils | |
parent | 8008ed2cb38fb61717c03ea01c4531c6089a1de5 (diff) | |
download | haskell-d78b2eb70ee84d83833be14e855d5e3d72356892.tar.gz |
Fix the build with GHC < 6.12
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ghc-pkg/Main.hs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs index ae7aca3398..79404bc85e 100644 --- a/utils/ghc-pkg/Main.hs +++ b/utils/ghc-pkg/Main.hs @@ -729,7 +729,7 @@ changeDBDir verbosity cmds db = do do_cmd (AddPackage p) = do let file = location db </> display (installedPackageId p) <.> "conf" when (verbosity > Normal) $ putStrLn ("writing " ++ file) - writeFileAtomic file utf8 (showInstalledPackageInfo p) + writeFileUtf8Atomic file (showInstalledPackageInfo p) do_cmd (ModifyPackage p) = do_cmd (AddPackage p) @@ -1151,7 +1151,7 @@ writeNewConfig verbosity filename ipis = do let shown = concat $ intersperse ",\n " $ map (show . convertPackageInfoOut) ipis fileContents = "[" ++ shown ++ "\n]" - writeFileAtomic filename utf8 fileContents + writeFileUtf8Atomic filename fileContents `catch` \e -> if isPermissionError e then die (filename ++ ": you don't have permission to modify this file") @@ -1557,10 +1557,12 @@ writeBinaryFileAtomic targetFile obj = hSetBinaryMode h True B.hPutStr h (Bin.encode obj) -writeFileAtomic :: FilePath -> TextEncoding -> String -> IO () -writeFileAtomic targetFile encoding content = +writeFileUtf8Atomic :: FilePath -> String -> IO () +writeFileUtf8Atomic targetFile content = withFileAtomic targetFile $ \h -> do - hSetEncoding h encoding +#if __GLASGOW_HASKELL__ >= 612 + hSetEncoding h utf8 +#endif hPutStr h content -- copied from Cabal's Distribution.Simple.Utils, except that we want |