diff options
author | wm4 <wm4@nowhere> | 2014-03-30 13:41:03 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-30 13:41:03 +0200 |
commit | 5cd20c73208e6fca063f829c86dd4cd22f55a31a (patch) | |
tree | 19437ad82631d4fdb7b4acc3b57620c4866e9bc5 /player | |
parent | 7cc985f3d01dbb27f17231793713caa6565e42ee (diff) | |
download | mpv-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 'player')
-rw-r--r-- | player/command.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/player/command.c b/player/command.c index d22382c7fb..13b0993f90 100644 --- a/player/command.c +++ b/player/command.c @@ -853,16 +853,19 @@ static int tag_property(m_option_t *prop, int action, void *arg, } case M_PROPERTY_KEY_ACTION: { struct m_property_action_arg *ka = arg; - bstr key = bstr0(ka->key); - if (bstr_eatstart0(&key, "list/")) { + bstr key; + char *rem; + m_property_split_path(ka->key, &key, &rem); + if (bstr_equals0(key, "list")) { struct m_property_action_arg nka = *ka; - nka.key = key.start; // ok because slice ends with \0 + nka.key = rem; return m_property_read_list(action, &nka, tags->num_keys, get_tag_entry, tags); } // Direct access without this prefix is allowed for compatibility. - bstr_eatstart0(&key, "by-key/"); - char *meta = mp_tags_get_bstr(tags, key); + bstr k = bstr0(ka->key); + bstr_eatstart0(&k, "by-key/"); + char *meta = mp_tags_get_bstr(tags, k); if (!meta) return M_PROPERTY_UNKNOWN; switch (ka->action) { |