summaryrefslogtreecommitdiffhomepage
path: root/include/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-01-11 20:51:50 +0100
committerTyge Løvset <[email protected]>2022-01-11 20:51:50 +0100
commitd85a4e9e396688b6b5b29c0ffb07de7ce9013b74 (patch)
tree47b60c3014cedd703b1db850c9a7a111e00b3b7c /include/stc
parentaf1b2068b39deebfbf723532a2eddc49da61894a (diff)
downloadSTC-modified-d85a4e9e396688b6b5b29c0ffb07de7ce9013b74.tar.gz
STC-modified-d85a4e9e396688b6b5b29c0ffb07de7ce9013b74.zip
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.
Diffstat (limited to 'include/stc')
-rw-r--r--include/stc/utf8.h5
1 files changed, 2 insertions, 3 deletions
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);
}