replace some code using switch and warn()
This commit is contained in:
parent
6396d08c25
commit
e84d614377
16
config.c
16
config.c
|
@ -710,16 +710,22 @@ config_parse(const char *confpatharg)
|
||||||
cfg = cfg_init(opts, CFGF_NONE);
|
cfg = cfg_init(opts, CFGF_NONE);
|
||||||
|
|
||||||
ret = cfg_parse(cfg, confpath);
|
ret = cfg_parse(cfg, confpath);
|
||||||
if(ret == CFG_FILE_ERROR)
|
|
||||||
|
switch(ret)
|
||||||
{
|
{
|
||||||
|
case CFG_FILE_ERROR:
|
||||||
perror("awesome: parsing configuration file failed");
|
perror("awesome: parsing configuration file failed");
|
||||||
if(!(defconfig = fopen(confpath, "w")))
|
if(!(defconfig = fopen(confpath, "w")))
|
||||||
perror("awesome: unable to create default configuration file");
|
perror("awesome: unable to create default configuration file");
|
||||||
}
|
break;
|
||||||
else if(ret == CFG_PARSE_ERROR)
|
case CFG_PARSE_ERROR:
|
||||||
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);
|
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);
|
||||||
if(ret != CFG_SUCCESS) {
|
break;
|
||||||
fprintf(stderr, "Using default compile-time configuration\n");
|
}
|
||||||
|
|
||||||
|
if(ret != CFG_SUCCESS)
|
||||||
|
{
|
||||||
|
warn("using default compile-time configuration\n");
|
||||||
cfg_free(cfg);
|
cfg_free(cfg);
|
||||||
cfg = cfg_init(opts, CFGF_NONE);
|
cfg = cfg_init(opts, CFGF_NONE);
|
||||||
cfg_parse_buf(cfg, AWESOME_DEFAULT_CONFIG);
|
cfg_parse_buf(cfg, AWESOME_DEFAULT_CONFIG);
|
||||||
|
|
Loading…
Reference in New Issue