Allow NULL rmlvo for xkb_keymap_new_from_names Previously we allowed you to pass a names struct with five NULL members, but not just pass NULL for the struct itself. This was pretty dumb. :( Signed-off-by: Daniel Stone <daniel@fooishbar.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/test/common.c b/test/common.c
index 2ed23cf..2ea2e5b 100644
--- a/test/common.c
+++ b/test/common.c
@@ -259,14 +259,18 @@ test_compile_rules(struct xkb_context *context, const char *rules,
{
struct xkb_keymap *keymap;
struct xkb_rule_names rmlvo = {
- .rules = rules,
- .model = model,
- .layout = layout,
- .variant = variant,
- .options = options
+ .rules = isempty(rules) ? NULL : rules,
+ .model = isempty(model) ? NULL : model,
+ .layout = isempty(layout) ? NULL : layout,
+ .variant = isempty(variant) ? NULL : variant,
+ .options = isempty(options) ? NULL : options
};
- keymap = xkb_keymap_new_from_names(context, &rmlvo, 0);
+ if (!rules && !model && !layout && !variant && !options)
+ keymap = xkb_keymap_new_from_names(context, NULL, 0);
+ else
+ keymap = xkb_keymap_new_from_names(context, &rmlvo, 0);
+
if (!keymap) {
fprintf(stderr,
"Failed to compile RMLVO: '%s', '%s', '%s', '%s', '%s'\n",
diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h
index cdc021b..ad758b8 100644
--- a/xkbcommon/xkbcommon.h
+++ b/xkbcommon/xkbcommon.h
@@ -681,7 +681,9 @@ enum xkb_keymap_compile_flags {
* keymaps.
*
* @param context The context in which to create the keymap.
- * @param names The RMLVO names to use.
+ * @param names The RMLVO names to use. In xkbcommon versions prior
+ * to 0.2.1, this field must be non-NULL. In later
+ * versions, passing NULL will use the default keymap.
* @param flags Optional flags for the keymap, or 0.
*
* @returns A keymap compiled according to the RMLVO names, or NULL if