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, ...)
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) {
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);
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;
}