[commit: ghc] master: copyFileWithHeader: write the header in UTF-8 (3e8303c)
Simon Marlow
marlowsd at gmail.com
Thu Nov 24 15:57:16 CET 2011
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/3e8303c137e647c4db919f7c21396e1325b58731
>---------------------------------------------------------------
commit 3e8303c137e647c4db919f7c21396e1325b58731
Author: Simon Marlow <marlowsd at gmail.com>
Date: Thu Nov 24 10:59:57 2011 +0000
copyFileWithHeader: write the header in UTF-8
>---------------------------------------------------------------
compiler/main/SysTools.lhs | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
index 0031159..4a51b31 100644
--- a/compiler/main/SysTools.lhs
+++ b/compiler/main/SysTools.lhs
@@ -582,10 +582,22 @@ copyWithHeader dflags purpose maybe_header from to = do
hout <- openBinaryFile to WriteMode
hin <- openBinaryFile from ReadMode
ls <- hGetContents hin -- inefficient, but it'll do for now. ToDo: speed up
- maybe (return ()) (hPutStr hout) maybe_header
+ maybe (return ()) (header hout) maybe_header
hPutStr hout ls
hClose hout
hClose hin
+ where
+#if __GLASGOW_HASKELL__ >= 702
+ -- write the header string in UTF-8. The header is something like
+ -- {-# LINE "foo.hs" #-}
+ -- and we want to make sure a Unicode filename isn't mangled.
+ header h str = do
+ hSetEncoding h utf8
+ hPutStr h str
+ hSetBinaryMode h True
+#else
+ header h str = hPutStr h str
+#endif
-- | read the contents of the named section in an ELF object as a
-- String.
More information about the Cvs-ghc
mailing list