diff options
| author | Tyge Løvset <[email protected]> | 2021-08-28 15:49:42 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-08-28 15:49:42 +0200 |
| commit | 28bf4ac92625b2ec7c4ddade9c14a4363ebd2681 (patch) | |
| tree | 580ec2fa435464e18505a9bb0b30720bde2340ca /include | |
| parent | 4c9ad3e584feff277800e1dfe49ae470e3c4a9c4 (diff) | |
| download | STC-modified-28bf4ac92625b2ec7c4ddade9c14a4363ebd2681.tar.gz STC-modified-28bf4ac92625b2ec7c4ddade9c14a4363ebd2681.zip | |
Breaking change cstr and csview renames in order to improve consistency:
cstr_equals() => cstr_equalto()
cstr_compare_ref() => cstr_compare()
cstr_equals_ref() => cstr_equals()
cstr_hash_ref() => cstr_hash()
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/ccommon.h | 2 | ||||
| -rw-r--r-- | include/stc/cstr.h | 15 | ||||
| -rw-r--r-- | include/stc/csview.h | 10 |
3 files changed, 12 insertions, 15 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index f79060a8..b2501416 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -99,7 +99,7 @@ #define c_rawstr_compare(x, y) strcmp(*(x), *(y))
#define c_rawstr_equals(x, y) (strcmp(*(x), *(y)) == 0)
-#define c_rawstr_hash(p, none) c_default_hash(*(p), strlen(*(p)))
+#define c_rawstr_hash(p, ...) c_default_hash(*(p), strlen(*(p)))
#define c_no_clone(x) (assert(!"c_no_clone() called"), x)
#define c_default_fromraw(x) (x)
diff --git a/include/stc/cstr.h b/include/stc/cstr.h index d5c2dd86..e7af71f3 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -118,11 +118,11 @@ STC_INLINE cstr_iter_t cstr_begin(cstr* self) STC_INLINE cstr_iter_t cstr_end(cstr* self)
{ return c_make(cstr_iter_t){self->str + _cstr_rep(self)->size}; }
STC_INLINE void cstr_next(cstr_iter_t* it) {++it->ref; }
-STC_INLINE bool cstr_equals(cstr s, const char* str)
+STC_INLINE bool cstr_equalto(cstr s, const char* str)
{ return strcmp(s.str, str) == 0; }
-STC_INLINE bool cstr_equals_s(cstr s1, cstr s2)
+STC_INLINE bool cstr_equalto_s(cstr s1, cstr s2)
{ return strcmp(s1.str, s2.str) == 0; }
-STC_INLINE bool cstr_iequals(cstr s, const char* str)
+STC_INLINE bool cstr_iequalto(cstr s, const char* str)
{ return c_strncasecmp(s.str, str, cstr_npos) == 0; }
STC_INLINE bool cstr_contains(cstr s, const char* needle)
{ return strstr(s.str, needle) != NULL; }
@@ -184,12 +184,11 @@ cstr_iends_with(cstr s, const char* sub) { return n <= sz && !c_strncasecmp(s.str + sz - n, sub, n);
}
-/* cvec/cmap adaption functions: */
+/* container adaptor functions: */
#define cstr_toraw(xp) ((xp)->str)
-#define cstr_compare_ref(xp, yp) strcmp((xp)->str, (yp)->str)
-#define cstr_equals_ref(xp, yp) (strcmp((xp)->str, (yp)->str) == 0)
-#define cstr_hash_ref(xp, none) c_default_hash((xp)->str, cstr_size(*(xp)))
-#define cstr_hash(x) c_default_hash((x).str, cstr_size(x))
+#define cstr_compare(xp, yp) strcmp((xp)->str, (yp)->str)
+#define cstr_equals(xp, yp) (strcmp((xp)->str, (yp)->str) == 0)
+#define cstr_hash(xp, ...) c_default_hash((xp)->str, cstr_size(*(xp)))
/* -------------------------- IMPLEMENTATION ------------------------- */
diff --git a/include/stc/csview.h b/include/stc/csview.h index c631a0b7..d5d6d246 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -57,8 +57,7 @@ STC_INLINE char csview_back(csview sv) { return sv.str[sv.size - 1]; } STC_INLINE void csview_clear(csview* self) { *self = csview_null; }
-#define csview_hash(sv) c_default_hash((sv).str, (sv).size)
-STC_INLINE bool csview_equals(csview sv, csview sv2)
+STC_INLINE bool csview_equalto(csview sv, csview sv2)
{ return sv.size == sv2.size && !memcmp(sv.str, sv2.str, sv.size); }
STC_INLINE size_t csview_find(csview sv, csview needle)
{ char* res = c_strnstrn(sv.str, needle.str, sv.size, needle.size);
@@ -115,10 +114,9 @@ STC_INLINE bool cstr_ends_with_v(cstr s, csview sub) /* ---- Container helper functions ---- */
-STC_INLINE bool csview_equals_ref(const csview* a, const csview* b)
- { return a->size == b->size && !memcmp(a->str, b->str, a->size); }
-#define csview_hash_ref(xp, none) c_default_hash((xp)->str, (xp)->size)
-#define csview_compare_ref(xp, yp) strcmp((xp)->str, (yp)->str)
+#define csview_compare(xp, yp) strcmp((xp)->str, (yp)->str)
+#define csview_hash(xp, ...) c_default_hash((xp)->str, (xp)->size)
+#define csview_equals(xp, yp) (strcmp((xp)->str, (yp)->str) == 0)
/* -------------------------- IMPLEMENTATION ------------------------- */
|
