Use explicit language extensions & remove extension fields from base.cabal
[ghc-base.git] / codepages / MakeTable.hs
index 408d932..e17380b 100644 (file)
@@ -14,7 +14,6 @@ Currently, this script only supports single-byte encodings, since the lookup
 tables required for the CJK double-byte codepages are too large to be
 statically linked into every executable.  We plan to add support for them once
 GHC is able to produce Windows DLLs.
-
 --}
 
 module Main where
@@ -33,11 +32,22 @@ import Control.Exception(evaluate)
 main :: IO ()
 main = do
     moduleName:outFile:files <- getArgs
-    sbes <- mapM readMapAndIx files
+    let badFiles = -- These fail with an error like
+                   --     MakeTable: Enum.toEnum{Word8}: tag (33088) is outside of bounds (0,255)
+                   -- I have no idea what's going on, so for now we just
+                   -- skip them.
+                   ["CPs/CP932.TXT",
+                    "CPs/CP936.TXT",
+                    "CPs/CP949.TXT",
+                    "CPs/CP950.TXT"]
+    let files' = filter (`notElem` badFiles) files
+    sbes <- mapM readMapAndIx files'
+    putStrLn "Writing output"
     withBinaryFile outFile WriteMode $ flip hPutStr
-        $ unlines $ makeTableFile moduleName files sbes
+        $ unlines $ makeTableFile moduleName files' sbes
   where
     readMapAndIx f = do
+        putStrLn ("Reading " ++ f)
         m <- readMap f
         return (codePageNum f, m)
 
@@ -190,18 +200,21 @@ compress n ms = runState (mapM lookupOrAdd chunks) (Map.empty, Map.empty)
 -- Static parts of the generated module.
 
 languageDirectives :: [String]
-languageDirectives = ["{-# LANGUAGE MagicHash #-}"]
+languageDirectives = ["{-# LANGUAGE CPP, MagicHash #-}"]
 
 
 firstComment :: [FilePath] -> [String]
 firstComment files = map ("-- " ++) $
     [ "Do not edit this file directly!"
-    , "It was generated by the MakeTable.hs script using the following files:"
+    , "It was generated by the MakeTable.hs script using the files below."
+    , "To regenerate it, run \"make\" in ../../../../codepages/"
+    , ""
+    , "Files:"
     ] ++ map takeFileName files
 
 theImports :: [String]
 theImports = map ("import " ++ )
-    ["GHC.Prim", "GHC.Base", "GHC.Word", "GHC.Num"]
+    ["GHC.Prim", "GHC.Base", "GHC.Word"]
 
 theTypes :: [String]
 theTypes = [ "data ConvArray a = ConvArray Addr#"