mirror of
https://github.com/carp-lang/Carp.git
synced 2024-08-16 08:40:41 +03:00
Unicode fixes (#994)
* Some compilers (tcc) will complain switching on const values. * Fix unicode example when compiling with -std=c99.
This commit is contained in:
parent
6593a64a19
commit
244df27942
@ -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[] = {
|
||||
|
@ -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) =
|
||||
|
Loading…
Reference in New Issue
Block a user