/*===================================================================*/
/*=========================== 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 ==============================*/
}
}
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 {
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,
*/
};
-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
* @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: */
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;
}
}
/* 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;
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;
}
/* 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;