From 7dcd3d4d3a881d5a82a38cec449abd71da29405b Mon Sep 17 00:00:00 2001 From: Pierre Le Marre Date: Thu, 21 Sep 2023 20:06:27 +0200 Subject: [PATCH 1/2] Messages: add new messages to registry This commit is another step to identify and document the maximum number of logging messages. Bulk changes: - Rename `conflicting-key-type` to `conflicting-key-type-merging-groups`. Giving more context in the name allow us to introduce `conflicting-key-type-definitions` later. - Add conflicting-key-type-definitions - Add conflicting-key-type-map-entry - Add undeclared-modifiers-in-key-type Also improve the log messages. - Add conflicting-key-type-preserve-entries - Use XKB_ERROR_UNSUPPORTED_MODIFIER_MASK - Add illegal-key-type-preserve-result - Add conflicting-key-type-level-names - Add duplicate-entry - Add unsupported-symbols-field - Add missing-symbols-group-name-index - Use XKB_ERROR_WRONG_FIELD_TYPE - Add conflicting-key-name - Use XKB_WARNING_UNDEFINED_KEYCODE - Add illegal-keycode-alias - Add unsupported-geometry-section - Add missing-default-section - Add XKB_LOG_MESSAGE_NO_ID - Rename log_vrb_with_code to log_vrb - Use ERROR_WRONG_FIELD_TYPE & ERROR_INVALID_SYNTAX - Add unknown-identifier - Add invalid-expression-type - Add invalid-operation + fixes - Add unknown-operator - Rename ERROR_UNKNOWN_IDENTIFIER to ERROR_INVALID_IDENTIFIER - Add undeclared-virtual-modifier - Add expected-array-entry - Add invalid-include-statement - Add included-file-not-found - Add allocation-error - Add invalid-included-file - Process symbols.c - Add invalid-value - Add invalid-real-modifier - Add unknown-field - Add wrong-scope - Add invalid-modmap-entry - Add wrong-statement-type - Add conflicting-key-symbols-entry - Add invalid-set-default-statement --- doc/message-registry.md | 336 ++++++++++++++++++++++++++++++++++++- doc/message-registry.yaml | 172 ++++++++++++++++++- src/context.h | 4 +- src/messages-codes.h | 76 ++++++++- src/messages-codes.h.jinja | 8 + src/xkbcomp/ast-build.c | 4 +- src/xkbcomp/expr.c | 132 +++++++++++---- src/xkbcomp/include.c | 39 +++-- src/xkbcomp/keycodes.c | 10 +- src/xkbcomp/keymap.c | 1 + src/xkbcomp/parser.y | 1 + src/xkbcomp/symbols.c | 81 +++++---- src/xkbcomp/types.c | 43 +++-- src/xkbcomp/xkbcomp-priv.h | 6 +- test/log.c | 9 +- tools/messages.c | 35 +++- 16 files changed, 846 insertions(+), 111 deletions(-) diff --git a/doc/message-registry.md b/doc/message-registry.md index dac417599..a3be5c185 100644 --- a/doc/message-registry.md +++ b/doc/message-registry.md @@ -6,7 +6,7 @@ NOTE: This file has been generated automatically by “update-message-registry.p --> This page lists the warnings and errors generated by xkbcommon. -There are currently 21 entries. +There are currently 52 entries. @todo The documentation of the log messages is a work in progress. @@ -15,26 +15,57 @@ There are currently 21 entries. | Code | Identifier | Description | Type | | --------- | ---------------------------- | ----------- | ---- | | [XKB-034] | `malformed-number-literal` | Warn on malformed number literals | Error | +| [XKB-043] | `conflicting-key-type-preserve-entries` | Conflicting “preserve” entries in a key type | Warning | | [XKB-060] | `unsupported-modifier-mask` | Warn on unsupported modifier mask | Error | +| [XKB-077] | `expected-array-entry` | Expected an array entry, but the index is missing | Error | +| [XKB-101] | `illegal-keycode-alias` | Illegal keycode alias with the name of a real key | Warning | | [XKB-107] | `unrecognized-keysym` | Warn on unrecognized keysyms | Warning | +| [XKB-123] | `undeclared-virtual-modifier` | A virtual modifier is used before being declared | Error | +| [XKB-150] | `wrong-statement-type` | The type of the statement is not allowed in the context | Error | +| [XKB-172] | `unsupported-geometry-section` | Geometry sections are not supported | Warning | | [XKB-183] | `cannot-infer-key-type` | Warn if no key type can be inferred | Warning | +| [XKB-195] | `illegal-key-type-preserve-result` | The result of a key type “preserve” entry must be a subset of its input modifiers. | Warning | +| [XKB-203] | `invalid-include-statement` | Syntax error in the include statement | Error | +| [XKB-206] | `invalid-modmap-entry` | A modmap entry is invalid | Error | | [XKB-237] | `unsupported-group-index` | Warn when a group index is not supported | Error | +| [XKB-239] | `conflicting-key-type-level-names` | The name of a key type level is defined multiple times. | Warning | +| [XKB-254] | `invalid-set-default-statement` | Invalid statement setting default values | Error | +| [XKB-266] | `conflicting-key-type-map-entry` | Conflicting “map” entries in type definition | Warning | | [XKB-286] | `undefined-key-type` | Warn if using an undefined key type | Warning | | [XKB-305] | `non-base-group-name` | Warn if a group name was defined for group other than the first one | Warning | | [XKB-312] | `unsupported-shift-level` | Warn when a shift level is not supported | Error | +| [XKB-338] | `included-file-not-found` | Could not find a file used in an include statement | Error | +| [XKB-345] | `unknown-operator` | Use of an operator that is unknown and thus unsupported | Error | +| [XKB-378] | `duplicate-entry` | An entry is duplicated and will be ignored | Warning | +| [XKB-407] | `conflicting-key-type-definitions` | Conflicting definitions of a key type | Warning | +| [XKB-428] | `wrong-scope` | A statement is in a wrong scope and should be moved | Error | +| [XKB-433] | `missing-default-section` | Missing default section in included file | Warning | | [XKB-461] | `conflicting-key-symbol` | Warn if there are conflicting keysyms while merging keys | Warning | +| [XKB-478] | `invalid-operation` | The operation is invalid in the context | Error | | [XKB-489] | `numeric-keysym` | Warn on numeric keysym (other than 0-9) | Warning | | [XKB-516] | `extra-symbols-ignored` | TODO: add description | Warning | +| [XKB-523] | `conflicting-key-name` | Conflicting definitions of a key name or alias | Warning | +| [XKB-550] | `allocation-error` | Cannot allocate memory | Error | | [XKB-578] | `wrong-field-type` | Warn when a field has not the expected type | Error | +| [XKB-623] | `invalid-real-modifier` | Invalid _real_ modifier | Error | | [XKB-645] | `unknown-char-escape-sequence` | Warn on unknown escape sequence in string literal | Warning | +| [XKB-661] | `invalid-included-file` | The target file of an include statement could not be processed | Error | | [XKB-700] | `multiple-groups-at-once` | Warn if a key defines multiple groups at once | Warning | +| [XKB-711] | `unsupported-symbols-field` | A legacy X11 symbol field is not supported | Warning | | [XKB-769] | `invalid-syntax` | The syntax is invalid and the file cannot be parsed | Error | -| [XKB-770] | `undefined-keycode` | TODO: add description | Warning | +| [XKB-770] | `undefined-keycode` | Reference to an undefined keycode | Warning | +| [XKB-784] | `invalid-expression-type` | An expression has not the expected type | Error | +| [XKB-796] | `invalid-value` | A value is invalid and will be ignored | Error | | [XKB-800] | `conflicting-modmap` | Warn if there are conflicting modmap definitions | Warning | +| [XKB-812] | `unknown-field` | A field is unknown and will be ignored | Error | | [XKB-883] | `conflicting-key-action` | Warn if there are conflicting actions while merging keys | Warning | -| [XKB-893] | `conflicting-key-type` | Warn if there are conflicting key types while merging groups | Warning | +| [XKB-893] | `conflicting-key-type-merging-groups` | Warn if there are conflicting key types while merging groups | Warning | +| [XKB-901] | `conflicting-key-symbols-entry` | Conflicting symbols entry for a key | Error | +| [XKB-903] | `missing-symbols-group-name-index` | Missing group index in a group name entry | Warning | | [XKB-935] | `conflicting-key-fields` | Warn if there are conflicting fields while merging keys | Warning | +| [XKB-949] | `invalid-identifier` | An identifier is used but is not built-in | Error | | [XKB-965] | `unresolved-keymap-symbol` | Warn if using a symbol not defined in the keymap | Warning | +| [XKB-971] | `undeclared-modifiers-in-key-type` | Some modifiers used in a key type “map” or “preserve” entry are not declared | Warning | ## Details @@ -53,6 +84,14 @@ xkbcommon can parse the following number literal formats: - *hexadecimal integer:* prefixed with “0x”: 0x123, 0xff, 0xAB, etc. +### XKB-043 – Conflicting key type preserve entries {#XKB-043} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
Conflicting “preserve” entries in a key type
+
+ ### XKB-060 – Unsupported modifier mask {#XKB-060}
@@ -61,6 +100,22 @@ xkbcommon can parse the following number literal formats:
Summary
Warn on unsupported modifier mask
+### XKB-077 – Expected array entry {#XKB-077} + +
+
Since
1.0.0
+
Type
Error
+
Summary
Expected an array entry, but the index is missing
+
+ +### XKB-101 – Illegal keycode alias {#XKB-101} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
Illegal keycode alias with the name of a real key
+
+ ### XKB-107 – Unrecognized keysym {#XKB-107}
@@ -111,6 +166,30 @@ key {[ comma, semicolon, periodcentered, multiply ]}; +### XKB-123 – Undeclared virtual modifier {#XKB-123} + +
+
Since
1.0.0
+
Type
Error
+
Summary
A virtual modifier is used before being declared
+
+ +### XKB-150 – Wrong statement type {#XKB-150} + +
+
Since
1.0.0
+
Type
Error
+
Summary
The type of the statement is not allowed in the context
+
+ +### XKB-172 – Unsupported geometry section {#XKB-172} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
Geometry sections are not supported
+
+ ### XKB-183 – Cannot infer key type {#XKB-183}
@@ -119,6 +198,30 @@ key {[ comma, semicolon, periodcentered, multiply ]};
Summary
Warn if no key type can be inferred
+### XKB-195 – Illegal key type preserve result {#XKB-195} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
The result of a key type “preserve” entry must be a subset of its input modifiers.
+
+ +### XKB-203 – Invalid include statement {#XKB-203} + +
+
Since
1.0.0
+
Type
Error
+
Summary
Syntax error in the include statement
+
+ +### XKB-206 – Invalid modmap entry {#XKB-206} + +
+
Since
1.0.0
+
Type
Error
+
Summary
A modmap entry is invalid
+
+ ### XKB-237 – Unsupported group index {#XKB-237}
@@ -130,6 +233,30 @@ key {[ comma, semicolon, periodcentered, multiply ]}; xkbcommon supports group index in the range (1..4). +### XKB-239 – Conflicting key type level names {#XKB-239} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
The name of a key type level is defined multiple times.
+
+ +### XKB-254 – Invalid set default statement {#XKB-254} + +
+
Since
1.0.0
+
Type
Error
+
Summary
Invalid statement setting default values
+
+ +### XKB-266 – Conflicting key type map entry {#XKB-266} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
Conflicting “map” entries in type definition
+
+ ### XKB-286 – Undefined key type {#XKB-286}
@@ -158,6 +285,66 @@ Shift levels are _one_-indexed. xkbcommon supports two formats of shift levels: as numbers and as identifiers `LevelN`, where `N` is in the range (1..8). +### XKB-338 – Included file not found {#XKB-338} + +
+
Since
1.0.0
+
Type
Error
+
Summary
Could not find a file used in an include statement
+
+ +### XKB-345 – Unknown operator {#XKB-345} + +
+
Since
1.0.0
+
Type
Error
+
Summary
Use of an operator that is unknown and thus unsupported
+
+ +### XKB-378 – Duplicate entry {#XKB-378} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
An entry is duplicated and will be ignored
+
+ +### XKB-407 – Conflicting key type definitions {#XKB-407} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
Conflicting definitions of a key type
+
+ +The given key type is defined multiple times, but only one definition is kept. + + +### XKB-428 – Wrong scope {#XKB-428} + +
+
Since
1.0.0
+
Type
Error
+
Summary
A statement is in a wrong scope and should be moved
+
+ +### XKB-433 – Missing default section {#XKB-433} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
Missing default section in included file
+
+ +When using an include statement, the included file may contains multiple sections. +The include statement may specify the name of the section to include, or leave it +unspecified. In the latter case, the included file must then define a *default* section. +The present warning is shown when no default section is defined. + +To solve this, either fix the include statement by specifying the exact section to +include, or declare a default section in the included file. + + ### XKB-461 – Conflicting key symbol {#XKB-461}
@@ -166,6 +353,14 @@ as numbers and as identifiers `LevelN`, where `N` is in the range (1..8).
Summary
Warn if there are conflicting keysyms while merging keys
+### XKB-478 – Invalid operation {#XKB-478} + +
+
Since
1.0.0
+
Type
Error
+
Summary
The operation is invalid in the context
+
+ ### XKB-489 – Numeric keysym {#XKB-489}
@@ -221,6 +416,22 @@ key { [ U1ED0 ] };
Summary
TODO: add description
+### XKB-523 – Conflicting key name {#XKB-523} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
Conflicting definitions of a key name or alias
+
+ +### XKB-550 – Allocation error {#XKB-550} + +
+
Since
1.0.0
+
Type
Error
+
Summary
Cannot allocate memory
+
+ ### XKB-578 – Wrong field type {#XKB-578}
@@ -229,6 +440,14 @@ key { [ U1ED0 ] };
Summary
Warn when a field has not the expected type
+### XKB-623 – Invalid real modifier {#XKB-623} + +
+
Since
1.0.0
+
Type
Error
+
Summary
Invalid _real_ modifier
+
+ ### XKB-645 – Unknown char escape sequence {#XKB-645}
@@ -252,6 +471,14 @@ xkbcommon support the following escape sequences in string literals: | `\NNN` | _Octal_ escape, from `\0` to `\777` | +### XKB-661 – Invalid included file {#XKB-661} + +
+
Since
1.0.0
+
Type
Error
+
Summary
The target file of an include statement could not be processed
+
+ ### XKB-700 – Multiple groups at once {#XKB-700}
@@ -260,6 +487,14 @@ xkbcommon support the following escape sequences in string literals:
Summary
Warn if a key defines multiple groups at once
+### XKB-711 – Unsupported symbols field {#XKB-711} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
A legacy X11 symbol field is not supported
+
+ ### XKB-769 – Invalid syntax {#XKB-769}
@@ -273,7 +508,23 @@ xkbcommon support the following escape sequences in string literals:
Since
1.0.0
Type
Warning
-
Summary
TODO: add description
+
Summary
Reference to an undefined keycode
+
+ +### XKB-784 – Invalid expression type {#XKB-784} + +
+
Since
1.0.0
+
Type
Error
+
Summary
An expression has not the expected type
+
+ +### XKB-796 – Invalid value {#XKB-796} + +
+
Since
1.0.0
+
Type
Error
+
Summary
A value is invalid and will be ignored
### XKB-800 – Conflicting modmap {#XKB-800} @@ -287,6 +538,14 @@ xkbcommon support the following escape sequences in string literals: @todo detailed explanation and examples +### XKB-812 – Unknown field {#XKB-812} + +
+
Since
1.0.0
+
Type
Error
+
Summary
A field is unknown and will be ignored
+
+ ### XKB-883 – Conflicting key action {#XKB-883}
@@ -295,7 +554,7 @@ xkbcommon support the following escape sequences in string literals:
Summary
Warn if there are conflicting actions while merging keys
-### XKB-893 – Conflicting key type {#XKB-893} +### XKB-893 – Conflicting key type merging groups {#XKB-893}
Since
1.0.0
@@ -303,6 +562,22 @@ xkbcommon support the following escape sequences in string literals:
Summary
Warn if there are conflicting key types while merging groups
+### XKB-901 – Conflicting key symbols entry {#XKB-901} + +
+
Since
1.0.0
+
Type
Error
+
Summary
Conflicting symbols entry for a key
+
+ +### XKB-903 – Missing symbols group name index {#XKB-903} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
Missing group index in a group name entry
+
+ ### XKB-935 – Conflicting key fields {#XKB-935}
@@ -311,6 +586,14 @@ xkbcommon support the following escape sequences in string literals:
Summary
Warn if there are conflicting fields while merging keys
+### XKB-949 – Invalid identifier {#XKB-949} + +
+
Since
1.0.0
+
Type
Error
+
Summary
An identifier is used but is not built-in
+
+ ### XKB-965 – Unresolved keymap symbol {#XKB-965}
@@ -319,24 +602,67 @@ xkbcommon support the following escape sequences in string literals:
Summary
Warn if using a symbol not defined in the keymap
+### XKB-971 – Undeclared modifiers in key type {#XKB-971} + +
+
Since
1.0.0
+
Type
Warning
+
Summary
Some modifiers used in a key type “map” or “preserve” entry are not declared
+
+ +The modifiers used in `map` or `preserve` entries should be declared using the entry +`modifiers` in the key type. + + [XKB-034]: @ref XKB-034 +[XKB-043]: @ref XKB-043 [XKB-060]: @ref XKB-060 +[XKB-077]: @ref XKB-077 +[XKB-101]: @ref XKB-101 [XKB-107]: @ref XKB-107 +[XKB-123]: @ref XKB-123 +[XKB-150]: @ref XKB-150 +[XKB-172]: @ref XKB-172 [XKB-183]: @ref XKB-183 +[XKB-195]: @ref XKB-195 +[XKB-203]: @ref XKB-203 +[XKB-206]: @ref XKB-206 [XKB-237]: @ref XKB-237 +[XKB-239]: @ref XKB-239 +[XKB-254]: @ref XKB-254 +[XKB-266]: @ref XKB-266 [XKB-286]: @ref XKB-286 [XKB-305]: @ref XKB-305 [XKB-312]: @ref XKB-312 +[XKB-338]: @ref XKB-338 +[XKB-345]: @ref XKB-345 +[XKB-378]: @ref XKB-378 +[XKB-407]: @ref XKB-407 +[XKB-428]: @ref XKB-428 +[XKB-433]: @ref XKB-433 [XKB-461]: @ref XKB-461 +[XKB-478]: @ref XKB-478 [XKB-489]: @ref XKB-489 [XKB-516]: @ref XKB-516 +[XKB-523]: @ref XKB-523 +[XKB-550]: @ref XKB-550 [XKB-578]: @ref XKB-578 +[XKB-623]: @ref XKB-623 [XKB-645]: @ref XKB-645 +[XKB-661]: @ref XKB-661 [XKB-700]: @ref XKB-700 +[XKB-711]: @ref XKB-711 [XKB-769]: @ref XKB-769 [XKB-770]: @ref XKB-770 +[XKB-784]: @ref XKB-784 +[XKB-796]: @ref XKB-796 [XKB-800]: @ref XKB-800 +[XKB-812]: @ref XKB-812 [XKB-883]: @ref XKB-883 [XKB-893]: @ref XKB-893 +[XKB-901]: @ref XKB-901 +[XKB-903]: @ref XKB-903 [XKB-935]: @ref XKB-935 +[XKB-949]: @ref XKB-949 [XKB-965]: @ref XKB-965 +[XKB-971]: @ref XKB-971 diff --git a/doc/message-registry.yaml b/doc/message-registry.yaml index f7e0c2e17..880c2f6a4 100644 --- a/doc/message-registry.yaml +++ b/doc/message-registry.yaml @@ -30,11 +30,26 @@ - *decimal integer:* 1, 123, etc. - *decimal floating-point number:* 1.23, etc. - *hexadecimal integer:* prefixed with “0x”: 0x123, 0xff, 0xAB, etc. +- id: "conflicting-key-type-preserve-entries" + code: 43 + added: ALWAYS + type: warning + description: "Conflicting “preserve” entries in a key type" - id: "unsupported-modifier-mask" code: 60 added: ALWAYS type: error description: "Warn on unsupported modifier mask" +- id: "expected-array-entry" + code: 77 + added: ALWAYS + type: error + description: "Expected an array entry, but the index is missing" +- id: "illegal-keycode-alias" + code: 101 + added: ALWAYS + type: warning + description: "Illegal keycode alias with the name of a real key" - id: "unrecognized-keysym" code: 107 added: ALWAYS @@ -65,11 +80,41 @@ ```c key {[ comma, semicolon, periodcentered, multiply ]}; ``` +- id: "undeclared-virtual-modifier" + code: 123 + added: ALWAYS + type: error + description: "A virtual modifier is used before being declared" +- id: "wrong-statement-type" + code: 150 + added: ALWAYS + type: error + description: "The type of the statement is not allowed in the context" +- id: "unsupported-geometry-section" + code: 172 + added: ALWAYS + type: warning + description: "Geometry sections are not supported" - id: "cannot-infer-key-type" code: 183 added: ALWAYS type: warning description: "Warn if no key type can be inferred" +- id: "illegal-key-type-preserve-result" + code: 195 + added: ALWAYS + type: warning + description: "The result of a key type “preserve” entry must be a subset of its input modifiers." +- id: "invalid-include-statement" + code: 203 + added: ALWAYS + type: error + description: "Syntax error in the include statement" +- id: "invalid-modmap-entry" + code: 206 + added: ALWAYS + type: error + description: "A modmap entry is invalid" - id: "unsupported-group-index" code: 237 added: ALWAYS @@ -77,6 +122,21 @@ description: "Warn when a group index is not supported" details: | xkbcommon supports group index in the range (1..{{XKB_MAX_GROUPS}}). +- id: "conflicting-key-type-level-names" + code: 239 + added: ALWAYS + type: warning + description: "The name of a key type level is defined multiple times." +- id: "invalid-set-default-statement" + code: 254 + added: ALWAYS + type: error + description: "Invalid statement setting default values" +- id: "conflicting-key-type-map-entry" + code: 266 + added: ALWAYS + type: warning + description: "Conflicting “map” entries in type definition" - id: "undefined-key-type" code: 286 added: ALWAYS @@ -95,11 +155,56 @@ details: | Shift levels are _one_-indexed. xkbcommon supports two formats of shift levels: as numbers and as identifiers `LevelN`, where `N` is in the range (1..8). +- id: "included-file-not-found" + code: 338 + added: ALWAYS + type: error + description: "Could not find a file used in an include statement" +- id: "unknown-operator" + code: 345 + added: ALWAYS + type: error + description: "Use of an operator that is unknown and thus unsupported" +- id: "duplicate-entry" + code: 378 + added: ALWAYS + type: warning + description: "An entry is duplicated and will be ignored" +- id: "conflicting-key-type-definitions" + code: 407 + added: ALWAYS + type: warning + description: "Conflicting definitions of a key type" + details: | + The given key type is defined multiple times, but only one definition is kept. +- id: "wrong-scope" + code: 428 + added: ALWAYS + type: error + description: "A statement is in a wrong scope and should be moved" +- id: "missing-default-section" + code: 433 + added: ALWAYS + type: warning + description: "Missing default section in included file" + details: | + When using an include statement, the included file may contains multiple sections. + The include statement may specify the name of the section to include, or leave it + unspecified. In the latter case, the included file must then define a *default* section. + The present warning is shown when no default section is defined. + + To solve this, either fix the include statement by specifying the exact section to + include, or declare a default section in the included file. - id: "conflicting-key-symbol" code: 461 added: ALWAYS type: warning description: "Warn if there are conflicting keysyms while merging keys" +- id: "invalid-operation" + code: 478 + added: ALWAYS + type: error + description: "The operation is invalid in the context" - id: "numeric-keysym" code: 489 added: 1.6.0 @@ -132,11 +237,26 @@ added: ALWAYS type: warning description: "TODO: add description" +- id: "conflicting-key-name" + code: 523 + added: ALWAYS + type: warning + description: "Conflicting definitions of a key name or alias" +- id: "allocation-error" + code: 550 + added: ALWAYS + type: error + description: "Cannot allocate memory" - id: "wrong-field-type" code: 578 added: ALWAYS type: error description: "Warn when a field has not the expected type" +- id: "invalid-real-modifier" + code: 623 + added: ALWAYS + type: error + description: "Invalid _real_ modifier" - id: "unknown-char-escape-sequence" code: 645 added: ALWAYS @@ -156,11 +276,21 @@ | `\e` | `U+001B` Escape | | `\\` | `U+005C` Backslash | | `\NNN` | _Octal_ escape, from `\0` to `\777` | +- id: "invalid-included-file" + code: 661 + added: ALWAYS + type: error + description: "The target file of an include statement could not be processed" - id: "multiple-groups-at-once" code: 700 added: ALWAYS type: warning description: "Warn if a key defines multiple groups at once" +- id: "unsupported-symbols-field" + code: 711 + added: ALWAYS + type: warning + description: "A legacy X11 symbol field is not supported" - id: "invalid-syntax" code: 769 added: ALWAYS @@ -170,7 +300,17 @@ code: 770 added: ALWAYS type: warning - description: "TODO: add description" + description: "Reference to an undefined keycode" +- id: "invalid-expression-type" + code: 784 + added: ALWAYS + type: error + description: "An expression has not the expected type" +- id: "invalid-value" + code: 796 + added: ALWAYS + type: error + description: "A value is invalid and will be ignored" - id: "conflicting-modmap" code: 800 added: ALWAYS @@ -178,26 +318,54 @@ description: "Warn if there are conflicting modmap definitions" details: | @todo detailed explanation and examples +- id: "unknown-field" + code: 812 + added: ALWAYS + type: error + description: "A field is unknown and will be ignored" - id: "conflicting-key-action" code: 883 added: ALWAYS type: warning description: "Warn if there are conflicting actions while merging keys" -- id: "conflicting-key-type" +- id: "conflicting-key-type-merging-groups" code: 893 added: ALWAYS type: warning description: "Warn if there are conflicting key types while merging groups" +- id: "conflicting-key-symbols-entry" + code: 901 + added: ALWAYS + type: error + description: "Conflicting symbols entry for a key" +- id: "missing-symbols-group-name-index" + code: 903 + added: ALWAYS + type: warning + description: "Missing group index in a group name entry" - id: "conflicting-key-fields" code: 935 added: ALWAYS type: warning description: "Warn if there are conflicting fields while merging keys" +- id: "invalid-identifier" + code: 949 + added: ALWAYS + type: error + description: "An identifier is used but is not built-in" - id: "unresolved-keymap-symbol" code: 965 added: ALWAYS type: warning description: "Warn if using a symbol not defined in the keymap" +- id: "undeclared-modifiers-in-key-type" + code: 971 + added: ALWAYS + type: warning + description: "Some modifiers used in a key type “map” or “preserve” entry are not declared" + details: | + The modifiers used in `map` or `preserve` entries should be declared using the entry + `modifiers` in the key type. # TODO: deprecated keysym # TODO: unicode keysym when named and recommended keysym exists diff --git a/src/context.h b/src/context.h index d5fa117b2..53d6e2f31 100644 --- a/src/context.h +++ b/src/context.h @@ -138,10 +138,8 @@ xkb_context_sanitize_rule_names(struct xkb_context *ctx, xkb_log_with_code((ctx), XKB_LOG_LEVEL_CRITICAL, 0, (id), __VA_ARGS__) #define log_wsgo(ctx, ...) \ xkb_log((ctx), XKB_LOG_LEVEL_CRITICAL, 0, __VA_ARGS__) -#define log_vrb_with_code(ctx, vrb, id, ...) \ +#define log_vrb(ctx, vrb, id, ...) \ xkb_log_with_code((ctx), XKB_LOG_LEVEL_WARNING, (vrb), (id), __VA_ARGS__) -#define log_vrb(ctx, vrb, ...) \ - xkb_log((ctx), XKB_LOG_LEVEL_WARNING, (vrb), __VA_ARGS__) /* * Variants which are prefixed by the name of the function they're diff --git a/src/messages-codes.h b/src/messages-codes.h index 1ba568c63..3f117e1a1 100644 --- a/src/messages-codes.h +++ b/src/messages-codes.h @@ -6,6 +6,14 @@ #include +/** + * Special case when no message identifier is defined. + * + * @added 1.6.0 + * + */ +#define XKB_LOG_MESSAGE_NO_ID 0 + /** * @name Codes of the log messages * @@ -16,47 +24,109 @@ enum xkb_message_code { _XKB_LOG_MESSAGE_MIN_CODE = 34, /** Warn on malformed number literals */ XKB_ERROR_MALFORMED_NUMBER_LITERAL = 34, + /** Conflicting “preserve” entries in a key type */ + XKB_WARNING_CONFLICTING_KEY_TYPE_PRESERVE_ENTRIES = 43, /** Warn on unsupported modifier mask */ XKB_ERROR_UNSUPPORTED_MODIFIER_MASK = 60, + /** Expected an array entry, but the index is missing */ + XKB_ERROR_EXPECTED_ARRAY_ENTRY = 77, + /** Illegal keycode alias with the name of a real key */ + XKB_WARNING_ILLEGAL_KEYCODE_ALIAS = 101, /** Warn on unrecognized keysyms */ XKB_WARNING_UNRECOGNIZED_KEYSYM = 107, + /** A virtual modifier is used before being declared */ + XKB_ERROR_UNDECLARED_VIRTUAL_MODIFIER = 123, + /** The type of the statement is not allowed in the context */ + XKB_ERROR_WRONG_STATEMENT_TYPE = 150, + /** Geometry sections are not supported */ + XKB_WARNING_UNSUPPORTED_GEOMETRY_SECTION = 172, /** Warn if no key type can be inferred */ XKB_WARNING_CANNOT_INFER_KEY_TYPE = 183, + /** The result of a key type “preserve” entry must be a subset of its input modifiers. */ + XKB_WARNING_ILLEGAL_KEY_TYPE_PRESERVE_RESULT = 195, + /** Syntax error in the include statement */ + XKB_ERROR_INVALID_INCLUDE_STATEMENT = 203, + /** A modmap entry is invalid */ + XKB_ERROR_INVALID_MODMAP_ENTRY = 206, /** Warn when a group index is not supported */ XKB_ERROR_UNSUPPORTED_GROUP_INDEX = 237, + /** The name of a key type level is defined multiple times. */ + XKB_WARNING_CONFLICTING_KEY_TYPE_LEVEL_NAMES = 239, + /** Invalid statement setting default values */ + XKB_ERROR_INVALID_SET_DEFAULT_STATEMENT = 254, + /** Conflicting “map” entries in type definition */ + XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY = 266, /** Warn if using an undefined key type */ XKB_WARNING_UNDEFINED_KEY_TYPE = 286, /** Warn if a group name was defined for group other than the first one */ XKB_WARNING_NON_BASE_GROUP_NAME = 305, /** Warn when a shift level is not supported */ XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL = 312, + /** Could not find a file used in an include statement */ + XKB_ERROR_INCLUDED_FILE_NOT_FOUND = 338, + /** Use of an operator that is unknown and thus unsupported */ + XKB_ERROR_UNKNOWN_OPERATOR = 345, + /** An entry is duplicated and will be ignored */ + XKB_WARNING_DUPLICATE_ENTRY = 378, + /** Conflicting definitions of a key type */ + XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS = 407, + /** A statement is in a wrong scope and should be moved */ + XKB_ERROR_WRONG_SCOPE = 428, + /** Missing default section in included file */ + XKB_WARNING_MISSING_DEFAULT_SECTION = 433, /** Warn if there are conflicting keysyms while merging keys */ XKB_WARNING_CONFLICTING_KEY_SYMBOL = 461, + /** The operation is invalid in the context */ + XKB_ERROR_INVALID_OPERATION = 478, /** Warn on numeric keysym (other than 0-9) */ XKB_WARNING_NUMERIC_KEYSYM = 489, /** TODO: add description */ XKB_WARNING_EXTRA_SYMBOLS_IGNORED = 516, + /** Conflicting definitions of a key name or alias */ + XKB_WARNING_CONFLICTING_KEY_NAME = 523, + /** Cannot allocate memory */ + XKB_ERROR_ALLOCATION_ERROR = 550, /** Warn when a field has not the expected type */ XKB_ERROR_WRONG_FIELD_TYPE = 578, + /** Invalid _real_ modifier */ + XKB_ERROR_INVALID_REAL_MODIFIER = 623, /** Warn on unknown escape sequence in string literal */ XKB_WARNING_UNKNOWN_CHAR_ESCAPE_SEQUENCE = 645, + /** The target file of an include statement could not be processed */ + XKB_ERROR_INVALID_INCLUDED_FILE = 661, /** Warn if a key defines multiple groups at once */ XKB_WARNING_MULTIPLE_GROUPS_AT_ONCE = 700, + /** A legacy X11 symbol field is not supported */ + XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD = 711, /** The syntax is invalid and the file cannot be parsed */ XKB_ERROR_INVALID_SYNTAX = 769, - /** TODO: add description */ + /** Reference to an undefined keycode */ XKB_WARNING_UNDEFINED_KEYCODE = 770, + /** An expression has not the expected type */ + XKB_ERROR_INVALID_EXPRESSION_TYPE = 784, + /** A value is invalid and will be ignored */ + XKB_ERROR_INVALID_VALUE = 796, /** Warn if there are conflicting modmap definitions */ XKB_WARNING_CONFLICTING_MODMAP = 800, + /** A field is unknown and will be ignored */ + XKB_ERROR_UNKNOWN_FIELD = 812, /** Warn if there are conflicting actions while merging keys */ XKB_WARNING_CONFLICTING_KEY_ACTION = 883, /** Warn if there are conflicting key types while merging groups */ - XKB_WARNING_CONFLICTING_KEY_TYPE = 893, + XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS = 893, + /** Conflicting symbols entry for a key */ + XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY = 901, + /** Missing group index in a group name entry */ + XKB_WARNING_MISSING_SYMBOLS_GROUP_NAME_INDEX = 903, /** Warn if there are conflicting fields while merging keys */ XKB_WARNING_CONFLICTING_KEY_FIELDS = 935, + /** An identifier is used but is not built-in */ + XKB_ERROR_INVALID_IDENTIFIER = 949, /** Warn if using a symbol not defined in the keymap */ XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL = 965, - _XKB_LOG_MESSAGE_MAX_CODE = 965 + /** Some modifiers used in a key type “map” or “preserve” entry are not declared */ + XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE = 971, + _XKB_LOG_MESSAGE_MAX_CODE = 971 }; typedef uint32_t xkb_message_code_t; diff --git a/src/messages-codes.h.jinja b/src/messages-codes.h.jinja index 2195af46e..49a876cd5 100644 --- a/src/messages-codes.h.jinja +++ b/src/messages-codes.h.jinja @@ -6,6 +6,14 @@ #include +/** + * Special case when no message identifier is defined. + * + * @added 1.6.0 + * + */ +#define XKB_LOG_MESSAGE_NO_ID 0 + /** * @name Codes of the log messages * diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c index 347eed868..4654ae4c6 100644 --- a/src/xkbcomp/ast-build.c +++ b/src/xkbcomp/ast-build.c @@ -525,7 +525,9 @@ IncludeCreate(struct xkb_context *ctx, char *str, enum merge_mode merge) return first; err: - log_err(ctx, "Illegal include statement \"%s\"; Ignored\n", stmt); + log_err_with_code(ctx, + XKB_ERROR_INVALID_INCLUDE_STATEMENT, + "Illegal include statement \"%s\"; Ignored\n", stmt); FreeInclude(first); free(stmt); return NULL; diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index 558fef3ef..6e3e4515b 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -63,7 +63,9 @@ ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr, default: break; } - log_wsgo(ctx, "Unexpected operator %d in ResolveLhs\n", expr->expr.op); + log_wsgo_with_code(ctx, + XKB_ERROR_INVALID_SYNTAX, + "Unexpected operator %d in ResolveLhs\n", expr->expr.op); return false; } @@ -139,7 +141,8 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr, switch (expr->expr.op) { case EXPR_VALUE: if (expr->expr.value_type != EXPR_TYPE_BOOLEAN) { - log_err(ctx, + log_err_with_code(ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "Found constant of type %s where boolean was expected\n", expr_value_type_to_string(expr->expr.value_type)); return false; @@ -163,11 +166,15 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr, return true; } } - log_err(ctx, "Identifier \"%s\" of type boolean is unknown\n", ident); + log_err_with_code(ctx, + XKB_ERROR_INVALID_IDENTIFIER, + "Identifier \"%s\" of type boolean is unknown\n", ident); return false; case EXPR_FIELD_REF: - log_err(ctx, "Default \"%s.%s\" of type boolean is unknown\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_EXPRESSION_TYPE, + "Default \"%s.%s\" of type boolean is unknown\n", xkb_atom_text(ctx, expr->field_ref.element), xkb_atom_text(ctx, expr->field_ref.field)); return false; @@ -188,12 +195,16 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr, case EXPR_ACTION_DECL: case EXPR_ACTION_LIST: case EXPR_KEYSYM_LIST: - log_err(ctx, "%s of boolean values not permitted\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_OPERATION, + "%s of boolean values not permitted\n", expr_op_type_to_string(expr->expr.op)); break; default: - log_wsgo(ctx, "Unknown operator %d in ResolveBoolean\n", + log_wsgo_with_code(ctx, + XKB_ERROR_UNKNOWN_OPERATOR, + "Unknown operator %d in ResolveBoolean\n", expr->expr.op); break; } @@ -210,7 +221,8 @@ ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr, switch (expr->expr.op) { case EXPR_VALUE: if (expr->expr.value_type != EXPR_TYPE_INT) { - log_err(ctx, + log_err_with_code(ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "Found constant of type %s where an int was expected\n", expr_value_type_to_string(expr->expr.value_type)); return false; @@ -239,7 +251,9 @@ ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr, break; case EXPR_DIVIDE: if (rightRtrn == 0) { - log_err(ctx, "Cannot divide by zero: %d / %d\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_OPERATION, + "Cannot divide by zero: %d / %d\n", leftRtrn, rightRtrn); return false; } @@ -263,8 +277,9 @@ ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr, return ExprResolveKeyCode(ctx, expr->unary.child, kc); default: - log_wsgo(ctx, "Unknown operator %d in ResolveKeyCode\n", - expr->expr.op); + log_wsgo_with_code(ctx, + XKB_ERROR_INVALID_SYNTAX, + "Unknown operator %d in ResolveKeyCode\n", expr->expr.op); break; } @@ -294,7 +309,8 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, switch (expr->expr.op) { case EXPR_VALUE: if (expr->expr.value_type != EXPR_TYPE_INT) { - log_err(ctx, + log_err_with_code(ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "Found constant of type %s where an int was expected\n", expr_value_type_to_string(expr->expr.value_type)); return false; @@ -308,7 +324,9 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, ok = lookup(ctx, lookupPriv, expr->ident.ident, EXPR_TYPE_INT, &u); if (!ok) - log_err(ctx, "Identifier \"%s\" of type int is unknown\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_IDENTIFIER, + "Identifier \"%s\" of type int is unknown\n", xkb_atom_text(ctx, expr->ident.ident)); else *val_rtrn = (int) u; @@ -316,7 +334,9 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, return ok; case EXPR_FIELD_REF: - log_err(ctx, "Default \"%s.%s\" of type int is unknown\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_EXPRESSION_TYPE, + "Default \"%s.%s\" of type int is unknown\n", xkb_atom_text(ctx, expr->field_ref.element), xkb_atom_text(ctx, expr->field_ref.field)); return false; @@ -343,13 +363,17 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, break; case EXPR_DIVIDE: if (r == 0) { - log_err(ctx, "Cannot divide by zero: %d / %d\n", l, r); + log_err_with_code(ctx, + XKB_ERROR_INVALID_OPERATION, + "Cannot divide by zero: %d / %d\n", l, r); return false; } *val_rtrn = l / r; break; default: - log_err(ctx, "%s of integers not permitted\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_OPERATION, + "%s of integers not permitted\n", expr_op_type_to_string(expr->expr.op)); return false; } @@ -357,11 +381,15 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, return true; case EXPR_ASSIGN: - log_wsgo(ctx, "Assignment operator not implemented yet\n"); + log_wsgo_with_code(ctx, + XKB_ERROR_INVALID_OPERATION, + "Assignment operator not implemented yet\n"); break; case EXPR_NOT: - log_err(ctx, "The ! operator cannot be applied to an integer\n"); + log_err_with_code(ctx, + XKB_ERROR_INVALID_OPERATION, + "The ! operator cannot be applied to an integer\n"); return false; case EXPR_INVERT: @@ -379,7 +407,9 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, lookupPriv); default: - log_wsgo(ctx, "Unknown operator %d in ResolveInteger\n", + log_wsgo_with_code(ctx, + XKB_ERROR_UNKNOWN_OPERATOR, + "Unknown operator %d in ResolveInteger\n", expr->expr.op); break; } @@ -454,7 +484,9 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr, switch (expr->expr.op) { case EXPR_VALUE: if (expr->expr.value_type != EXPR_TYPE_STRING) { - log_err(ctx, "Found constant of type %s, expected a string\n", + log_err_with_code(ctx, + XKB_ERROR_WRONG_FIELD_TYPE, + "Found constant of type %s, expected a string\n", expr_value_type_to_string(expr->expr.value_type)); return false; } @@ -463,12 +495,16 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr, return true; case EXPR_IDENT: - log_err(ctx, "Identifier \"%s\" of type string not found\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_IDENTIFIER, + "Identifier \"%s\" of type string not found\n", xkb_atom_text(ctx, expr->ident.ident)); return false; case EXPR_FIELD_REF: - log_err(ctx, "Default \"%s.%s\" of type string not found\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_EXPRESSION_TYPE, + "Default \"%s.%s\" of type string not found\n", xkb_atom_text(ctx, expr->field_ref.element), xkb_atom_text(ctx, expr->field_ref.field)); return false; @@ -485,12 +521,16 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr, case EXPR_ACTION_DECL: case EXPR_ACTION_LIST: case EXPR_KEYSYM_LIST: - log_err(ctx, "%s of strings not permitted\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_SYNTAX, + "%s of strings not permitted\n", expr_op_type_to_string(expr->expr.op)); return false; default: - log_wsgo(ctx, "Unknown operator %d in ResolveString\n", + log_wsgo_with_code(ctx, + XKB_ERROR_UNKNOWN_OPERATOR, + "Unknown operator %d in ResolveString\n", expr->expr.op); break; } @@ -502,18 +542,22 @@ ExprResolveEnum(struct xkb_context *ctx, const ExprDef *expr, unsigned int *val_rtrn, const LookupEntry *values) { if (expr->expr.op != EXPR_IDENT) { - log_err(ctx, "Found a %s where an enumerated value was expected\n", + log_err_with_code(ctx, + XKB_ERROR_WRONG_FIELD_TYPE, + "Found a %s where an enumerated value was expected\n", expr_op_type_to_string(expr->expr.op)); return false; } if (!SimpleLookup(ctx, values, expr->ident.ident, EXPR_TYPE_INT, val_rtrn)) { - log_err(ctx, "Illegal identifier %s; expected one of:\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_IDENTIFIER, + "Illegal identifier %s; expected one of:\n", xkb_atom_text(ctx, expr->ident.ident)); while (values && values->name) { - log_err(ctx, "\t%s\n", values->name); + log_err_with_code(ctx, XKB_ERROR_INVALID_IDENTIFIER, "\t%s\n", values->name); values++; } return false; @@ -536,7 +580,8 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, switch (expr->expr.op) { case EXPR_VALUE: if (expr->expr.value_type != EXPR_TYPE_INT) { - log_err(ctx, + log_err_with_code(ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "Found constant of type %s where a mask was expected\n", expr_value_type_to_string(expr->expr.value_type)); return false; @@ -548,12 +593,16 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, ok = lookup(ctx, lookupPriv, expr->ident.ident, EXPR_TYPE_INT, val_rtrn); if (!ok) - log_err(ctx, "Identifier \"%s\" of type int is unknown\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_IDENTIFIER, + "Identifier \"%s\" of type int is unknown\n", xkb_atom_text(ctx, expr->ident.ident)); return ok; case EXPR_FIELD_REF: - log_err(ctx, "Default \"%s.%s\" of type int is unknown\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_EXPRESSION_TYPE, + "Default \"%s.%s\" of type int is unknown\n", xkb_atom_text(ctx, expr->field_ref.element), xkb_atom_text(ctx, expr->field_ref.field)); return false; @@ -564,7 +613,8 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, case EXPR_ACTION_DECL: if (bogus == NULL) bogus = "function use"; - log_err(ctx, + log_err_with_code(ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "Unexpected %s in mask expression; Expression Ignored\n", bogus); return false; @@ -588,7 +638,9 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, break; case EXPR_MULTIPLY: case EXPR_DIVIDE: - log_err(ctx, "Cannot %s masks; Illegal operation ignored\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_OPERATION, + "Cannot %s masks; Illegal operation ignored\n", (expr->expr.op == EXPR_DIVIDE ? "divide" : "multiply")); return false; default: @@ -598,7 +650,9 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, return true; case EXPR_ASSIGN: - log_wsgo(ctx, "Assignment operator not implemented yet\n"); + log_wsgo_with_code(ctx, + XKB_ERROR_INVALID_OPERATION, + "Assignment operator not implemented yet\n"); break; case EXPR_INVERT: @@ -614,12 +668,16 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, case EXPR_NOT: left = expr->unary.child; if (!ExprResolveIntegerLookup(ctx, left, &v, lookup, lookupPriv)) - log_err(ctx, "The %s operator cannot be used with a mask\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_OPERATION, + "The %s operator cannot be used with a mask\n", (expr->expr.op == EXPR_NEGATE ? "-" : "!")); return false; default: - log_wsgo(ctx, "Unknown operator %d in ResolveMask\n", + log_wsgo_with_code(ctx, + XKB_ERROR_UNKNOWN_OPERATOR, + "Unknown operator %d in ResolveMask\n", expr->expr.op); break; } @@ -696,7 +754,8 @@ ExprResolveMod(struct xkb_context *ctx, const ExprDef *def, xkb_atom_t name; if (def->expr.op != EXPR_IDENT) { - log_err(ctx, + log_err_with_code(ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "Cannot resolve virtual modifier: " "found %s where a virtual modifier name was expected\n", expr_op_type_to_string(def->expr.op)); @@ -706,7 +765,8 @@ ExprResolveMod(struct xkb_context *ctx, const ExprDef *def, name = def->ident.ident; ndx = XkbModNameToIndex(mods, name, mod_type); if (ndx == XKB_MOD_INVALID) { - log_err(ctx, + log_err_with_code(ctx, + XKB_ERROR_UNDECLARED_VIRTUAL_MODIFIER, "Cannot resolve virtual modifier: " "\"%s\" was not previously declared\n", xkb_atom_text(ctx, name)); diff --git a/src/xkbcomp/include.c b/src/xkbcomp/include.c index d39be89bd..fc692fb13 100644 --- a/src/xkbcomp/include.c +++ b/src/xkbcomp/include.c @@ -201,21 +201,31 @@ LogIncludePaths(struct xkb_context *ctx) unsigned int i; if (xkb_context_num_include_paths(ctx) > 0) { - log_err(ctx, "%d include paths searched:\n", + log_err_with_code(ctx, + XKB_ERROR_INCLUDED_FILE_NOT_FOUND, + "%d include paths searched:\n", xkb_context_num_include_paths(ctx)); for (i = 0; i < xkb_context_num_include_paths(ctx); i++) - log_err(ctx, "\t%s\n", + log_err_with_code(ctx, + XKB_ERROR_INCLUDED_FILE_NOT_FOUND, + "\t%s\n", xkb_context_include_path_get(ctx, i)); } else { - log_err(ctx, "There are no include paths to search\n"); + log_err_with_code(ctx, + XKB_ERROR_INCLUDED_FILE_NOT_FOUND, + "There are no include paths to search\n"); } if (xkb_context_num_failed_include_paths(ctx) > 0) { - log_err(ctx, "%d include paths could not be added:\n", + log_err_with_code(ctx, + XKB_ERROR_INCLUDED_FILE_NOT_FOUND, + "%d include paths could not be added:\n", xkb_context_num_failed_include_paths(ctx)); for (i = 0; i < xkb_context_num_failed_include_paths(ctx); i++) - log_err(ctx, "\t%s\n", + log_err_with_code(ctx, + XKB_ERROR_INCLUDED_FILE_NOT_FOUND, + "\t%s\n", xkb_context_failed_include_path_get(ctx, i)); } } @@ -246,7 +256,9 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name, buf = asprintf_safe("%s/%s/%s", xkb_context_include_path_get(ctx, i), typeDir, name); if (!buf) { - log_err(ctx, "Failed to alloc buffer for (%s/%s/%s)\n", + log_err_with_code(ctx, + XKB_ERROR_ALLOCATION_ERROR, + "Failed to alloc buffer for (%s/%s/%s)\n", xkb_context_include_path_get(ctx, i), typeDir, name); continue; } @@ -264,7 +276,9 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name, /* We only print warnings if we can't find the file on the first lookup */ if (*offset == 0) { - log_err(ctx, "Couldn't find file \"%s/%s\" in include paths\n", + log_err_with_code(ctx, + XKB_ERROR_INCLUDED_FILE_NOT_FOUND, + "Couldn't find file \"%s/%s\" in include paths\n", typeDir, name); LogIncludePaths(ctx); } @@ -292,7 +306,8 @@ ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt, if (xkb_file) { if (xkb_file->file_type != file_type) { - log_err(ctx, + log_err_with_code(ctx, + XKB_ERROR_INVALID_INCLUDED_FILE, "Include file of wrong type (expected %s, got %s); " "Include file \"%s\" ignored\n", xkb_file_type_to_string(file_type), @@ -310,10 +325,14 @@ ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt, if (!xkb_file) { if (stmt->map) - log_err(ctx, "Couldn't process include statement for '%s(%s)'\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_INCLUDED_FILE, + "Couldn't process include statement for '%s(%s)'\n", stmt->file, stmt->map); else - log_err(ctx, "Couldn't process include statement for '%s'\n", + log_err_with_code(ctx, + XKB_ERROR_INVALID_INCLUDED_FILE, + "Couldn't process include statement for '%s'\n", stmt->file); } diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c index 35c84b768..41ddb2017 100644 --- a/src/xkbcomp/keycodes.c +++ b/src/xkbcomp/keycodes.c @@ -230,13 +230,15 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, xkb_atom_t name, if (merge == MERGE_OVERRIDE) { darray_item(info->key_names, old_kc) = XKB_ATOM_NONE; if (report) - log_warn(info->ctx, + log_warn_with_code(info->ctx, + XKB_WARNING_CONFLICTING_KEY_NAME, "Key name %s assigned to multiple keys; " "Using %d, ignoring %d\n", kname, kc, old_kc); } else { if (report) log_vrb(info->ctx, 3, + XKB_WARNING_CONFLICTING_KEY_NAME, "Key name %s assigned to multiple keys; " "Using %d, ignoring %d\n", kname, old_kc, kc); return true; @@ -397,6 +399,7 @@ HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge) if (old->alias == def->alias) { if (def->real == old->real) { log_vrb(info->ctx, 1, + XKB_WARNING_CONFLICTING_KEY_NAME, "Alias of %s for %s declared more than once; " "First definition ignored\n", KeyNameText(info->ctx, def->alias), @@ -408,7 +411,8 @@ HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge) use = (merge == MERGE_AUGMENT ? old->real : def->real); ignore = (merge == MERGE_AUGMENT ? def->real : old->real); - log_warn(info->ctx, + log_warn_with_code(info->ctx, + XKB_WARNING_CONFLICTING_KEY_NAME, "Multiple definitions for alias %s; " "Using %s, ignoring %s\n", KeyNameText(info->ctx, old->alias), @@ -573,6 +577,7 @@ CopyKeyAliasesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info) /* Check that ->real is a key. */ if (!XkbKeyByName(keymap, alias->real, false)) { log_vrb(info->ctx, 5, + XKB_WARNING_UNDEFINED_KEYCODE, "Attempt to alias %s to non-existent key %s; Ignored\n", KeyNameText(info->ctx, alias->alias), KeyNameText(info->ctx, alias->real)); @@ -583,6 +588,7 @@ CopyKeyAliasesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info) /* Check that ->alias is not a key. */ if (XkbKeyByName(keymap, alias->alias, false)) { log_vrb(info->ctx, 5, + XKB_WARNING_ILLEGAL_KEYCODE_ALIAS, "Attempt to create alias with the name of a real key; " "Alias \"%s = %s\" ignored\n", KeyNameText(info->ctx, alias->alias), diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c index 0d1491333..087815927 100644 --- a/src/xkbcomp/keymap.c +++ b/src/xkbcomp/keymap.c @@ -245,6 +245,7 @@ CompileKeymap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge) file->file_type > LAST_KEYMAP_FILE_TYPE) { if (file->file_type == FILE_TYPE_GEOMETRY) { log_vrb(ctx, 1, + XKB_WARNING_UNSUPPORTED_GEOMETRY_SECTION, "Geometry sections are not supported; ignoring\n"); } else { log_err(ctx, "Cannot define %s in a keymap file\n", diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y index e1226b1e4..0fd663ac7 100644 --- a/src/xkbcomp/parser.y +++ b/src/xkbcomp/parser.y @@ -856,6 +856,7 @@ parse(struct xkb_context *ctx, struct scanner *scanner, const char *map) if (first) log_vrb(ctx, 5, + XKB_WARNING_MISSING_DEFAULT_SECTION, "No map in include statement, but \"%s\" contains several; " "Using first defined map, \"%s\"\n", scanner->file_name, first->name); diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index e438139da..6d31c7c9f 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -62,9 +62,6 @@ #include "keysym.h" -// TODO: convert log_err to log_err_with_code -// TODO: convert log_vrb to log_vrb_with_code - enum key_repeat { KEY_REPEAT_UNDEFINED = 0, KEY_REPEAT_YES = 1, @@ -246,7 +243,7 @@ MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber, if (report) { log_warn_with_code(info->ctx, - XKB_WARNING_CONFLICTING_KEY_TYPE, + XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS, "Multiple definitions for group %d type of key %s; " "Using %s, ignoring %s\n", group + 1, KeyNameText(info->ctx, key_name), @@ -592,7 +589,8 @@ HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *include) if (stmt->modifier) { next_incl.explicit_group = atoi(stmt->modifier) - 1; if (next_incl.explicit_group >= XKB_MAX_GROUPS) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Cannot set explicit group to %d - must be between 1..%d; " "Ignoring group number\n", next_incl.explicit_group + 1, XKB_MAX_GROUPS); @@ -640,7 +638,8 @@ GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, } if (i >= XKB_MAX_GROUPS) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Too many groups of %s for key %s (max %u); " "Ignoring %s defined for extra groups\n", name, KeyInfoText(info, keyi), XKB_MAX_GROUPS, name); @@ -686,7 +685,8 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, } if (value->expr.op != EXPR_KEYSYM_LIST) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "Expected a list of symbols, found %s; " "Ignoring symbols for group %u of %s\n", expr_op_type_to_string(value->expr.op), ndx + 1, @@ -695,7 +695,8 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, } if (groupi->defined & GROUP_FIELD_SYMS) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY, "Symbols for key %s, group %u already defined; " "Ignoring duplicate definition\n", KeyInfoText(info, keyi), ndx + 1); @@ -784,7 +785,8 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, union xkb_action *toAct = &darray_item(groupi->levels, i).action; if (!HandleActionDef(info->ctx, info->actions, &info->mods, act, toAct)) - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_INVALID_VALUE, "Illegal action definition for %s; " "Action for group %u/level %u ignored\n", KeyInfoText(info, keyi), ndx + 1, i + 1); @@ -815,7 +817,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, xkb_atom_t val; if (!ExprResolveString(info->ctx, value, &val)) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "The type field of a key symbol map must be a string; " "Ignoring illegal type definition\n"); return false; @@ -853,7 +856,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, if (!ExprResolveModMask(info->ctx, value, MOD_VIRT, &info->mods, &mask)) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_UNSUPPORTED_MODIFIER_MASK, "Expected a virtual modifier mask, found %s; " "Ignoring virtual modifiers definition for key %s\n", expr_op_type_to_string(value->expr.op), @@ -868,6 +872,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, istreq(field, "lock") || istreq(field, "locks")) { log_vrb(info->ctx, 1, + XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Key behaviors not supported; " "Ignoring locking specification for key %s\n", KeyInfoText(info, keyi)); @@ -876,6 +881,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, istreq(field, "permanentradiogroup") || istreq(field, "allownone")) { log_vrb(info->ctx, 1, + XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Radio groups not supported; " "Ignoring radio group specification for key %s\n", KeyInfoText(info, keyi)); @@ -883,6 +889,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, else if (istreq_prefix("overlay", field) || istreq_prefix("permanentoverlay", field)) { log_vrb(info->ctx, 1, + XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Overlays not supported; " "Ignoring overlay specification for key %s\n", KeyInfoText(info, keyi)); @@ -893,7 +900,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, unsigned int val; if (!ExprResolveEnum(info->ctx, value, &val, repeatEntries)) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_INVALID_VALUE, "Illegal repeat setting for %s; " "Non-boolean repeat setting ignored\n", KeyInfoText(info, keyi)); @@ -908,7 +916,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, bool set; if (!ExprResolveBoolean(info->ctx, value, &set)) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_INVALID_VALUE, "Illegal groupsWrap setting for %s; " "Non-boolean value ignored\n", KeyInfoText(info, keyi)); @@ -923,7 +932,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, bool set; if (!ExprResolveBoolean(info->ctx, value, &set)) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_INVALID_VALUE, "Illegal groupsClamp setting for %s; " "Non-boolean value ignored\n", KeyInfoText(info, keyi)); @@ -950,7 +960,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, keyi->defined |= KEY_FIELD_GROUPINFO; } else { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_UNKNOWN_FIELD, "Unknown field %s in a symbol interpretation; " "Definition ignored\n", field); @@ -968,6 +979,7 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value) if (!arrayNdx) { log_vrb(info->ctx, 1, + XKB_WARNING_MISSING_SYMBOLS_GROUP_NAME_INDEX, "You must specify an index when specifying a group name; " "Group name definition without array subscript ignored\n"); return false; @@ -981,7 +993,8 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value) } if (!ExprResolveString(info->ctx, value, &name)) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "Group name must be a string; " "Illegal name for group %d ignored\n", group); return false; @@ -1031,24 +1044,28 @@ HandleGlobalVar(SymbolsInfo *info, VarDef *stmt) } else if (!elem && (istreq(field, "groupswrap") || istreq(field, "wrapgroups"))) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Global \"groupswrap\" not supported; Ignored\n"); ret = true; } else if (!elem && (istreq(field, "groupsclamp") || istreq(field, "clampgroups"))) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Global \"groupsclamp\" not supported; Ignored\n"); ret = true; } else if (!elem && (istreq(field, "groupsredirect") || istreq(field, "redirectgroups"))) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Global \"groupsredirect\" not supported; Ignored\n"); ret = true; } else if (!elem && istreq(field, "allownone")) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Radio groups not supported; " "Ignoring \"allownone\" specification\n"); ret = true; @@ -1070,7 +1087,8 @@ HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi) for (; def; def = (VarDef *) def->common.next) { if (def->name && def->name->expr.op == EXPR_FIELD_REF) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_WRONG_SCOPE, "Cannot set a global default value from within a key statement; " "Move statements to the global file scope\n"); continue; @@ -1180,7 +1198,8 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def) // Handle normal entry ndx = XkbModNameToIndex(&info->mods, def->modifier, MOD_REAL); if (ndx == XKB_MOD_INVALID) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_INVALID_REAL_MODIFIER, "Illegal modifier map definition; " "Ignoring map for non-modifier \"%s\"\n", xkb_atom_text(ctx, def->modifier)); @@ -1205,7 +1224,8 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def) tmp.u.keySym = sym; } else { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_INVALID_MODMAP_ENTRY, "Modmap entries may contain only key names or keysyms; " "Illegal definition for %s modifier ignored\n", ModIndexText(info->ctx, &info->mods, tmp.modifier)); @@ -1243,7 +1263,8 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleModMapDef(info, (ModMapDef *) stmt); break; default: - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_WRONG_STATEMENT_TYPE, "Symbols files may not include other types; " "Ignoring %s\n", stmt_type_to_string(stmt->type)); ok = false; @@ -1254,7 +1275,9 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge) info->errorCount++; if (info->errorCount > 10) { - log_err(info->ctx, "Abandoning symbols file \"%s\"\n", + log_err_with_code(info->ctx, + XKB_ERROR_INVALID_SYNTAX, + "Abandoning symbols file \"%s\"\n", file->name); break; } @@ -1436,7 +1459,7 @@ CopySymbolsDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info, */ key = XkbKeyByName(keymap, keyi->name, false); if (!key) { - log_vrb_with_code(info->ctx, 5, + log_vrb(info->ctx, 5, XKB_WARNING_UNDEFINED_KEYCODE, "Key %s not found in keycodes; Symbols ignored\n", KeyInfoText(info, keyi)); @@ -1480,7 +1503,7 @@ CopySymbolsDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info, if (type->num_levels < darray_size(groupi->levels)) { struct xkb_level *leveli; - log_vrb_with_code(info->ctx, 1, + log_vrb(info->ctx, 1, XKB_WARNING_EXTRA_SYMBOLS_IGNORED, "Type \"%s\" has %d levels, but %s has %d levels; " "Ignoring extra symbols\n", @@ -1533,7 +1556,7 @@ CopyModMapDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info, if (!entry->haveSymbol) { key = XkbKeyByName(keymap, entry->u.keyName, true); if (!key) { - log_vrb_with_code(info->ctx, 5, + log_vrb(info->ctx, 5, XKB_WARNING_UNDEFINED_KEYCODE, "Key %s not found in keycodes; " "Modifier map entry for %s not updated\n", @@ -1545,7 +1568,7 @@ CopyModMapDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info, else { key = FindKeyForSymbol(keymap, entry->u.keySym); if (!key) { - log_vrb_with_code(info->ctx, 5, + log_vrb(info->ctx, 5, XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL, "Key \"%s\" not found in symbol map; " "Modifier map entry for %s not updated\n", diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c index e8e82df44..fe089ae2d 100644 --- a/src/xkbcomp/types.c +++ b/src/xkbcomp/types.c @@ -143,7 +143,8 @@ AddKeyType(KeyTypesInfo *info, KeyTypeInfo *new, bool same_file) if (old) { if (new->merge == MERGE_REPLACE || new->merge == MERGE_OVERRIDE) { if ((same_file && verbosity > 0) || verbosity > 9) { - log_warn(info->ctx, + log_warn_with_code(info->ctx, + XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS, "Multiple definitions of the %s key type; " "Earlier definition ignored\n", xkb_atom_text(info->ctx, new->name)); @@ -158,6 +159,7 @@ AddKeyType(KeyTypesInfo *info, KeyTypeInfo *new, bool same_file) if (same_file) log_vrb(info->ctx, 4, + XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS, "Multiple definitions of the %s key type; " "Later definition ignored\n", xkb_atom_text(info->ctx, new->name)); @@ -255,7 +257,8 @@ SetModifiers(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, "Illegal array subscript ignored\n"); if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->mods, &mods)) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_UNSUPPORTED_MODIFIER_MASK, "Key type mask field must be a modifier mask; " "Key type definition ignored\n"); return false; @@ -298,7 +301,8 @@ AddMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, old = FindMatchingMapEntry(type, new->mods.mods); if (old) { if (report && old->level != new->level) { - log_warn(info->ctx, + log_warn_with_code(info->ctx, + XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY, "Multiple map entries for %s in %s; " "Using %d, ignoring %d\n", MapEntryTxt(info, new), TypeTxt(info, type), @@ -307,6 +311,7 @@ AddMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, } else { log_vrb(info->ctx, 10, + XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY, "Multiple occurrences of map[%s]= %d in %s; Ignored\n", MapEntryTxt(info, new), new->level + 1, TypeTxt(info, type)); @@ -345,7 +350,8 @@ SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, if (entry.mods.mods & (~type->mods)) { log_vrb(info->ctx, 1, - "Map entry for unused modifiers in %s; " + XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE, + "Map entry for modifiers not used by type %s; " "Using %s instead of %s\n", TypeTxt(info, type), ModMaskText(info->ctx, &info->mods, @@ -388,6 +394,7 @@ AddPreserve(KeyTypesInfo *info, KeyTypeInfo *type, /* Map exists with same preserve; do nothing. */ if (entry->preserve.mods == preserve_mods) { log_vrb(info->ctx, 10, + XKB_WARNING_DUPLICATE_ENTRY, "Identical definitions for preserve[%s] in %s; " "Ignored\n", ModMaskText(info->ctx, &info->mods, mods), @@ -397,6 +404,7 @@ AddPreserve(KeyTypesInfo *info, KeyTypeInfo *type, /* Map exists with different preserve; latter wins. */ log_vrb(info->ctx, 1, + XKB_WARNING_CONFLICTING_KEY_TYPE_PRESERVE_ENTRIES, "Multiple definitions for preserve[%s] in %s; " "Using %s, ignoring %s\n", ModMaskText(info->ctx, &info->mods, mods), @@ -441,14 +449,16 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, after = ModMaskText(info->ctx, &info->mods, mods); log_vrb(info->ctx, 1, - "Preserve for modifiers not used by the %s type; " + XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE, + "Preserve entry for modifiers not used by the %s type; " "Index %s converted to %s\n", TypeTxt(info, type), before, after); } if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->mods, &preserve_mods)) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_UNSUPPORTED_MODIFIER_MASK, "Preserve value in a key type is not a modifier mask; " "Ignoring preserve[%s] in type %s\n", ModMaskText(info->ctx, &info->mods, mods), @@ -464,6 +474,7 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, after = ModMaskText(info->ctx, &info->mods, preserve_mods); log_vrb(info->ctx, 1, + XKB_WARNING_ILLEGAL_KEY_TYPE_PRESERVE_RESULT, "Illegal value for preserve[%s] in type %s; " "Converted %s to %s\n", ModMaskText(info->ctx, &info->mods, mods), @@ -488,6 +499,7 @@ AddLevelName(KeyTypesInfo *info, KeyTypeInfo *type, /* Same level, same name. */ if (darray_item(type->level_names, level) == name) { log_vrb(info->ctx, 10, + XKB_WARNING_DUPLICATE_ENTRY, "Duplicate names for level %d of key type %s; Ignored\n", level + 1, TypeTxt(info, type)); return true; @@ -500,6 +512,7 @@ AddLevelName(KeyTypesInfo *info, KeyTypeInfo *type, darray_item(type->level_names, level)); new = xkb_atom_text(info->ctx, name); log_vrb(info->ctx, 1, + XKB_WARNING_CONFLICTING_KEY_TYPE_LEVEL_NAMES, "Multiple names for level %d of key type %s; " "Using %s, ignoring %s\n", level + 1, TypeTxt(info, type), @@ -531,7 +544,8 @@ SetLevelName(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, type, "level name", "integer"); if (!ExprResolveString(info->ctx, value, &level_name)) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "Non-string name for level %d in key type %s; " "Ignoring illegal level name definition\n", level + 1, xkb_atom_text(info->ctx, type->name)); @@ -566,7 +580,8 @@ SetKeyTypeField(KeyTypesInfo *info, KeyTypeInfo *type, type_field = TYPE_FIELD_LEVEL_NAME; ok = SetLevelName(info, type, arrayNdx, value); } else { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_UNKNOWN_FIELD, "Unknown field %s in key type %s; Definition ignored\n", field, TypeTxt(info, type)); } @@ -589,7 +604,8 @@ HandleKeyTypeBody(KeyTypesInfo *info, VarDef *def, KeyTypeInfo *type) continue; if (elem && istreq(elem, "type")) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_INVALID_SET_DEFAULT_STATEMENT, "Support for changing the default type has been removed; " "Statement ignored\n"); continue; @@ -644,7 +660,8 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleKeyTypeDef(info, (KeyTypeDef *) stmt, merge); break; case STMT_VAR: - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_WRONG_STATEMENT_TYPE, "Support for changing the default type has been removed; " "Statement ignored\n"); ok = true; @@ -653,7 +670,8 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleVModDef(info->ctx, &info->mods, (VModDef *) stmt, merge); break; default: - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_WRONG_STATEMENT_TYPE, "Key type files may not include other declarations; " "Ignoring %s\n", stmt_type_to_string(stmt->type)); ok = false; @@ -664,7 +682,8 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge) info->errorCount++; if (info->errorCount > 10) { - log_err(info->ctx, + log_err_with_code(info->ctx, + XKB_ERROR_INVALID_SYNTAX, "Abandoning keytypes file \"%s\"\n", file->name); break; } diff --git a/src/xkbcomp/xkbcomp-priv.h b/src/xkbcomp/xkbcomp-priv.h index 5a7765f43..50c07b56a 100644 --- a/src/xkbcomp/xkbcomp-priv.h +++ b/src/xkbcomp/xkbcomp-priv.h @@ -82,7 +82,8 @@ static inline bool ReportNotArray(struct xkb_context *ctx, const char *type, const char *field, const char *name) { - log_err(ctx, + log_err_with_code(ctx, + XKB_ERROR_WRONG_FIELD_TYPE, "The %s %s field is not an array; " "Ignoring illegal assignment in %s\n", type, field, name); @@ -93,7 +94,8 @@ static inline bool ReportShouldBeArray(struct xkb_context *ctx, const char *type, const char *field, const char *name) { - log_err(ctx, + log_err_with_code(ctx, + XKB_ERROR_EXPECTED_ARRAY_ENTRY, "Missing subscript for %s %s; " "Ignoring illegal assignment in %s\n", type, field, name); diff --git a/test/log.c b/test/log.c index 384fabcb0..14e4845ff 100644 --- a/test/log.c +++ b/test/log.c @@ -25,6 +25,7 @@ #include "test.h" #include "context.h" +#include "messages-codes.h" #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wmissing-format-attribute" @@ -89,14 +90,14 @@ main(void) log_info(ctx, "first info\n"); log_dbg(ctx, "first debug: %s\n", "hello"); log_err(ctx, "first error: %lu\n", 115415UL); - log_vrb(ctx, 5, "first verbose 5\n"); + log_vrb(ctx, 5, XKB_LOG_MESSAGE_NO_ID, "first verbose 5\n"); xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG); log_warn(ctx, "second warning: %d\n", 87); log_dbg(ctx, "second debug: %s %s\n", "hello", "world"); log_info(ctx, "second info\n"); log_err(ctx, "second error: %lu\n", 115415UL); - log_vrb(ctx, 6, "second verbose 6\n"); + log_vrb(ctx, 6, XKB_LOG_MESSAGE_NO_ID, "second verbose 6\n"); xkb_context_set_log_verbosity(ctx, 0); xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL); @@ -104,14 +105,14 @@ main(void) log_dbg(ctx, "third debug: %s %s\n", "hello", "world"); log_info(ctx, "third info\n"); log_err(ctx, "third error: %lu\n", 115415UL); - log_vrb(ctx, 0, "third verbose 0\n"); + log_vrb(ctx, 0, XKB_LOG_MESSAGE_NO_ID, "third verbose 0\n"); printf("%s", log_string.item); assert(streq(log_string.item, "warning: first warning: 87\n" "error: first error: 115415\n" - "warning: first verbose 5\n" + "warning: [XKB-000] first verbose 5\n" "warning: second warning: 87\n" "debug: second debug: hello world\n" "info: second info\n" diff --git a/tools/messages.c b/tools/messages.c index abda073a6..fc3b4117d 100644 --- a/tools/messages.c +++ b/tools/messages.c @@ -39,26 +39,57 @@ static const struct xkb_message_entry xkb_messages[] = { {XKB_ERROR_MALFORMED_NUMBER_LITERAL, "Malformed number literal"}, + {XKB_WARNING_CONFLICTING_KEY_TYPE_PRESERVE_ENTRIES, "Conflicting key type preserve entries"}, {XKB_ERROR_UNSUPPORTED_MODIFIER_MASK, "Unsupported modifier mask"}, + {XKB_ERROR_EXPECTED_ARRAY_ENTRY, "Expected array entry"}, + {XKB_WARNING_ILLEGAL_KEYCODE_ALIAS, "Illegal keycode alias"}, {XKB_WARNING_UNRECOGNIZED_KEYSYM, "Unrecognized keysym"}, + {XKB_ERROR_UNDECLARED_VIRTUAL_MODIFIER, "Undeclared virtual modifier"}, + {XKB_ERROR_WRONG_STATEMENT_TYPE, "Wrong statement type"}, + {XKB_WARNING_UNSUPPORTED_GEOMETRY_SECTION, "Unsupported geometry section"}, {XKB_WARNING_CANNOT_INFER_KEY_TYPE, "Cannot infer key type"}, + {XKB_WARNING_ILLEGAL_KEY_TYPE_PRESERVE_RESULT, "Illegal key type preserve result"}, + {XKB_ERROR_INVALID_INCLUDE_STATEMENT, "Invalid include statement"}, + {XKB_ERROR_INVALID_MODMAP_ENTRY, "Invalid modmap entry"}, {XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Unsupported group index"}, + {XKB_WARNING_CONFLICTING_KEY_TYPE_LEVEL_NAMES, "Conflicting key type level names"}, + {XKB_ERROR_INVALID_SET_DEFAULT_STATEMENT, "Invalid set default statement"}, + {XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY, "Conflicting key type map entry"}, {XKB_WARNING_UNDEFINED_KEY_TYPE, "Undefined key type"}, {XKB_WARNING_NON_BASE_GROUP_NAME, "Non base group name"}, {XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL, "Unsupported shift level"}, + {XKB_ERROR_INCLUDED_FILE_NOT_FOUND, "Included file not found"}, + {XKB_ERROR_UNKNOWN_OPERATOR, "Unknown operator"}, + {XKB_WARNING_DUPLICATE_ENTRY, "Duplicate entry"}, + {XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS, "Conflicting key type definitions"}, + {XKB_ERROR_WRONG_SCOPE, "Wrong scope"}, + {XKB_WARNING_MISSING_DEFAULT_SECTION, "Missing default section"}, {XKB_WARNING_CONFLICTING_KEY_SYMBOL, "Conflicting key symbol"}, + {XKB_ERROR_INVALID_OPERATION, "Invalid operation"}, {XKB_WARNING_NUMERIC_KEYSYM, "Numeric keysym"}, {XKB_WARNING_EXTRA_SYMBOLS_IGNORED, "Extra symbols ignored"}, + {XKB_WARNING_CONFLICTING_KEY_NAME, "Conflicting key name"}, + {XKB_ERROR_ALLOCATION_ERROR, "Allocation error"}, {XKB_ERROR_WRONG_FIELD_TYPE, "Wrong field type"}, + {XKB_ERROR_INVALID_REAL_MODIFIER, "Invalid real modifier"}, {XKB_WARNING_UNKNOWN_CHAR_ESCAPE_SEQUENCE, "Unknown char escape sequence"}, + {XKB_ERROR_INVALID_INCLUDED_FILE, "Invalid included file"}, {XKB_WARNING_MULTIPLE_GROUPS_AT_ONCE, "Multiple groups at once"}, + {XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Unsupported symbols field"}, {XKB_ERROR_INVALID_SYNTAX, "Invalid syntax"}, {XKB_WARNING_UNDEFINED_KEYCODE, "Undefined keycode"}, + {XKB_ERROR_INVALID_EXPRESSION_TYPE, "Invalid expression type"}, + {XKB_ERROR_INVALID_VALUE, "Invalid value"}, {XKB_WARNING_CONFLICTING_MODMAP, "Conflicting modmap"}, + {XKB_ERROR_UNKNOWN_FIELD, "Unknown field"}, {XKB_WARNING_CONFLICTING_KEY_ACTION, "Conflicting key action"}, - {XKB_WARNING_CONFLICTING_KEY_TYPE, "Conflicting key type"}, + {XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS, "Conflicting key type merging groups"}, + {XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY, "Conflicting key symbols entry"}, + {XKB_WARNING_MISSING_SYMBOLS_GROUP_NAME_INDEX, "Missing symbols group name index"}, {XKB_WARNING_CONFLICTING_KEY_FIELDS, "Conflicting key fields"}, - {XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL, "Unresolved keymap symbol"} + {XKB_ERROR_INVALID_IDENTIFIER, "Invalid identifier"}, + {XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL, "Unresolved keymap symbol"}, + {XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE, "Undeclared modifiers in key type"} }; int From b1f6a80b5789b29774326846d70e024340d14652 Mon Sep 17 00:00:00 2001 From: Pierre Le Marre Date: Thu, 21 Sep 2023 20:06:27 +0200 Subject: [PATCH 2/2] Messages: merge macros with and without message code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously we had two types of macros for logging: with and without message code. They were intended to be merged afterwards. The idea is to use a special code – `XKB_LOG_MESSAGE_NO_ID = 0` – that should *not* be displayed. But we would like to avoid checking this special code at run time. This is achieved using macro tricks; they are detailed in the code (see: `PREPEND_MESSAGE_ID`). Now it is also easier to spot the remaining undocumented log entries: just search `XKB_LOG_MESSAGE_NO_ID`. --- src/compose/parser.c | 4 +- src/compose/table.c | 6 ++- src/context-priv.c | 1 + src/context.c | 8 ++-- src/context.h | 68 ++++++++++++++++++++------------ src/messages-codes.h | 6 --- src/messages-codes.h.jinja | 6 --- src/x11/keymap.c | 4 +- src/xkbcomp/action.c | 43 ++++++++++---------- src/xkbcomp/ast-build.c | 2 +- src/xkbcomp/compat.c | 38 +++++++++--------- src/xkbcomp/expr.c | 80 +++++++++++++++++++------------------- src/xkbcomp/include.c | 20 +++++----- src/xkbcomp/keycodes.c | 30 +++++++------- src/xkbcomp/keymap.c | 14 ++++--- src/xkbcomp/rules.c | 26 +++++++++---- src/xkbcomp/scanner.c | 3 +- src/xkbcomp/symbols.c | 76 ++++++++++++++++++------------------ src/xkbcomp/types.c | 26 ++++++------- src/xkbcomp/vmod.c | 8 ++-- src/xkbcomp/xkbcomp-priv.h | 9 +++-- src/xkbcomp/xkbcomp.c | 18 +++++---- test/log.c | 28 ++++++------- 23 files changed, 280 insertions(+), 244 deletions(-) diff --git a/src/compose/parser.c b/src/compose/parser.c index 124456d11..88105fa21 100644 --- a/src/compose/parser.c +++ b/src/compose/parser.c @@ -727,7 +727,9 @@ parse_file(struct xkb_compose_table *table, FILE *file, const char *file_name) ok = map_file(file, &string, &size); if (!ok) { - log_err(table->ctx, "Couldn't read Compose file %s: %s\n", + log_err(table->ctx, + XKB_LOG_MESSAGE_NO_ID, + "Couldn't read Compose file %s: %s\n", file_name, strerror(errno)); return false; } diff --git a/src/compose/table.c b/src/compose/table.c index ea5e45a84..3abc64940 100644 --- a/src/compose/table.c +++ b/src/compose/table.c @@ -206,7 +206,8 @@ xkb_compose_table_new_from_locale(struct xkb_context *ctx, } free(path); - log_err(ctx, "couldn't find a Compose file for locale \"%s\" (mapped to \"%s\")\n", + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "couldn't find a Compose file for locale \"%s\" (mapped to \"%s\")\n", locale, table->locale); xkb_compose_table_unref(table); return NULL; @@ -220,7 +221,8 @@ xkb_compose_table_new_from_locale(struct xkb_context *ctx, return NULL; } - log_dbg(ctx, "created compose table from locale %s with path %s\n", + log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, + "created compose table from locale %s with path %s\n", table->locale, path); free(path); diff --git a/src/context-priv.c b/src/context-priv.c index 30f3f05d5..cc5764d3f 100644 --- a/src/context-priv.c +++ b/src/context-priv.c @@ -182,6 +182,7 @@ xkb_context_sanitize_rule_names(struct xkb_context *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", diff --git a/src/context.c b/src/context.c index b8b214bcd..bcec16c43 100644 --- a/src/context.c +++ b/src/context.c @@ -65,13 +65,14 @@ xkb_context_include_path_append(struct xkb_context *ctx, const char *path) } darray_append(ctx->includes, tmp); - log_dbg(ctx, "Include path added: %s\n", tmp); + log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, "Include path added: %s\n", tmp); return 1; err: darray_append(ctx->failed_includes, tmp); - log_dbg(ctx, "Include path failed: %s (%s)\n", tmp, strerror(err)); + log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, + "Include path failed: %s (%s)\n", tmp, strerror(err)); return 0; } @@ -304,7 +305,8 @@ xkb_context_new(enum xkb_context_flags flags) if (!(flags & XKB_CONTEXT_NO_DEFAULT_INCLUDES) && !xkb_context_include_path_append_default(ctx)) { - log_err(ctx, "failed to add default include path %s\n", + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "failed to add default include path %s\n", DFLT_XKB_CONFIG_ROOT); xkb_context_unref(ctx); return NULL; diff --git a/src/context.h b/src/context.h index 53d6e2f31..a523d90dd 100644 --- a/src/context.h +++ b/src/context.h @@ -109,6 +109,35 @@ void xkb_context_sanitize_rule_names(struct xkb_context *ctx, struct xkb_rule_names *rmlvo); +/* + * Macro sorcery: PREPEND_MESSAGE_ID enables the log functions to format messages + * with the message ID only if the ID is not 0 (XKB_LOG_MESSAGE_NO_ID). + * This avoid checking the ID value at run time. + * + * The trick resides in CHECK_ID: + * • CHECK_ID(0) expands to: + * ‣ SECOND(MATCH0, WITH_ID, unused) + * ‣ SECOND(unused,WITHOUT_ID, WITH_ID, unused) + * ‣ WITHOUT_ID + * • CHECK_ID(123) expands to: + * ‣ SECOND(MATCH123, WITH_ID, unused) + * ‣ WITH_ID +*/ +#define EXPAND(...) __VA_ARGS__ /* needed for MSVC compatibility */ + +#define JOIN_EXPAND(a, b) a##b +#define JOIN(a, b) JOIN_EXPAND(a, b) + +#define SECOND_EXPAND(a, b, ...) b +#define SECOND(...) EXPAND(SECOND_EXPAND(__VA_ARGS__)) + +#define MATCH0 unused,WITHOUT_ID +#define CHECK_ID(value) SECOND(JOIN(MATCH, value), WITH_ID, unused) + +#define FORMAT_MESSAGE_WITHOUT_ID(id, fmt) fmt +#define FORMAT_MESSAGE_WITH_ID(id, fmt) "[XKB-%03d] " fmt, id +#define PREPEND_MESSAGE_ID(id, fmt) JOIN(FORMAT_MESSAGE_, CHECK_ID(id))(id, fmt) + /* * The format is not part of the argument list in order to avoid the * "ISO C99 requires rest arguments to be used" warning when only the @@ -116,30 +145,19 @@ xkb_context_sanitize_rule_names(struct xkb_context *ctx, * result in an error, though. */ #define xkb_log_with_code(ctx, level, verbosity, msg_id, fmt, ...) \ - xkb_log(ctx, level, verbosity, "[XKB-%03d] " fmt, \ - msg_id, ##__VA_ARGS__) -#define log_dbg_with_code(ctx, id, ...) \ - xkb_log_with_code((ctx), XKB_LOG_LEVEL_DEBUG, 0, (id), __VA_ARGS__) -#define log_dbg(ctx, ...) \ - xkb_log((ctx), XKB_LOG_LEVEL_DEBUG, 0, __VA_ARGS__) -#define log_info_with_code(ctx, id, ...) \ - xkb_log_with_code((ctx), XKB_LOG_LEVEL_INFO, 0, (id), __VA_ARGS__) -#define log_info(ctx, ...) \ - xkb_log((ctx), XKB_LOG_LEVEL_INFO, 0, __VA_ARGS__) -#define log_warn_with_code(ctx, id, ...) \ - xkb_log_with_code((ctx), XKB_LOG_LEVEL_WARNING, 0, (id), __VA_ARGS__) -#define log_warn(ctx, ...) \ - xkb_log((ctx), XKB_LOG_LEVEL_WARNING, 0, __VA_ARGS__) -#define log_err_with_code(ctx, id, ...) \ - xkb_log_with_code((ctx), XKB_LOG_LEVEL_ERROR, 0, (id), __VA_ARGS__) -#define log_err(ctx, ...) \ - xkb_log((ctx), XKB_LOG_LEVEL_ERROR, 0, __VA_ARGS__) -#define log_wsgo_with_code(ctx, id, ...) \ - xkb_log_with_code((ctx), XKB_LOG_LEVEL_CRITICAL, 0, (id), __VA_ARGS__) -#define log_wsgo(ctx, ...) \ - xkb_log((ctx), XKB_LOG_LEVEL_CRITICAL, 0, __VA_ARGS__) + xkb_log(ctx, level, verbosity, PREPEND_MESSAGE_ID(msg_id, fmt), ##__VA_ARGS__) +#define log_dbg(ctx, id, ...) \ + xkb_log_with_code((ctx), XKB_LOG_LEVEL_DEBUG, 0, id, __VA_ARGS__) +#define log_info(ctx, id, ...) \ + xkb_log_with_code((ctx), XKB_LOG_LEVEL_INFO, 0, id, __VA_ARGS__) +#define log_warn(ctx, id, ...) \ + xkb_log_with_code((ctx), XKB_LOG_LEVEL_WARNING, 0, id, __VA_ARGS__) +#define log_err(ctx, id, ...) \ + xkb_log_with_code((ctx), XKB_LOG_LEVEL_ERROR, 0, id, __VA_ARGS__) +#define log_wsgo(ctx, id, ...) \ + xkb_log_with_code((ctx), XKB_LOG_LEVEL_CRITICAL, 0, id, __VA_ARGS__) #define log_vrb(ctx, vrb, id, ...) \ - xkb_log_with_code((ctx), XKB_LOG_LEVEL_WARNING, (vrb), (id), __VA_ARGS__) + xkb_log_with_code((ctx), XKB_LOG_LEVEL_WARNING, (vrb), id, __VA_ARGS__) /* * Variants which are prefixed by the name of the function they're @@ -147,8 +165,8 @@ xkb_context_sanitize_rule_names(struct xkb_context *ctx, * Here we must have the silly 1 variant. */ #define log_err_func(ctx, fmt, ...) \ - log_err(ctx, "%s: " fmt, __func__, __VA_ARGS__) + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "%s: " fmt, __func__, __VA_ARGS__) #define log_err_func1(ctx, fmt) \ - log_err(ctx, "%s: " fmt, __func__) + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "%s: " fmt, __func__) #endif diff --git a/src/messages-codes.h b/src/messages-codes.h index 3f117e1a1..5d8c84c71 100644 --- a/src/messages-codes.h +++ b/src/messages-codes.h @@ -8,17 +8,11 @@ /** * Special case when no message identifier is defined. - * - * @added 1.6.0 - * */ #define XKB_LOG_MESSAGE_NO_ID 0 /** * @name Codes of the log messages - * - * @added 1.6.0 - * */ enum xkb_message_code { _XKB_LOG_MESSAGE_MIN_CODE = 34, diff --git a/src/messages-codes.h.jinja b/src/messages-codes.h.jinja index 49a876cd5..468a6dede 100644 --- a/src/messages-codes.h.jinja +++ b/src/messages-codes.h.jinja @@ -8,17 +8,11 @@ /** * Special case when no message identifier is defined. - * - * @added 1.6.0 - * */ #define XKB_LOG_MESSAGE_NO_ID 0 /** * @name Codes of the log messages - * - * @added 1.6.0 - * */ enum xkb_message_code { _XKB_LOG_MESSAGE_MIN_CODE = {{ entries[0].code }}, diff --git a/src/x11/keymap.c b/src/x11/keymap.c index f2045b984..72f663927 100644 --- a/src/x11/keymap.c +++ b/src/x11/keymap.c @@ -63,7 +63,7 @@ */ #define FAIL_UNLESS(expr) do { \ if (!(expr)) { \ - log_err(keymap->ctx, \ + log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, \ "x11: failed to get keymap from X server: unmet condition in %s(): %s\n", \ __func__, STRINGIFY(expr)); \ goto fail; \ @@ -72,7 +72,7 @@ #define FAIL_IF_BAD_REPLY(reply, request_name) do { \ if (!reply) { \ - log_err(keymap->ctx, \ + log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, \ "x11: failed to get keymap from X server: %s request failed\n", \ (request_name)); \ goto fail; \ diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c index 1410aab51..4556584cf 100644 --- a/src/xkbcomp/action.c +++ b/src/xkbcomp/action.c @@ -194,7 +194,7 @@ ReportMismatch(struct xkb_context *ctx, xkb_message_code_t code, enum xkb_action_type action, enum action_field field, const char *type) { - log_err_with_code(ctx, code, + log_err(ctx, code, "Value of %s field must be of type %s; " "Action %s definition ignored\n", fieldText(field), type, ActionTypeText(action)); @@ -205,7 +205,7 @@ static inline bool ReportIllegal(struct xkb_context *ctx, enum xkb_action_type action, enum action_field field) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Field %s is not defined for an action of type %s; " "Action definition ignored\n", fieldText(field), ActionTypeText(action)); @@ -216,7 +216,7 @@ static inline bool ReportActionNotArray(struct xkb_context *ctx, enum xkb_action_type action, enum action_field field) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "The %s field in the %s action is not an array; " "Action definition ignored\n", fieldText(field), ActionTypeText(action)); @@ -423,7 +423,7 @@ HandleMovePtr(struct xkb_context *ctx, const struct xkb_mod_set *mods, field, "integer"); if (val < INT16_MIN || val > INT16_MAX) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "The %s field in the %s action must be in range %d..%d; " "Action definition ignored\n", fieldText(field), ActionTypeText(action->type), @@ -470,7 +470,7 @@ HandlePtrBtn(struct xkb_context *ctx, const struct xkb_mod_set *mods, field, "integer (range 1..5)"); if (btn < 0 || btn > 5) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Button must specify default or be in the range 1..5; " "Illegal button value %d ignored\n", btn); return false; @@ -495,7 +495,7 @@ HandlePtrBtn(struct xkb_context *ctx, const struct xkb_mod_set *mods, field, "integer"); if (val < 0 || val > 255) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "The count field must have a value in the range 0..255; " "Illegal count %d ignored\n", val); return false; @@ -555,13 +555,13 @@ HandleSetPtrDflt(struct xkb_context *ctx, const struct xkb_mod_set *mods, field, "integer (range 1..5)"); if (btn < 0 || btn > 5) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "New default button value must be in the range 1..5; " "Illegal default button value %d ignored\n", btn); return false; } if (btn == 0) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Cannot set default pointer button to \"default\"; " "Illegal default button setting ignored\n"); return false; @@ -603,7 +603,7 @@ HandleSwitchScreen(struct xkb_context *ctx, const struct xkb_mod_set *mods, field, "integer (0..255)"); if (val < 0 || val > 255) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Screen index must be in the range 1..255; " "Illegal screen value %d ignored\n", val); return false; @@ -667,7 +667,7 @@ HandlePrivate(struct xkb_context *ctx, const struct xkb_mod_set *mods, ACTION_TYPE_PRIVATE, field, "integer"); if (type < 0 || type > 255) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Private action type must be in the range 0..255; " "Illegal type %d ignored\n", type); return false; @@ -684,7 +684,7 @@ HandlePrivate(struct xkb_context *ctx, const struct xkb_mod_set *mods, * make actions like these no-ops for now. */ if (type < ACTION_TYPE_PRIVATE) { - log_info(ctx, + log_info(ctx, XKB_LOG_MESSAGE_NO_ID, "Private actions of type %s are not supported; Ignored\n", ActionTypeText(type)); act->type = ACTION_TYPE_NONE; @@ -708,7 +708,7 @@ HandlePrivate(struct xkb_context *ctx, const struct xkb_mod_set *mods, str = xkb_atom_text(ctx, val); len = strlen(str); if (len < 1 || len > sizeof(act->data)) { - log_warn(ctx, + log_warn(ctx, XKB_LOG_MESSAGE_NO_ID, "A private action has %ld data bytes; " "Illegal data ignored\n", sizeof(act->data)); return false; @@ -723,14 +723,14 @@ HandlePrivate(struct xkb_context *ctx, const struct xkb_mod_set *mods, int ndx, datum; if (!ExprResolveInteger(ctx, array_ndx, &ndx)) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Array subscript must be integer; " "Illegal subscript ignored\n"); return false; } if (ndx < 0 || (size_t) ndx >= sizeof(act->data)) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "The data for a private action is %lu bytes long; " "Attempt to use data[%d] ignored\n", (unsigned long) sizeof(act->data), ndx); @@ -742,7 +742,7 @@ HandlePrivate(struct xkb_context *ctx, const struct xkb_mod_set *mods, field, "integer"); if (datum < 0 || datum > 255) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "All data for a private action must be 0..255; " "Illegal datum %d ignored\n", datum); return false; @@ -794,14 +794,15 @@ HandleActionDef(struct xkb_context *ctx, ActionsInfo *info, enum xkb_action_type handler_type; if (def->expr.op != EXPR_ACTION_DECL) { - log_err(ctx, "Expected an action definition, found %s\n", + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "Expected an action definition, found %s\n", expr_op_type_to_string(def->expr.op)); return false; } str = xkb_atom_text(ctx, def->action.name); if (!stringToAction(str, &handler_type)) { - log_err(ctx, "Unknown action %s\n", str); + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Unknown action %s\n", str); return false; } @@ -841,7 +842,7 @@ HandleActionDef(struct xkb_context *ctx, ActionsInfo *info, return false; if (elemRtrn) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Cannot change defaults in an action definition; " "Ignoring attempt to change %s.%s\n", elemRtrn, fieldRtrn); @@ -849,7 +850,8 @@ HandleActionDef(struct xkb_context *ctx, ActionsInfo *info, } if (!stringToField(fieldRtrn, &fieldNdx)) { - log_err(ctx, "Unknown field name %s\n", fieldRtrn); + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "Unknown field name %s\n", fieldRtrn); return false; } @@ -873,7 +875,8 @@ SetActionField(struct xkb_context *ctx, ActionsInfo *info, return false; if (!stringToField(field, &action_field)) { - log_err(ctx, "\"%s\" is not a legal field name\n", field); + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "\"%s\" is not a legal field name\n", field); return false; } diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c index 4654ae4c6..7c7646140 100644 --- a/src/xkbcomp/ast-build.c +++ b/src/xkbcomp/ast-build.c @@ -525,7 +525,7 @@ IncludeCreate(struct xkb_context *ctx, char *str, enum merge_mode merge) return first; err: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_INCLUDE_STATEMENT, "Illegal include statement \"%s\"; Ignored\n", stmt); FreeInclude(first); diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 121f5f27e..9b6f9de58 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -209,7 +209,7 @@ AddInterp(CompatInfo *info, SymInterpInfo *new, bool same_file) if (new->merge == MERGE_REPLACE) { if (report) - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Multiple definitions for \"%s\"; " "Earlier interpretation ignored\n", siText(new, info)); @@ -239,7 +239,7 @@ AddInterp(CompatInfo *info, SymInterpInfo *new, bool same_file) } if (collide) { - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Multiple interpretations of \"%s\"; " "Using %s definition for duplicate fields\n", siText(new, info), @@ -270,7 +270,7 @@ ResolveStateAndPredicate(ExprDef *expr, enum xkb_match_operation *pred_rtrn, const char *pred_txt = xkb_atom_text(info->ctx, expr->action.name); if (!LookupString(symInterpretMatchMaskNames, pred_txt, pred_rtrn) || !expr->action.args || expr->action.args->common.next) { - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Illegal modifier predicate \"%s\"; Ignored\n", pred_txt); return false; } @@ -333,7 +333,7 @@ AddLedMap(CompatInfo *info, LedInfo *new, bool same_file) if (new->merge == MERGE_REPLACE) { if (report) - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Map for indicator %s redefined; " "Earlier definition ignored\n", xkb_atom_text(info->ctx, old->led.name)); @@ -358,7 +358,7 @@ AddLedMap(CompatInfo *info, LedInfo *new, bool same_file) } if (collide) { - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Map for indicator %s redefined; " "Using %s definition for duplicate fields\n", xkb_atom_text(info->ctx, old->led.name), @@ -369,7 +369,7 @@ AddLedMap(CompatInfo *info, LedInfo *new, bool same_file) } if (info->num_leds >= XKB_MAX_LEDS) { - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Too many LEDs defined (maximum %d)\n", XKB_MAX_LEDS); return false; @@ -506,7 +506,7 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field, si->defined |= SI_FIELD_AUTO_REPEAT; } else if (istreq(field, "locking")) { - log_dbg(info->ctx, + log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID, "The \"locking\" field in symbol interpretation is unsupported; " "Ignored\n"); } @@ -572,7 +572,7 @@ SetLedMapField(CompatInfo *info, LedInfo *ledi, const char *field, ledi->defined |= LED_FIELD_CTRLS; } else if (istreq(field, "allowexplicit")) { - log_dbg(info->ctx, + log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID, "The \"allowExplicit\" field in indicator statements is unsupported; " "Ignored\n"); } @@ -609,18 +609,18 @@ SetLedMapField(CompatInfo *info, LedInfo *ledi, const char *field, istreq(field, "leddriveskeyboard") || istreq(field, "indicatordriveskbd") || istreq(field, "indicatordriveskeyboard")) { - log_dbg(info->ctx, + log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID, "The \"%s\" field in indicator statements is unsupported; " "Ignored\n", field); } else if (istreq(field, "index")) { /* Users should see this, it might cause unexpected behavior. */ - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "The \"index\" field in indicator statements is unsupported; " "Ignored\n"); } else { - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Unknown field %s in map for %s indicator; " "Definition ignored\n", field, xkb_atom_text(info->ctx, ledi->led.name)); @@ -660,7 +660,7 @@ HandleInterpBody(CompatInfo *info, VarDef *def, SymInterpInfo *si) for (; def; def = (VarDef *) def->common.next) { if (def->name && def->name->expr.op == EXPR_FIELD_REF) { - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Cannot set a global default value from within an interpret statement; " "Move statements to the global file scope\n"); ok = false; @@ -685,7 +685,7 @@ HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge) SymInterpInfo si; if (!ResolveStateAndPredicate(def->match, &pred, &mods, info)) { - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Couldn't determine matching modifiers; " "Symbol interpretation ignored\n"); return false; @@ -734,7 +734,7 @@ HandleLedMapDef(CompatInfo *info, LedMapDef *def, enum merge_mode merge) } if (elem) { - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Cannot set defaults for \"%s\" element in indicator map; " "Assignment to %s.%s ignored\n", elem, elem, field); ok = false; @@ -769,7 +769,7 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleInterpDef(info, (InterpDef *) stmt, merge); break; case STMT_GROUP_COMPAT: - log_dbg(info->ctx, + log_dbg(info->ctx, XKB_LOG_MESSAGE_NO_ID, "The \"group\" statement in compat is unsupported; " "Ignored\n"); ok = true; @@ -784,7 +784,7 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleVModDef(info->ctx, &info->mods, (VModDef *) stmt, merge); break; default: - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Compat files may not include other types; " "Ignoring %s\n", stmt_type_to_string(stmt->type)); ok = false; @@ -795,7 +795,7 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge) info->errorCount++; if (info->errorCount > 10) { - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Abandoning compatibility map \"%s\"\n", file->name); break; } @@ -837,7 +837,7 @@ CopyLedMapDefsToKeymap(struct xkb_keymap *keymap, CompatInfo *info) /* Not previously declared; create it with next free index. */ if (i >= keymap->num_leds) { - log_dbg(keymap->ctx, + log_dbg(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, "Indicator name \"%s\" was not declared in the keycodes section; " "Adding new indicator\n", xkb_atom_text(keymap->ctx, ledi->led.name)); @@ -849,7 +849,7 @@ CopyLedMapDefsToKeymap(struct xkb_keymap *keymap, CompatInfo *info) if (i >= keymap->num_leds) { /* Not place to put it; ignore. */ if (i >= XKB_MAX_LEDS) { - log_err(keymap->ctx, + log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, "Too many indicators (maximum is %d); " "Indicator name \"%s\" ignored\n", XKB_MAX_LEDS, diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index 6e3e4515b..2459713fd 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -63,7 +63,7 @@ ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr, default: break; } - log_wsgo_with_code(ctx, + log_wsgo(ctx, XKB_ERROR_INVALID_SYNTAX, "Unexpected operator %d in ResolveLhs\n", expr->expr.op); return false; @@ -141,7 +141,7 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr, switch (expr->expr.op) { case EXPR_VALUE: if (expr->expr.value_type != EXPR_TYPE_BOOLEAN) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Found constant of type %s where boolean was expected\n", expr_value_type_to_string(expr->expr.value_type)); @@ -166,13 +166,13 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr, return true; } } - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_IDENTIFIER, "Identifier \"%s\" of type boolean is unknown\n", ident); return false; case EXPR_FIELD_REF: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_EXPRESSION_TYPE, "Default \"%s.%s\" of type boolean is unknown\n", xkb_atom_text(ctx, expr->field_ref.element), @@ -195,14 +195,14 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr, case EXPR_ACTION_DECL: case EXPR_ACTION_LIST: case EXPR_KEYSYM_LIST: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_OPERATION, "%s of boolean values not permitted\n", expr_op_type_to_string(expr->expr.op)); break; default: - log_wsgo_with_code(ctx, + log_wsgo(ctx, XKB_ERROR_UNKNOWN_OPERATOR, "Unknown operator %d in ResolveBoolean\n", expr->expr.op); @@ -221,7 +221,7 @@ ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr, switch (expr->expr.op) { case EXPR_VALUE: if (expr->expr.value_type != EXPR_TYPE_INT) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Found constant of type %s where an int was expected\n", expr_value_type_to_string(expr->expr.value_type)); @@ -251,7 +251,7 @@ ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr, break; case EXPR_DIVIDE: if (rightRtrn == 0) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_OPERATION, "Cannot divide by zero: %d / %d\n", leftRtrn, rightRtrn); @@ -277,7 +277,7 @@ ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr, return ExprResolveKeyCode(ctx, expr->unary.child, kc); default: - log_wsgo_with_code(ctx, + log_wsgo(ctx, XKB_ERROR_INVALID_SYNTAX, "Unknown operator %d in ResolveKeyCode\n", expr->expr.op); break; @@ -309,7 +309,7 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, switch (expr->expr.op) { case EXPR_VALUE: if (expr->expr.value_type != EXPR_TYPE_INT) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Found constant of type %s where an int was expected\n", expr_value_type_to_string(expr->expr.value_type)); @@ -324,7 +324,7 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, ok = lookup(ctx, lookupPriv, expr->ident.ident, EXPR_TYPE_INT, &u); if (!ok) - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_IDENTIFIER, "Identifier \"%s\" of type int is unknown\n", xkb_atom_text(ctx, expr->ident.ident)); @@ -334,7 +334,7 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, return ok; case EXPR_FIELD_REF: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_EXPRESSION_TYPE, "Default \"%s.%s\" of type int is unknown\n", xkb_atom_text(ctx, expr->field_ref.element), @@ -363,7 +363,7 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, break; case EXPR_DIVIDE: if (r == 0) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_OPERATION, "Cannot divide by zero: %d / %d\n", l, r); return false; @@ -371,7 +371,7 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, *val_rtrn = l / r; break; default: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_OPERATION, "%s of integers not permitted\n", expr_op_type_to_string(expr->expr.op)); @@ -381,13 +381,13 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, return true; case EXPR_ASSIGN: - log_wsgo_with_code(ctx, + log_wsgo(ctx, XKB_ERROR_INVALID_OPERATION, "Assignment operator not implemented yet\n"); break; case EXPR_NOT: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_OPERATION, "The ! operator cannot be applied to an integer\n"); return false; @@ -407,7 +407,7 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr, lookupPriv); default: - log_wsgo_with_code(ctx, + log_wsgo(ctx, XKB_ERROR_UNKNOWN_OPERATOR, "Unknown operator %d in ResolveInteger\n", expr->expr.op); @@ -437,7 +437,7 @@ ExprResolveGroup(struct xkb_context *ctx, const ExprDef *expr, return false; if (result <= 0 || result > XKB_MAX_GROUPS) { - log_err_with_code(ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, + log_err(ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Group index %u is out of range (1..%d)\n", result, XKB_MAX_GROUPS); return false; @@ -460,7 +460,7 @@ ExprResolveLevel(struct xkb_context *ctx, const ExprDef *expr, return false; if (result < 1) { - log_err_with_code(ctx, XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL, + log_err(ctx, XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL, "Shift level %d is out of range\n", result); return false; } @@ -484,7 +484,7 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr, switch (expr->expr.op) { case EXPR_VALUE: if (expr->expr.value_type != EXPR_TYPE_STRING) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Found constant of type %s, expected a string\n", expr_value_type_to_string(expr->expr.value_type)); @@ -495,14 +495,14 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr, return true; case EXPR_IDENT: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_IDENTIFIER, "Identifier \"%s\" of type string not found\n", xkb_atom_text(ctx, expr->ident.ident)); return false; case EXPR_FIELD_REF: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_EXPRESSION_TYPE, "Default \"%s.%s\" of type string not found\n", xkb_atom_text(ctx, expr->field_ref.element), @@ -521,14 +521,14 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr, case EXPR_ACTION_DECL: case EXPR_ACTION_LIST: case EXPR_KEYSYM_LIST: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_SYNTAX, "%s of strings not permitted\n", expr_op_type_to_string(expr->expr.op)); return false; default: - log_wsgo_with_code(ctx, + log_wsgo(ctx, XKB_ERROR_UNKNOWN_OPERATOR, "Unknown operator %d in ResolveString\n", expr->expr.op); @@ -542,7 +542,7 @@ ExprResolveEnum(struct xkb_context *ctx, const ExprDef *expr, unsigned int *val_rtrn, const LookupEntry *values) { if (expr->expr.op != EXPR_IDENT) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Found a %s where an enumerated value was expected\n", expr_op_type_to_string(expr->expr.op)); @@ -551,13 +551,13 @@ ExprResolveEnum(struct xkb_context *ctx, const ExprDef *expr, if (!SimpleLookup(ctx, values, expr->ident.ident, EXPR_TYPE_INT, val_rtrn)) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_IDENTIFIER, "Illegal identifier %s; expected one of:\n", xkb_atom_text(ctx, expr->ident.ident)); while (values && values->name) { - log_err_with_code(ctx, XKB_ERROR_INVALID_IDENTIFIER, "\t%s\n", values->name); + log_err(ctx, XKB_ERROR_INVALID_IDENTIFIER, "\t%s\n", values->name); values++; } return false; @@ -580,7 +580,7 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, switch (expr->expr.op) { case EXPR_VALUE: if (expr->expr.value_type != EXPR_TYPE_INT) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Found constant of type %s where a mask was expected\n", expr_value_type_to_string(expr->expr.value_type)); @@ -593,14 +593,14 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, ok = lookup(ctx, lookupPriv, expr->ident.ident, EXPR_TYPE_INT, val_rtrn); if (!ok) - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_IDENTIFIER, "Identifier \"%s\" of type int is unknown\n", xkb_atom_text(ctx, expr->ident.ident)); return ok; case EXPR_FIELD_REF: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_EXPRESSION_TYPE, "Default \"%s.%s\" of type int is unknown\n", xkb_atom_text(ctx, expr->field_ref.element), @@ -613,7 +613,7 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, case EXPR_ACTION_DECL: if (bogus == NULL) bogus = "function use"; - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Unexpected %s in mask expression; Expression Ignored\n", bogus); @@ -638,7 +638,7 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, break; case EXPR_MULTIPLY: case EXPR_DIVIDE: - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_OPERATION, "Cannot %s masks; Illegal operation ignored\n", (expr->expr.op == EXPR_DIVIDE ? "divide" : "multiply")); @@ -650,7 +650,7 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, return true; case EXPR_ASSIGN: - log_wsgo_with_code(ctx, + log_wsgo(ctx, XKB_ERROR_INVALID_OPERATION, "Assignment operator not implemented yet\n"); break; @@ -668,14 +668,14 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr, case EXPR_NOT: left = expr->unary.child; if (!ExprResolveIntegerLookup(ctx, left, &v, lookup, lookupPriv)) - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_OPERATION, "The %s operator cannot be used with a mask\n", (expr->expr.op == EXPR_NEGATE ? "-" : "!")); return false; default: - log_wsgo_with_code(ctx, + log_wsgo(ctx, XKB_ERROR_UNKNOWN_OPERATOR, "Unknown operator %d in ResolveMask\n", expr->expr.op); @@ -718,7 +718,7 @@ ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr, return false; if (val < XKB_KEYSYM_MIN) { - log_warn_with_code(ctx, XKB_WARNING_UNRECOGNIZED_KEYSYM, + log_warn(ctx, XKB_WARNING_UNRECOGNIZED_KEYSYM, "unrecognized keysym \"-0x%x\" (%d)\n", (unsigned int) -val, val); return false; @@ -731,14 +731,14 @@ ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr, } if (val <= XKB_KEYSYM_MAX) { - log_warn_with_code(ctx, XKB_WARNING_NUMERIC_KEYSYM, + log_warn(ctx, XKB_WARNING_NUMERIC_KEYSYM, "numeric keysym \"0x%x\" (%d)", (unsigned int) val, val); *sym_rtrn = (xkb_keysym_t) val; return true; } - log_warn_with_code(ctx, XKB_WARNING_UNRECOGNIZED_KEYSYM, + log_warn(ctx, XKB_WARNING_UNRECOGNIZED_KEYSYM, "unrecognized keysym \"0x%x\" (%d)\n", (unsigned int) val, val); return false; @@ -754,7 +754,7 @@ ExprResolveMod(struct xkb_context *ctx, const ExprDef *def, xkb_atom_t name; if (def->expr.op != EXPR_IDENT) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Cannot resolve virtual modifier: " "found %s where a virtual modifier name was expected\n", @@ -765,7 +765,7 @@ ExprResolveMod(struct xkb_context *ctx, const ExprDef *def, name = def->ident.ident; ndx = XkbModNameToIndex(mods, name, mod_type); if (ndx == XKB_MOD_INVALID) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_UNDECLARED_VIRTUAL_MODIFIER, "Cannot resolve virtual modifier: " "\"%s\" was not previously declared\n", diff --git a/src/xkbcomp/include.c b/src/xkbcomp/include.c index fc692fb13..d47156eff 100644 --- a/src/xkbcomp/include.c +++ b/src/xkbcomp/include.c @@ -201,29 +201,29 @@ LogIncludePaths(struct xkb_context *ctx) unsigned int i; if (xkb_context_num_include_paths(ctx) > 0) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INCLUDED_FILE_NOT_FOUND, "%d include paths searched:\n", xkb_context_num_include_paths(ctx)); for (i = 0; i < xkb_context_num_include_paths(ctx); i++) - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INCLUDED_FILE_NOT_FOUND, "\t%s\n", xkb_context_include_path_get(ctx, i)); } else { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INCLUDED_FILE_NOT_FOUND, "There are no include paths to search\n"); } if (xkb_context_num_failed_include_paths(ctx) > 0) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INCLUDED_FILE_NOT_FOUND, "%d include paths could not be added:\n", xkb_context_num_failed_include_paths(ctx)); for (i = 0; i < xkb_context_num_failed_include_paths(ctx); i++) - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INCLUDED_FILE_NOT_FOUND, "\t%s\n", xkb_context_failed_include_path_get(ctx, i)); @@ -256,7 +256,7 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name, buf = asprintf_safe("%s/%s/%s", xkb_context_include_path_get(ctx, i), typeDir, name); if (!buf) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_ALLOCATION_ERROR, "Failed to alloc buffer for (%s/%s/%s)\n", xkb_context_include_path_get(ctx, i), typeDir, name); @@ -276,7 +276,7 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name, /* We only print warnings if we can't find the file on the first lookup */ if (*offset == 0) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INCLUDED_FILE_NOT_FOUND, "Couldn't find file \"%s/%s\" in include paths\n", typeDir, name); @@ -306,7 +306,7 @@ ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt, if (xkb_file) { if (xkb_file->file_type != file_type) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_INCLUDED_FILE, "Include file of wrong type (expected %s, got %s); " "Include file \"%s\" ignored\n", @@ -325,12 +325,12 @@ ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt, if (!xkb_file) { if (stmt->map) - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_INCLUDED_FILE, "Couldn't process include statement for '%s(%s)'\n", stmt->file, stmt->map); else - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_INVALID_INCLUDED_FILE, "Couldn't process include statement for '%s'\n", stmt->file); diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c index 41ddb2017..91471ea7f 100644 --- a/src/xkbcomp/keycodes.c +++ b/src/xkbcomp/keycodes.c @@ -99,7 +99,7 @@ AddLedName(KeyNamesInfo *info, enum merge_mode merge, bool same_file, old = FindLedByName(info, new->name, &old_idx); if (old) { if (old_idx == new_idx) { - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Multiple indicators named \"%s\"; " "Identical definitions ignored\n", xkb_atom_text(info->ctx, new->name)); @@ -109,7 +109,7 @@ AddLedName(KeyNamesInfo *info, enum merge_mode merge, bool same_file, if (report) { xkb_led_index_t use = (replace ? new_idx + 1 : old_idx + 1); xkb_led_index_t ignore = (replace ? old_idx + 1 : new_idx + 1); - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Multiple indicators named %s; Using %d, ignoring %d\n", xkb_atom_text(info->ctx, new->name), use, ignore); } @@ -129,7 +129,8 @@ AddLedName(KeyNamesInfo *info, enum merge_mode merge, bool same_file, if (report) { const xkb_atom_t use = (replace ? new->name : old->name); const xkb_atom_t ignore = (replace ? old->name : new->name); - log_warn(info->ctx, "Multiple names for indicator %d; " + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, + "Multiple names for indicator %d; " "Using %s, ignoring %s\n", new_idx + 1, xkb_atom_text(info->ctx, use), xkb_atom_text(info->ctx, ignore)); @@ -200,7 +201,7 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, xkb_atom_t name, if (old_name == name) { if (report) - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Multiple identical key name definitions; " "Later occurrences of \"%s = %d\" ignored\n", lname, kc); @@ -208,14 +209,14 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, xkb_atom_t name, } else if (merge == MERGE_AUGMENT) { if (report) - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Multiple names for keycode %d; " "Using %s, ignoring %s\n", kc, lname, kname); return true; } else { if (report) - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Multiple names for keycode %d; " "Using %s, ignoring %s\n", kc, kname, lname); darray_item(info->key_names, kc) = XKB_ATOM_NONE; @@ -230,7 +231,7 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, xkb_atom_t name, if (merge == MERGE_OVERRIDE) { darray_item(info->key_names, old_kc) = XKB_ATOM_NONE; if (report) - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_CONFLICTING_KEY_NAME, "Key name %s assigned to multiple keys; " "Using %d, ignoring %d\n", kname, kc, old_kc); @@ -380,7 +381,7 @@ HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge) } if (stmt->value < 0 || stmt->value > XKB_KEYCODE_MAX) { - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Illegal keycode %lld: must be between 0..%u; " "Key ignored\n", (long long) stmt->value, XKB_KEYCODE_MAX); return false; @@ -411,7 +412,7 @@ HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge) use = (merge == MERGE_AUGMENT ? old->real : def->real); ignore = (merge == MERGE_AUGMENT ? def->real : old->real); - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_CONFLICTING_KEY_NAME, "Multiple definitions for alias %s; " "Using %s, ignoring %s\n", @@ -442,13 +443,13 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt) return false; if (elem) { - log_err(info->ctx, "Unknown element %s encountered; " + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Unknown element %s encountered; " "Default for field %s ignored\n", elem, field); return false; } if (!istreq(field, "minimum") && !istreq(field, "maximum")) { - log_err(info->ctx, "Unknown field encountered; " + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Unknown field encountered; " "Assignment to field %s ignored\n", field); return false; } @@ -466,7 +467,7 @@ HandleLedNameDef(KeyNamesInfo *info, LedNameDef *def, if (def->ndx < 1 || def->ndx > XKB_MAX_LEDS) { info->errorCount++; - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Illegal indicator index (%d) specified; must be between 1 .. %d; " "Ignored\n", def->ndx, XKB_MAX_LEDS); return false; @@ -511,7 +512,7 @@ HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleLedNameDef(info, (LedNameDef *) stmt, merge); break; default: - log_err(info->ctx, + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Keycode files may define key and indicator names only; " "Ignoring %s\n", stmt_type_to_string(stmt->type)); ok = false; @@ -522,7 +523,8 @@ HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge) info->errorCount++; if (info->errorCount > 10) { - log_err(info->ctx, "Abandoning keycodes file \"%s\"\n", + log_err(info->ctx, XKB_LOG_MESSAGE_NO_ID, + "Abandoning keycodes file \"%s\"\n", file->name); break; } diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c index 087815927..0aaed1f84 100644 --- a/src/xkbcomp/keymap.c +++ b/src/xkbcomp/keymap.c @@ -248,14 +248,15 @@ CompileKeymap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge) XKB_WARNING_UNSUPPORTED_GEOMETRY_SECTION, "Geometry sections are not supported; ignoring\n"); } else { - log_err(ctx, "Cannot define %s in a keymap file\n", + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "Cannot define %s in a keymap file\n", xkb_file_type_to_string(file->file_type)); } continue; } if (files[file->file_type]) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "More than one %s section in keymap file; " "All sections after the first ignored\n", xkb_file_type_to_string(file->file_type)); @@ -274,7 +275,8 @@ CompileKeymap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge) type <= LAST_KEYMAP_FILE_TYPE; type++) { if (files[type] == NULL) { - log_err(ctx, "Required section %s missing from keymap\n", + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "Required section %s missing from keymap\n", xkb_file_type_to_string(type)); ok = false; } @@ -286,12 +288,14 @@ CompileKeymap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge) for (type = FIRST_KEYMAP_FILE_TYPE; type <= LAST_KEYMAP_FILE_TYPE; type++) { - log_dbg(ctx, "Compiling %s \"%s\"\n", + log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, + "Compiling %s \"%s\"\n", xkb_file_type_to_string(type), files[type]->name); ok = compile_file_fns[type](files[type], keymap, merge); if (!ok) { - log_err(ctx, "Failed to compile %s\n", + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "Failed to compile %s\n", xkb_file_type_to_string(type)); return false; } diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c index 8029682aa..f5d9c4960 100644 --- a/src/xkbcomp/rules.c +++ b/src/xkbcomp/rules.c @@ -424,10 +424,14 @@ matcher_include(struct matcher *m, struct scanner *parent_scanner, if (file) { bool ret = read_rules_file(m->ctx, m, include_depth + 1, file, s.buf); if (!ret) - log_err(m->ctx, "No components returned from included XKB rules \"%s\"\n", s.buf); + log_err(m->ctx, XKB_LOG_MESSAGE_NO_ID, + "No components returned from included XKB rules \"%s\"\n", + s.buf); fclose(file); } else { - log_err(m->ctx, "Failed to open included XKB rules \"%s\"\n", s.buf); + log_err(m->ctx, XKB_LOG_MESSAGE_NO_ID, + "Failed to open included XKB rules \"%s\"\n", + s.buf); } } @@ -1087,7 +1091,8 @@ read_rules_file(struct xkb_context *ctx, ret = map_file(file, &string, &size); if (!ret) { - log_err(ctx, "Couldn't read rules file \"%s\": %s\n", + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "Couldn't read rules file \"%s\": %s\n", path, strerror(errno)); goto out; } @@ -1126,7 +1131,8 @@ xkb_components_from_rules(struct xkb_context *ctx, darray_empty(matcher->kccgst[KCCGST_COMPAT]) || /* darray_empty(matcher->kccgst[KCCGST_GEOMETRY]) || */ darray_empty(matcher->kccgst[KCCGST_SYMBOLS])) { - log_err(ctx, "No components returned from XKB rules \"%s\"\n", path); + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "No components returned from XKB rules \"%s\"\n", path); ret = false; goto err_out; } @@ -1139,19 +1145,23 @@ xkb_components_from_rules(struct xkb_context *ctx, mval = &matcher->rmlvo.model; if (!mval->matched && mval->sval.len > 0) - log_err(matcher->ctx, "Unrecognized RMLVO model \"%.*s\" was ignored\n", + log_err(matcher->ctx, XKB_LOG_MESSAGE_NO_ID, + "Unrecognized RMLVO model \"%.*s\" was ignored\n", mval->sval.len, mval->sval.start); darray_foreach(mval, matcher->rmlvo.layouts) if (!mval->matched && mval->sval.len > 0) - log_err(matcher->ctx, "Unrecognized RMLVO layout \"%.*s\" was ignored\n", + log_err(matcher->ctx, XKB_LOG_MESSAGE_NO_ID, + "Unrecognized RMLVO layout \"%.*s\" was ignored\n", mval->sval.len, mval->sval.start); darray_foreach(mval, matcher->rmlvo.variants) if (!mval->matched && mval->sval.len > 0) - log_err(matcher->ctx, "Unrecognized RMLVO variant \"%.*s\" was ignored\n", + log_err(matcher->ctx, XKB_LOG_MESSAGE_NO_ID, + "Unrecognized RMLVO variant \"%.*s\" was ignored\n", mval->sval.len, mval->sval.start); darray_foreach(mval, matcher->rmlvo.options) if (!mval->matched && mval->sval.len > 0) - log_err(matcher->ctx, "Unrecognized RMLVO option \"%.*s\" was ignored\n", + log_err(matcher->ctx, XKB_LOG_MESSAGE_NO_ID, + "Unrecognized RMLVO option \"%.*s\" was ignored\n", mval->sval.len, mval->sval.start); err_out: diff --git a/src/xkbcomp/scanner.c b/src/xkbcomp/scanner.c index e78f10236..e9d503ced 100644 --- a/src/xkbcomp/scanner.c +++ b/src/xkbcomp/scanner.c @@ -205,7 +205,8 @@ XkbParseFile(struct xkb_context *ctx, FILE *file, ok = map_file(file, &string, &size); if (!ok) { - log_err(ctx, "Couldn't read XKB file %s: %s\n", + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, + "Couldn't read XKB file %s: %s\n", file_name, strerror(errno)); return NULL; } diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index 6d31c7c9f..20eebeb20 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -242,7 +242,7 @@ MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber, xkb_atom_t ignore = (clobber ? into->type : from->type); if (report) { - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS, "Multiple definitions for group %d type of key %s; " "Using %s, ignoring %s\n", @@ -288,7 +288,7 @@ MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber, ignore = (clobber ? &intoLevel->action : &fromLevel->action); if (report) { - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_CONFLICTING_KEY_ACTION, "Multiple actions for level %d/group %u on key %s; " "Using %s, ignoring %s\n", @@ -313,7 +313,7 @@ MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber, } else if (!XkbLevelsSameSyms(fromLevel, intoLevel)) { if (report) { - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_CONFLICTING_KEY_SYMBOL, "Multiple symbols for level %d/group %u on key %s; " "Using %s, ignoring %s\n", @@ -414,7 +414,7 @@ MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from, bool same_file) } if (collide) { - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_CONFLICTING_KEY_FIELDS, "Symbol map for key %s redefined; " "Using %s definition for conflicting fields\n", @@ -474,7 +474,7 @@ AddModMapEntry(SymbolsInfo *info, ModMapEntry *new) ignore = (clobber ? old->modifier : new->modifier); if (new->haveSymbol) { - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_CONFLICTING_MODMAP, "Symbol \"%s\" added to modifier map for multiple modifiers; " "Using %s, ignoring %s\n", @@ -482,7 +482,7 @@ AddModMapEntry(SymbolsInfo *info, ModMapEntry *new) ModIndexText(info->ctx, &info->mods, use), ModIndexText(info->ctx, &info->mods, ignore)); } else { - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_CONFLICTING_MODMAP, "Key \"%s\" added to modifier map for multiple modifiers; " "Using %s, ignoring %s\n", @@ -589,7 +589,7 @@ HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *include) if (stmt->modifier) { next_incl.explicit_group = atoi(stmt->modifier) - 1; if (next_incl.explicit_group >= XKB_MAX_GROUPS) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Cannot set explicit group to %d - must be between 1..%d; " "Ignoring group number\n", @@ -638,7 +638,7 @@ GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, } if (i >= XKB_MAX_GROUPS) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Too many groups of %s for key %s (max %u); " "Ignoring %s defined for extra groups\n", @@ -652,7 +652,7 @@ GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, } if (!ExprResolveGroup(info->ctx, arrayNdx, ndx_rtrn)) { - log_err_with_code(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, + log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Illegal group index for %s of key %s\n" "Definition with non-integer array index ignored\n", name, KeyInfoText(info, keyi)); @@ -685,7 +685,7 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, } if (value->expr.op != EXPR_KEYSYM_LIST) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Expected a list of symbols, found %s; " "Ignoring symbols for group %u of %s\n", @@ -695,7 +695,7 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, } if (groupi->defined & GROUP_FIELD_SYMS) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY, "Symbols for key %s, group %u already defined; " "Ignoring duplicate definition\n", @@ -757,7 +757,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, } if (value->expr.op != EXPR_ACTION_LIST) { - log_wsgo(info->ctx, + log_wsgo(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Bad expression type (%d) for action list value; " "Ignoring actions for group %u of %s\n", value->expr.op, ndx, KeyInfoText(info, keyi)); @@ -765,7 +765,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, } if (groupi->defined & GROUP_FIELD_ACTS) { - log_wsgo(info->ctx, + log_wsgo(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Actions for key %s, group %u already defined\n", KeyInfoText(info, keyi), ndx); return false; @@ -785,7 +785,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, union xkb_action *toAct = &darray_item(groupi->levels, i).action; if (!HandleActionDef(info->ctx, info->actions, &info->mods, act, toAct)) - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_INVALID_VALUE, "Illegal action definition for %s; " "Action for group %u/level %u ignored\n", @@ -817,7 +817,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, xkb_atom_t val; if (!ExprResolveString(info->ctx, value, &val)) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_WRONG_FIELD_TYPE, "The type field of a key symbol map must be a string; " "Ignoring illegal type definition\n"); @@ -829,7 +829,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, keyi->defined |= KEY_FIELD_DEFAULT_TYPE; } else if (!ExprResolveGroup(info->ctx, arrayNdx, &ndx)) { - log_err_with_code(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, + log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Illegal group index for type of key %s; " "Definition with non-integer array index ignored\n", KeyInfoText(info, keyi)); @@ -856,7 +856,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, if (!ExprResolveModMask(info->ctx, value, MOD_VIRT, &info->mods, &mask)) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_UNSUPPORTED_MODIFIER_MASK, "Expected a virtual modifier mask, found %s; " "Ignoring virtual modifiers definition for key %s\n", @@ -900,7 +900,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, unsigned int val; if (!ExprResolveEnum(info->ctx, value, &val, repeatEntries)) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_INVALID_VALUE, "Illegal repeat setting for %s; " "Non-boolean repeat setting ignored\n", @@ -916,7 +916,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, bool set; if (!ExprResolveBoolean(info->ctx, value, &set)) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_INVALID_VALUE, "Illegal groupsWrap setting for %s; " "Non-boolean value ignored\n", @@ -932,7 +932,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, bool set; if (!ExprResolveBoolean(info->ctx, value, &set)) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_INVALID_VALUE, "Illegal groupsClamp setting for %s; " "Non-boolean value ignored\n", @@ -948,7 +948,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, xkb_layout_index_t grp; if (!ExprResolveGroup(info->ctx, value, &grp)) { - log_err_with_code(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, + log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Illegal group index for redirect of key %s; " "Definition with non-integer group ignored\n", KeyInfoText(info, keyi)); @@ -960,7 +960,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, keyi->defined |= KEY_FIELD_GROUPINFO; } else { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_UNKNOWN_FIELD, "Unknown field %s in a symbol interpretation; " "Definition ignored\n", @@ -986,14 +986,14 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value) } if (!ExprResolveGroup(info->ctx, arrayNdx, &group)) { - log_err_with_code(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, + log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Illegal index in group name definition; " "Definition with non-integer array index ignored\n"); return false; } if (!ExprResolveString(info->ctx, value, &name)) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Group name must be a string; " "Illegal name for group %d ignored\n", group); @@ -1007,7 +1007,7 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value) group_to_use = info->explicit_group; } else { - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_NON_BASE_GROUP_NAME, "An explicit group was specified for the '%s' map, " "but it provides a name for a group other than Group1 (%d); " @@ -1044,27 +1044,27 @@ HandleGlobalVar(SymbolsInfo *info, VarDef *stmt) } else if (!elem && (istreq(field, "groupswrap") || istreq(field, "wrapgroups"))) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Global \"groupswrap\" not supported; Ignored\n"); ret = true; } else if (!elem && (istreq(field, "groupsclamp") || istreq(field, "clampgroups"))) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Global \"groupsclamp\" not supported; Ignored\n"); ret = true; } else if (!elem && (istreq(field, "groupsredirect") || istreq(field, "redirectgroups"))) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Global \"groupsredirect\" not supported; Ignored\n"); ret = true; } else if (!elem && istreq(field, "allownone")) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Radio groups not supported; " "Ignoring \"allownone\" specification\n"); @@ -1087,7 +1087,7 @@ HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi) for (; def; def = (VarDef *) def->common.next) { if (def->name && def->name->expr.op == EXPR_FIELD_REF) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_WRONG_SCOPE, "Cannot set a global default value from within a key statement; " "Move statements to the global file scope\n"); @@ -1132,7 +1132,7 @@ SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi) } if (warn) { - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_MULTIPLE_GROUPS_AT_ONCE, "For the map %s an explicit group specified, " "but key %s has more than one group defined; " @@ -1198,7 +1198,7 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def) // Handle normal entry ndx = XkbModNameToIndex(&info->mods, def->modifier, MOD_REAL); if (ndx == XKB_MOD_INVALID) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_INVALID_REAL_MODIFIER, "Illegal modifier map definition; " "Ignoring map for non-modifier \"%s\"\n", @@ -1224,7 +1224,7 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def) tmp.u.keySym = sym; } else { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_INVALID_MODMAP_ENTRY, "Modmap entries may contain only key names or keysyms; " "Illegal definition for %s modifier ignored\n", @@ -1263,7 +1263,7 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleModMapDef(info, (ModMapDef *) stmt); break; default: - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_WRONG_STATEMENT_TYPE, "Symbols files may not include other types; " "Ignoring %s\n", stmt_type_to_string(stmt->type)); @@ -1275,7 +1275,7 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge) info->errorCount++; if (info->errorCount > 10) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_INVALID_SYNTAX, "Abandoning symbols file \"%s\"\n", file->name); @@ -1411,7 +1411,7 @@ FindTypeForGroup(struct xkb_keymap *keymap, KeyInfo *keyi, } if (type_name == XKB_ATOM_NONE) { - log_warn_with_code(keymap->ctx, + log_warn(keymap->ctx, XKB_WARNING_CANNOT_INFER_KEY_TYPE, "Couldn't find an automatic type for key '%s' group %d with %lu levels; " "Using the default type\n", @@ -1425,7 +1425,7 @@ FindTypeForGroup(struct xkb_keymap *keymap, KeyInfo *keyi, break; if (i >= keymap->num_types) { - log_warn_with_code(keymap->ctx, + log_warn(keymap->ctx, XKB_WARNING_UNDEFINED_KEY_TYPE, "The type \"%s\" for key '%s' group %d was not previously defined; " "Using the default type\n", @@ -1613,7 +1613,7 @@ CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info) continue; if (key->num_groups < 1) - log_info(info->ctx, + log_info(info->ctx, XKB_LOG_MESSAGE_NO_ID, "No symbols defined for %s\n", KeyNameText(info->ctx, key->name)); } diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c index fe089ae2d..34e10286c 100644 --- a/src/xkbcomp/types.c +++ b/src/xkbcomp/types.c @@ -143,7 +143,7 @@ AddKeyType(KeyTypesInfo *info, KeyTypeInfo *new, bool same_file) if (old) { if (new->merge == MERGE_REPLACE || new->merge == MERGE_OVERRIDE) { if ((same_file && verbosity > 0) || verbosity > 9) { - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS, "Multiple definitions of the %s key type; " "Earlier definition ignored\n", @@ -252,12 +252,12 @@ SetModifiers(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, xkb_mod_mask_t mods; if (arrayNdx) - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "The modifiers field of a key type is not an array; " "Illegal array subscript ignored\n"); if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->mods, &mods)) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_UNSUPPORTED_MODIFIER_MASK, "Key type mask field must be a modifier mask; " "Key type definition ignored\n"); @@ -265,7 +265,7 @@ SetModifiers(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, } if (type->defined & TYPE_FIELD_MASK) { - log_warn(info->ctx, + log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID, "Multiple modifier mask definitions for key type %s; " "Using %s, ignoring %s\n", xkb_atom_text(info->ctx, type->name), @@ -301,7 +301,7 @@ AddMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, old = FindMatchingMapEntry(type, new->mods.mods); if (old) { if (report && old->level != new->level) { - log_warn_with_code(info->ctx, + log_warn(info->ctx, XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY, "Multiple map entries for %s in %s; " "Using %d, ignoring %d\n", @@ -361,7 +361,7 @@ SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, } if (!ExprResolveLevel(info->ctx, value, &entry.level)) { - log_err_with_code(info->ctx, XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL, + log_err(info->ctx, XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL, "Level specifications in a key type must be integer; " "Ignoring malformed level specification\n"); return false; @@ -457,7 +457,7 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->mods, &preserve_mods)) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_UNSUPPORTED_MODIFIER_MASK, "Preserve value in a key type is not a modifier mask; " "Ignoring preserve[%s] in type %s\n", @@ -544,7 +544,7 @@ SetLevelName(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, type, "level name", "integer"); if (!ExprResolveString(info->ctx, value, &level_name)) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_WRONG_FIELD_TYPE, "Non-string name for level %d in key type %s; " "Ignoring illegal level name definition\n", @@ -580,7 +580,7 @@ SetKeyTypeField(KeyTypesInfo *info, KeyTypeInfo *type, type_field = TYPE_FIELD_LEVEL_NAME; ok = SetLevelName(info, type, arrayNdx, value); } else { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_UNKNOWN_FIELD, "Unknown field %s in key type %s; Definition ignored\n", field, TypeTxt(info, type)); @@ -604,7 +604,7 @@ HandleKeyTypeBody(KeyTypesInfo *info, VarDef *def, KeyTypeInfo *type) continue; if (elem && istreq(elem, "type")) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_INVALID_SET_DEFAULT_STATEMENT, "Support for changing the default type has been removed; " "Statement ignored\n"); @@ -660,7 +660,7 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleKeyTypeDef(info, (KeyTypeDef *) stmt, merge); break; case STMT_VAR: - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_WRONG_STATEMENT_TYPE, "Support for changing the default type has been removed; " "Statement ignored\n"); @@ -670,7 +670,7 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleVModDef(info->ctx, &info->mods, (VModDef *) stmt, merge); break; default: - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_WRONG_STATEMENT_TYPE, "Key type files may not include other declarations; " "Ignoring %s\n", stmt_type_to_string(stmt->type)); @@ -682,7 +682,7 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge) info->errorCount++; if (info->errorCount > 10) { - log_err_with_code(info->ctx, + log_err(info->ctx, XKB_ERROR_INVALID_SYNTAX, "Abandoning keytypes file \"%s\"\n", file->name); break; diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c index 0e8ac125f..f348b0ff1 100644 --- a/src/xkbcomp/vmod.c +++ b/src/xkbcomp/vmod.c @@ -48,7 +48,7 @@ HandleVModDef(struct xkb_context *ctx, struct xkb_mod_set *mods, * through modifier_map or some such. */ if (!ExprResolveModMask(ctx, stmt->value, MOD_REAL, mods, &mapping)) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Declaration of %s ignored\n", xkb_atom_text(ctx, stmt->name)); return false; @@ -61,7 +61,7 @@ HandleVModDef(struct xkb_context *ctx, struct xkb_mod_set *mods, xkb_mods_enumerate(i, mod, mods) { if (mod->name == stmt->name) { if (mod->type != MOD_VIRT) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Can't add a virtual modifier named \"%s\"; " "there is already a non-virtual modifier with this name! Ignored\n", xkb_atom_text(ctx, mod->name)); @@ -77,7 +77,7 @@ HandleVModDef(struct xkb_context *ctx, struct xkb_mod_set *mods, use = (merge == MERGE_OVERRIDE ? mapping : mod->mapping); ignore = (merge == MERGE_OVERRIDE ? mod->mapping : mapping); - log_warn(ctx, + log_warn(ctx, XKB_LOG_MESSAGE_NO_ID, "Virtual modifier %s defined multiple times; " "Using %s, ignoring %s\n", xkb_atom_text(ctx, stmt->name), @@ -93,7 +93,7 @@ HandleVModDef(struct xkb_context *ctx, struct xkb_mod_set *mods, } if (mods->num_mods >= XKB_MAX_MODS) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Too many modifiers defined (maximum %d)\n", XKB_MAX_MODS); return false; diff --git a/src/xkbcomp/xkbcomp-priv.h b/src/xkbcomp/xkbcomp-priv.h index 50c07b56a..3de8d8ddd 100644 --- a/src/xkbcomp/xkbcomp-priv.h +++ b/src/xkbcomp/xkbcomp-priv.h @@ -82,7 +82,7 @@ static inline bool ReportNotArray(struct xkb_context *ctx, const char *type, const char *field, const char *name) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE, "The %s %s field is not an array; " "Ignoring illegal assignment in %s\n", @@ -94,7 +94,7 @@ static inline bool ReportShouldBeArray(struct xkb_context *ctx, const char *type, const char *field, const char *name) { - log_err_with_code(ctx, + log_err(ctx, XKB_ERROR_EXPECTED_ARRAY_ENTRY, "Missing subscript for %s %s; " "Ignoring illegal assignment in %s\n", @@ -106,7 +106,8 @@ static inline bool ReportBadType(struct xkb_context *ctx, xkb_message_code_t code, const char *type, const char *field, const char *name, const char *wanted) { - log_err_with_code(ctx, code, "The %s %s field must be a %s; " + log_err(ctx, code, + "The %s %s field must be a %s; " "Ignoring illegal assignment in %s\n", type, field, wanted, name); return false; @@ -116,7 +117,7 @@ static inline bool ReportBadField(struct xkb_context *ctx, const char *type, const char *field, const char *name) { - log_err(ctx, + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "Unknown %s field %s in %s; " "Ignoring assignment to unknown field in %s\n", type, field, name, name); diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c index 48547c978..c3ff76d23 100644 --- a/src/xkbcomp/xkbcomp.c +++ b/src/xkbcomp/xkbcomp.c @@ -36,14 +36,14 @@ static bool compile_keymap_file(struct xkb_keymap *keymap, XkbFile *file) { if (file->file_type != FILE_TYPE_KEYMAP) { - log_err(keymap->ctx, + log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, "Cannot compile a %s file alone into a keymap\n", xkb_file_type_to_string(file->file_type)); return false; } if (!CompileKeymap(file, keymap, MERGE_OVERRIDE)) { - log_err(keymap->ctx, + log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, "Failed to compile keymap\n"); return false; } @@ -59,7 +59,7 @@ text_v1_keymap_new_from_names(struct xkb_keymap *keymap, struct xkb_component_names kccgst; XkbFile *file; - log_dbg(keymap->ctx, + log_dbg(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, "Compiling from RMLVO: rules '%s', model '%s', layout '%s', " "variant '%s', options '%s'\n", rmlvo->rules, rmlvo->model, rmlvo->layout, rmlvo->variant, @@ -67,7 +67,7 @@ text_v1_keymap_new_from_names(struct xkb_keymap *keymap, ok = xkb_components_from_rules(keymap->ctx, rmlvo, &kccgst); if (!ok) { - log_err(keymap->ctx, + log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, "Couldn't look up rules '%s', model '%s', layout '%s', " "variant '%s', options '%s'\n", rmlvo->rules, rmlvo->model, rmlvo->layout, rmlvo->variant, @@ -75,7 +75,7 @@ text_v1_keymap_new_from_names(struct xkb_keymap *keymap, return false; } - log_dbg(keymap->ctx, + log_dbg(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, "Compiling from KcCGST: keycodes '%s', types '%s', " "compat '%s', symbols '%s'\n", kccgst.keycodes, kccgst.types, kccgst.compat, kccgst.symbols); @@ -88,7 +88,7 @@ text_v1_keymap_new_from_names(struct xkb_keymap *keymap, free(kccgst.symbols); if (!file) { - log_err(keymap->ctx, + log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, "Failed to generate parsed XKB file from components\n"); return false; } @@ -107,7 +107,8 @@ text_v1_keymap_new_from_string(struct xkb_keymap *keymap, xkb_file = XkbParseString(keymap->ctx, string, len, "(input string)", NULL); if (!xkb_file) { - log_err(keymap->ctx, "Failed to parse input xkb string\n"); + log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, + "Failed to parse input xkb string\n"); return false; } @@ -124,7 +125,8 @@ text_v1_keymap_new_from_file(struct xkb_keymap *keymap, FILE *file) xkb_file = XkbParseFile(keymap->ctx, file, "(unknown file)", NULL); if (!xkb_file) { - log_err(keymap->ctx, "Failed to parse input xkb file\n"); + log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID, + "Failed to parse input xkb file\n"); return false; } diff --git a/test/log.c b/test/log.c index 14e4845ff..0bdb6927c 100644 --- a/test/log.c +++ b/test/log.c @@ -86,25 +86,25 @@ main(void) xkb_context_set_user_data(ctx, &log_string); xkb_context_set_log_fn(ctx, log_fn); - log_warn(ctx, "first warning: %d\n", 87); - log_info(ctx, "first info\n"); - log_dbg(ctx, "first debug: %s\n", "hello"); - log_err(ctx, "first error: %lu\n", 115415UL); + log_warn(ctx, XKB_LOG_MESSAGE_NO_ID, "first warning: %d\n", 87); + log_info(ctx, XKB_LOG_MESSAGE_NO_ID, "first info\n"); + log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, "first debug: %s\n", "hello"); + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "first error: %lu\n", 115415UL); log_vrb(ctx, 5, XKB_LOG_MESSAGE_NO_ID, "first verbose 5\n"); xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG); - log_warn(ctx, "second warning: %d\n", 87); - log_dbg(ctx, "second debug: %s %s\n", "hello", "world"); - log_info(ctx, "second info\n"); - log_err(ctx, "second error: %lu\n", 115415UL); + log_warn(ctx, XKB_LOG_MESSAGE_NO_ID, "second warning: %d\n", 87); + log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, "second debug: %s %s\n", "hello", "world"); + log_info(ctx, XKB_LOG_MESSAGE_NO_ID, "second info\n"); + log_err(ctx, XKB_ERROR_MALFORMED_NUMBER_LITERAL, "second error: %lu\n", 115415UL); log_vrb(ctx, 6, XKB_LOG_MESSAGE_NO_ID, "second verbose 6\n"); xkb_context_set_log_verbosity(ctx, 0); xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL); - log_warn(ctx, "third warning: %d\n", 87); - log_dbg(ctx, "third debug: %s %s\n", "hello", "world"); - log_info(ctx, "third info\n"); - log_err(ctx, "third error: %lu\n", 115415UL); + log_warn(ctx, XKB_LOG_MESSAGE_NO_ID, "third warning: %d\n", 87); + log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, "third debug: %s %s\n", "hello", "world"); + log_info(ctx, XKB_LOG_MESSAGE_NO_ID, "third info\n"); + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "third error: %lu\n", 115415UL); log_vrb(ctx, 0, XKB_LOG_MESSAGE_NO_ID, "third verbose 0\n"); printf("%s", log_string.item); @@ -112,11 +112,11 @@ main(void) assert(streq(log_string.item, "warning: first warning: 87\n" "error: first error: 115415\n" - "warning: [XKB-000] first verbose 5\n" + "warning: first verbose 5\n" "warning: second warning: 87\n" "debug: second debug: hello world\n" "info: second info\n" - "error: second error: 115415\n")); + "error: [XKB-034] second error: 115415\n")); xkb_context_unref(ctx); darray_free(log_string);