From 5412993724aee1126bfc8dfbc0422ebe5251b9b6 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 20 Sep 2012 03:33:57 +0200 Subject: 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". --- core/parser-cfg.c | 92 +++++++++++++++++++++++-------------------------------- 1 file changed, 38 insertions(+), 54 deletions(-) (limited to 'core') 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] != '#') { -- cgit v1.2.3