summaryrefslogtreecommitdiffstats
path: root/core/parser-cfg.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/parser-cfg.c')
-rw-r--r--core/parser-cfg.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/core/parser-cfg.c b/core/parser-cfg.c
index 1a67389854..e5bf6eb3b5 100644
--- a/core/parser-cfg.c
+++ b/core/parser-cfg.c
@@ -61,7 +61,6 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile)
int param_pos; /* param pos */
int ret = 1;
int errors = 0;
- int prev_mode = config->mode;
m_profile_t *profile = NULL;
mp_msg(MSGT_CFGPARSER, MSGL_V, "Reading config file %s", conffile);
@@ -71,9 +70,7 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile)
": too deep 'include'. check your configfiles\n");
ret = -1;
goto out;
- } else
-
- config->mode = M_CONFIG_FILE;
+ }
if ((line = malloc(MAX_LINE_LEN + 1)) == NULL) {
mp_msg(MSGT_CFGPARSER, MSGL_FATAL,
@@ -145,10 +142,13 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile)
++line_pos;
param_pos = 0;
+ bool param_set = false;
/* check '=' */
if (line[line_pos] == '=') {
line_pos++;
+ param_set = true;
+
/* whitespaces... */
while (isspace(line[line_pos]))
++line_pos;
@@ -197,23 +197,34 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile)
ret = -1;
}
+ bstr bopt = bstr0(opt);
+ bstr bparam = bstr0(param);
+
+ tmp = m_config_map_option(config, &bopt, &bparam, false);
+ if (tmp > 0 && !param_set)
+ tmp = M_OPT_MISSING_PARAM;
+ if (tmp < 0) {
+ PRINT_LINENUM;
+ mp_msg(MSGT_CFGPARSER, MSGL_ERR,
+ "error parsing option %s=%s: %s\n",
+ opt, param, m_option_strerror(tmp));
+ continue;
+ }
+
if (profile) {
if (!strcmp(opt, "profile-desc"))
m_profile_set_desc(profile, param), tmp = 1;
else
tmp = m_config_set_profile_option(config, profile,
- opt, param);
- } else
- tmp = m_config_set_option0(config, opt, param);
+ bopt, bparam);
+ } else {
+ tmp = m_config_set_option_ext(config, bopt, bparam,
+ M_SETOPT_FROM_CONFIG_FILE);
+ }
if (tmp < 0) {
PRINT_LINENUM;
- if (tmp == M_OPT_UNKNOWN) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "unknown option '%s'\n", opt);
- continue;
- }
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "setting option %s='%s' failed\n", opt, param);
+ "setting option %s='%s' failed.\n", opt, param);
continue;
/* break */
}
@@ -225,7 +236,6 @@ out:
free(line);
if (fp)
fclose(fp);
- config->mode = prev_mode;
--recursion_depth;
if (ret < 0) {
mp_msg(MSGT_CFGPARSER, MSGL_FATAL, "Error loading config file %s.\n",