summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-10-29 17:02:39 +0200
committerTyge Løvset <[email protected]>2021-10-29 17:02:39 +0200
commitead0b1d0c6cc724e7f2d7eb2ed9273dd7a18935f (patch)
treec83eac9187b020e8510e3ee11e982a29f0c29152
parent9708235ec4147d2c0428c9ae5186fad452b116ad (diff)
downloadSTC-modified-ead0b1d0c6cc724e7f2d7eb2ed9273dd7a18935f.tar.gz
STC-modified-ead0b1d0c6cc724e7f2d7eb2ed9273dd7a18935f.zip
Swapped .._equals() and _equalto() functions for consistency
-rw-r--r--benchmarks/others/old/sstr.h6
-rw-r--r--docs/cmap_api.md16
-rw-r--r--docs/csptr_api.md1
-rw-r--r--docs/cstr_api.md8
-rw-r--r--docs/csview_api.md4
-rw-r--r--examples/advanced.c4
-rw-r--r--examples/cstr_match.c2
-rw-r--r--examples/sptr_ex.c2
-rw-r--r--include/stc/alt/cstr.h6
-rw-r--r--include/stc/ccommon.h6
-rw-r--r--include/stc/cstr.h6
-rw-r--r--include/stc/csview.h4
-rw-r--r--include/stc/template.h2
13 files changed, 33 insertions, 34 deletions
diff --git a/benchmarks/others/old/sstr.h b/benchmarks/others/old/sstr.h
index 5301978a..68b724a8 100644
--- a/benchmarks/others/old/sstr.h
+++ b/benchmarks/others/old/sstr.h
@@ -163,15 +163,15 @@ STC_INLINE sstr_size_t sstr_capacity(sstr s) {
return sstr_select_(&s, cap(&s));
}
-STC_INLINE bool sstr_equalto(sstr s1, const char* str) {
+STC_INLINE bool sstr_equals(sstr s1, const char* str) {
return strcmp(sstr_str(&s1), str) == 0;
}
-STC_INLINE bool sstr_equalto_s(sstr s1, sstr s2) {
+STC_INLINE bool sstr_equals_s(sstr s1, sstr s2) {
return strcmp(sstr_str(&s1), sstr_str(&s2)) == 0;
}
-STC_INLINE int sstr_equals(const sstr* s1, const sstr* s2) {
+STC_INLINE bool sstr_equalto(const sstr* s1, const sstr* s2) {
return strcmp(sstr_str(s1), sstr_str(s2)) == 0;
}
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index 628e982a..f8b24704 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -82,14 +82,14 @@ Helpers:
uint64_t c_strhash(const char *str); // utility function
int c_rawstr_compare(const char* const* a, const char* const* b);
-bool c_rawstr_equals(const char* const* a, const char* const* b);
+bool c_rawstr_equalto(const char* const* a, const char* const* b);
uint64_t c_rawstr_hash(const char* const* strp, ...);
uint64_t c_default_hash(const void *data, size_t len); // key any trivial type
uint64_t c_default_hash32(const void* data, size_t is4); // key one 32bit int
uint64_t c_default_hash64(const void* data, size_t is8); // key one 64bit int
-int c_default_equals(const i_keyraw* a, const i_keyraw* b); // the == operator
-int c_memcmp_equals(const i_keyraw* a, const i_keyraw* b); // uses memcmp
+bool c_default_equalto(const i_keyraw* a, const i_keyraw* b); // the == operator
+bool c_memcmp_equalto(const i_keyraw* a, const i_keyraw* b); // uses memcmp
Type c_no_clone(Type val);
Type c_default_fromraw(Type val); // plain copy
@@ -203,7 +203,7 @@ typedef struct { int x, y, z; } Vec3i;
#define i_key Vec3i
#define i_val int
-#define i_cmp c_memcmp_equals // bitwise compare, and use c_default_hash
+#define i_cmp c_memcmp_equalto // bitwise compare, and use c_default_hash
#define i_tag vi
#include <stc/cmap.h>
@@ -273,7 +273,7 @@ typedef struct {
cstr country;
} Viking;
-static int Viking_equals(const Viking* a, const Viking* b) {
+static bool Viking_equalto(const Viking* a, const Viking* b) {
return cstr_equals_s(a->name, b->name) && cstr_equals_s(a->country, b->country);
}
@@ -287,7 +287,7 @@ static void Viking_del(Viking* v) {
#define i_key Viking
#define i_val int
-#define i_equ Viking_equals
+#define i_equ Viking_equalto
#define i_hash Viking_hash
#define i_del Viking_del
#define i_tag vk
@@ -346,7 +346,7 @@ typedef struct {
const char* country;
} RViking;
-static int RViking_equals(const RViking* r1, const RViking* r2)
+static bool RViking_equalto(const RViking* r1, const RViking* r2)
{ return !strcmp(r1->name, r2->name) && !strcmp(r1->country, r2->country); }
static uint32_t RViking_hash(const RViking* r, int ignored)
@@ -362,7 +362,7 @@ static RViking Viking_toR(const Viking* v)
#define i_val int
#define i_keydel Viking_del
#define i_keyraw RViking
-#define i_equ RViking_equals
+#define i_equ RViking_equalto
#define i_hash RViking_hash
#define i_keyfrom Viking_fromR
#define i_keyto Viking_toR
diff --git a/docs/csptr_api.md b/docs/csptr_api.md
index 60825152..ba85ba8c 100644
--- a/docs/csptr_api.md
+++ b/docs/csptr_api.md
@@ -52,7 +52,6 @@ void csptr_X_reset_with(csptr_X* self, i_val val); // make and as
void csptr_X_reset_from(csptr_X* self, i_val* p); // create csptr from p.
int csptr_X_compare(const csptr_X* x, const csptr_X* y);
-bool csptr_X_equals(const csptr_X* x, const csptr_X* y);
```
## Types and constants
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index 4b1c959f..acea7b6f 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -60,8 +60,8 @@ void cstr_replace_all(cstr* self, const char* find, const char* replace)
void cstr_erase(cstr* self, size_t pos);
void cstr_erase_n(cstr* self, size_t pos, size_t n);
-bool cstr_equalto(cstr s, const char* str);
-bool cstr_equalto_s(cstr s, cstr s2);
+bool cstr_equals(cstr s, const char* str);
+bool cstr_equals_s(cstr s, cstr s2);
size_t cstr_find(cstr s, const char* needle);
size_t cstr_find_n(cstr s, const char* needle, size_t pos, size_t nmax);
bool cstr_contains(cstr s, const char* needle);
@@ -86,11 +86,11 @@ Note that all methods with arguments `(..., const char* str, size_t n)`, `n` mus
#### Helper methods:
```c
int cstr_compare(const cstr *s1, const cstr *s2);
-bool cstr_equals(const cstr *s1, const cstr *s2);
+bool cstr_equalto(const cstr *s1, const cstr *s2);
bool cstr_hash(const cstr *s, ...);
int c_rawstr_compare(const char** x, const char** y);
-bool c_rawstr_equals(const char** x, const char** y);
+bool c_rawstr_equalto(const char** x, const char** y);
uint64_t c_rawstr_hash(const char* const* x, ...);
uint64_t c_strhash(const char* str);
diff --git a/docs/csview_api.md b/docs/csview_api.md
index 4295e4e9..4d80692d 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -45,7 +45,7 @@ csview csview_slice(csview sv, intptr_t p1, intptr_t p2); // negative p
csview csview_first_token(csview sv, csview sep); // see split example below.
csview csview_next_token(csview sv, csview sep, csview token);
-bool csview_equalto(csview sv, csview sv2);
+bool csview_equals(csview sv, csview sv2);
size_t csview_find(csview sv, csview needle);
bool csview_contains(csview sv, csview needle);
bool csview_starts_with(csview sv, csview sub);
@@ -79,7 +79,7 @@ bool cstr_ends_with_v(cstr s, csview sub);
#### Helper methods
```c
int csview_compare(const csview* x, const csview* y);
-bool csview_equals(const csview* x, const csview* y);
+bool csview_equalto(const csview* x, const csview* y);
uint64_t csview_hash(const csview* x, ...);
```
## Types
diff --git a/examples/advanced.c b/examples/advanced.c
index 1c5da926..60276b09 100644
--- a/examples/advanced.c
+++ b/examples/advanced.c
@@ -22,7 +22,7 @@ uint64_t vikingraw_hash(const VikingRaw* raw, size_t ignore) {
uint64_t hash = c_strhash(raw->name) ^ (c_strhash(raw->country) >> 15);
return hash;
}
-static inline int vikingraw_equals(const VikingRaw* rx, const VikingRaw* ry) {
+static inline bool vikingraw_equalto(const VikingRaw* rx, const VikingRaw* ry) {
return strcmp(rx->name, ry->name) == 0 && strcmp(rx->country, ry->country) == 0;
}
@@ -37,7 +37,7 @@ static inline VikingRaw viking_toRaw(const Viking* vk) {
#define i_tag vk
#define i_key Viking
#define i_val int
-#define i_equ vikingraw_equals
+#define i_equ vikingraw_equalto
#define i_hash vikingraw_hash
#define i_keyraw VikingRaw
#define i_keyfrom viking_fromRaw
diff --git a/examples/cstr_match.c b/examples/cstr_match.c
index 28c1a22b..9e5cc11c 100644
--- a/examples/cstr_match.c
+++ b/examples/cstr_match.c
@@ -6,7 +6,7 @@ int main()
c_autovar (cstr ss = cstr_lit("The quick brown fox jumps over the lazy dog.JPG"), cstr_del(&ss)) {
size_t pos = cstr_find_n(ss, "brown", 0, 5);
printf("%zu [%s]\n", pos, pos == cstr_npos ? "<NULL>" : &ss.str[pos]);
- printf("equals: %d\n", cstr_equalto(ss, "The quick brown fox jumps over the lazy dog.JPG"));
+ printf("equals: %d\n", cstr_equals(ss, "The quick brown fox jumps over the lazy dog.JPG"));
printf("contains: %d\n", cstr_contains(ss, "umps ove"));
printf("starts_with: %d\n", cstr_starts_with(ss, "The quick brown"));
printf("ends_with: %d\n", cstr_ends_with(ss, ".jpg"));
diff --git a/examples/sptr_ex.c b/examples/sptr_ex.c
index 17ac27e1..8c803db5 100644
--- a/examples/sptr_ex.c
+++ b/examples/sptr_ex.c
@@ -38,7 +38,7 @@ void example3()
});
c_foreach (s, cvec_song, v)
- if (!cstr_equalto(s.ref->get->artist, "Bob Dylan"))
+ if (!cstr_equals(s.ref->get->artist, "Bob Dylan"))
cvec_song_emplace_back(&v2, *s.ref); // note: calls csptr_song_clone()
c_apply(cvec_song, push_back, &v2, {
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