diff options
author | simonmar <unknown> | 2006-01-09 13:25:50 +0000 |
---|---|---|
committer | simonmar <unknown> | 2006-01-09 13:25:50 +0000 |
commit | 5d8f5e005c673f6e14a7e1b61f889b176ccf4766 (patch) | |
tree | 4f230930fbc9e1fb59a4b957ba9dc1fd6d216512 /ghc/compiler/utils/Encoding.hs | |
parent | e1001abdb4f7ff4d703fc3dc0d587f861e11740c (diff) | |
download | haskell-5d8f5e005c673f6e14a7e1b61f889b176ccf4766.tar.gz |
[project @ 2006-01-09 13:25:50 by simonmar]
Fix up to compile with GHC 5.04.x again.
Also includes a fix for a memory error I discovered along the way:
should fix the "scavenge_one" crash in the stage2 build of recent
HEADs.
Diffstat (limited to 'ghc/compiler/utils/Encoding.hs')
-rw-r--r-- | ghc/compiler/utils/Encoding.hs | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/ghc/compiler/utils/Encoding.hs b/ghc/compiler/utils/Encoding.hs index d15c0216ae..1f266e11a7 100644 --- a/ghc/compiler/utils/Encoding.hs +++ b/ghc/compiler/utils/Encoding.hs @@ -1,7 +1,6 @@ -{-# OPTIONS_GHC -O #-} -- ----------------------------------------------------------------------------- -- --- (c) The University of Glasgow, 1997-2003 +-- (c) The University of Glasgow, 1997-2006 -- -- Character encodings -- @@ -19,10 +18,6 @@ module Encoding ( utf8EncodedLength, countUTF8Chars, - -- * Latin-1 - latin1DecodeChar, - latin1EncodeChar, - -- * Z-encoding zEncodeString, zDecodeString @@ -34,21 +29,11 @@ import Foreign import Data.Char ( ord, chr, isDigit, digitToInt, isHexDigit ) import Numeric ( showHex ) +import Data.Bits import GHC.Ptr ( Ptr(..) ) import GHC.Base -- ----------------------------------------------------------------------------- --- Latin-1 - -latin1DecodeChar ptr = do - w <- peek ptr - return (unsafeChr (fromIntegral w), ptr `plusPtr` 1) - -latin1EncodeChar c ptr = do - poke ptr (fromIntegral (ord c)) - return (ptr `plusPtr` 1) - --- ----------------------------------------------------------------------------- -- UTF-8 -- We can't write the decoder as efficiently as we'd like without @@ -200,8 +185,10 @@ utf8EncodedLength str = go 0 str {- This is the main name-encoding and decoding function. It encodes any -string into a string that is acceptable as a C name. This is the name -by which things are known right through the compiler. +string into a string that is acceptable as a C name. This is done +right before we emit a symbol name into the compiled C or asm code. +Z-encoding of strings is cached in the FastString interface, so we +never encode the same string more than once. The basic encoding scheme is this. |