Blame SOURCES/0003-xkb-Split-out-code-to-start-and-finish-xkbcomp.patch

70130e
From 04122fce2aac2185efc9a0e6d6e4363e73990658 Mon Sep 17 00:00:00 2001
70130e
From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= <krh@bitplanet.net>
70130e
Date: Tue, 9 Apr 2013 17:11:03 -0400
70130e
Subject: [PATCH 03/39] xkb: Split out code to start and finish xkbcomp
70130e
70130e
Using the context struct from previous commit, we can now split out
70130e
code to start xkbcomp and to finish and clean up after it.
70130e
70130e
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
70130e
---
70130e
 xkb/ddxLoad.c | 39 ++++++++++++++++++++++++++++-----------
70130e
 1 file changed, 28 insertions(+), 11 deletions(-)
70130e
70130e
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
70130e
index 5da3a35..001ff46 100644
70130e
--- a/xkb/ddxLoad.c
70130e
+++ b/xkb/ddxLoad.c
70130e
@@ -99,10 +99,7 @@ typedef struct XkbCompContext {
70130e
 } XkbCompContextRec, *XkbCompContextPtr;
70130e
 
70130e
 static Bool
70130e
-XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
70130e
-                           XkbComponentNamesPtr names,
70130e
-                           unsigned want,
70130e
-                           unsigned need, XkbCompContextPtr ctx)
70130e
+StartXkbComp(XkbCompContextPtr ctx)
70130e
 {
70130e
     char xkm_output_dir[PATH_MAX];
70130e
 
70130e
@@ -168,14 +165,15 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
70130e
     ctx->out = fopen(ctx->tmpname, "w");
70130e
 #endif
70130e
 
70130e
+    return ctx->out != NULL;
70130e
+}
70130e
+
70130e
+static Bool
70130e
+FinishXkbComp(XkbCompContextPtr ctx)
70130e
+{
70130e
+    if (!ctx->buf)
70130e
+	return FALSE;
70130e
     if (ctx->out != NULL) {
70130e
-#ifdef DEBUG
70130e
-        if (xkbDebugFlags) {
70130e
-            ErrorF("[xkb] XkbDDXCompileKeymapByNames compiling keymap:\n");
70130e
-            XkbWriteXKBKeymapForNames(stderr, names, xkb, want, need);
70130e
-        }
70130e
-#endif
70130e
-        XkbWriteXKBKeymapForNames(ctx->out, names, xkb, want, need);
70130e
 #ifndef WIN32
70130e
         if (Pclose(ctx->out) == 0)
70130e
 #else
70130e
@@ -209,6 +207,25 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
70130e
     return FALSE;
70130e
 }
70130e
 
70130e
+static Bool
70130e
+XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
70130e
+                           XkbComponentNamesPtr names,
70130e
+                           unsigned want,
70130e
+                           unsigned need, XkbCompContextPtr ctx)
70130e
+{
70130e
+    if (StartXkbComp(ctx)) {
70130e
+#ifdef DEBUG
70130e
+        if (xkbDebugFlags) {
70130e
+            ErrorF("[xkb] XkbDDXCompileKeymapByNames compiling keymap:\n");
70130e
+            XkbWriteXKBKeymapForNames(stderr, names, xkb, want, need);
70130e
+        }
70130e
+#endif
70130e
+        XkbWriteXKBKeymapForNames(ctx->out, names, xkb, want, need);
70130e
+    }
70130e
+
70130e
+    return FinishXkbComp(ctx);
70130e
+}
70130e
+
70130e
 static FILE *
70130e
 XkbDDXOpenConfigFile(char *mapName, char *fileNameRtrn, int fileNameRtrnLen)
70130e
 {
70130e
-- 
70130e
1.8.3.1
70130e