projects
/
ghc-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d6879ef
)
Fix whitespace in codepages/MakeTable.hs
author
Ian Lynagh
<igloo@earth.li>
Sun, 31 Oct 2010 15:49:53 +0000
(15:49 +0000)
committer
Ian Lynagh
<igloo@earth.li>
Sun, 31 Oct 2010 15:49:53 +0000
(15:49 +0000)
codepages/MakeTable.hs
patch
|
blob
|
history
diff --git
a/codepages/MakeTable.hs
b/codepages/MakeTable.hs
index
af123df
..
408d932
100644
(file)
--- a/
codepages/MakeTable.hs
+++ b/
codepages/MakeTable.hs
@@
-1,6
+1,6
@@
-{--
+{--
This is a script to generate the necessary tables to support Windows code page
This is a script to generate the necessary tables to support Windows code page
-encoding/decoding.
+encoding/decoding.
License: see libraries/base/LICENSE
License: see libraries/base/LICENSE
@@
-15,7
+15,7
@@
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.
statically linked into every executable. We plan to add support for them once
GHC is able to produce Windows DLLs.
---}
+--}
module Main where
module Main where
@@
-70,7
+70,7
@@
readCharHex :: String -> Char
readCharHex s = if c > fromEnum (maxBound :: Word16)
then error "Can't handle non-BMP character."
else toEnum c
readCharHex s = if c > fromEnum (maxBound :: Word16)
then error "Can't handle non-BMP character."
else toEnum c
- where c = readHex' s
+ where c = readHex' s
-------------------------------------------
-------------------------------------------
@@
-90,13
+90,13
@@
makeTableFile moduleName files maps = concat
++ [" ]"]
mkTableEntry (i,m) = " (" ++ show i ++ ", " ++ makeSBE m ++ " )"
blockSizeText = ["blockBitSize :: Int", "blockBitSize = " ++ show blockBitSize]
++ [" ]"]
mkTableEntry (i,m) = " (" ++ show i ++ ", " ++ makeSBE m ++ " )"
blockSizeText = ["blockBitSize :: Int", "blockBitSize = " ++ show blockBitSize]
-
+
makeSBE :: Map.Map Word8 Char -> String
makeSBE m = unlines
[ "SingleByteCP {"
, " decoderArray = " ++ mkConvArray es
makeSBE :: Map.Map Word8 Char -> String
makeSBE m = unlines
[ "SingleByteCP {"
, " decoderArray = " ++ mkConvArray es
- , " , encoderArray = " ++ mkCompactArray (swapMap m)
+ , " , encoderArray = " ++ mkCompactArray (swapMap m)
, " }"
]
where
, " }"
]
where
@@
-167,7
+167,7
@@
mkCompactArray m = unlines [
type CompressState b = (Map.Map Int [b], Map.Map [b] Int)
-- each entry in the list corresponds to a block of size n.
type CompressState b = (Map.Map Int [b], Map.Map [b] Int)
-- each entry in the list corresponds to a block of size n.
-compress :: (Bounded a, Enum a, Ord a, Bounded b, Ord b) => Int -> Map.Map a b
+compress :: (Bounded a, Enum a, Ord a, Bounded b, Ord b) => Int -> Map.Map a b
-> ([Int], CompressState b)
compress n ms = runState (mapM lookupOrAdd chunks) (Map.empty, Map.empty)
where
-> ([Int], CompressState b)
compress n ms = runState (mapM lookupOrAdd chunks) (Map.empty, Map.empty)
where
@@
-226,7
+226,7
@@
class (Ord a, Enum a, Bounded a, Show a) => Embed a where
instance Embed Word8 where
mkHex = showHex'
instance Embed Word8 where
mkHex = showHex'
-
+
instance Embed Word16 where
mkHex = repDualByte
instance Embed Word16 where
mkHex = repDualByte
@@
-241,7
+241,7
@@
showHex' :: Integral a => a -> String
showHex' s = "\\x" ++ showHex s ""
repDualByte :: Enum c => c -> String
showHex' s = "\\x" ++ showHex s ""
repDualByte :: Enum c => c -> String
-repDualByte c
+repDualByte c
| n >= 2^(16::Int) = error "value is too high!"
-- NOTE : this assumes little-endian architecture. But we're only using this on Windows,
-- so it's probably OK.
| n >= 2^(16::Int) = error "value is too high!"
-- NOTE : this assumes little-endian architecture. But we're only using this on Windows,
-- so it's probably OK.