From 3fbc5727832c0687d97a218e85d93857aadcea1c Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 25 May 2021 23:22:18 +0200 Subject: Replaced csview cstr_trimmed(cstr s, left, right) with: cstr* cstr_trim(cstr* self, left, right); --- docs/cstr_api.md | 1 + docs/csview_api.md | 1 - include/stc/cstr.h | 2 ++ include/stc/csview.h | 2 -- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/cstr_api.md b/docs/cstr_api.md index 9e62fe67..49ece6e0 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -42,6 +42,7 @@ cstr* cstr_assign(cstr* self, const char* str); cstr* cstr_assign_n(cstr* self, const char* str, size_t n); // assign n first chars of str cstr* cstr_assign_fmt(cstr* self, const char* fmt, ...); // printf() formatting cstr* cstr_copy(cstr* self, cstr s); // cstr_take(self, cstr_clone(s)) +cstr* cstr_trim(cstr* self, size_t left, size_t right); cstr* cstr_append(cstr* self, const char* str); cstr* cstr_append_s(cstr* self, cstr s); diff --git a/docs/csview_api.md b/docs/csview_api.md index bb612d55..64c42973 100644 --- a/docs/csview_api.md +++ b/docs/csview_api.md @@ -59,7 +59,6 @@ void csview_next(csview_iter_t* it); ```c cstr cstr_from_v(csview sv); csview cstr_to_v(const cstr* self); -csview cstr_trimmed(cstr s, size_t left, size_t right); cstr* cstr_assign_v(cstr* self, csview sv); cstr* cstr_append_v(cstr* self, csview sv); void cstr_insert_v(cstr* self, size_t pos, csview sv); diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 54ec993b..695385a2 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -80,6 +80,8 @@ STC_INLINE cstr cstr_clone(cstr s) { return cstr_from_n(s.str, _cstr_rep(&s)->size); } STC_INLINE cstr cstr_substr(cstr s, size_t pos, size_t n) { return cstr_from_n(s.str + pos, n); } +STC_INLINE cstr* cstr_trim(cstr* self, size_t left, size_t right) + { return cstr_assign_n(self, self->str + left, _cstr_rep(self)->size - left - right); } STC_INLINE void cstr_clear(cstr* self) { self->str[_cstr_rep(self)->size = 0] = '\0'; } STC_INLINE cstr* cstr_assign(cstr* self, const char* str) diff --git a/include/stc/csview.h b/include/stc/csview.h index 990104f1..c851cf31 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -96,8 +96,6 @@ STC_INLINE cstr cstr_from_v(csview sv) { return cstr_from_n(sv.str, sv.size); } STC_INLINE csview cstr_to_v(const cstr* self) { return c_make(csview){self->str, _cstr_rep(self)->size}; } -STC_INLINE csview cstr_trimmed(cstr s, size_t left, size_t right) - { return csview_trimmed(c_sv(s), left, right); } STC_INLINE cstr* cstr_assign_v(cstr* self, csview sv) { return cstr_assign_n(self, sv.str, sv.size); } STC_INLINE cstr* cstr_append_v(cstr* self, csview sv) -- cgit v1.2.3