summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2014-01-28 00:42:20 +0000
committerokan <okan>2014-01-28 00:42:20 +0000
commit51b3fbee52a54cd068b5485542b454244d651c34 (patch)
tree3ac8509e9724d39c90254538c8227b6566a2e660
parent0608610cc7fb83ffa360fa85968e60b098cf3ded (diff)
downloadcwm-51b3fbee52a54cd068b5485542b454244d651c34.tar.gz
cwm-51b3fbee52a54cd068b5485542b454244d651c34.tar.xz
cwm-51b3fbee52a54cd068b5485542b454244d651c34.zip
Move conf_init/clear into main - no behaviour change; from Tiago Cunha.
-rw-r--r--calmwm.c5
-rw-r--r--parse.y7
2 files changed, 5 insertions, 7 deletions
diff --git a/calmwm.c b/calmwm.c
index 1c38b2e..abdb79c 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -108,8 +108,11 @@ main(int argc, char **argv)
 	}
 
 	conf_init(&Conf);
-	if (conf_path && (parse_config(conf_path, &Conf) == -1))
+	if (conf_path && (parse_config(conf_path, &Conf) == -1)) {
 		warnx("config file %s has errors, not loading", conf_path);
+		conf_clear(&Conf);
+		conf_init(&Conf);
+	}
 	free(conf_path);
 
 	x_init(display_name);
diff --git a/parse.y b/parse.y
index a23e1c5..984f6bc 100644
--- a/parse.y
+++ b/parse.y
@@ -545,7 +545,7 @@ popfile(void)
 int
 parse_config(const char *filename, struct conf *xconf)
 {
-	int			 errors = 0;
+	int		 errors = 0;
 
 	conf = xconf;
 
@@ -558,10 +558,5 @@ parse_config(const char *filename, struct conf *xconf)
 	errors = file->errors;
 	popfile();
 
-	if (errors) {
-		conf_clear(conf);
-		conf_init(conf);
-	}
-
 	return (errors ? -1 : 0);
 }