diff options
Diffstat (limited to 'strv.c')
-rw-r--r-- | strv.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -0,0 +1,14 @@ +#include <string.h> + +#include "strv.h" + +strv_t strv_head(strv_t ss, int chr, size_t *i) { + size_t j = i ? *i : 0; + char *c = memchr(&ss.s[j], chr, ss.n - j); + strv_t r = { + &ss.s[j], + c ? c - &ss.s[j] : ss.n - j + }; + if (i) *i = j + r.n + !!c; + return r; +} |