]> git.sur5r.net Git - i3/i3/commitdiff
Merge branch 'master' into next
authorMichael Stapelberg <michael@stapelberg.de>
Sun, 12 Feb 2012 10:21:01 +0000 (10:21 +0000)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 12 Feb 2012 10:21:01 +0000 (10:21 +0000)
i3-config-wizard/main.c

index bf260c2f7128c4e776029ec31a5043a22057f415..cf55c38c358fbd4a606cb999c0d69fb7dfcdcbc5 100644 (file)
@@ -295,6 +295,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;
@@ -331,8 +332,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) {
@@ -345,7 +349,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);