summaryrefslogtreecommitdiffhomepage
path: root/misc/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-29 00:28:50 +0100
committerTyge Løvset <[email protected]>2022-12-29 00:28:50 +0100
commit0761c13f316cc98ae7756f3527931aa86bed5016 (patch)
treee90777558956fcf91d6b1c958e0c3a6fb0ab007f /misc/include
parentd623c6c85071b9af5d607bb5d9aceceaea05220a (diff)
downloadSTC-modified-0761c13f316cc98ae7756f3527931aa86bed5016.tar.gz
STC-modified-0761c13f316cc98ae7756f3527931aa86bed5016.zip
Restructuring of some headers into include/algo folder. Some API changes *_replace*() functions have been renamed, and a few minor API changes.
Diffstat (limited to 'misc/include')
-rw-r--r--misc/include/alt/cstr.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/misc/include/alt/cstr.h b/misc/include/alt/cstr.h
index ecb9c9fb..8de6c4b0 100644
--- a/misc/include/alt/cstr.h
+++ b/misc/include/alt/cstr.h
@@ -182,12 +182,12 @@ STC_INLINE uint64_t cstr_hash(const cstr *self) {
return cfasthash(self->str, _cstr_p(self)->size);
}
-STC_INLINE void
-cstr_replace(cstr* self, const char* find, const char* repl, unsigned count) {
- csview in = cstr_sv(self);
- cstr_take(self, cstr_replace_sv(in, c_SV(find, strlen(find)),
- c_SV(repl, strlen(repl)), count));
+STC_INLINE void cstr_replace_ex(cstr* self, const char* find, const char* repl, unsigned count) {
+ cstr_take(self, cstr_replace_sv(cstr_sv(self), c_SV(find, strlen(find)),
+ c_SV(repl, strlen(repl)), count));
}
+STC_INLINE void cstr_replace(cstr* self, const char* search, const char* repl)
+ { cstr_replace_ex(self, search, repl, ~0U); }
/* -------------------------- IMPLEMENTATION ------------------------- */
#if defined(i_implement)
@@ -324,7 +324,6 @@ STC_DEF cstr
cstr_replace_sv(csview str, csview find, csview repl, unsigned count) {
cstr out = cstr_NULL;
size_t from = 0; char* res;
- if (count == 0) count = ~0;
if (find.size)
while (count-- && (res = cstrnstrn(str.str + from, find.str, str.size - from, find.size))) {
const size_t pos = res - str.str;