]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
fix and speed up u8_analyze for our purposes
authorWolfgang Bumiller <blub@speed.at>
Sat, 22 Dec 2012 21:43:14 +0000 (22:43 +0100)
committerWolfgang Bumiller <blub@speed.at>
Sun, 23 Dec 2012 09:23:42 +0000 (10:23 +0100)
utf8lib.c

index cf722296e8d68a1835626cf075067c32dcb5582b..12074320cf20ae6bedef7d670f72d1625dbff814 100644 (file)
--- 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)