summary refs log tree commit diff
path: root/parse.y
diff options
context:
space:
mode:
authorokan <okan>2014-01-27 14:49:40 +0000
committerokan <okan>2014-01-27 14:49:40 +0000
commit469db5f3719333ff97443e17b81008fb0cddf922 (patch)
tree83d3e91b22efddfecab28a6b1e336436c6940c9e /parse.y
parent6f103498437d2b2b9eeee66be168a1cc0144bdff (diff)
downloadcwm-469db5f3719333ff97443e17b81008fb0cddf922.tar.gz
cwm-469db5f3719333ff97443e17b81008fb0cddf922.tar.xz
cwm-469db5f3719333ff97443e17b81008fb0cddf922.zip
simplify parse_config using assignment; inspired by a very old diff from
Tiago Cunha.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y59
1 files changed, 2 insertions, 57 deletions
diff --git a/parse.y b/parse.y
index cb14dd1..a23e1c5 100644
--- a/parse.y
+++ b/parse.y
@@ -547,76 +547,21 @@ parse_config(const char *filename, struct conf *xconf)
 {
 	int			 errors = 0;
 
-	conf = xcalloc(1, sizeof(*conf));
+	conf = xconf;
 
 	if ((file = pushfile(filename)) == NULL) {
-		free(conf);
 		return (-1);
 	}
 	topfile = file;
 
-	conf_init(conf);
-
 	yyparse();
 	errors = file->errors;
 	popfile();
 
 	if (errors) {
 		conf_clear(conf);
+		conf_init(conf);
 	}
-	else {
-		struct autogroupwin	*ag;
-		struct keybinding	*kb;
-		struct winmatch		*wm;
-		struct cmd		*cmd;
-		struct mousebinding	*mb;
-		int			 i;
-
-		conf_clear(xconf);
-
-		xconf->flags = conf->flags;
-		xconf->bwidth = conf->bwidth;
-		xconf->mamount = conf->mamount;
-		xconf->snapdist = conf->snapdist;
-		xconf->gap = conf->gap;
-
-		while ((cmd = TAILQ_FIRST(&conf->cmdq)) != NULL) {
-			TAILQ_REMOVE(&conf->cmdq, cmd, entry);
-			TAILQ_INSERT_TAIL(&xconf->cmdq, cmd, entry);
-		}
-
-		while ((kb = TAILQ_FIRST(&conf->keybindingq)) != NULL) {
-			TAILQ_REMOVE(&conf->keybindingq, kb, entry);
-			TAILQ_INSERT_TAIL(&xconf->keybindingq, kb, entry);
-		}
-
-		while ((ag = TAILQ_FIRST(&conf->autogroupq)) != NULL) {
-			TAILQ_REMOVE(&conf->autogroupq, ag, entry);
-			TAILQ_INSERT_TAIL(&xconf->autogroupq, ag, entry);
-		}
-
-		while ((wm = TAILQ_FIRST(&conf->ignoreq)) != NULL) {
-			TAILQ_REMOVE(&conf->ignoreq, wm, entry);
-			TAILQ_INSERT_TAIL(&xconf->ignoreq, wm, entry);
-		}
-
-		while ((mb = TAILQ_FIRST(&conf->mousebindingq)) != NULL) {
-			TAILQ_REMOVE(&conf->mousebindingq, mb, entry);
-			TAILQ_INSERT_TAIL(&xconf->mousebindingq, mb, entry);
-		}
-
-		(void)strlcpy(xconf->termpath, conf->termpath,
-		    sizeof(xconf->termpath));
-		(void)strlcpy(xconf->lockpath, conf->lockpath,
-		    sizeof(xconf->lockpath));
-
-		for (i = 0; i < CWM_COLOR_NITEMS; i++)
-			xconf->color[i] = conf->color[i];
-
-		xconf->font = conf->font;
-	}
-
-	free(conf);
 
 	return (errors ? -1 : 0);
 }