summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-02-13 18:03:22 +0100
committerTyge Løvset <[email protected]>2023-02-13 18:03:22 +0100
commita3645620cf4b8855801d9ca0cf7385de5a70c5d9 (patch)
tree4ef27f9dc36d03507d86a4e6fee66494152c76dd /include
parent3421d7b745310da05117fa97348a99a4a6ef8b5b (diff)
downloadSTC-modified-a3645620cf4b8855801d9ca0cf7385de5a70c5d9.tar.gz
STC-modified-a3645620cf4b8855801d9ca0cf7385de5a70c5d9.zip
Removed support for uppercase version of c_sv() (i.e c_SV => c_sv).
Renamed c_ARGSV => c_SV. Old name is still working.
Diffstat (limited to 'include')
-rw-r--r--include/stc/ccommon.h16
-rw-r--r--include/stc/cstr.h16
-rw-r--r--include/stc/csview.h8
-rw-r--r--include/stc/priv/altnames.h3
-rw-r--r--include/stc/utf8.h2
5 files changed, 22 insertions, 23 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 0b3083ef..04c26d4c 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -129,13 +129,13 @@ typedef const char* crawstr;
#define crawstr_hash(p) cstrhash(*(p))
#define crawstr_len(literal) (c_sizeof("" literal) - 1)
-#define c_SV(...) c_MACRO_OVERLOAD(c_SV, __VA_ARGS__)
-#define c_SV_1(lit) c_SV_2(lit, crawstr_len(lit))
-#define c_SV_2(str, n) (c_LITERAL(csview){str, n})
-#define c_SVARG(sv) (int)(sv).size, (sv).str /* use with "%.*s" */
-#define c_PAIR(ref) (ref)->first, (ref)->second
+#define c_sv(...) c_MACRO_OVERLOAD(c_sv, __VA_ARGS__)
+#define c_sv_1(lit) c_sv_2(lit, crawstr_len(lit))
+#define c_sv_2(str, n) (c_LITERAL(csview){str, n})
-#define _c_ROTL(x, k) (x << (k) | x >> (8*sizeof(x) - (k)))
+#define c_SV(sv) (int)(sv).size, (sv).str // print csview: use format "%.*s"
+#define c_PAIR(ref) (ref)->first, (ref)->second
+#define c_ROTL(x, k) (x << (k) | x >> (8*sizeof(x) - (k)))
STC_INLINE uint64_t cfasthash(const void* key, intptr_t len) {
const uint8_t *x = (const uint8_t*) key;
@@ -143,7 +143,7 @@ STC_INLINE uint64_t cfasthash(const void* key, intptr_t len) {
uint32_t u4;
while (n--) {
memcpy(&u8, x, 8), x += 8;
- h += (_c_ROTL(u8, 26) ^ u8)*0xc6a4a7935bd1e99d;
+ h += (c_ROTL(u8, 26) ^ u8)*0xc6a4a7935bd1e99d;
}
switch (len &= 7) {
case 0: return h;
@@ -152,7 +152,7 @@ STC_INLINE uint64_t cfasthash(const void* key, intptr_t len) {
}
h += *x++;
while (--len) h = (h << 10) - h + *x++;
- return _c_ROTL(h, 26) ^ h;
+ return c_ROTL(h, 26) ^ h;
}
STC_INLINE uint64_t cstrhash(const char *str)
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index c5808d02..ce6dba81 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -181,10 +181,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, c_strlen(str))); }
+ { return cstr_tolower_sv(c_sv(str, c_strlen(str))); }
STC_INLINE cstr cstr_toupper(const char* str)
- { return cstr_toupper_sv(c_SV(str, c_strlen(str))); }
+ { return cstr_toupper_sv(c_sv(str, c_strlen(str))); }
STC_INLINE void cstr_lowercase(cstr* self)
{ cstr_take(self, cstr_tolower_sv(cstr_sv(self))); }
@@ -316,7 +316,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);
intptr_t len = c_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));
}
@@ -330,7 +330,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, c_strlen(sub))); }
+ { return cstr_ends_with_sv(self, c_sv(sub, c_strlen(sub))); }
STC_INLINE bool cstr_iends_with(const cstr* self, const char* sub) {
csview sv = cstr_sv(self);
@@ -375,8 +375,8 @@ STC_INLINE char* cstr_append_s(cstr* self, cstr s) {
#define cstr_replace(...) c_MACRO_OVERLOAD(cstr_replace, __VA_ARGS__)
#define cstr_replace_3(self, search, repl) cstr_replace_4(self, search, repl, INT32_MAX)
STC_INLINE void cstr_replace_4(cstr* self, const char* search, const char* repl, int32_t count) {
- cstr_take(self, cstr_replace_sv(cstr_sv(self), c_SV(search, c_strlen(search)),
- c_SV(repl, c_strlen(repl)), count));
+ cstr_take(self, cstr_replace_sv(cstr_sv(self), c_sv(search, c_strlen(search)),
+ c_sv(repl, c_strlen(repl)), count));
}
STC_INLINE void cstr_replace_at_sv(cstr* self, intptr_t pos, intptr_t len, const csview repl) {
@@ -385,7 +385,7 @@ STC_INLINE void cstr_replace_at_sv(cstr* self, intptr_t pos, intptr_t len, const
}
STC_INLINE void cstr_replace_at(cstr* self, intptr_t pos, intptr_t len, const char* repl)
- { cstr_replace_at_sv(self, pos, len, c_SV(repl, c_strlen(repl))); }
+ { cstr_replace_at_sv(self, pos, len, c_sv(repl, c_strlen(repl))); }
STC_INLINE void cstr_replace_at_s(cstr* self, intptr_t pos, intptr_t len, cstr repl)
{ cstr_replace_at_sv(self, pos, len, cstr_sv(&repl)); }
@@ -395,7 +395,7 @@ STC_INLINE void cstr_u8_replace_at(cstr* self, intptr_t bytepos, intptr_t u8len,
STC_INLINE void cstr_insert(cstr* self, intptr_t pos, const char* str)
- { cstr_replace_at_sv(self, pos, 0, c_SV(str, c_strlen(str))); }
+ { cstr_replace_at_sv(self, pos, 0, c_sv(str, c_strlen(str))); }
STC_INLINE void cstr_insert_sv(cstr* self, intptr_t pos, csview sv)
{ cstr_replace_at_sv(self, pos, 0, sv); }
diff --git a/include/stc/csview.h b/include/stc/csview.h
index 748f7d30..bba3aea3 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -27,12 +27,12 @@
#include "forward.h"
#include "utf8.h"
-#define csview_NULL c_SV_1("")
+#define csview_NULL c_sv_1("")
#define csview_init() csview_NULL
#define csview_drop(p) c_default_drop(p)
#define csview_clone(sv) c_default_clone(sv)
-#define csview_lit(literal) c_SV_1(literal)
-#define csview_from_n(str, n) c_SV_2(str, n)
+#define csview_lit(literal) c_sv_1(literal)
+#define csview_from_n(str, n) c_sv_2(str, n)
STC_API intptr_t csview_find_sv(csview sv, csview search);
@@ -47,7 +47,7 @@ STC_INLINE bool csview_equals(csview sv, const char* str)
{ intptr_t n = c_strlen(str); return sv.size == n && !c_memcmp(sv.str, str, n); }
STC_INLINE intptr_t csview_find(csview sv, const char* str)
- { return csview_find_sv(sv, c_SV(str, c_strlen(str))); }
+ { return csview_find_sv(sv, c_sv(str, c_strlen(str))); }
STC_INLINE bool csview_contains(csview sv, const char* str)
{ return csview_find(sv, str) != c_NPOS; }
diff --git a/include/stc/priv/altnames.h b/include/stc/priv/altnames.h
index bfda05ca..b10c7a11 100644
--- a/include/stc/priv/altnames.h
+++ b/include/stc/priv/altnames.h
@@ -35,5 +35,4 @@
#define c_DEFER c_defer
#define c_NEW c_new
#define c_ARRAYLEN c_arraylen
-#define c_ARGSV c_SVARG
-#define c_sv c_SV
+#define c_ARGSV c_SV // [deprecated]
diff --git a/include/stc/utf8.h b/include/stc/utf8.h
index 7ad01ef4..a4cc3846 100644
--- a/include/stc/utf8.h
+++ b/include/stc/utf8.h
@@ -68,7 +68,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, INTPTR_MAX), c_SV(s2, INTPTR_MAX));
+ return utf8_icmp_sv(c_sv(s1, INTPTR_MAX), c_sv(s2, INTPTR_MAX));
}
STC_INLINE bool utf8_valid(const char* s) {