blob: a3e9f6a2f93f43d420fb9a101970be070ec3114c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <string.h>
#include "strv.h"
strv_t strv(const char *s) {
return (strv_t) { s, strlen(s) };
}
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;
}
|