From 4f148501736d9b58c6ba113af2df82e1c7e3decb Mon Sep 17 00:00:00 2001 From: beauby Date: Fri, 10 Feb 2012 01:11:00 +0100 Subject: [PATCH 1/2] BugFix: keep the indentation of config.keycodes --- i3-config-wizard/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/i3-config-wizard/main.c b/i3-config-wizard/main.c index 8f245e44..1a66b9f0 100644 --- a/i3-config-wizard/main.c +++ b/i3-config-wizard/main.c @@ -329,8 +329,11 @@ static void finish() { /* Skip leading whitespace */ char *walk = line; - while (isspace(*walk) && walk < (line + len)) + while (isspace(*walk) && walk < (line + len)) { + /* Pre-output the skipped whitespaces to keep proper indentation */ + fputc(*walk, ks_config); walk++; + } /* Set the modifier the user chose */ if (strncmp(walk, "set $mod ", strlen("set $mod ")) == 0) { @@ -343,7 +346,7 @@ static void finish() { /* Check for 'bindcode'. If it’s not a bindcode line, we * just copy it to the output file */ if (strncmp(walk, "bindcode", strlen("bindcode")) != 0) { - fputs(line, ks_config); + fputs(walk, ks_config); continue; } char *result = rewrite_binding(walk); From b3e3ecf722abc6540a5a975a4e643c7d207d356f Mon Sep 17 00:00:00 2001 From: beauby Date: Fri, 10 Feb 2012 01:12:43 +0100 Subject: [PATCH 2/2] Fixed a memory leak --- i3-config-wizard/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/i3-config-wizard/main.c b/i3-config-wizard/main.c index 1a66b9f0..9c2bbe55 100644 --- a/i3-config-wizard/main.c +++ b/i3-config-wizard/main.c @@ -293,6 +293,7 @@ static void finish() { FILE *ks_config = fopen(config_path, "w"); if (ks_config == NULL) err(1, "Could not open output config file \"%s\"", config_path); + free(config_path); char *line = NULL; size_t len = 0;