projects
/
platform
/
upstream
/
libxkbcommon.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Structured log messages with a message registry
[platform/upstream/libxkbcommon.git]
/
src
/
xkbcomp
/
action.c
diff --git
a/src/xkbcomp/action.c
b/src/xkbcomp/action.c
index
f99a850
..
1410aab
100644
(file)
--- a/
src/xkbcomp/action.c
+++ b/
src/xkbcomp/action.c
@@
-51,6
+51,8
@@
* Ran Benita <ran234@gmail.com>
*/
* Ran Benita <ran234@gmail.com>
*/
+#include "config.h"
+
#include "xkbcomp-priv.h"
#include "text.h"
#include "expr.h"
#include "xkbcomp-priv.h"
#include "text.h"
#include "expr.h"
@@
-188,10
+190,11
@@
fieldText(enum action_field field)
/***====================================================================***/
static inline bool
/***====================================================================***/
static inline bool
-ReportMismatch(struct xkb_context *ctx, enum xkb_action_type action,
- enum action_field field, const char *type)
+ReportMismatch(struct xkb_context *ctx, xkb_message_code_t code,
+ enum xkb_action_type action, enum action_field field,
+ const char *type)
{
{
- log_err
(ctx
,
+ log_err
_with_code(ctx, code
,
"Value of %s field must be of type %s; "
"Action %s definition ignored\n",
fieldText(field), type, ActionTypeText(action));
"Value of %s field must be of type %s; "
"Action %s definition ignored\n",
fieldText(field), type, ActionTypeText(action));
@@
-241,7
+244,8
@@
CheckBooleanFlag(struct xkb_context *ctx, enum xkb_action_type action,
return ReportActionNotArray(ctx, action, field);
if (!ExprResolveBoolean(ctx, value, &set))
return ReportActionNotArray(ctx, action, field);
if (!ExprResolveBoolean(ctx, value, &set))
- return ReportMismatch(ctx, action, field, "boolean");
+ return ReportMismatch(ctx, XKB_ERROR_WRONG_FIELD_TYPE,
+ action, field, "boolean");
if (set)
*flags_inout |= flag;
if (set)
*flags_inout |= flag;
@@
-272,7
+276,7
@@
CheckModifierField(struct xkb_context *ctx, const struct xkb_mod_set *mods,
}
if (!ExprResolveModMask(ctx, value, MOD_BOTH, mods, mods_rtrn))
}
if (!ExprResolveModMask(ctx, value, MOD_BOTH, mods, mods_rtrn))
- return ReportMismatch(ctx, action,
+ return ReportMismatch(ctx,
XKB_ERROR_WRONG_FIELD_TYPE,
action,
ACTION_FIELD_MODIFIERS, "modifier mask");
*flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP;
ACTION_FIELD_MODIFIERS, "modifier mask");
*flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP;
@@
-298,7
+302,8
@@
CheckAffectField(struct xkb_context *ctx, enum xkb_action_type action,
return ReportActionNotArray(ctx, action, ACTION_FIELD_AFFECT);
if (!ExprResolveEnum(ctx, value, &flags, lockWhich))
return ReportActionNotArray(ctx, action, ACTION_FIELD_AFFECT);
if (!ExprResolveEnum(ctx, value, &flags, lockWhich))
- return ReportMismatch(ctx, action, ACTION_FIELD_AFFECT,
+ return ReportMismatch(ctx, XKB_ERROR_WRONG_FIELD_TYPE,
+ action, ACTION_FIELD_AFFECT,
"lock, unlock, both, neither");
*flags_inout &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
"lock, unlock, both, neither");
*flags_inout &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
@@
-357,8
+362,8
@@
CheckGroupField(struct xkb_context *ctx, enum xkb_action_type action,
}
if (!ExprResolveGroup(ctx, spec, &idx))
}
if (!ExprResolveGroup(ctx, spec, &idx))
- return ReportMismatch(ctx,
action, ACTION_FIELD_GROUP
,
- "integer (range 1..8)");
+ return ReportMismatch(ctx,
XKB_ERROR_UNSUPPORTED_GROUP_INDEX, action
,
+
ACTION_FIELD_GROUP,
"integer (range 1..8)");
/* +n, -n are relative, n is absolute. */
if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) {
/* +n, -n are relative, n is absolute. */
if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) {
@@
-414,7
+419,8
@@
HandleMovePtr(struct xkb_context *ctx, const struct xkb_mod_set *mods,
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveInteger(ctx, value, &val))
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveInteger(ctx, value, &val))
- return ReportMismatch(ctx, action->type, field, "integer");
+ return ReportMismatch(ctx, XKB_ERROR_WRONG_FIELD_TYPE, action->type,
+ field, "integer");
if (val < INT16_MIN || val > INT16_MAX) {
log_err(ctx,
if (val < INT16_MIN || val > INT16_MAX) {
log_err(ctx,
@@
-460,8
+466,8
@@
HandlePtrBtn(struct xkb_context *ctx, const struct xkb_mod_set *mods,
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveButton(ctx, value, &btn))
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveButton(ctx, value, &btn))
- return ReportMismatch(ctx,
action->type, field
,
- "integer (range 1..5)");
+ return ReportMismatch(ctx,
XKB_ERROR_WRONG_FIELD_TYPE, action->type
,
+
field,
"integer (range 1..5)");
if (btn < 0 || btn > 5) {
log_err(ctx,
if (btn < 0 || btn > 5) {
log_err(ctx,
@@
-485,7
+491,8
@@
HandlePtrBtn(struct xkb_context *ctx, const struct xkb_mod_set *mods,
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveInteger(ctx, value, &val))
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveInteger(ctx, value, &val))
- return ReportMismatch(ctx, action->type, field, "integer");
+ return ReportMismatch(ctx, XKB_ERROR_WRONG_FIELD_TYPE, action->type,
+ field, "integer");
if (val < 0 || val > 255) {
log_err(ctx,
if (val < 0 || val > 255) {
log_err(ctx,
@@
-522,8
+529,8
@@
HandleSetPtrDflt(struct xkb_context *ctx, const struct xkb_mod_set *mods,
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveEnum(ctx, value, &val, ptrDflts))
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveEnum(ctx, value, &val, ptrDflts))
- return ReportMismatch(ctx,
action->type, field
,
- "pointer component");
+ return ReportMismatch(ctx,
XKB_ERROR_WRONG_FIELD_TYPE, action->type
,
+
field,
"pointer component");
return true;
}
else if (field == ACTION_FIELD_BUTTON || field == ACTION_FIELD_VALUE) {
return true;
}
else if (field == ACTION_FIELD_BUTTON || field == ACTION_FIELD_VALUE) {
@@
-544,8
+551,8
@@
HandleSetPtrDflt(struct xkb_context *ctx, const struct xkb_mod_set *mods,
}
if (!ExprResolveButton(ctx, button, &btn))
}
if (!ExprResolveButton(ctx, button, &btn))
- return ReportMismatch(ctx,
action->type, field
,
- "integer (range 1..5)");
+ return ReportMismatch(ctx,
XKB_ERROR_WRONG_FIELD_TYPE, action->type
,
+
field,
"integer (range 1..5)");
if (btn < 0 || btn > 5) {
log_err(ctx,
if (btn < 0 || btn > 5) {
log_err(ctx,
@@
-592,8
+599,8
@@
HandleSwitchScreen(struct xkb_context *ctx, const struct xkb_mod_set *mods,
}
if (!ExprResolveInteger(ctx, scrn, &val))
}
if (!ExprResolveInteger(ctx, scrn, &val))
- return ReportMismatch(ctx,
action->type, field
,
- "integer (0..255)");
+ return ReportMismatch(ctx,
XKB_ERROR_WRONG_FIELD_TYPE, action->type
,
+
field,
"integer (0..255)");
if (val < 0 || val > 255) {
log_err(ctx,
if (val < 0 || val > 255) {
log_err(ctx,
@@
-628,8
+635,8
@@
HandleSetLockControls(struct xkb_context *ctx, const struct xkb_mod_set *mods,
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveMask(ctx, value, &mask, ctrlMaskNames))
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveMask(ctx, value, &mask, ctrlMaskNames))
- return ReportMismatch(ctx,
action->type, field
,
- "controls mask");
+ return ReportMismatch(ctx,
XKB_ERROR_WRONG_FIELD_TYPE, action->type
,
+
field,
"controls mask");
act->ctrls = mask;
return true;
act->ctrls = mask;
return true;
@@
-656,7
+663,8
@@
HandlePrivate(struct xkb_context *ctx, const struct xkb_mod_set *mods,
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveInteger(ctx, value, &type))
return ReportActionNotArray(ctx, action->type, field);
if (!ExprResolveInteger(ctx, value, &type))
- return ReportMismatch(ctx, ACTION_TYPE_PRIVATE, field, "integer");
+ return ReportMismatch(ctx, XKB_ERROR_WRONG_FIELD_TYPE,
+ ACTION_TYPE_PRIVATE, field, "integer");
if (type < 0 || type > 255) {
log_err(ctx,
if (type < 0 || type > 255) {
log_err(ctx,
@@
-694,19
+702,21
@@
HandlePrivate(struct xkb_context *ctx, const struct xkb_mod_set *mods,
size_t len;
if (!ExprResolveString(ctx, value, &val))
size_t len;
if (!ExprResolveString(ctx, value, &val))
- return ReportMismatch(ctx, action->type, field, "string");
+ return ReportMismatch(ctx, XKB_ERROR_WRONG_FIELD_TYPE,
+ action->type, field, "string");
str = xkb_atom_text(ctx, val);
len = strlen(str);
str = xkb_atom_text(ctx, val);
len = strlen(str);
- if (len < 1 || len >
7
) {
+ if (len < 1 || len >
sizeof(act->data)
) {
log_warn(ctx,
log_warn(ctx,
- "A private action has
7
data bytes; "
- "Illegal data ignored\n");
+ "A private action has
%ld
data bytes; "
+ "Illegal data ignored\n"
, sizeof(act->data)
);
return false;
}
/* act->data may not be null-terminated, this is intentional */
return false;
}
/* act->data may not be null-terminated, this is intentional */
- strncpy((char *) act->data, str, sizeof(act->data));
+ memset(act->data, 0, sizeof(act->data));
+ memcpy(act->data, str, len);
return true;
}
else {
return true;
}
else {
@@
-728,7
+738,8
@@
HandlePrivate(struct xkb_context *ctx, const struct xkb_mod_set *mods,
}
if (!ExprResolveInteger(ctx, value, &datum))
}
if (!ExprResolveInteger(ctx, value, &datum))
- return ReportMismatch(ctx, act->type, field, "integer");
+ return ReportMismatch(ctx, XKB_ERROR_WRONG_FIELD_TYPE, act->type,
+ field, "integer");
if (datum < 0 || datum > 255) {
log_err(ctx,
if (datum < 0 || datum > 255) {
log_err(ctx,