mirror of
https://github.com/mpv-player/mpv
synced 2025-02-27 02:40:53 +00:00
m_option: add function to check whether parameters are required
To avoid that it will be duplicated with m_option.c and m_config.c.
This commit is contained in:
parent
c6037982fd
commit
9fd2e449de
@ -585,10 +585,7 @@ int m_config_option_requires_param(struct m_config *config, bstr name)
|
||||
if (opt) {
|
||||
if (bstr_endswith0(name, "-clr"))
|
||||
return 0;
|
||||
if (((opt->flags & M_OPT_OPTIONAL_PARAM) ||
|
||||
(opt->type->flags & M_OPT_TYPE_OPTIONAL_PARAM)))
|
||||
return 0;
|
||||
return 1;
|
||||
return m_option_required_params(opt);
|
||||
}
|
||||
return M_OPT_UNKNOWN;
|
||||
}
|
||||
|
@ -59,6 +59,14 @@ 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)))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct m_option *m_option_list_findb(const struct m_option *list,
|
||||
struct bstr name)
|
||||
{
|
||||
|
@ -464,6 +464,8 @@ static inline void m_option_free(const m_option_t *opt, void *dst)
|
||||
opt->type->free(dst);
|
||||
}
|
||||
|
||||
int m_option_required_params(const m_option_t *opt);
|
||||
|
||||
// Cause a compilation warning if typeof(expr) != type.
|
||||
// Should be used with pointer types only.
|
||||
#define MP_EXPECT_TYPE(type, expr) (0 ? (type)0 : (expr))
|
||||
|
Loading…
Reference in New Issue
Block a user