From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 8 Sep 2013 13:18:07 +0000 (+0200)
Subject: Silently ignore characters in config/windows/toggle_order to which no window exists.
X-Git-Tag: tce~969
X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/%7B%7Btodo.comment%7D%7D?a=commitdiff_plain;h=98b3c95a0e8208d8f60f1d87047b3766ffa16608;p=plomrogue

Silently ignore characters in config/windows/toggle_order to which no window exists.
---

diff --git a/src/wincontrol.c b/src/wincontrol.c
index 487b1fa..582b631 100644
--- a/src/wincontrol.c
+++ b/src/wincontrol.c
@@ -2,7 +2,7 @@
 
 #include "wincontrol.h"
 #include <stdlib.h> /* for free() */
-#include <string.h> /* for strlen() */
+#include <string.h> /* for strlen(), strchr(), strstr() */
 #include <stdint.h> /* for uint8_t, uint16_t */
 #include <stdio.h> /* for fwrite() */
 #include <unistd.h> /* for access(), unlink() */
@@ -382,6 +382,10 @@ extern void sorted_wintoggle(struct World * world)
     uint8_t i = 0;
     for (; i < linemax - 1; i++)
     {
+        if (NULL == strchr(world->winconf_ids, win_order[i]))
+        {
+            continue;
+        }
         toggle_window(world->wmeta, get_win_by_id(world, win_order[i]));
     }
 }
diff --git a/src/wincontrol.h b/src/wincontrol.h
index 6a1021b..e783160 100644
--- a/src/wincontrol.h
+++ b/src/wincontrol.h
@@ -52,8 +52,9 @@ extern void free_wins(struct World * world);
 
 
 /* Toggle windows in world->wins in the order desribed by the first line of
- * config/windows/toggled_win_order, wherein each character may correspond to
- * one hardcoded window.
+ * config/windows/toggled_win_order, wherein each character should correspond to
+ * one window the ID of which is found in world->winconf_ids. Unknown characters
+ * are silently ignored.
  */
 extern void sorted_wintoggle(struct World * world);