From d85a4e9e396688b6b5b29c0ffb07de7ce9013b74 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 11 Jan 2022 20:51:50 +0100 Subject: Added tinycthread: include/threads.h, src/threads.c. Ex: sptr_threads.c - emulates standard C11 threads library for compilers not supporting C11 threads.h. Fixed and cleanup of CMake build. --- include/stc/utf8.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include/stc') diff --git a/include/stc/utf8.h b/include/stc/utf8.h index d11bcc43..f397c0d0 100644 --- a/include/stc/utf8.h +++ b/include/stc/utf8.h @@ -9,7 +9,6 @@ enum utf8_state { utf8_REJECT = 12 }; -typedef struct { bool valid; size_t size; } utf8_result; /* number of codepoints in the utf8 string s, or SIZE_MAX if invalid utf8: */ STC_API size_t utf8_codepoint_count(const char *s); STC_API size_t utf8_codepoint_count_n(const char *s, size_t n); @@ -45,7 +44,7 @@ STC_INLINE const char *utf8_next(const char *s) // --------------------------- IMPLEMENTATION --------------------------------- #ifdef _i_implement -static const uint8_t utf8_table[] = { +STC_DEF const uint8_t utf8_table[] = { 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, 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, 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, @@ -87,7 +86,7 @@ STC_DEF size_t utf8_codepoint_count_n(const char *s, size_t n) { uint32_t state = 0, codepoint; size_t size = 0; - while (n--) + while (n-- && *s) size += !utf8_decode(&state, &codepoint, (uint8_t)*s++); return size | (size_t) -(state != 0); } -- cgit v1.2.3