diff options
| -rw-r--r-- | docs/cstr_api.md | 2 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 4 | ||||
| -rw-r--r-- | include/stc/cstr.h | 4 | ||||
| -rw-r--r-- | include/stc/csview.h | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/docs/cstr_api.md b/docs/cstr_api.md index 69512a9e..29dfe464 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -144,7 +144,7 @@ int cstr_cmp(const cstr* s1, const cstr* s2); bool cstr_eq(const cstr* s1, const cstr* s2); uint64_t cstr_hash(const cstr* self); -char* stc_strnstrn(const char* str, const char* search, intptr_t slen, intptr_t nlen); +char* stc_strnstrn(const char* str, intptr_t slen, const char* needle, intptr_t nlen); ``` ## Types diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index d074701f..80cbc5e4 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -159,8 +159,8 @@ STC_INLINE uint64_t stc_hash(const void* key, intptr_t len) { STC_INLINE uint64_t stc_strhash(const char *str) { return stc_hash(str, c_strlen(str)); } -STC_INLINE char* stc_strnstrn(const char *str, const char *needle, - intptr_t slen, const intptr_t nlen) { +STC_INLINE char* stc_strnstrn(const char *str, intptr_t slen, + const char *needle, intptr_t nlen) { if (!nlen) return (char *)str; if (nlen > slen) return NULL; slen -= nlen; diff --git a/include/stc/cstr.h b/include/stc/cstr.h index d2faeb62..f7e7b8ad 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -455,7 +455,7 @@ STC_DEF uint64_t cstr_hash(const cstr *self) { STC_DEF intptr_t cstr_find_sv(const cstr* self, csview search) { csview sv = cstr_sv(self); - char* res = stc_strnstrn(sv.buf, search.buf, sv.size, search.size); + char* res = stc_strnstrn(sv.buf, sv.size, search.buf, search.size); return res ? (res - sv.buf) : c_NPOS; } @@ -588,7 +588,7 @@ STC_DEF cstr cstr_replace_sv(csview in, csview search, csview repl, int32_t coun intptr_t from = 0; char* res; if (!count) count = INT32_MAX; if (search.size) - while (count-- && (res = stc_strnstrn(in.buf + from, search.buf, in.size - from, search.size))) { + while (count-- && (res = stc_strnstrn(in.buf + from, in.size - from, search.buf, search.size))) { const intptr_t pos = (res - in.buf); cstr_append_n(&out, in.buf + from, pos - from); cstr_append_n(&out, repl.buf, repl.size); diff --git a/include/stc/csview.h b/include/stc/csview.h index f41acf4f..11e42c97 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -165,7 +165,7 @@ STC_DEF csview_iter csview_advance(csview_iter it, intptr_t pos) { } STC_DEF intptr_t csview_find_sv(csview sv, csview search) { - char* res = stc_strnstrn(sv.buf, search.buf, sv.size, search.size); + char* res = stc_strnstrn(sv.buf, sv.size, search.buf, search.size); return res ? (res - sv.buf) : c_NPOS; } @@ -197,7 +197,7 @@ STC_DEF csview csview_slice_ex(csview sv, intptr_t p1, intptr_t p2) { STC_DEF csview csview_token(csview sv, const char* sep, intptr_t* start) { intptr_t sep_size = c_strlen(sep); csview slice = {sv.buf + *start, sv.size - *start}; - const char* res = stc_strnstrn(slice.buf, sep, slice.size, sep_size); + const char* res = stc_strnstrn(slice.buf, slice.size, sep, sep_size); csview tok = {slice.buf, res ? (res - slice.buf) : slice.size}; *start += tok.size + sep_size; return tok; |
