From d9b49f546e9e1a0d0d751ce09094647cf7534dad Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 31 Oct 2007 15:11:39 +0100 Subject: [PATCH] config: print useful error messages on parsing error or config file error --- awesomerc | 1 + config.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/awesomerc b/awesomerc index b2ecd89f..44744c61 100644 --- a/awesomerc +++ b/awesomerc @@ -1,4 +1,5 @@ # Configuration file for awesome +dwqcdasls,vl;sd general { diff --git a/config.c b/config.c index 41b2cee6..9c117cc0 100644 --- a/config.c +++ b/config.c @@ -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");