ref: 78fc2830c2af10627e870844fe26b37e75d96c0c
parent: 3df1fd41a90bcd4e751adad72e9cde9ff02124c0
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Jan 5 22:36:19 EST 2025
u8_nextmemchar: make clang-analyzer less confused
--- a/utf8.c
+++ b/utf8.c
@@ -80,13 +80,13 @@
Rune
u8_nextmemchar(const char *s, size_t *i)
{
- size_t sz = u8_seqlen(&s[*i]);
+ size_t sz = trailingBytesForUTF8[(uint8_t)s[*i]];
Rune ch = 0;
- for(size_t j = 0; j < sz; j++){
+ for(size_t j = 0; j <= sz; j++){
ch <<= 6;
ch += (uint8_t)s[(*i)++];
};
- return ch - offsetsFromUTF8[sz-1];
+ return ch - offsetsFromUTF8[sz];
}
int