summaryrefslogtreecommitdiffstats
path: root/options/m_property.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-30 13:41:03 +0200
committerwm4 <wm4@nowhere>2014-03-30 13:41:03 +0200
commit5cd20c73208e6fca063f829c86dd4cd22f55a31a (patch)
tree19437ad82631d4fdb7b4acc3b57620c4866e9bc5 /options/m_property.c
parent7cc985f3d01dbb27f17231793713caa6565e42ee (diff)
downloadmpv-5cd20c73208e6fca063f829c86dd4cd22f55a31a.tar.bz2
mpv-5cd20c73208e6fca063f829c86dd4cd22f55a31a.tar.xz
command: add helper function to split property paths
We've just checked whether a sub-path started with "name/", but that changes behavior whether the property name has a trailing '/' or not. Using a helper function to split of path components avoids this problem.
Diffstat (limited to 'options/m_property.c')
-rw-r--r--options/m_property.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/options/m_property.c b/options/m_property.c
index ff23979ade..d235c27c95 100644
--- a/options/m_property.c
+++ b/options/m_property.c
@@ -232,6 +232,20 @@ int m_property_do(struct mp_log *log, const m_option_t *prop_list,
}
}
+bool m_property_split_path(const char *path, bstr *prefix, char **rem)
+{
+ char *next = strchr(path, '/');
+ if (next) {
+ *prefix = bstr_splice(bstr0(path), 0, next - path);
+ *rem = next + 1;
+ return true;
+ } else {
+ *prefix = bstr0(path);
+ *rem = "";
+ return false;
+ }
+}
+
static int m_property_do_bstr(const m_option_t *prop_list, bstr name,
int action, void *arg, void *ctx)
{