diff options
| author | Tyge Løvset <[email protected]> | 2020-11-24 11:42:19 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-11-24 11:42:19 +0100 |
| commit | 02dee6ce206368adc6dbd43985eafd29bcd273ea (patch) | |
| tree | eeda6b9f310e3feeb5b0112bd8c2a6125314a15e | |
| parent | 4f5bd7adb34a2aea5536dafb19dd91a6a7b76295 (diff) | |
| download | STC-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.h | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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;
}
|
