From c9e0c46d29db9c2a85154c9c6a75ce0d2e2180ff Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Mon, 8 Aug 2022 21:00:05 +0200 Subject: Changed cstr_icmp_n() to cstr_icmp_sv(), and FIXED it. --- include/stc/cstr.h | 2 +- include/stc/csview.h | 2 +- include/stc/utf8.h | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/stc/cstr.h b/include/stc/cstr.h index bfc3b51d..0dabc044 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -303,7 +303,7 @@ STC_INLINE bool cstr_starts_with_s(cstr s, cstr sub) STC_INLINE bool cstr_istarts_with(cstr s, const char* sub) { csview sv = cstr_sv(&s); size_t len = strlen(sub); - return len <= sv.size && !utf8_icmp_n(cstr_npos, sv.str, sv.size, sub, len); + return len <= sv.size && !utf8_icmp_sv(cstr_npos, sv, c_sv(sub, len)); } diff --git a/include/stc/csview.h b/include/stc/csview.h index 2ebcaabe..cd19aed7 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -127,7 +127,7 @@ STC_INLINE int csview_cmp(const csview* x, const csview* y) { return strcmp(x->str, y->str); } STC_INLINE int csview_icmp(const csview* x, const csview* y) - { return utf8_icmp_n(~(size_t)0, x->str, x->size, y->str, y->size); } + { return utf8_icmp_sv(csview_npos, *x, *y); } STC_INLINE bool csview_eq(const csview* x, const csview* y) { return x->size == y->size && !memcmp(x->str, y->str, x->size); } diff --git a/include/stc/utf8.h b/include/stc/utf8.h index 34368737..4b87bc0b 100644 --- a/include/stc/utf8.h +++ b/include/stc/utf8.h @@ -16,8 +16,7 @@ extern uint32_t utf8_casefold(uint32_t c); extern uint32_t utf8_tolower(uint32_t c); extern uint32_t utf8_toupper(uint32_t c); extern bool utf8_valid_n(const char* s, size_t nbytes); -extern int utf8_icmp_n(size_t u8max, const char* s1, size_t n1, - const char* s2, size_t n2); +extern int utf8_icmp_sv(size_t u8max, csview s1, csview s2); extern unsigned utf8_encode(char *out, uint32_t c); extern uint32_t utf8_peek(const char *s, int u8pos); @@ -36,7 +35,7 @@ STC_INLINE uint32_t utf8_decode(utf8_decode_t* d, const uint32_t byte) { /* case-insensitive utf8 string comparison */ STC_INLINE int utf8_icmp(const char* s1, const char* s2) { - return utf8_icmp_n(~(size_t)0, s1, ~(size_t)0, s2, ~(size_t)0); + return utf8_icmp_sv(~(size_t)0, c_sv(s1, ~(size_t)0), c_sv(s2, ~(size_t)0)); } STC_INLINE bool utf8_valid(const char* s) { -- cgit v1.2.3