diff --git a/core/carp_utf8.h b/core/carp_utf8.h index a7765b85..1fc02013 100644 --- a/core/carp_utf8.h +++ b/core/carp_utf8.h @@ -49,8 +49,8 @@ static size_t utf8encode(char *s, uint32_t c) { } // Adapted from: http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ -static const uint32_t UTF8_ACCEPT = 0; -static const uint32_t UTF8_REJECT = 12; +#define UTF8_ACCEPT 0 +#define UTF8_REJECT 12 static uint32_t inline utf8decode(uint32_t *state, uint32_t *codep, uint32_t byte) { static const uint8_t utf8d[] = { diff --git a/src/SymPath.hs b/src/SymPath.hs index 539af1a8..ae9881ea 100644 --- a/src/SymPath.hs +++ b/src/SymPath.hs @@ -4,6 +4,7 @@ module SymPath (SymPath(..) , consPath) where import qualified Data.Map as Map +import Data.Char (isAscii, ord) import Util -- | The path to a binding @@ -17,7 +18,7 @@ instance Show SymPath where -- | Replaces symbols not allowed in C-identifiers. mangle :: String -> String -mangle = sreplace . creplace +mangle = ureplace . sreplace . creplace where creplace = replaceChars (Map.fromList [('+', "_PLUS_") ,('-', "_MINUS_") ,('*', "_MUL_") @@ -59,6 +60,7 @@ mangle = sreplace . creplace ,("volatile", "_VOLATILE_") ,("void", "_VOID_") ,("while", "_WHILE_")]) + ureplace = concatMap (\c -> if isAscii c then pure c else "_U" ++ show (ord c) ++ "U_") pathToC :: SymPath -> String pathToC (SymPath modulePath name) =