tools: don't depend on src/utils.h
authorRan Benita <ran@unusedvar.com>
Sun, 28 Jun 2020 06:50:47 +0000 (09:50 +0300)
committerRan Benita <ran@unusedvar.com>
Sun, 28 Jun 2020 06:50:47 +0000 (09:50 +0300)
The idea is to make the tools/demos as standalone as possible so that
they may serve as examples as well.

Signed-off-by: Ran Benita <ran@unusedvar.com>
tools/interactive-evdev.c
tools/interactive-wayland.c
tools/interactive-x11.c
tools/print-compiled-keymap.c
tools/tools-common.h

index e09da6a..e8afb5e 100644 (file)
@@ -459,11 +459,11 @@ main(int argc, char *argv[])
     }
     else {
         struct xkb_rule_names rmlvo = {
-            .rules = isempty(rules) ? NULL : rules,
-            .model = isempty(model) ? NULL : model,
-            .layout = isempty(layout) ? NULL : layout,
-            .variant = isempty(variant) ? NULL : variant,
-            .options = isempty(options) ? NULL : options
+            .rules = (rules == NULL || rules[0] == '\0') ? NULL : rules,
+            .model = (model == NULL || model[0] == '\0') ? NULL : model,
+            .layout = (layout == NULL || layout[0] == '\0') ? NULL : layout,
+            .variant = (variant == NULL || variant[0] == '\0') ? NULL : variant,
+            .options = (options == NULL || options[0] == '\0') ? NULL : options
         };
 
         if (!rules && !model && !layout && !variant && !options)
index 0ffccd0..8cc41de 100644 (file)
 #include <errno.h>
 #include <fcntl.h>
 #include <locale.h>
+#include <stdbool.h>
 #include <stdint.h>
-#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/mman.h>
+#include <unistd.h>
 
 #include "xkbcommon/xkbcommon.h"
 #include "tools-common.h"
@@ -39,6 +42,8 @@
 #include "xdg-shell-client-protocol.h"
 #include <wayland-util.h>
 
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
 struct interactive_dpy {
     struct wl_display *dpy;
     struct wl_compositor *compositor;
index 4cc24d8..d98433e 100644 (file)
@@ -24,6 +24,8 @@
 #include "config.h"
 
 #include <locale.h>
+#include <stdbool.h>
+#include <stdlib.h>
 
 #include <xcb/xkb.h>
 
index 04d98ba..1ba648b 100644 (file)
 
 #include "config.h"
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
-#include "utils.h"
 #include "xkbcommon/xkbcommon.h"
 
 int
@@ -63,7 +64,7 @@ main(int argc, char *argv[])
         goto out;
     }
 
-    if (streq(keymap_path, "-")) {
+    if (strcmp(keymap_path, "-") == 0) {
         FILE *tmp;
 
         tmp = tmpfile();
index e971af5..f0faa34 100644 (file)
@@ -33,7 +33,6 @@
 #define _XKBCOMMON_COMPAT_H
 #include "xkbcommon/xkbcommon.h"
 #include "xkbcommon/xkbcommon-compose.h"
-#include "utils.h"
 
 void
 tools_print_keycode_state(struct xkb_state *state,