From: Florian Forster Date: Fri, 22 Dec 2023 13:20:55 +0000 (+0100) Subject: contrib/format.sh src/utils/utf8/utf8.c X-Git-Tag: 6.0.0-rc0~22^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b979ee4f98efcc2b3ed934abddfa6cc9e8d859f5;p=thirdparty%2Fcollectd.git contrib/format.sh src/utils/utf8/utf8.c --- diff --git a/src/utils/utf8/utf8.c b/src/utils/utf8/utf8.c index 1a1f90f78..c06abe4c0 100644 --- a/src/utils/utf8/utf8.c +++ b/src/utils/utf8/utf8.c @@ -25,6 +25,7 @@ #define UTF8_ACCEPT 0 #define UTF8_REJECT 1 +// clang-format off static const uint8_t utf8d[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f @@ -41,21 +42,19 @@ static const uint8_t utf8d[] = { 1,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,3,1,1,1,1,1,1, // s5..s6 1,3,1,1,1,1,1,3,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // s7..s8 }; +// clang-format on -uint32_t inline -decode(uint32_t* state, uint32_t* codep, uint32_t byte) { +uint32_t inline decode(uint32_t *state, uint32_t *codep, uint32_t byte) { uint32_t type = utf8d[byte]; - *codep = (*state != UTF8_ACCEPT) ? - (byte & 0x3fu) | (*codep << 6) : - (0xff >> type) & (byte); + *codep = (*state != UTF8_ACCEPT) ? (byte & 0x3fu) | (*codep << 6) + : (0xff >> type) & (byte); - *state = utf8d[256 + *state*16 + type]; + *state = utf8d[256 + *state * 16 + type]; return *state; } -int -IsUTF8(uint8_t* s) { +int IsUTF8(uint8_t *s) { uint32_t codepoint, state = 0; while (*s)