bstr: add bstrspn()

This commit is contained in:
wm4 committed 2013-04-21 03:47:05 +02:00
1 parent 465ccd2c93
commit 5bc7e4d6eb
2 files changed
+10

No files matched your search

+9
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++)
+1
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);