diff options
| author | tylov <[email protected]> | 2023-08-13 23:15:45 +0200 |
|---|---|---|
| committer | tylov <[email protected]> | 2023-08-13 23:15:45 +0200 |
| commit | 25dc58db206714dc02c1ae0548f6ba7dd3519d29 (patch) | |
| tree | dcf65b08300d82c4d6752284d5c0a5a00507f07f /include/stc/ccommon.h | |
| parent | 8bb2f5618e4cefe668a663936354cf53191f2129 (diff) | |
| download | STC-modified-25dc58db206714dc02c1ae0548f6ba7dd3519d29.tar.gz STC-modified-25dc58db206714dc02c1ae0548f6ba7dd3519d29.zip | |
API CHANGES:
Changed csview: becomes a null-terminated string view.
Added csubview: a null-terminated string view/span, like previous csview.
Note that csview works like a csubview, so not much compability issues should arise.
However, some functions have changed from _sv suffix to _ss.
Diffstat (limited to 'include/stc/ccommon.h')
| -rw-r--r-- | include/stc/ccommon.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 45fa01c6..24967a10 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -130,11 +130,15 @@ typedef const char* ccharptr; #define ccharptr_clone(s) (s) #define ccharptr_drop(p) ((void)p) +#define c_ss(...) c_MACRO_OVERLOAD(c_ss, __VA_ARGS__) +#define c_ss_1(literal) c_ss_2(literal, c_litstrlen(literal)) +#define c_ss_2(str, n) (c_LITERAL(csubstr){str, n}) +#define c_SS(ss) (int)(ss).size, (ss).str // printf("%.*s\n", c_SS(ss)); + #define c_sv(...) c_MACRO_OVERLOAD(c_sv, __VA_ARGS__) -#define c_sv_1(lit) c_sv_2(lit, c_litstrlen(lit)) +#define c_sv_1(literal) c_sv_2(literal, c_litstrlen(literal)) #define c_sv_2(str, n) (c_LITERAL(csview){str, n}) -#define c_SV(sv) (int)(sv).size, (sv).str // print csview: use format "%.*s" #define c_ROTL(x, k) (x << (k) | x >> (8*sizeof(x) - (k))) STC_INLINE uint64_t cfasthash(const void* key, intptr_t len) { |
