diff options
| author | Tyge Løvset <[email protected]> | 2022-12-20 10:59:31 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-12-20 10:59:31 +0100 |
| commit | 21817cae767d72e6007150b639f9365e35502173 (patch) | |
| tree | 4c897b401c75a243f11c6ea8cf0ca8699376a680 /include | |
| parent | 6167fa5e361b2954440594cb693f25f643eb9e0a (diff) | |
| download | STC-modified-21817cae767d72e6007150b639f9365e35502173.tar.gz STC-modified-21817cae767d72e6007150b639f9365e35502173.zip | |
Renamed c_sv() => c_SV() and reverted cstr_new() => cstr_lit(). Old names are deprecated (not removed).
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/alt/cstr.h | 14 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 10 | ||||
| -rw-r--r-- | include/stc/cstr.h | 16 | ||||
| -rw-r--r-- | include/stc/csview.h | 7 | ||||
| -rw-r--r-- | include/stc/utf8.h | 2 |
5 files changed, 25 insertions, 24 deletions
diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h index 4496fb35..37eaa318 100644 --- a/include/stc/alt/cstr.h +++ b/include/stc/alt/cstr.h @@ -95,15 +95,15 @@ STC_INLINE void cstr_push_back(cstr* self, char value) STC_INLINE void cstr_pop_back(cstr* self) { self->str[ --_cstr_p(self)->size ] = '\0'; } STC_INLINE void cstr_insert_n(cstr* self, const size_t pos, const char* str, const size_t n) - { cstr_replace_at_sv(self, pos, 0, c_sv(str, n)); } + { cstr_replace_at_sv(self, pos, 0, c_SV(str, n)); } STC_INLINE void cstr_insert(cstr* self, const size_t pos, const char* str) - { cstr_replace_at_sv(self, pos, 0, c_sv(str, strlen(str))); } + { cstr_replace_at_sv(self, pos, 0, c_SV(str, strlen(str))); } STC_INLINE void cstr_insert_s(cstr* self, const size_t pos, cstr s) - { cstr_replace_at_sv(self, pos, 0, c_sv(s.str, _cstr_p(&s)->size)); } + { cstr_replace_at_sv(self, pos, 0, c_SV(s.str, _cstr_p(&s)->size)); } STC_INLINE void cstr_replace_at(cstr* self, const size_t pos, const size_t len, const char* str) - { cstr_replace_at_sv(self, pos, len, c_sv(str, strlen(str))); } + { cstr_replace_at_sv(self, pos, len, c_SV(str, strlen(str))); } STC_INLINE void cstr_replace_s(cstr* self, const size_t pos, const size_t len, cstr s) - { cstr_replace_at_sv(self, pos, len, c_sv(s.str, _cstr_p(&s)->size)); } + { cstr_replace_at_sv(self, pos, len, c_SV(s.str, _cstr_p(&s)->size)); } STC_INLINE char* cstr_front(cstr* self) { return self->str; } STC_INLINE char* cstr_back(cstr* self) { return self->str + _cstr_p(self)->size - 1; } @@ -185,8 +185,8 @@ STC_INLINE uint64_t cstr_hash(const cstr *self) { STC_INLINE void cstr_replace(cstr* self, const char* find, const char* repl, unsigned count) { csview in = cstr_sv(self); - cstr_take(self, cstr_replace_sv(in, c_sv(find, strlen(find)), - c_sv(repl, strlen(repl)), count)); + cstr_take(self, cstr_replace_sv(in, c_SV(find, strlen(find)), + c_SV(repl, strlen(repl)), count)); } /* -------------------------- IMPLEMENTATION ------------------------- */ diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 9aa55e00..af6b52a5 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -117,12 +117,13 @@ typedef const char* crawstr; #define crawstr_hash(p) cstrhash(*(p)) #define c_strlen_lit(literal) (sizeof("" literal) - 1U) -#define c_sv(...) c_MACRO_OVERLOAD(c_sv, __VA_ARGS__) -#define c_sv1(lit) c_sv2(lit, c_strlen_lit(lit)) -#define c_sv2(str, n) (c_INIT(csview){str, n}) -#define c_ARGsv(sv) c_ARGSV(sv) /* [deprecated] */ +#define c_SV(...) c_MACRO_OVERLOAD(c_SV, __VA_ARGS__) +#define c_SV1(lit) c_SV2(lit, c_strlen_lit(lit)) +#define c_SV2(str, n) (c_INIT(csview){str, n}) #define c_ARGSV(sv) (int)(sv).size, (sv).str /* use with "%.*s" */ #define c_PAIR(ref) (ref)->first, (ref)->second +#define c_sv c_SV /* [deprecated] */ +#define c_ARGsv(sv) c_ARGSV(sv) /* [deprecated] */ #define _c_ROTL(x, k) (x << (k) | x >> (8*sizeof(x) - (k))) @@ -177,7 +178,6 @@ STC_INLINE char* cstrnstrn(const char *str, const char *needle, ; _.it.ref && (_.key = &_.it.ref->first, _.val = &_.it.ref->second) \ ; C##_next(&_.it)) -#define c_forloop c_forrange // [deprecated] #define c_forrange(...) c_MACRO_OVERLOAD(c_forrange, __VA_ARGS__) #define c_forrange1(stop) c_forrange3(_c_i, 0, stop) #define c_forrange2(i, stop) c_forrange3(i, 0, stop) diff --git a/include/stc/cstr.h b/include/stc/cstr.h index b60a072e..a0dd1adc 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -183,10 +183,10 @@ STC_INLINE cstr cstr_toupper_sv(csview sv) { return cstr_tocase(sv, 2); } STC_INLINE cstr cstr_tolower(const char* str) - { return cstr_tolower_sv(c_sv(str, strlen(str))); } + { return cstr_tolower_sv(c_SV(str, strlen(str))); } STC_INLINE cstr cstr_toupper(const char* str) - { return cstr_toupper_sv(c_sv(str, strlen(str))); } + { return cstr_toupper_sv(c_SV(str, strlen(str))); } STC_INLINE void cstr_lowercase(cstr* self) { cstr_take(self, cstr_tolower_sv(cstr_sv(self))); } @@ -318,7 +318,7 @@ STC_INLINE bool cstr_starts_with_s(const cstr* self, cstr sub) STC_INLINE bool cstr_istarts_with(const cstr* self, const char* sub) { csview sv = cstr_sv(self); size_t len = strlen(sub); - return len <= sv.size && !utf8_icmp_sv(sv, c_sv(sub, len)); + return len <= sv.size && !utf8_icmp_sv(sv, c_SV(sub, len)); } @@ -332,7 +332,7 @@ STC_INLINE bool cstr_ends_with_s(const cstr* self, cstr sub) { return cstr_ends_with_sv(self, cstr_sv(&sub)); } STC_INLINE bool cstr_ends_with(const cstr* self, const char* sub) - { return cstr_ends_with_sv(self, c_sv(sub, strlen(sub))); } + { return cstr_ends_with_sv(self, c_SV(sub, strlen(sub))); } STC_INLINE bool cstr_iends_with(const cstr* self, const char* sub) { csview sv = cstr_sv(self); @@ -381,7 +381,7 @@ STC_INLINE void cstr_replace_at_sv(cstr* self, size_t pos, size_t len, const csv } STC_INLINE void cstr_replace_at(cstr* self, size_t pos, size_t len, const char* repl) - { cstr_replace_at_sv(self, pos, len, c_sv(repl, strlen(repl))); } + { cstr_replace_at_sv(self, pos, len, c_SV(repl, strlen(repl))); } STC_INLINE void cstr_replace_at_s(cstr* self, size_t pos, size_t len, cstr repl) { cstr_replace_at_sv(self, pos, len, cstr_sv(&repl)); } @@ -391,7 +391,7 @@ STC_INLINE void cstr_u8_replace(cstr* self, size_t bytepos, size_t u8len, csview STC_INLINE void cstr_insert(cstr* self, size_t pos, const char* str) - { cstr_replace_at_sv(self, pos, 0, c_sv(str, strlen(str))); } + { cstr_replace_at_sv(self, pos, 0, c_SV(str, strlen(str))); } STC_INLINE void cstr_insert_sv(cstr* self, size_t pos, csview sv) { cstr_replace_at_sv(self, pos, 0, sv); } @@ -584,8 +584,8 @@ cstr_replace_sv(csview in, csview search, csview repl, unsigned count) { STC_DEF void cstr_replace(cstr* self, const char* search, const char* repl, unsigned count) { csview in = cstr_sv(self); - cstr_take(self, cstr_replace_sv(in, c_sv(search, strlen(search)), - c_sv(repl, strlen(repl)), count)); + cstr_take(self, cstr_replace_sv(in, c_SV(search, strlen(search)), + c_SV(repl, strlen(repl)), count)); } STC_DEF void cstr_erase(cstr* self, const size_t pos, size_t len) { diff --git a/include/stc/csview.h b/include/stc/csview.h index e0f2ad0e..972bc788 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -27,11 +27,12 @@ #include "forward.h" #include "utf8.h" -#define csview_NULL c_sv1("") +#define csview_NULL c_SV1("") #define csview_init() csview_NULL #define csview_drop(p) c_default_drop(p) #define csview_clone(sv) c_default_clone(sv) -#define csview_from_n(str, n) c_sv2(str, n) +#define csview_lit(literal) c_SV1(literal) +#define csview_from_n(str, n) c_SV2(str, n) STC_API size_t csview_find_sv(csview sv, csview search); @@ -46,7 +47,7 @@ STC_INLINE bool csview_equals(csview sv, const char* str) { size_t n = strlen(str); return sv.size == n && !memcmp(sv.str, str, n); } STC_INLINE size_t csview_find(csview sv, const char* str) - { return csview_find_sv(sv, c_sv(str, strlen(str))); } + { return csview_find_sv(sv, c_SV(str, strlen(str))); } STC_INLINE bool csview_contains(csview sv, const char* str) { return csview_find(sv, str) != c_NPOS; } diff --git a/include/stc/utf8.h b/include/stc/utf8.h index ab39f3ba..cf36ee1c 100644 --- a/include/stc/utf8.h +++ b/include/stc/utf8.h @@ -43,7 +43,7 @@ STC_INLINE uint32_t utf8_peek(const char* s) { /* case-insensitive utf8 string comparison */ STC_INLINE int utf8_icmp(const char* s1, const char* s2) { - return utf8_icmp_sv(c_sv(s1, ~(size_t)0), c_sv(s2, ~(size_t)0)); + return utf8_icmp_sv(c_SV(s1, ~(size_t)0), c_SV(s2, ~(size_t)0)); } STC_INLINE bool utf8_valid(const char* s) { |
