mirror of https://github.com/mpv-player/mpv
m_config: minor simplification
The optstruct parameter in the m_config_parse_option functions was not needed.
This commit is contained in:
parent
44d6ac06ae
commit
4e45fbed24
|
@ -500,11 +500,11 @@ const char *m_config_get_positional_option(const struct m_config *config, int n)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_subopts(struct m_config *config, void *optstruct, char *name,
|
static int parse_subopts(struct m_config *config, char *name, char *prefix,
|
||||||
char *prefix, struct bstr param, int flags);
|
struct bstr param, int flags);
|
||||||
|
|
||||||
static int m_config_parse_option(struct m_config *config, void *optstruct,
|
static int m_config_parse_option(struct m_config *config, struct bstr name,
|
||||||
struct bstr name, struct bstr param, int flags)
|
struct bstr param, int flags)
|
||||||
{
|
{
|
||||||
assert(config != NULL);
|
assert(config != NULL);
|
||||||
assert(name.len != 0);
|
assert(name.len != 0);
|
||||||
|
@ -548,7 +548,7 @@ static int m_config_parse_option(struct m_config *config, void *optstruct,
|
||||||
char prefix[110];
|
char prefix[110];
|
||||||
assert(strlen(co->name) < 100);
|
assert(strlen(co->name) < 100);
|
||||||
sprintf(prefix, "%s-", co->name);
|
sprintf(prefix, "%s-", co->name);
|
||||||
return parse_subopts(config, optstruct, co->name, prefix, param, flags);
|
return parse_subopts(config, co->name, prefix, param, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set)
|
if (set)
|
||||||
|
@ -557,8 +557,8 @@ static int m_config_parse_option(struct m_config *config, void *optstruct,
|
||||||
return m_option_parse(co->opt, name, param, set ? co->data : NULL);
|
return m_option_parse(co->opt, name, param, set ? co->data : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_subopts(struct m_config *config, void *optstruct, char *name,
|
static int parse_subopts(struct m_config *config, char *name, char *prefix,
|
||||||
char *prefix, struct bstr param, int flags)
|
struct bstr param, int flags)
|
||||||
{
|
{
|
||||||
char **lst = NULL;
|
char **lst = NULL;
|
||||||
// Split the argument into child options
|
// Split the argument into child options
|
||||||
|
@ -571,8 +571,7 @@ static int parse_subopts(struct m_config *config, void *optstruct, char *name,
|
||||||
char n[110];
|
char n[110];
|
||||||
if (snprintf(n, 110, "%s%s", prefix, lst[2 * i]) > 100)
|
if (snprintf(n, 110, "%s%s", prefix, lst[2 * i]) > 100)
|
||||||
abort();
|
abort();
|
||||||
r = m_config_parse_option(config, optstruct, bstr0(n),
|
r = m_config_parse_option(config,bstr0(n), bstr0(lst[2 * i + 1]), flags);
|
||||||
bstr0(lst[2 * i + 1]), flags);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if (r > M_OPT_EXIT) {
|
if (r > M_OPT_EXIT) {
|
||||||
mp_tmsg(MSGT_CFGPARSER, MSGL_ERR,
|
mp_tmsg(MSGT_CFGPARSER, MSGL_ERR,
|
||||||
|
@ -592,7 +591,7 @@ int m_config_parse_suboptions(struct m_config *config, char *name,
|
||||||
{
|
{
|
||||||
if (!subopts || !*subopts)
|
if (!subopts || !*subopts)
|
||||||
return 0;
|
return 0;
|
||||||
int r = parse_subopts(config, config->optstruct, name, "", bstr0(subopts), 0);
|
int r = parse_subopts(config, name, "", bstr0(subopts), 0);
|
||||||
if (r < 0 && r > M_OPT_EXIT) {
|
if (r < 0 && r > M_OPT_EXIT) {
|
||||||
mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "Error parsing suboption %s (%s)\n",
|
mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "Error parsing suboption %s (%s)\n",
|
||||||
name, m_option_strerror(r));
|
name, m_option_strerror(r));
|
||||||
|
@ -604,7 +603,7 @@ int m_config_parse_suboptions(struct m_config *config, char *name,
|
||||||
int m_config_set_option_ext(struct m_config *config, struct bstr name,
|
int m_config_set_option_ext(struct m_config *config, struct bstr name,
|
||||||
struct bstr param, int flags)
|
struct bstr param, int flags)
|
||||||
{
|
{
|
||||||
int r = m_config_parse_option(config, config->optstruct, name, param, flags);
|
int r = m_config_parse_option(config, name, param, flags);
|
||||||
if (r < 0 && r > M_OPT_EXIT) {
|
if (r < 0 && r > M_OPT_EXIT) {
|
||||||
mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "Error parsing option %.*s (%s)\n",
|
mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "Error parsing option %.*s (%s)\n",
|
||||||
BSTR_P(name), m_option_strerror(r));
|
BSTR_P(name), m_option_strerror(r));
|
||||||
|
|
Loading…
Reference in New Issue