bstr: add bstrspn()

This commit is contained in:
wm4 2013-04-21 01:03:46 +02:00
parent 465ccd2c93
commit 5bc7e4d6eb
2 changed files with 10 additions and 0 deletions

View File

@ -82,6 +82,15 @@ int bstrcspn(struct bstr str, const char *reject)
return i;
}
int bstrspn(struct bstr str, const char *accept)
{
int i;
for (i = 0; i < str.len; i++)
if (!strchr(accept, str.start[i]))
break;
return i;
}
int bstr_find(struct bstr haystack, struct bstr needle)
{
for (int i = 0; i < haystack.len; i++)

View File

@ -58,6 +58,7 @@ int bstrcmp(struct bstr str1, struct bstr str2);
int bstrcasecmp(struct bstr str1, struct bstr str2);
int bstrchr(struct bstr str, int c);
int bstrrchr(struct bstr str, int c);
int bstrspn(struct bstr str, const char *accept);
int bstrcspn(struct bstr str, const char *reject);
int bstr_find(struct bstr haystack, struct bstr needle);