From: Wolfgang Bumiller Date: Sun, 23 Dec 2012 09:34:29 +0000 (+0100) Subject: Uchar -> uchar_t for consistency X-Git-Tag: before-library~539 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=e72d141ec42590277dd88efd57d15c0449333b51 Uchar -> uchar_t for consistency --- diff --git a/gmqcc.h b/gmqcc.h index 9fe1b65..7913034 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -932,14 +932,14 @@ typedef uint32_t longbit; /*===================================================================*/ /*=========================== utf8lib.c =============================*/ /*===================================================================*/ -typedef uint32_t Uchar; - -bool u8_analyze (const char *_s, size_t *_start, size_t *_len, Uchar *_ch, size_t _maxlen); -size_t u8_strlen (const char*); -size_t u8_strnlen (const char*, size_t); -Uchar u8_getchar (const char*, const char**); -Uchar u8_getnchar(const char*, const char**, size_t); -int u8_fromchar(Uchar w, char *to, size_t maxlen); +typedef uint32_t uchar_t; + +bool u8_analyze (const char *_s, size_t *_start, size_t *_len, uchar_t *_ch, size_t _maxlen); +size_t u8_strlen (const char*); +size_t u8_strnlen (const char*, size_t); +uchar_t u8_getchar (const char*, const char**); +uchar_t u8_getnchar(const char*, const char**, size_t); +int u8_fromchar(uchar_t w, char *to, size_t maxlen); /*===================================================================*/ /*============================= opts.c ==============================*/ diff --git a/lexer.c b/lexer.c index 55557da..a2e69d5 100644 --- a/lexer.c +++ b/lexer.c @@ -858,7 +858,7 @@ static int GMQCC_WARN lex_finish_string(lex_file *lex, int quote) } } if (OPTS_FLAG(UTF8) && ch >= 128) { - u8len = u8_fromchar((Uchar)ch, u8buf, sizeof(u8buf)); + u8len = u8_fromchar((uchar_t)ch, u8buf, sizeof(u8buf)); if (!u8len) ch = 0; else { @@ -1427,7 +1427,7 @@ int lex_do(lex_file *lex) else { if (!lex->flags.preprocessing && strlen(lex->tok.value) > 1) { - Uchar u8char; + uchar_t u8char; /* check for a valid utf8 character */ if (!OPTS_FLAG(UTF8) || !u8_analyze(lex->tok.value, NULL, NULL, &u8char, 8)) { if (lexwarn(lex, WARN_MULTIBYTE_CHARACTER, diff --git a/utf8lib.c b/utf8lib.c index 1207432..8a9469b 100644 --- a/utf8lib.c +++ b/utf8lib.c @@ -24,7 +24,7 @@ static unsigned char utf8_lengths[256] = { */ }; -static Uchar utf8_range[5] = { +static uchar_t utf8_range[5] = { 1, /* invalid - let's not allow the creation of 0-bytes :P 1, * ascii minimum 0x80, * 2-byte minimum @@ -40,12 +40,12 @@ static Uchar utf8_range[5] = { * @param _maxlen Maximum number of bytes to read from _s * @return Whether or not another valid character is in the string */ -bool u8_analyze(const char *_s, size_t *_start, size_t *_len, Uchar *_ch, size_t _maxlen) +bool u8_analyze(const char *_s, size_t *_start, size_t *_len, uchar_t *_ch, size_t _maxlen) { const unsigned char *s = (const unsigned char*)_s; size_t i, j; size_t bits = 0; - Uchar ch; + uchar_t ch; i = 0; /* findchar: */ @@ -61,7 +61,7 @@ bool u8_analyze(const char *_s, size_t *_start, size_t *_len, Uchar *_ch, size_t if (bits == 1) { /* ascii */ if (_start) *_start = i; if (_len) *_len = 1; - if (_ch) *_ch = (Uchar)s[i]; + if (_ch) *_ch = (uchar_t)s[i]; return true; } @@ -169,10 +169,10 @@ size_t u8_strnlen(const char *_s, size_t n) } /* Required for character constants */ -Uchar u8_getchar(const char *_s, const char **_end) +uchar_t u8_getchar(const char *_s, const char **_end) { size_t st, ln; - Uchar ch; + uchar_t ch; if (!u8_analyze(_s, &st, &ln, &ch, 0x10)) ch = 0; @@ -181,10 +181,10 @@ Uchar u8_getchar(const char *_s, const char **_end) return ch; } -Uchar u8_getnchar(const char *_s, const char **_end, size_t _maxlen) +uchar_t u8_getnchar(const char *_s, const char **_end, size_t _maxlen) { size_t st, ln; - Uchar ch; + uchar_t ch; if (!u8_analyze(_s, &st, &ln, &ch, _maxlen)) ch = 0; @@ -194,7 +194,7 @@ Uchar u8_getnchar(const char *_s, const char **_end, size_t _maxlen) } /* required for \x{asdf}-like string escape sequences */ -int u8_fromchar(Uchar w, char *to, size_t maxlen) +int u8_fromchar(uchar_t w, char *to, size_t maxlen) { if (maxlen < 1) return 0;