From ccfef3a4f82ce48facde6499c53e62ab1065cd8b Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 1 Jun 2022 21:57:03 +0200 Subject: Change: Split replace into two: cstr_replace(s, search, repl), cstr_replace_from(s, pos, search, repl): matches cstr_find() + cstr_find_from(). --- include/stc/cstr.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/stc') diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 19dc0d67..71206301 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -320,7 +320,7 @@ STC_INLINE void cstr_replace_n(cstr* self, size_t pos, size_t len, const char* r STC_INLINE void cstr_replace_at(cstr* self, size_t pos, size_t len, const char* repl) { cstr_replace_n(self, pos, len, repl, strlen(repl)); } -STC_INLINE size_t cstr_replace(cstr* self, size_t pos, const char* search, const char* repl) { +STC_INLINE size_t cstr_replace_from(cstr* self, size_t pos, const char* search, const char* repl) { pos = cstr_find_from(*self, pos, search); if (pos == cstr_npos) return pos; @@ -329,6 +329,9 @@ STC_INLINE size_t cstr_replace(cstr* self, size_t pos, const char* search, const return pos + rlen; } +STC_INLINE size_t cstr_replace(cstr* self, const char* search, const char* repl) + { return cstr_replace_from(self, 0, search, repl); } + STC_INLINE void cstr_replace_s(cstr* self, size_t pos, size_t len, cstr s) { csview sv = cstr_sv(&s); cstr_replace_n(self, pos, len, sv.str, sv.size); -- cgit v1.2.3