summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-11-24 11:42:19 +0100
committerTyge Løvset <[email protected]>2020-11-24 11:42:19 +0100
commit02dee6ce206368adc6dbd43985eafd29bcd273ea (patch)
treeeeda6b9f310e3feeb5b0112bd8c2a6125314a15e
parent4f5bd7adb34a2aea5536dafb19dd91a6a7b76295 (diff)
downloadSTC-modified-02dee6ce206368adc6dbd43985eafd29bcd273ea.tar.gz
STC-modified-02dee6ce206368adc6dbd43985eafd29bcd273ea.zip
Fixed return value from cstr_find_n(), and added cstr_length() alias to cstr_size().
-rw-r--r--stc/cstr.h5
1 files changed, 4 insertions, 1 deletions
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;
}