tools: avoid use of a private api
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 24 Jul 2020 03:25:11 +0000 (13:25 +1000)
committerRan Benita <ran@unusedvar.com>
Sat, 25 Jul 2020 08:05:14 +0000 (11:05 +0300)
This is merely to fill in some NULL pointers anyway, we can just use
the #defines we have available at build time.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools/compile-keymap.c

index 9458f6a..be2eaeb 100644 (file)
@@ -290,11 +290,13 @@ main(int argc, char **argv)
 {
     struct xkb_context *ctx;
     struct xkb_rule_names names = {
-        .rules = NULL,
-        .model = NULL,
+        .rules = DEFAULT_XKB_RULES,
+        .model = DEFAULT_XKB_MODEL,
+        /* layout and variant are tied together, so we either get user-supplied for
+         * both or default for both, see below */
         .layout = NULL,
         .variant = NULL,
-        .options = NULL,
+        .options = DEFAULT_XKB_OPTIONS,
     };
     int rc = 1;
     const char **path;
@@ -307,6 +309,16 @@ main(int argc, char **argv)
     if (!parse_options(argc, argv, &names))
         return EXIT_INVALID_USAGE;
 
+    /* Now fill in the layout */
+    if (isempty(names.layout)) {
+        if (!isempty(names.variant)) {
+            fprintf(stderr, "Error: a variant requires a layout\n");
+            return EXIT_INVALID_USAGE;
+        }
+        names.layout = DEFAULT_XKB_LAYOUT;
+        names.variant = DEFAULT_XKB_VARIANT;
+    }
+
     ctx = xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES);
     assert(ctx);
 
@@ -315,7 +327,6 @@ main(int argc, char **argv)
         xkb_context_set_log_verbosity(ctx, 10);
     }
 
-    xkb_context_sanitize_rule_names(ctx, &names);
     if (darray_empty(includes))
         darray_append(includes, DEFAULT_INCLUDE_PATH_PLACEHOLDER);