Mercurial > pidgin.yaz
changeset 27884:48b32e603c76
- evolved is_zenkaku_space() to is_multibyte_utf8().
- now badchar() catches ']'.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 06 Sep 2008 16:10:18 +0000 |
parents | 75cba280460b |
children | 1e9d17432a26 |
files | libpurple/util.c |
diffstat | 1 files changed, 15 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/util.c Sat Sep 06 04:45:37 2008 +0000 +++ b/libpurple/util.c Sat Sep 06 16:10:18 2008 +0000 @@ -2006,14 +2006,19 @@ } static gboolean -is_zenkaku_space(const char *c) +is_multibyte_utf8(const char *c) { gboolean rv = FALSE; const guchar *u = (guchar *)c; - if(!c || !strcmp(c, "") || strlen(c) < 3) + if(!c || !strcmp(c, "") || *u <= 0x7f) rv = FALSE; - else if(*u == 0xe3 && *(u+1) == 0x80 && *(u+2) == 0x80) + else if(*u >= 0xc2 && *u <= 0xdf && + *(u+1) >= 0x80 && *(u+1) <= 0xbf ) /* 2bytes */ + rv = TRUE; + else if(*u >= 0xe0 && *u <= 0xfd && + *(u+1) >= 0x80 && *(u+1) <= 0xbf && + *(u+2) >= 0x80 && *(u+2) <= 0xbf) /* 3bytes or more */ rv = TRUE; return rv; @@ -2032,6 +2037,7 @@ case '>': case '"': case '\'': + case ']': return TRUE; default: return FALSE; @@ -2100,7 +2106,7 @@ (!g_ascii_strncasecmp(c, "https://", 8)))) { t = c; while (1) { - if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) { + if (badchar(*t) || badentity(t) || is_multibyte_utf8(t)) { if ((!g_ascii_strncasecmp(c, "http://", 7) && (t - c == 7)) || (!g_ascii_strncasecmp(c, "https://", 8) && (t - c == 8))) { @@ -2134,7 +2140,7 @@ if (c[4] != '.') { t = c; while (1) { - if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) { + if (badchar(*t) || badentity(t) || is_multibyte_utf8(t)) { if (t - c == 4) { break; } @@ -2165,7 +2171,7 @@ } else if (!g_ascii_strncasecmp(c, "ftp://", 6) || !g_ascii_strncasecmp(c, "sftp://", 7)) { t = c; while (1) { - if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) { + if (badchar(*t) || badentity(t) || is_multibyte_utf8(t)) { if ((!g_ascii_strncasecmp(c, "ftp://", 6) && (t - c == 6)) || (!g_ascii_strncasecmp(c, "sftp://", 7) && (t - c == 7))) { @@ -2195,7 +2201,7 @@ if (c[4] != '.') { t = c; while (1) { - if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) { + if (badchar(*t) || badentity(t) || is_multibyte_utf8(t)) { if (t - c == 4) { break; } @@ -2222,7 +2228,7 @@ } else if (!g_ascii_strncasecmp(c, "mailto:", 7)) { t = c; while (1) { - if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) { + if (badchar(*t) || badentity(t) || is_multibyte_utf8(t)) { char *d; if (t - c == 7) { break; @@ -2256,7 +2262,7 @@ (c == text || badchar(c[-1]) || badentity(c-1))) { t = c; while (1) { - if (badchar(*t) || badentity(t) || is_zenkaku_space(t)) { + if (badchar(*t) || badentity(t) || is_multibyte_utf8(t)) { if (t - c == 5) { break;