summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2022-05-06 06:55:21 +0200
committerTyge Lovset <[email protected]>2022-05-06 06:55:21 +0200
commit9df37980d5801d4251db29fb33d8f8fa94570a2b (patch)
treea839a6a7657769d474c8b6bf0be2690dbabeeea7 /include
parentbf3a35e3cd8d1df9548aa0e57b58d7a0e5dfef14 (diff)
downloadSTC-modified-9df37980d5801d4251db29fb33d8f8fa94570a2b.tar.gz
STC-modified-9df37980d5801d4251db29fb33d8f8fa94570a2b.zip
Internal: made c_sv(lit) available after include ccommon.h and forward.h
Diffstat (limited to 'include')
-rw-r--r--include/stc/ccommon.h3
-rw-r--r--include/stc/csview.h6
2 files changed, 4 insertions, 5 deletions
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)}; }