From ac0ca3de8123324d24317d88de38d46ed3f6a956 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Sat, 22 Dec 2012 22:43:14 +0100 Subject: [PATCH] fix and speed up u8_analyze for our purposes --- utf8lib.c | 2 ++ 1 file changed, 2 insertions(+) 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) -- 2.39.2