summaryrefslogtreecommitdiffstats
path: root/bstr.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-04-19 06:53:56 +0300
committerUoti Urpala <uau@mplayer2.org>2011-04-20 04:22:53 +0300
commita2d28010cc7804cf4062f80eef5271c7e3eeb469 (patch)
treeff91e9a1203cecabddd009f2c27c63deabe90e81 /bstr.c
parent52d60a7334a731278e9f68d80e0f7cc5639437c4 (diff)
downloadmpv-a2d28010cc7804cf4062f80eef5271c7e3eeb469.tar.bz2
mpv-a2d28010cc7804cf4062f80eef5271c7e3eeb469.tar.xz
cleanup: find_subfiles.c: simplify (mainly using bstr)
Diffstat (limited to 'bstr.c')
-rw-r--r--bstr.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/bstr.c b/bstr.c
index f4d3bdef42..68342fabfe 100644
--- a/bstr.c
+++ b/bstr.c
@@ -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]);
+}