Skip to content

Commit

Permalink
Guard deprecated keysym test with verbositoty level
Browse files Browse the repository at this point in the history
  • Loading branch information
wismill committed Oct 6, 2023
1 parent f3dc70f commit ed99e43
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 31 deletions.
2 changes: 2 additions & 0 deletions src/keysym.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ enum xkb_keysym_format {
XKB_KEYSYM_FORMAT_NUMERIC
};

#define XKB_MIN_VERBOSITY_DEPRECATED_KEYSYM 5

typedef uint8_t xkb_keysym_format_t;

xkb_keysym_t
Expand Down
30 changes: 17 additions & 13 deletions src/xkbcomp/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,15 +712,17 @@ ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr,
xkb_keysym_format_t keysym_format;
*sym_rtrn = xkb_keysym_with_format_from_name(str, 0, &keysym_format);
if (*sym_rtrn != XKB_KEY_NoSymbol) {
const char *ref_name = NULL;
if (xkb_keysym_is_deprecated(*sym_rtrn, keysym_format, str, &ref_name)) {
if (ref_name == NULL) {
log_warn(ctx, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"%s\"\n", str);
} else {
log_warn(ctx, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"%s\"; please use \"%s\"\n",
str, ref_name);
if (unlikely(ctx->log_verbosity >= XKB_MIN_VERBOSITY_DEPRECATED_KEYSYM)) {
const char *ref_name = NULL;
if (xkb_keysym_is_deprecated(*sym_rtrn, keysym_format, str, &ref_name)) {
if (ref_name == NULL) {
log_warn(ctx, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"%s\"\n", str);
} else {
log_warn(ctx, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"%s\"; please use \"%s\"\n",
str, ref_name);
}
}
}
return true;
Expand All @@ -744,10 +746,12 @@ ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr,
}

if (val <= XKB_KEYSYM_MAX) {
const char *ref_name = NULL;
if (xkb_keysym_is_deprecated(val, XKB_KEYSYM_FORMAT_NUMERIC, NULL, &ref_name)) {
log_warn(ctx, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"0x%x\" (%d)\n", val, val);
if (unlikely(ctx->log_verbosity >= XKB_MIN_VERBOSITY_DEPRECATED_KEYSYM)) {
const char *ref_name = NULL;
if (xkb_keysym_is_deprecated(val, XKB_KEYSYM_FORMAT_NUMERIC, NULL, &ref_name)) {
log_warn(ctx, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"0x%x\" (%d)\n", val, val);
}
}
log_warn(ctx, XKB_WARNING_NUMERIC_KEYSYM,
"numeric keysym \"0x%x\" (%d)",
Expand Down
41 changes: 23 additions & 18 deletions src/xkbcomp/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,17 @@ resolve_keysym(struct parser_param *param, const char *name, xkb_keysym_t *sym_r
sym = xkb_keysym_with_format_from_name(name, XKB_KEYSYM_NO_FLAGS, &keysym_format);
if (sym != XKB_KEY_NoSymbol) {
*sym_rtrn = sym;
const char *ref_name = NULL;
if (xkb_keysym_is_deprecated(sym, keysym_format, name, &ref_name)) {
if (ref_name == NULL) {
parser_warn(param, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"%s\"", name);
} else {
parser_warn(param, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"%s\"; please use \"%s\"",
name, ref_name);
if (unlikely(param->ctx->log_verbosity >= XKB_MIN_VERBOSITY_DEPRECATED_KEYSYM)) {
const char *ref_name = NULL;
if (xkb_keysym_is_deprecated(sym, keysym_format, name, &ref_name)) {
if (ref_name == NULL) {
parser_warn(param, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"%s\"", name);
} else {
parser_warn(param, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"%s\"; please use \"%s\"",
name, ref_name);
}
}
}
return true;
Expand Down Expand Up @@ -769,15 +771,18 @@ KeySym : IDENT
else {
if ($1 <= XKB_KEYSYM_MAX) {
$$ = (xkb_keysym_t) $1;
const char *ref_name = NULL;
if (xkb_keysym_is_deprecated($$, XKB_KEYSYM_FORMAT_NUMERIC, NULL, &ref_name)) {
if (ref_name == NULL) {
parser_warn(param, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"0x%"PRIx64"\"", $1);
} else {
parser_warn(param, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"0x%"PRIx64"\"; please use \"%s\"",
$1, ref_name);

if (unlikely(param->ctx->log_verbosity >= XKB_MIN_VERBOSITY_DEPRECATED_KEYSYM)) {
const char *ref_name = NULL;
if (xkb_keysym_is_deprecated($$, XKB_KEYSYM_FORMAT_NUMERIC, NULL, &ref_name)) {
if (ref_name == NULL) {
parser_warn(param, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"0x%"PRIx64"\"", $1);
} else {
parser_warn(param, XKB_WARNING_DEPRECATED_KEYSYM,
"deprecated keysym \"0x%"PRIx64"\"; please use \"%s\"",
$1, ref_name);
}
}
}
} else {
Expand Down

0 comments on commit ed99e43

Please sign in to comment.