[commit: ghc] master: ghc-cabal: force use of UTF8 when writing out `haddock-prologue.txt` (8f26728)

git at git.haskell.org git at git.haskell.org
Sun Mar 23 12:40:05 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/8f26728a44be395a41d9dd9cb933e8006f5a6dc4/ghc

>---------------------------------------------------------------

commit 8f26728a44be395a41d9dd9cb933e8006f5a6dc4
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Sun Mar 23 13:33:03 2014 +0100

    ghc-cabal: force use of UTF8 when writing out `haddock-prologue.txt`
    
    This unbreaks the GHC build if a non-UTF8 locale such as LANG=C is active
    
    See also haskell/cabal#1721 and haskell/haddock#286
    
    Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>


>---------------------------------------------------------------

8f26728a44be395a41d9dd9cb933e8006f5a6dc4
 utils/ghc-cabal/Main.hs |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/utils/ghc-cabal/Main.hs b/utils/ghc-cabal/Main.hs
index 8fa2c29..a7d9e60 100644
--- a/utils/ghc-cabal/Main.hs
+++ b/utils/ghc-cabal/Main.hs
@@ -452,7 +452,8 @@ generate directory distdir dll0Modules config_args
                 "$(eval $(" ++ directory ++ "_PACKAGE_MAGIC))"
                 ]
       writeFile (distdir ++ "/package-data.mk") $ unlines xs
-      writeFile (distdir ++ "/haddock-prologue.txt") $
+
+      writeFileUtf8 (distdir ++ "/haddock-prologue.txt") $
           if null (description pd) then synopsis pd
                                    else description pd
       unless (null dll0Modules) $
@@ -475,3 +476,8 @@ generate directory distdir dll0Modules config_args
      mkSearchPath = intercalate [searchPathSeparator]
      boolToYesNo True = "YES"
      boolToYesNo False = "NO"
+
+     -- | Version of 'writeFile' that always uses UTF8 encoding
+     writeFileUtf8 f txt = withFile f WriteMode $ \hdl -> do
+         hSetEncoding hdl utf8
+         hPutStr hdl txt



More information about the ghc-commits mailing list