config: print useful error messages on parsing error or config file error

This commit is contained in:
Julien Danjou 2007-10-31 15:11:39 +01:00
parent eabbd371a5
commit d9b49f546e
2 changed files with 7 additions and 4 deletions

View file

@ -1,4 +1,5 @@
# Configuration file for awesome
dwqcdasls,vl;sd
general
{

View file

@ -240,9 +240,8 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
};
cfg_t *cfg, *cfg_general, *cfg_colors, *cfg_statusbar,
*cfg_tags, *cfg_layouts, *cfg_rules, *cfg_keys, *cfgsectmp;
int i = 0;
int i = 0, k = 0, ret;
unsigned int j = 0;
int k = 0;
const char *tmp, *homedir;
char *confpath;
KeySym tmp_key;
@ -266,8 +265,11 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
cfg = cfg_init(opts, CFGF_NONE);
if(cfg_parse(cfg, confpath) != CFG_SUCCESS)
fprintf(stderr, "awesome: fatal: Parsing configuration file %s failed.\n", confpath);
ret = cfg_parse(cfg, confpath);
if(ret == CFG_FILE_ERROR)
perror("awesome: parsing configuration file failed");
else if(ret == CFG_PARSE_ERROR)
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);
cfg_general = cfg_getsec(cfg, "general");
cfg_colors = cfg_getsec(cfg, "colors");