Bläddra i källkod

Check if cmd exist before xstrdup it in mousebind_section and remove fifo if it exists before init

Martin Duquesnoy 12 år sedan
förälder
incheckning
545b1a2a7e
3 ändrade filer med 15 tillägg och 5 borttagningar
  1. 6 2
      src/config.c
  2. 6 0
      src/fifo.c
  3. 3 3
      wmfsrc

+ 6 - 2
src/config.c

@@ -14,8 +14,9 @@
 static void
 config_mouse_section(struct mbhead *mousebinds, struct conf_sec **sec)
 {
-     int i = 0;
      struct mousebind *m;
+     int i = 0;
+     char *p;
 
      SLIST_INIT(mousebinds);
 
@@ -25,7 +26,10 @@ config_mouse_section(struct mbhead *mousebinds, struct conf_sec **sec)
 
           m->button   = fetch_opt_first(sec[i], "1", "button").num;
           m->func     = uicb_name_func(fetch_opt_first(sec[i], "", "func").str);
-          m->cmd      = xstrdup(fetch_opt_first(sec[i], "", "cmd").str);
+
+          if((p = fetch_opt_first(sec[i], "", "cmd").str))
+               m->cmd = xstrdup(p);
+
           m->use_area = false;
 
           SLIST_INSERT_HEAD(mousebinds, m, next);

+ 6 - 0
src/fifo.c

@@ -4,6 +4,8 @@
  *  For license, see COPYING.
  */
 
+#include <sys/stat.h> /* access */
+
 #include "wmfs.h"
 #include "util.h"
 #include "config.h"
@@ -24,6 +26,10 @@ fifo_init(void)
 {
      xasprintf(&(W->fifo.path), "%s/wmfs-%s.fifo", P_tmpdir, DisplayString(W->dpy));
 
+     /* Check if fifo already exists */
+     if(access(W->fifo.path, F_OK) != -1)
+          unlink(W->fifo.path);
+
      if(mkfifo(W->fifo.path, 0644) < 0)
           warnx("Can't create FIFO: %s\n", strerror(errno));
 

+ 3 - 3
wmfsrc

@@ -90,9 +90,9 @@
 [client]
 
   [mouse] button = "1" func = "client_focus_click" [/mouse]
-  [mouse] button = "1" func = "mouse_swap"   [/mouse]
-  [mouse] button = "2" func = "mouse_tab"    [/mouse]
-  [mouse] button = "3" func = "mouse_resize" [/mouse]
+  [mouse] button = "1" func = "mouse_swap"         [/mouse]
+  [mouse] button = "2" func = "mouse_tab"          [/mouse]
+  [mouse] button = "3" func = "mouse_resize"       [/mouse]
 
 [/client]