diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-04-19 06:53:56 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-04-20 04:22:53 +0300 |
commit | a2d28010cc7804cf4062f80eef5271c7e3eeb469 (patch) | |
tree | ff91e9a1203cecabddd009f2c27c63deabe90e81 /bstr.c | |
parent | 52d60a7334a731278e9f68d80e0f7cc5639437c4 (diff) | |
download | mpv-a2d28010cc7804cf4062f80eef5271c7e3eeb469.tar.bz2 mpv-a2d28010cc7804cf4062f80eef5271c7e3eeb469.tar.xz |
cleanup: find_subfiles.c: simplify (mainly using bstr)
Diffstat (limited to 'bstr.c')
-rw-r--r-- | bstr.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -19,6 +19,7 @@ #include <string.h> #include <libavutil/avutil.h> #include <assert.h> +#include <ctype.h> #include "talloc.h" @@ -70,6 +71,14 @@ int bstrrchr(struct bstr str, int c) return -1; } +int bstr_find(struct bstr haystack, struct bstr needle) +{ + for (int i = 0; i < haystack.len; i++) + if (bstr_startswith(bstr_splice(haystack, i, haystack.len), needle)) + return i; + return -1; +} + struct bstr bstr_strip(struct bstr str) { while (str.len && isspace(*str.start)) { @@ -148,3 +157,9 @@ struct bstr *bstr_splitlines(void *talloc_ctx, struct bstr str) r[count - 1].len = str.start + str.len - p; return r; } + +void bstr_lower(struct bstr str) +{ + for (int i = 0; i < str.len; i++) + str.start[i] = tolower(str.start[i]); +} |