Skip to content

Commit ba5e876

Browse files
committed
style: apply clang-format to sanitize_utf8 (CI lint fix)
Compact multi-condition if-checks that fit within the 100-char column limit onto single lines, and repack the 4-byte sequence check so three conditions share the first line (95 chars) with the fourth wrapping to the continuation, as clang-format-20 requires. Signed-off-by: piiiico <pico@amdal.dev>
1 parent 93e33d7 commit ba5e876

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/mcp/mcp.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,21 +2872,18 @@ static char *sanitize_utf8(const char *src) {
28722872
}
28732873
} else if ((c & 0xF0) == 0xE0) {
28742874
/* 3-byte: 1110xxxx 10xxxxxx 10xxxxxx */
2875-
if (i + 2 < src_len && (s[i + 1] & 0xC0) == 0x80 &&
2876-
(s[i + 2] & 0xC0) == 0x80) {
2875+
if (i + 2 < src_len && (s[i + 1] & 0xC0) == 0x80 && (s[i + 2] & 0xC0) == 0x80) {
28772876
/* Reject overlong (E0 + < A0) and surrogates (ED + >= A0). */
2878-
if (!(c == 0xE0 && s[i + 1] < 0xA0) &&
2879-
!(c == 0xED && s[i + 1] >= 0xA0)) {
2877+
if (!(c == 0xE0 && s[i + 1] < 0xA0) && !(c == 0xED && s[i + 1] >= 0xA0)) {
28802878
seq_len = 3;
28812879
}
28822880
}
28832881
} else if (c >= 0xF0 && c <= 0xF4) {
28842882
/* 4-byte: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
2885-
if (i + 3 < src_len && (s[i + 1] & 0xC0) == 0x80 &&
2886-
(s[i + 2] & 0xC0) == 0x80 && (s[i + 3] & 0xC0) == 0x80) {
2883+
if (i + 3 < src_len && (s[i + 1] & 0xC0) == 0x80 && (s[i + 2] & 0xC0) == 0x80 &&
2884+
(s[i + 3] & 0xC0) == 0x80) {
28872885
/* Reject overlong (F0 + < 90) and > U+10FFFF (F4 + > 8F). */
2888-
if (!(c == 0xF0 && s[i + 1] < 0x90) &&
2889-
!(c == 0xF4 && s[i + 1] > 0x8F)) {
2886+
if (!(c == 0xF0 && s[i + 1] < 0x90) && !(c == 0xF4 && s[i + 1] > 0x8F)) {
28902887
seq_len = 4;
28912888
}
28922889
}

0 commit comments

Comments
 (0)