1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-26 13:19:12 +00:00

m_option: explicitly allow m_option.name==NULL

Doesn't require other code to care about this, which will allow us to
simplify the property code.

Only "wildcard" options like "vf" and string lists used this, and
m_option_list_findb() (which is excused).
This commit is contained in:
wm4 2014-02-21 12:23:53 +01:00
parent 641fdff65f
commit c3c82f5c3b

View File

@ -953,9 +953,8 @@ static int parse_str_list(struct mp_log *log, const m_option_t *opt,
{ {
char **res; char **res;
int op = OP_NONE; int op = OP_NONE;
int len = strlen(opt->name); if (bstr_endswith0(bstr0(opt->name), "*")) {
if (opt->name[len - 1] == '*' && (name.len > len - 1)) { struct bstr suffix = bstr_cut(name, strlen(opt->name) - 1);
struct bstr suffix = bstr_cut(name, len - 1);
if (bstrcmp0(suffix, "-add") == 0) if (bstrcmp0(suffix, "-add") == 0)
op = OP_ADD; op = OP_ADD;
else if (bstrcmp0(suffix, "-pre") == 0) else if (bstrcmp0(suffix, "-pre") == 0)
@ -964,6 +963,8 @@ static int parse_str_list(struct mp_log *log, const m_option_t *opt,
op = OP_DEL; op = OP_DEL;
else if (bstrcmp0(suffix, "-clr") == 0) else if (bstrcmp0(suffix, "-clr") == 0)
op = OP_CLR; op = OP_CLR;
else if (suffix.len == 0)
op = OP_NONE;
else else
return M_OPT_UNKNOWN; return M_OPT_UNKNOWN;
} }
@ -2327,7 +2328,6 @@ static int parse_obj_settings_del(struct mp_log *log, struct bstr opt_name,
static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
struct bstr name, struct bstr param, void *dst) struct bstr name, struct bstr param, void *dst)
{ {
int len = strlen(opt->name);
m_obj_settings_t *res = NULL; m_obj_settings_t *res = NULL;
int op = OP_NONE; int op = OP_NONE;
bool *mark_del = NULL; bool *mark_del = NULL;
@ -2336,8 +2336,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
assert(opt->priv); assert(opt->priv);
if (opt->name[len - 1] == '*' && (name.len > len - 1)) { if (bstr_endswith0(bstr0(opt->name), "*")) {
struct bstr suffix = bstr_cut(name, len - 1); struct bstr suffix = bstr_cut(name, strlen(opt->name) - 1);
if (bstrcmp0(suffix, "-add") == 0) if (bstrcmp0(suffix, "-add") == 0)
op = OP_ADD; op = OP_ADD;
else if (bstrcmp0(suffix, "-set") == 0) else if (bstrcmp0(suffix, "-set") == 0)
@ -2350,10 +2350,11 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
op = OP_CLR; op = OP_CLR;
else if (bstrcmp0(suffix, "-toggle") == 0) else if (bstrcmp0(suffix, "-toggle") == 0)
op = OP_TOGGLE; op = OP_TOGGLE;
else if (suffix.len == 0)
op = OP_NONE;
else { else {
char prefix[len]; char pre[80];
strncpy(prefix, opt->name, len - 1); snprintf(pre, sizeof(pre), "%.*s", strlen(opt->name) - 1, opt->name);
prefix[len - 1] = '\0';
mp_err(log, "Option %.*s: unknown postfix %.*s\n" mp_err(log, "Option %.*s: unknown postfix %.*s\n"
"Supported postfixes are:\n" "Supported postfixes are:\n"
" %s-set\n" " %s-set\n"
@ -2368,7 +2369,7 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
" Filter names work as well.\n\n" " Filter names work as well.\n\n"
" %s-clr\n" " %s-clr\n"
" Clear the current list.\n", " Clear the current list.\n",
BSTR_P(name), BSTR_P(suffix), prefix, prefix, prefix, prefix, prefix); BSTR_P(name), BSTR_P(suffix), pre, pre, pre, pre, pre);
return M_OPT_UNKNOWN; return M_OPT_UNKNOWN;
} }