From: Wolfgang Bumiller Date: Sat, 22 Dec 2012 21:43:14 +0000 (+0100) Subject: fix and speed up u8_analyze for our purposes X-Git-Tag: before-library~543 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ac0ca3de8123324d24317d88de38d46ed3f6a956;p=xonotic%2Fgmqcc.git fix and speed up u8_analyze for our purposes --- diff --git a/utf8lib.c b/utf8lib.c index cf72229..1207432 100644 --- a/utf8lib.c +++ b/utf8lib.c @@ -74,6 +74,7 @@ bool u8_analyze(const char *_s, size_t *_start, size_t *_len, Uchar *_ch, size_t /* in gmqcc, invalid / overlong encodings are considered an error * goto findchar; */ + if (!s[i]) goto done; return false; } ch = (ch << 6) | (s[i+j] & 0x3F); @@ -87,6 +88,7 @@ bool u8_analyze(const char *_s, size_t *_start, size_t *_len, Uchar *_ch, size_t return false; } +done: if (_start) *_start = i; if (_len)