summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-21 01:03:46 +0200
committerwm4 <wm4@nowhere>2013-04-21 03:47:05 +0200
commit5bc7e4d6ebdbd0c8bb30763b38cd48b6d79fffe1 (patch)
tree5fb5d315d82650a8e8fb9cfeb61fa9a424923c44 /core
parent465ccd2c93079fa1dd9e0d8b211eb5481bf95dd7 (diff)
downloadmpv-5bc7e4d6ebdbd0c8bb30763b38cd48b6d79fffe1.tar.bz2
mpv-5bc7e4d6ebdbd0c8bb30763b38cd48b6d79fffe1.tar.xz
bstr: add bstrspn()
Diffstat (limited to 'core')
-rw-r--r--core/bstr.c9
-rw-r--r--core/bstr.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/core/bstr.c b/core/bstr.c
index a472fbfb02..16da0993ea 100644
--- a/core/bstr.c
+++ b/core/bstr.c
@@ -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++)
diff --git a/core/bstr.h b/core/bstr.h
index bcac6cdba3..7dd318002a 100644
--- a/core/bstr.h
+++ b/core/bstr.h
@@ -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);