diff options
Diffstat (limited to 'options/m_option.c')
-rw-r--r-- | options/m_option.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/options/m_option.c b/options/m_option.c index 699ecb4539..b5f9930068 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -74,9 +74,15 @@ char *m_option_strerror(int code) int m_option_required_params(const m_option_t *opt) { - if (((opt->flags & M_OPT_OPTIONAL_PARAM) || - (opt->type->flags & M_OPT_TYPE_OPTIONAL_PARAM))) + if (opt->type->flags & M_OPT_TYPE_OPTIONAL_PARAM) return 0; + if (opt->type == &m_option_type_choice) { + struct m_opt_choice_alternatives *alt; + for (alt = opt->priv; alt->name; alt++) { + if (strcmp(alt->name, "yes") == 0) + return 0; + } + } return 1; } @@ -535,9 +541,17 @@ static int parse_choice(struct mp_log *log, const struct m_option *opt, struct bstr name, struct bstr param, void *dst) { struct m_opt_choice_alternatives *alt = opt->priv; - for ( ; alt->name; alt++) + for ( ; alt->name; alt++) { if (!bstrcmp0(param, alt->name)) break; + } + if (!alt->name && param.len == 0) { + // allow flag-style options, e.g. "--mute" implies "--mute=yes" + for (alt = opt->priv; alt->name; alt++) { + if (!strcmp("yes", alt->name)) + break; + } + } if (!alt->name) { if (param.len == 0) return M_OPT_MISSING_PARAM; |