From 02dee6ce206368adc6dbd43985eafd29bcd273ea Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 24 Nov 2020 11:42:19 +0100 Subject: Fixed return value from cstr_find_n(), and added cstr_length() alias to cstr_size(). --- stc/cstr.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stc/cstr.h b/stc/cstr.h index 57131b2c..4f701c33 100644 --- a/stc/cstr.h +++ b/stc/cstr.h @@ -170,6 +170,9 @@ cstr_getline(cstr_t *self, FILE *stream) { /* readonly */ +STC_INLINE size_t +cstr_length(cstr_t s) { return cstr_size(s); } + STC_INLINE bool cstr_equals(cstr_t s1, const char* str) { return strcmp(s1.str, str) == 0; @@ -190,7 +193,7 @@ cstr_find(cstr_t s, const char* needle) { } STC_INLINE size_t cstr_find_n(cstr_t s, const char* needle, size_t pos, size_t nlen) { - if (pos > cstr_size(s)) return NULL; + if (pos > cstr_size(s)) return cstr_npos; char* res = c_strnfind(s.str + pos, needle, nlen); return res ? res - s.str : cstr_npos; } -- cgit v1.2.3