diff options
author | wm4 <wm4@nowhere> | 2014-06-07 23:41:47 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-06-08 00:03:45 +0200 |
commit | 924d4db0de4969b6713b96be73cc947bbff05ad1 (patch) | |
tree | 7ef9ad4ad9a49c88d2e672c7a2514fd1447787c5 /options/m_option.c | |
parent | 5cc68c792be1d0ae42017f6960ba1d0448646ff5 (diff) | |
download | mpv-924d4db0de4969b6713b96be73cc947bbff05ad1.tar.bz2 mpv-924d4db0de4969b6713b96be73cc947bbff05ad1.tar.xz |
options: change --sub-file behavior
--sub-file is actually a string list, so you can add multipel external
subtitle files. But to be able to set a list, the option value was split
on ",". This made it impossible to add filenames.
One possible solution would be adding escaping. That's probably a good
idea (and some other options already do this), but it's also complicated
both to implement and for the user.
The simpler solution is making --sub-file appending, and make it take
only a single entry.
I'm not quite sure about this yet. It breaks the invariant that if a
value is printed and parsed, you get the same value back. So for now,
just go with the simple solution.
Fixes #840.
Diffstat (limited to 'options/m_option.c')
-rw-r--r-- | options/m_option.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/options/m_option.c b/options/m_option.c index f52a81a0b9..77e610f08c 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -1344,6 +1344,42 @@ const m_option_type_t m_option_type_string_list = { .set = str_list_set, }; +static void str_list_append(void *dst, bstr s) +{ + if (!dst) + return; + char **list= VAL(dst); + int len = 0; + while (list && list[len]) + len++; + MP_TARRAY_APPEND(NULL, list, len, bstrto0(NULL, s)); + MP_TARRAY_APPEND(NULL, list, len, NULL); + VAL(dst) = list; +} + +static int parse_str_append_list(struct mp_log *log, const m_option_t *opt, + struct bstr name, struct bstr param, void *dst) +{ + if (param.len == 0) + return M_OPT_MISSING_PARAM; + + str_list_append(dst, param); + + return 1; +} + +const m_option_type_t m_option_type_string_append_list = { + .name = "String list", + .size = sizeof(char **), + .flags = M_OPT_TYPE_DYNAMIC, + .parse = parse_str_append_list, + .print = print_str_list, + .copy = copy_str_list, + .free = free_str_list, + .get = str_list_get, + .set = str_list_set, +}; + static int read_subparam(struct mp_log *log, bstr optname, bstr *str, bstr *out_subparam); |