Commit 59e03bf5f2b6d14d2f73f1de46e2b72028200819

Daniel Stone 2012-03-09T16:54:47

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>

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;