Thu Dec 10 13:10:07 EST 2009 Duncan Coutts <du...@ha...>
* Make c2hs read text files in latin1 encoding
Ignore-this: 9edf2d4a79a63f95d20f435cad9e1303
The c2hs lexer cannot cope with code points over 255.
Fixes the ghc-6.12 build problem where it consumes all memory.
hunk ./tools/c2hs/base/state/CIO.hs 1
+{-# LANGUAGE CPP #-}
+{-# OPTIONS_GHC -cpp #-}
hunk ./tools/c2hs/base/state/CIO.hs 78
+#if __GLASGOW_HASKELL__ >= 612
+import System.IO (hSetEncoding, latin1)
+#endif
hunk ./tools/c2hs/base/state/CIO.hs 90
-openFileCIO p m = liftIO (openFile p m)
+openFileCIO p m = liftIO $ do
+ hnd <- openFile p m
+#if __GLASGOW_HASKELL__ >= 612
+ hSetEncoding hnd latin1
+#endif
+ return hnd
hunk ./tools/c2hs/base/state/CIO.hs 116
-writeFileCIO fname contents = liftIO (writeFile fname contents)
+writeFileCIO fname contents = do
+ hnd <- openFileCIO fname WriteMode
+ hPutStrCIO hnd contents
+ hCloseCIO hnd
hunk ./tools/c2hs/base/state/CIO.hs 122
-readFileCIO fname = liftIO (readFile fname)
+readFileCIO fname = do
+ hnd <- openFileCIO fname ReadMode
+ liftIO (hGetContents hnd)
|