#define DEFAULT_XKB_OPTIONS NULL
#endif
-const char *
+static const char *
xkb_context_get_default_rules(struct xkb_context *ctx)
{
const char *env = NULL;
return env ? env : DEFAULT_XKB_RULES;
}
-const char *
+static const char *
xkb_context_get_default_model(struct xkb_context *ctx)
{
const char *env = NULL;
return env ? env : DEFAULT_XKB_MODEL;
}
-const char *
+static const char *
xkb_context_get_default_layout(struct xkb_context *ctx)
{
const char *env = NULL;
return env ? env : DEFAULT_XKB_LAYOUT;
}
-const char *
+static const char *
xkb_context_get_default_variant(struct xkb_context *ctx)
{
const char *env = NULL;
return env ? env : DEFAULT_XKB_VARIANT;
}
-const char *
+static const char *
xkb_context_get_default_options(struct xkb_context *ctx)
{
const char *env = NULL;
return env ? env : DEFAULT_XKB_OPTIONS;
}
+
+void
+xkb_context_sanitize_rule_names(struct xkb_context *ctx,
+ struct xkb_rule_names *rmlvo)
+{
+ if (isempty(rmlvo->rules))
+ rmlvo->rules = xkb_context_get_default_rules(ctx);
+ if (isempty(rmlvo->model))
+ rmlvo->model = xkb_context_get_default_model(ctx);
+ /* Layout and variant are tied together, so don't try to use one from
+ * the caller and one from the environment. */
+ if (isempty(rmlvo->layout)) {
+ rmlvo->layout = xkb_context_get_default_layout(ctx);
+ rmlvo->variant = xkb_context_get_default_variant(ctx);
+ }
+ /* Options can be empty, so respect that if passed in. */
+ if (rmlvo->options == NULL)
+ rmlvo->options = xkb_context_get_default_options(ctx);
+}
xkb_log(struct xkb_context *ctx, enum xkb_log_level level, int verbosity,
const char *fmt, ...);
-const char *
-xkb_context_get_default_rules(struct xkb_context *ctx);
-
-const char *
-xkb_context_get_default_model(struct xkb_context *ctx);
-
-const char *
-xkb_context_get_default_layout(struct xkb_context *ctx);
-
-const char *
-xkb_context_get_default_variant(struct xkb_context *ctx);
-
-const char *
-xkb_context_get_default_options(struct xkb_context *ctx);
+void
+xkb_context_sanitize_rule_names(struct xkb_context *ctx,
+ struct xkb_rule_names *rmlvo);
/*
* The format is not part of the argument list in order to avoid the
return NULL;
}
+ keymap = xkb_keymap_new(ctx, format, flags);
+ if (!keymap)
+ return NULL;
+
if (rmlvo_in)
rmlvo = *rmlvo_in;
else
memset(&rmlvo, 0, sizeof(rmlvo));
-
- if (isempty(rmlvo.rules))
- rmlvo.rules = xkb_context_get_default_rules(ctx);
- if (isempty(rmlvo.model))
- rmlvo.model = xkb_context_get_default_model(ctx);
- /* Layout and variant are tied together, so don't try to use one from
- * the caller and one from the environment. */
- if (isempty(rmlvo.layout)) {
- rmlvo.layout = xkb_context_get_default_layout(ctx);
- rmlvo.variant = xkb_context_get_default_variant(ctx);
- }
- /* Options can be empty, so respect that if passed in. */
- if (rmlvo.options == NULL)
- rmlvo.options = xkb_context_get_default_options(ctx);
-
- keymap = xkb_keymap_new(ctx, format, flags);
- if (!keymap)
- return NULL;
+ xkb_context_sanitize_rule_names(ctx, &rmlvo);
if (!ops->keymap_new_from_names(keymap, &rmlvo)) {
xkb_keymap_unref(keymap);