diff options
author | wm4 <wm4@nowhere> | 2013-04-21 01:03:46 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-04-21 03:47:05 +0200 |
commit | 5bc7e4d6ebdbd0c8bb30763b38cd48b6d79fffe1 (patch) | |
tree | 5fb5d315d82650a8e8fb9cfeb61fa9a424923c44 /core/bstr.c | |
parent | 465ccd2c93079fa1dd9e0d8b211eb5481bf95dd7 (diff) | |
download | mpv-5bc7e4d6ebdbd0c8bb30763b38cd48b6d79fffe1.tar.bz2 mpv-5bc7e4d6ebdbd0c8bb30763b38cd48b6d79fffe1.tar.xz |
bstr: add bstrspn()
Diffstat (limited to 'core/bstr.c')
-rw-r--r-- | core/bstr.c | 9 |
1 files changed, 9 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++) |