diff options
| author | Tyge Løvset <[email protected]> | 2022-03-04 20:21:29 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-03-04 20:21:29 +0100 |
| commit | 9f1a51593ae7dd45db46f39ac18901ad175af18e (patch) | |
| tree | 442b418ab28ad27aeea76af9a5fb83a3235e7cb5 /include | |
| parent | 3c379fbfb2b7301cd5c4f5371a9f0b96a1369b60 (diff) | |
| download | STC-modified-9f1a51593ae7dd45db46f39ac18901ad175af18e.tar.gz STC-modified-9f1a51593ae7dd45db46f39ac18901ad175af18e.zip | |
Replaced c_strlit type with c_strlen_lit(lit) macro and its usage.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/alt/cstr.h | 2 | ||||
| -rw-r--r-- | include/stc/cbits.h | 2 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 2 | ||||
| -rw-r--r-- | include/stc/cstr.h | 2 | ||||
| -rw-r--r-- | include/stc/csview.h | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h index adad3e3d..82ebae91 100644 --- a/include/stc/alt/cstr.h +++ b/include/stc/alt/cstr.h @@ -82,7 +82,7 @@ STC_INLINE _cstr_rep_t cstr_rep_(cstr* self) { /**************************** PUBLIC API **********************************/
-#define cstr_new(literal) cstr_from_n(literal, sizeof((c_strlit){literal}) - 1)
+#define cstr_new(literal) cstr_from_n(literal, c_strlen_lit(literal))
#define cstr_npos (SIZE_MAX >> 1)
#define cstr_null (c_make(cstr){.sso = {.cap_len = SSO_CAP}})
#define cstr_toraw(self) cstr_str(self)
diff --git a/include/stc/cbits.h b/include/stc/cbits.h index 6c2235e7..af9336c1 100644 --- a/include/stc/cbits.h +++ b/include/stc/cbits.h @@ -78,7 +78,7 @@ STC_INLINE void cbits_drop(cbits* self) { c_free(self->data64); } STC_INLINE size_t cbits_size(cbits set) { return set.size; }
#define cbits_new(literal) \
- cbits_from_n(literal, sizeof c_make(c_strlit){literal} - 1)
+ cbits_from_n(literal, c_strlen_lit(literal))
STC_INLINE cbits* cbits_take(cbits* self, cbits other) {
if (self->data64 != other.data64) {cbits_drop(self); *self = other;}
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 263971a0..52daf837 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -77,7 +77,7 @@ # define c_free(p) free(p)
#endif
-typedef const char c_strlit[];
+#define c_strlen_lit(literal) (sizeof "" literal - 1U)
#define c_delete(T, ptr) do { T *_c_p = ptr; T##_drop(_c_p); c_free(_c_p); } while (0)
#define c_swap(T, x, y) do { T _c_t = x; x = y; y = _c_t; } while (0)
#define c_arraylen(a) (sizeof (a)/sizeof (a)[0])
diff --git a/include/stc/cstr.h b/include/stc/cstr.h index fc4c22d1..9ddf3d32 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -68,7 +68,7 @@ STC_INLINE cstr cstr_init() { return cstr_null; } #define cstr_str(self) (self)->str
#define cstr_toraw(self) (self)->str
#define cstr_new(literal) \
- cstr_from_n(literal, sizeof c_make(c_strlit){literal} - 1)
+ cstr_from_n(literal, c_strlen_lit(literal))
STC_INLINE cstr cstr_from(const char* str)
{ return cstr_from_n(str, strlen(str)); }
STC_INLINE char* cstr_data(cstr* self) { return self->str; }
diff --git a/include/stc/csview.h b/include/stc/csview.h index c2bd041d..85ade552 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -38,7 +38,7 @@ STC_API csview csview_slice(csview sv, intptr_t p1, intptr_t p2); STC_API csview csview_token(csview sv, csview sep, size_t* start);
#define csview_new(literal) \
- c_make(csview){literal, sizeof c_make(c_strlit){literal} - 1}
+ c_make(csview){literal, c_strlen_lit(literal)}
STC_INLINE csview csview_init() { return csview_null; }
STC_INLINE csview csview_from(const char* str)
{ return c_make(csview){str, strlen(str)}; }
|
