Use compile_keymap in xkb_compile_keymap_from_components We already had this exact function sitting right next to us, so use it rather than open-coding. 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c
index e462b29..5630ea5 100644
--- a/src/xkbcomp/xkbcomp.c
+++ b/src/xkbcomp/xkbcomp.c
@@ -187,48 +187,6 @@ XkbChooseMap(XkbFile *file, const char *name)
return map;
}
-struct xkb_desc *
-xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
-{
- XkbFile *file, *mapToUse;
- struct xkb_desc * xkb = NULL;
-
- uSetErrorFile(NULL);
-
- if (!ktcsg || ISEMPTY(ktcsg->keycodes)) {
- ERROR("keycodes required to generate XKB keymap\n");
- goto fail;
- }
-
- if (!(file = XkbKeymapFileFromComponents(ktcsg))) {
- ERROR("failed to generate parsed XKB file from components\n");
- goto fail;
- }
-
- /* Find map to use */
- if (!(mapToUse = XkbChooseMap(file, NULL)))
- goto unwind_file;
-
- /* Compile the keyboard */
- if (!(xkb = XkbcAllocKeyboard())) {
- ERROR("could not allocate keyboard description\n");
- goto unwind_file;
- }
-
- if (!CompileKeymap(mapToUse, xkb, MergeReplace)) {
- ERROR("failed to compile keymap\n");
- XkbcFreeKeyboard(xkb);
- xkb = NULL;
- }
-
-unwind_file:
- FreeXKBFile(file);
- free(scanFile);
- XkbFreeIncludePath();
-fail:
- return xkb;
-}
-
static struct xkb_desc *
compile_keymap(XkbFile *file, const char *mapName)
{
@@ -269,6 +227,24 @@ unwind_file:
}
struct xkb_desc *
+xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
+{
+ XkbFile *file;
+
+ if (!ktcsg || ISEMPTY(ktcsg->keycodes)) {
+ ERROR("keycodes required to generate XKB keymap\n");
+ return NULL;
+ }
+
+ if (!(file = XkbKeymapFileFromComponents(ktcsg))) {
+ ERROR("failed to generate parsed XKB file from components\n");
+ return NULL;
+ }
+
+ return compile_keymap(file, NULL);
+}
+
+struct xkb_desc *
xkb_compile_keymap_from_string(const char *string, const char *mapName)
{
XkbFile *file;