From ead0b1d0c6cc724e7f2d7eb2ed9273dd7a18935f Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 29 Oct 2021 17:02:39 +0200 Subject: Swapped .._equals() and _equalto() functions for consistency --- include/stc/alt/cstr.h | 6 +++--- include/stc/ccommon.h | 6 +++--- include/stc/cstr.h | 6 +++--- include/stc/csview.h | 4 ++-- include/stc/template.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h index e5dc65ec..98a090e0 100644 --- a/include/stc/alt/cstr.h +++ b/include/stc/alt/cstr.h @@ -163,15 +163,15 @@ STC_INLINE cstr_size_t cstr_capacity(cstr s) { return cstr_select_(&s, cap(&s)); } -STC_INLINE bool cstr_equalto(cstr s1, const char* str) { +STC_INLINE bool cstr_equals(cstr s1, const char* str) { return strcmp(cstr_str(&s1), str) == 0; } -STC_INLINE bool cstr_equalto_s(cstr s1, cstr s2) { +STC_INLINE bool cstr_equals_s(cstr s1, cstr s2) { return strcmp(cstr_str(&s1), cstr_str(&s2)) == 0; } -STC_INLINE int cstr_equals(const cstr* s1, const cstr* s2) { +STC_INLINE bool cstr_equalto(const cstr* s1, const cstr* s2) { return strcmp(cstr_str(s1), cstr_str(s2)) == 0; } diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 5c46852d..6e6aefd2 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -97,11 +97,11 @@ #define c_no_compare(x, y) (assert(!"c_no_compare() called"), (x)==(y)) #define c_less_compare(less, x, y) (less(y, x) - less(x, y)) -#define c_default_equals(x, y) (*(x) == *(y)) -#define c_memcmp_equals(x, y) (memcmp(x, y, sizeof *(x)) == 0) +#define c_default_equalto(x, y) (*(x) == *(y)) +#define c_memcmp_equalto(x, y) (memcmp(x, y, sizeof *(x)) == 0) #define c_rawstr_compare(x, y) strcmp(*(x), *(y)) -#define c_rawstr_equals(x, y) (strcmp(*(x), *(y)) == 0) +#define c_rawstr_equalto(x, y) (strcmp(*(x), *(y)) == 0) #define c_rawstr_hash(p, dummy) c_strhash(*(p)) #define c_no_clone(x) (assert(!"c_no_clone() called"), x) diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 5fc5d51a..c0a6650b 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -116,9 +116,9 @@ STC_INLINE cstr_iter cstr_begin(cstr* self) STC_INLINE cstr_iter cstr_end(cstr* self) { return c_make(cstr_iter){self->str + _cstr_rep(self)->size}; } STC_INLINE void cstr_next(cstr_iter* it) {++it->ref; } -STC_INLINE bool cstr_equalto(cstr s, const char* str) +STC_INLINE bool cstr_equals(cstr s, const char* str) { return strcmp(s.str, str) == 0; } -STC_INLINE bool cstr_equalto_s(cstr s1, cstr s2) +STC_INLINE bool cstr_equals_s(cstr s1, cstr s2) { return strcmp(s1.str, s2.str) == 0; } STC_INLINE bool cstr_contains(cstr s, const char* needle) { return strstr(s.str, needle) != NULL; } @@ -168,7 +168,7 @@ cstr_ends_with(cstr s, const char* sub) { /* container adaptor functions: */ #define cstr_compare(xp, yp) strcmp((xp)->str, (yp)->str) -#define cstr_equals(xp, yp) (strcmp((xp)->str, (yp)->str) == 0) +#define cstr_equalto(xp, yp) (strcmp((xp)->str, (yp)->str) == 0) #define cstr_hash(xp, dummy) c_strhash((xp)->str) /* -------------------------- IMPLEMENTATION ------------------------- */ diff --git a/include/stc/csview.h b/include/stc/csview.h index 78cb919a..87707d84 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -57,7 +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; } -STC_INLINE bool csview_equalto(csview sv, csview sv2) +STC_INLINE bool csview_equals(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); @@ -116,7 +116,7 @@ STC_INLINE bool cstr_ends_with_v(cstr s, csview sub) #define csview_compare(xp, yp) strcmp((xp)->str, (yp)->str) #define csview_hash(xp, dummy) c_strhash((xp)->str) -#define csview_equals(xp, yp) (strcmp((xp)->str, (yp)->str) == 0) +#define csview_equalto(xp, yp) (strcmp((xp)->str, (yp)->str) == 0) /* -------------------------- IMPLEMENTATION ------------------------- */ diff --git a/include/stc/template.h b/include/stc/template.h index 44bc595c..28c6879a 100644 --- a/include/stc/template.h +++ b/include/stc/template.h @@ -127,7 +127,7 @@ #if !defined i_equ && defined i_cmp #define i_equ !i_cmp #elif !defined i_equ - #define i_equ c_default_equals + #define i_equ c_default_equalto #endif #ifndef i_hash #define i_hash c_default_hash -- cgit v1.2.3