diff options
author | wm4 <wm4@nowhere> | 2012-09-20 03:33:57 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-02-09 00:21:17 +0100 |
commit | 5412993724aee1126bfc8dfbc0422ebe5251b9b6 (patch) | |
tree | 52215fbc4c2063b9d23830baf90dc7dbb223f14b | |
parent | 830560979c02b4e06924a813cf9bacb1629d40c9 (diff) | |
download | mpv-5412993724aee1126bfc8dfbc0422ebe5251b9b6.tar.bz2 mpv-5412993724aee1126bfc8dfbc0422ebe5251b9b6.tar.xz |
config: do not require option value
Now setting a value with "=" is not required anymore in config files.
This should work analogous to command line arguments. Putting an entry
"opt=value" into the config file is like "--opt=value" on the command
line, and "opt" is like "--opt=" and "--opt".
-rw-r--r-- | core/parser-cfg.c | 92 |
1 files changed, 38 insertions, 54 deletions
diff --git a/core/parser-cfg.c b/core/parser-cfg.c index bf97dde010..1a67389854 100644 --- a/core/parser-cfg.c +++ b/core/parser-cfg.c @@ -144,66 +144,50 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile) while (isspace(line[line_pos])) ++line_pos; - /* check '=' */ - if (line[line_pos++] != '=') { - PRINT_LINENUM; - mp_msg(MSGT_CFGPARSER, MSGL_ERR, - "option %s needs a parameter\n", opt); - ret = -1; - errors++; - continue; - } - - /* whitespaces... */ - while (isspace(line[line_pos])) - ++line_pos; + param_pos = 0; - /* read the parameter */ - if (line[line_pos] == '"' || line[line_pos] == '\'') { - c = line[line_pos]; - ++line_pos; - for (param_pos = 0; line[line_pos] != c; /* NOTHING */) { - param[param_pos++] = line[line_pos++]; - if (param_pos >= MAX_PARAM_LEN) { - PRINT_LINENUM; - mp_msg(MSGT_CFGPARSER, MSGL_ERR, - "option %s has a too long parameter\n", opt); - ret = -1; - errors++; - goto nextline; + /* check '=' */ + if (line[line_pos] == '=') { + line_pos++; + /* whitespaces... */ + while (isspace(line[line_pos])) + ++line_pos; + + /* read the parameter */ + if (line[line_pos] == '"' || line[line_pos] == '\'') { + c = line[line_pos]; + ++line_pos; + for (param_pos = 0; line[line_pos] != c; /* NOTHING */) { + param[param_pos++] = line[line_pos++]; + if (param_pos >= MAX_PARAM_LEN) { + PRINT_LINENUM; + mp_msg(MSGT_CFGPARSER, MSGL_ERR, + "option %s has a too long parameter\n", opt); + ret = -1; + errors++; + goto nextline; + } } - } - line_pos++; /* skip the closing " or ' */ - } else { - for (param_pos = 0; isprint(line[line_pos]) - && !isspace(line[line_pos]) - && line[line_pos] != '#'; /* NOTHING */) { - param[param_pos++] = line[line_pos++]; - if (param_pos >= MAX_PARAM_LEN) { - PRINT_LINENUM; - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "too long parameter\n"); - ret = -1; - errors++; - goto nextline; + line_pos++; /* skip the closing " or ' */ + } else { + for (param_pos = 0; isprint(line[line_pos]) + && !isspace(line[line_pos]) + && line[line_pos] != '#'; /* NOTHING */) { + param[param_pos++] = line[line_pos++]; + if (param_pos >= MAX_PARAM_LEN) { + PRINT_LINENUM; + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "too long parameter\n"); + ret = -1; + errors++; + goto nextline; + } } } - } - param[param_pos] = '\0'; - /* did we read a parameter? */ - if (param_pos == 0) { - PRINT_LINENUM; - mp_msg(MSGT_CFGPARSER, MSGL_ERR, - "option %s needs a parameter\n", opt); - ret = -1; - errors++; - continue; + while (isspace(line[line_pos])) + ++line_pos; } - - /* now, check if we have some more chars on the line */ - /* whitespace... */ - while (isspace(line[line_pos])) - ++line_pos; + param[param_pos] = '\0'; /* EOL / comment */ if (line[line_pos] != '\0' && line[line_pos] != '#') { |