--- drw.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/drw.c b/drw.c index ced7d37..b6073a4 100644 --- a/drw.c +++ b/drw.c @@ -25,16 +25,6 @@ utf8decodebyte(const char c, size_t *i) return 0; } -static size_t -utf8validate(long *u, size_t i) -{ - if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF)) - *u = UTF_INVALID; - for (i = 1; *u > utfmax[i]; ++i) - ; - return i; -} - static size_t utf8decode(const char *c, long *u, size_t clen) { @@ -54,8 +44,9 @@ utf8decode(const char *c, long *u, size_t clen) } if (j < len) return 0; - *u = udecoded; - utf8validate(u, len); + + *u = (!BETWEEN(udecoded, utfmin[i], utfmax[i]) || BETWEEN(udecoded, 0xD800, 0xDFFF)) + ? UTF_INVALID : udecoded; return len; } -- 2.30.2