projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use existing function uniqAway instead of duplicating code
[ghc-hetmet.git]
/
compiler
/
utils
/
Encoding.hs
diff --git
a/compiler/utils/Encoding.hs
b/compiler/utils/Encoding.hs
index
152bf3c
..
5afe870
100644
(file)
--- a/
compiler/utils/Encoding.hs
+++ b/
compiler/utils/Encoding.hs
@@
-26,9
+26,9
@@
module Encoding (
#define COMPILING_FAST_STRING
#include "HsVersions.h"
import Foreign
#define COMPILING_FAST_STRING
#include "HsVersions.h"
import Foreign
-import Data.Char ( ord, chr, isDigit, digitToInt, isHexDigit )
-import Numeric ( showHex )
-
+import Data.Char ( ord, chr, isDigit, digitToInt, intToDigit,
+ isHexDigit )
+import Numeric ( showIntAtBase )
import Data.Bits
import GHC.Ptr ( Ptr(..) )
import GHC.Base
import Data.Bits
import GHC.Ptr ( Ptr(..) )
import GHC.Base
@@
-138,6
+138,7
@@
countUTF8Chars ptr bytes = go ptr 0
unPtr (Ptr a) = a
unPtr (Ptr a) = a
+utf8EncodeChar :: Char -> Ptr Word8 -> IO (Ptr Word8)
utf8EncodeChar c ptr =
let x = ord c in
case () of
utf8EncodeChar c ptr =
let x = ord c in
case () of
@@
-281,6
+282,9
@@
encode_ch c = 'z' : if isDigit (head hex_str) then hex_str
-- eg. strings of unicode characters come out as 'z1234Uz5678U', we
-- could remove the 'U' in the middle (the 'z' works as a separator).
-- eg. strings of unicode characters come out as 'z1234Uz5678U', we
-- could remove the 'U' in the middle (the 'z' works as a separator).
+ showHex = showIntAtBase 16 intToDigit
+ -- needed because prior to GHC 6.2, Numeric.showHex added a "0x" prefix
+
zDecodeString :: EncodedString -> UserString
zDecodeString [] = []
zDecodeString ('Z' : d : rest)
zDecodeString :: EncodedString -> UserString
zDecodeString [] = []
zDecodeString ('Z' : d : rest)