expr: remove support for evaluating string as integer As the comment nicely puts it, this is a bit weird. When you try to evaluate an expression of type string into an integer, what it does is: "" -> 0 "c" -> (ascii value, i.e. like a char literal) more than one char -> error The first one is obviously not very useful; why not just write 0? The second one might be useful (though I don't see where in a keymap it would be), but I don't think anyone would consider trying "X" for that anyway. A look through xkeyboard-config shows "" only used once as a string, and "X" also only used as strings (and mostly in geometry which we don't evaluate anyway). And I seriously doubt it's used (purposely) anywhere else. So remove it. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 11f803a..d82aad8 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -359,11 +359,7 @@ ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr, xkb_keycode_t *kc)
/**
* This function returns ... something. It's a bit of a guess, really.
*
- * If a string is given in value ctx, its first character will be
- * returned in uval. If an integer is given in value ctx, it will be
- * returned in ival. If a float is given in value ctx, it will be
- * returned as millimetres (rather than points) in ival.
- *
+ * If an integer is given in value ctx, it will be returned in ival.
* If an ident or field reference is given, the lookup function (if given)
* will be called. At the moment, only SimpleLookup use this, and they both
* return the results in uval. And don't support field references.
@@ -381,21 +377,6 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr,
switch (expr->op) {
case EXPR_VALUE:
- if (expr->value_type == EXPR_TYPE_STRING) {
- const char *str;
- str = xkb_atom_text(ctx, expr->value.str);
- if (str != NULL)
- switch (strlen(str)) {
- case 0:
- val_rtrn->uval = 0;
- return true;
- case 1:
- val_rtrn->uval = str[0];
- return true;
- default:
- break;
- }
- }
if (expr->value_type != EXPR_TYPE_INT) {
log_err(ctx,
"Found constant of type %s where an int was expected\n",