diff options
| author | Tyge Løvset <[email protected]> | 2022-12-19 09:04:23 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-12-19 09:04:23 +0100 |
| commit | 1d4ad83d6f3388982cb0aeadbc9815b4776df504 (patch) | |
| tree | 6d0d389219644b127eaa83c8a54ccd93deef96b7 /include/stc/csview.h | |
| parent | 26a75a218a115a10cee82534be568a606c83dbb2 (diff) | |
| download | STC-modified-1d4ad83d6f3388982cb0aeadbc9815b4776df504.tar.gz STC-modified-1d4ad83d6f3388982cb0aeadbc9815b4776df504.zip | |
Renames:
cstr_null => cstr_NULL
csview_null => csview_NULL
cstr_npos => c_NPOS
csview_npos => c_NPOS
c_ARGsv(sv) => c_ARGSV(sv)
c_init(x) => c_INIT(x)
Diffstat (limited to 'include/stc/csview.h')
| -rw-r--r-- | include/stc/csview.h | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/include/stc/csview.h b/include/stc/csview.h index 4bd37173..e0f2ad0e 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -27,19 +27,17 @@ #include "forward.h" #include "utf8.h" -#define csview_null c_sv("") -#define csview_npos (SIZE_MAX >> 1) - -#define csview_init() csview_null -#define csview_drop c_default_drop -#define csview_clone c_default_clone -#define csview_from_n c_sv +#define csview_NULL c_sv1("") +#define csview_init() csview_NULL +#define csview_drop(p) c_default_drop(p) +#define csview_clone(sv) c_default_clone(sv) +#define csview_from_n(str, n) c_sv2(str, n) STC_API size_t csview_find_sv(csview sv, csview search); STC_INLINE csview csview_from(const char* str) - { return c_init(csview){str, strlen(str)}; } -STC_INLINE void csview_clear(csview* self) { *self = csview_null; } + { return c_INIT(csview){str, strlen(str)}; } +STC_INLINE void csview_clear(csview* self) { *self = csview_NULL; } STC_INLINE size_t csview_size(csview sv) { return sv.size; } STC_INLINE bool csview_empty(csview sv) { return sv.size == 0; } @@ -51,7 +49,7 @@ STC_INLINE size_t csview_find(csview sv, const char* str) { return csview_find_sv(sv, c_sv(str, strlen(str))); } STC_INLINE bool csview_contains(csview sv, const char* str) - { return csview_find(sv, str) != csview_npos; } + { return csview_find(sv, str) != c_NPOS; } STC_INLINE bool csview_starts_with(csview sv, const char* str) { size_t n = strlen(str); @@ -77,12 +75,12 @@ STC_INLINE csview csview_slice(csview sv, size_t p1, size_t p2) { /* utf8 iterator */ STC_INLINE csview_iter csview_begin(const csview* self) { - if (!self->size) return c_init(csview_iter){NULL}; - return c_init(csview_iter){.u8 = {{self->str, utf8_chr_size(self->str)}, + if (!self->size) return c_INIT(csview_iter){NULL}; + return c_INIT(csview_iter){.u8 = {{self->str, utf8_chr_size(self->str)}, self->str + self->size}}; } STC_INLINE csview_iter csview_end(const csview* self) { - return c_init(csview_iter){.u8 = {{NULL}, self->str + self->size}}; + return c_INIT(csview_iter){.u8 = {{NULL}, self->str + self->size}}; } STC_INLINE void csview_next(csview_iter* it) { it->ref += it->u8.chr.size; @@ -164,7 +162,7 @@ STC_API uint64_t csview_hash(const csview *self); STC_DEF size_t csview_find_sv(csview sv, csview search) { char* res = cstrnstrn(sv.str, search.str, sv.size, search.size); - return res ? (size_t)(res - sv.str) : csview_npos; + return res ? (size_t)(res - sv.str) : c_NPOS; } STC_DEF uint64_t csview_hash(const csview *self) |
