From 9df37980d5801d4251db29fb33d8f8fa94570a2b Mon Sep 17 00:00:00 2001 From: Tyge Lovset Date: Fri, 6 May 2022 06:55:21 +0200 Subject: Internal: made c_sv(lit) available after include ccommon.h and forward.h --- include/stc/ccommon.h | 3 ++- include/stc/csview.h | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index f05bc040..c00023ce 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -83,7 +83,6 @@ # define c_free(p) free(p) #endif -#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]) @@ -114,6 +113,8 @@ typedef const char* crawstr; #define crawstr_cmp(xp, yp) strcmp(*(xp), *(yp)) #define crawstr_hash(p) c_strhash(*(p)) +#define c_strlen_lit(literal) (sizeof "" literal - 1U) +#define c_sv(lit) c_make(csview){lit, c_strlen_lit(lit)} #define _c_ROTL(x, k) (x << (k) | x >> (8*sizeof(x) - (k))) diff --git a/include/stc/csview.h b/include/stc/csview.h index d56781a6..53f08dbb 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -27,18 +27,16 @@ #include "forward.h" #include "utf8.h" -#define csview_null c_make(csview){"", 0} +#define csview_null c_sv("") +#define csview_new(literal) c_sv(literal) #define csview_npos (SIZE_MAX >> 1) #define c_PRIsv "%.*s" #define c_ARGsv(sv) (int)(sv).size, (sv).str -#define c_sv(literal) csview_new(literal) STC_API csview csview_substr(csview sv, intptr_t pos, size_t n); 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, 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)}; } -- cgit v1.2.3