]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
contrib/format.sh src/utils/utf8/utf8.c
authorFlorian Forster <octo@collectd.org>
Fri, 22 Dec 2023 13:20:55 +0000 (14:20 +0100)
committerFlorian Forster <octo@collectd.org>
Thu, 28 Dec 2023 08:53:22 +0000 (09:53 +0100)
src/utils/utf8/utf8.c

index 1a1f90f7856dee33d459d1cc16af3254ab77cf90..c06abe4c0cfd52f7d0657c75e7c0e8209a8f6564 100644 (file)
@@ -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)