Add a Makefile for MakeTable, and remove GHC.Num generated import
authorIan Lynagh <igloo@earth.li>
Sun, 31 Oct 2010 16:17:32 +0000 (16:17 +0000)
committerIan Lynagh <igloo@earth.li>
Sun, 31 Oct 2010 16:17:32 +0000 (16:17 +0000)
codepages/MakeTable.hs
codepages/Makefile [new file with mode: 0644]

index 408d932..cd9a8b6 100644 (file)
@@ -33,11 +33,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)
 
@@ -201,7 +212,7 @@ firstComment files = map ("-- " ++) $
 
 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#"
diff --git a/codepages/Makefile b/codepages/Makefile
new file mode 100644 (file)
index 0000000..dab5cf5
--- /dev/null
@@ -0,0 +1,19 @@
+
+.PHONY: default
+default:
+       $(MAKE) getCodepages
+       $(MAKE) genTable
+
+.PHONY: getCodepages
+getCodepages:
+       rm -rf www.unicode.org
+       rm -rf CPs
+       mkdir CPs
+       wget -r -np http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/
+       find www.unicode.org -name 'CP*' -exec cp {} CPs \;
+
+.PHONY: genTable
+genTable:
+       ghc --make MakeTable
+       ./MakeTable GHC.IO.Encoding.CodePage.Table ../GHC/IO/Encoding/CodePage/Table.hs CPs/*
+