From 5cd20c73208e6fca063f829c86dd4cd22f55a31a Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 30 Mar 2014 13:41:03 +0200 Subject: 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. --- player/command.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'player') 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) { -- cgit v1.2.3