tools/how-to-type: add --keysym for how to type a keysym
[platform/upstream/libxkbcommon.git] / src / registry.c
index 19e004b..7198828 100644 (file)
@@ -133,6 +133,7 @@ static bool
 parse(struct rxkb_context *ctx, const char *path,
       enum rxkb_popularity popularity);
 
+ATTR_PRINTF(3, 4)
 static void
 rxkb_log(struct rxkb_context *ctx, enum rxkb_log_level level,
          const char *fmt, ...)
@@ -583,9 +584,8 @@ err:
 XKB_EXPORT bool
 rxkb_context_include_path_append_default(struct rxkb_context *ctx)
 {
-    const char *home, *xdg, *root;
+    const char *home, *xdg, *root, *extra;
     char *user_path;
-    int err;
     bool ret = false;
 
     if (ctx->context_state != CONTEXT_NEW) {
@@ -597,28 +597,34 @@ rxkb_context_include_path_append_default(struct rxkb_context *ctx)
 
     xdg = secure_getenv("XDG_CONFIG_HOME");
     if (xdg != NULL) {
-        err = asprintf(&user_path, "%s/xkb", xdg);
-        if (err >= 0) {
+        user_path = asprintf_safe("%s/xkb", xdg);
+        if (user_path) {
             ret |= rxkb_context_include_path_append(ctx, user_path);
             free(user_path);
         }
     } else if (home != NULL) {
         /* XDG_CONFIG_HOME fallback is $HOME/.config/ */
-        err = asprintf(&user_path, "%s/.config/xkb", home);
-        if (err >= 0) {
+        user_path = asprintf_safe("%s/.config/xkb", home);
+        if (user_path) {
             ret |= rxkb_context_include_path_append(ctx, user_path);
             free(user_path);
         }
     }
 
     if (home != NULL) {
-        err = asprintf(&user_path, "%s/.xkb", home);
-        if (err >= 0) {
+        user_path = asprintf_safe("%s/.xkb", home);
+        if (user_path) {
             ret |= rxkb_context_include_path_append(ctx, user_path);
             free(user_path);
         }
     }
 
+    extra = secure_getenv("XKB_CONFIG_EXTRA_PATH");
+    if (extra != NULL)
+        ret |= rxkb_context_include_path_append(ctx, extra);
+    else
+        ret |= rxkb_context_include_path_append(ctx, DFLT_XKB_CONFIG_EXTRA_PATH);
+
     root = secure_getenv("XKB_CONFIG_ROOT");
     if (root != NULL)
         ret |= rxkb_context_include_path_append(ctx, root);
@@ -736,6 +742,10 @@ parse_config_item(struct rxkb_context *ctx,
             if (!*name || !strlen(*name))  {
                 log_err(ctx, "xml:%d: missing required element 'name'\n",
                         ci->line);
+                free(*name);
+                free(*description);
+                free(*brief);
+                free(*vendor);
                 return false;
             }