X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcontext-priv.c;h=cc5764d3fc883ea5d8f724fbe96a4bf2a51295b8;hb=bb3a6894d5521a9cbf9be2ec0012cf6b861537e2;hp=c9342016856d282ae830d0e04cdb9e85b57bb4f0;hpb=2ecc0f8316bdbc41f81845fc9a5f0809c38a6229;p=platform%2Fupstream%2Flibxkbcommon.git diff --git a/src/context-priv.c b/src/context-priv.c index c934201..cc5764d 100644 --- a/src/context-priv.c +++ b/src/context-priv.c @@ -24,15 +24,26 @@ * Author: Daniel Stone */ +#include "config.h" + #include #include #include -#include #include "xkbcommon/xkbcommon.h" #include "utils.h" #include "context.h" +char * +xkb_context_getenv(struct xkb_context *ctx, const char *name) +{ + if (ctx->use_secure_getenv) { + return secure_getenv(name); + } else { + return getenv(name); + } +} + unsigned int xkb_context_num_failed_include_paths(struct xkb_context *ctx) { @@ -52,19 +63,13 @@ xkb_context_failed_include_path_get(struct xkb_context *ctx, xkb_atom_t xkb_atom_lookup(struct xkb_context *ctx, const char *string) { - return atom_lookup(ctx->atom_table, string, strlen(string)); + return atom_intern(ctx->atom_table, string, strlen(string), false); } xkb_atom_t xkb_atom_intern(struct xkb_context *ctx, const char *string, size_t len) { - return atom_intern(ctx->atom_table, string, len, false); -} - -xkb_atom_t -xkb_atom_steal(struct xkb_context *ctx, char *string) -{ - return atom_intern(ctx->atom_table, string, strlen(string), true); + return atom_intern(ctx->atom_table, string, len, true); } const char * @@ -104,21 +109,13 @@ xkb_context_get_buffer(struct xkb_context *ctx, size_t size) return rtrn; } -#ifndef DEFAULT_XKB_VARIANT -#define DEFAULT_XKB_VARIANT NULL -#endif - -#ifndef DEFAULT_XKB_OPTIONS -#define DEFAULT_XKB_OPTIONS NULL -#endif - static const char * xkb_context_get_default_rules(struct xkb_context *ctx) { const char *env = NULL; if (ctx->use_environment_names) - env = secure_getenv("XKB_DEFAULT_RULES"); + env = xkb_context_getenv(ctx, "XKB_DEFAULT_RULES"); return env ? env : DEFAULT_XKB_RULES; } @@ -129,7 +126,7 @@ xkb_context_get_default_model(struct xkb_context *ctx) const char *env = NULL; if (ctx->use_environment_names) - env = secure_getenv("XKB_DEFAULT_MODEL"); + env = xkb_context_getenv(ctx, "XKB_DEFAULT_MODEL"); return env ? env : DEFAULT_XKB_MODEL; } @@ -140,7 +137,7 @@ xkb_context_get_default_layout(struct xkb_context *ctx) const char *env = NULL; if (ctx->use_environment_names) - env = secure_getenv("XKB_DEFAULT_LAYOUT"); + env = xkb_context_getenv(ctx, "XKB_DEFAULT_LAYOUT"); return env ? env : DEFAULT_XKB_LAYOUT; } @@ -149,12 +146,12 @@ static const char * xkb_context_get_default_variant(struct xkb_context *ctx) { const char *env = NULL; - const char *layout = secure_getenv("XKB_DEFAULT_LAYOUT"); + const char *layout = xkb_context_getenv(ctx, "XKB_DEFAULT_LAYOUT"); /* We don't want to inherit the variant if they haven't also set a * layout, since they're so closely paired. */ if (layout && ctx->use_environment_names) - env = secure_getenv("XKB_DEFAULT_VARIANT"); + env = xkb_context_getenv(ctx, "XKB_DEFAULT_VARIANT"); return env ? env : DEFAULT_XKB_VARIANT; } @@ -165,7 +162,7 @@ xkb_context_get_default_options(struct xkb_context *ctx) const char *env = NULL; if (ctx->use_environment_names) - env = secure_getenv("XKB_DEFAULT_OPTIONS"); + env = xkb_context_getenv(ctx, "XKB_DEFAULT_OPTIONS"); return env ? env : DEFAULT_XKB_OPTIONS; } @@ -182,6 +179,17 @@ xkb_context_sanitize_rule_names(struct xkb_context *ctx, * the caller and one from the environment. */ if (isempty(rmlvo->layout)) { rmlvo->layout = xkb_context_get_default_layout(ctx); + if (!isempty(rmlvo->variant)) { + const char *variant = xkb_context_get_default_variant(ctx); + log_warn(ctx, + XKB_LOG_MESSAGE_NO_ID, + "Layout not provided, but variant set to \"%s\": " + "ignoring variant and using defaults for both: " + "layout=\"%s\", variant=\"%s\".\n", + rmlvo->variant, + rmlvo->layout, + variant ? variant : ""); + } rmlvo->variant = xkb_context_get_default_variant(ctx); } /* Options can be empty, so respect that if passed in. */