Commit babae389354e67b121a48894a82a62acc40b30ec

Dan Nicholson 2009-04-08T17:54:55

Change CompileKeymapFromRules to take XkbRMLVOSet Let's use a nice interface now that it's available from XKBrulescommon.h.

diff --git a/include/X11/extensions/XKBcommon.h b/include/X11/extensions/XKBcommon.h
index 39679f3..ebac78e 100644
--- a/include/X11/extensions/XKBcommon.h
+++ b/include/X11/extensions/XKBcommon.h
@@ -126,7 +126,7 @@ typedef struct _XkbcDesc {
 _XFUNCPROTOBEGIN
 
 extern XkbcDescPtr
-XkbcCompileKeymapFromRules(const char *rules, XkbRF_VarDefsPtr defs);
+XkbcCompileKeymapFromRules(XkbRMLVOSet *rmlvo);
 
 extern XkbcDescPtr
 XkbcCompileKeymapFromComponents(XkbComponentNamesPtr ktcsg);
diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c
index 05cb7ad..a9db543 100644
--- a/src/xkbcomp/xkbcomp.c
+++ b/src/xkbcomp/xkbcomp.c
@@ -111,29 +111,35 @@ fail:
 }
 
 XkbcDescPtr
-XkbcCompileKeymapFromRules(const char *rules, XkbRF_VarDefsPtr defs)
+XkbcCompileKeymapFromRules(XkbRMLVOSet *rmlvo)
 {
     char rulesPath[PATH_MAX];
     int pathlen;
+    XkbRF_VarDefsRec defs;
     XkbComponentNamesPtr names;
     XkbcDescPtr xkb;
 
-    if (ISEMPTY(rules) || !defs || ISEMPTY(defs->layout)) {
+    if (!rmlvo || ISEMPTY(rmlvo->rules) || ISEMPTY(rmlvo->layout)) {
         ERROR("rules and layout required to generate XKB keymap\n");
         return NULL;
     }
 
     pathlen = snprintf(rulesPath, sizeof(rulesPath),
-                       DFLT_XKB_CONFIG_ROOT "/rules/%s", rules);
+                       DFLT_XKB_CONFIG_ROOT "/rules/%s", rmlvo->rules);
     if (pathlen >= sizeof(rulesPath)) {
         ERROR("XKB rules path truncated\n");
         return NULL;
     }
 
-    names = XkbComponentsFromRules(rulesPath, defs);
+    defs.model = rmlvo->model;
+    defs.layout = rmlvo->layout;
+    defs.variant = rmlvo->variant;
+    defs.options = rmlvo->options;
+
+    names = XkbComponentsFromRules(rulesPath, &defs);
     if (!names) {
         ERROR("failed to generate XKB components from rules \"%s\"\n",
-              rules);
+              rmlvo->rules);
         return NULL;
     }
 
diff --git a/test/rulescomp.c b/test/rulescomp.c
index 01aecc7..4dbe353 100644
--- a/test/rulescomp.c
+++ b/test/rulescomp.c
@@ -34,8 +34,7 @@ authorization from the authors.
 
 int main(int argc, char *argv[])
 {
-    char *rules = NULL;
-    XkbRF_VarDefsRec defs;
+    XkbRMLVOSet rmlvo;
     XkbcDescPtr xkb;
 
     /* Require rmlvo */
@@ -46,16 +45,16 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
-    rules = argv[1];
-    defs.model = argv[2];
-    defs.layout = argv[3];
-    defs.variant = argv[4];
-    defs.options = argv[5];
+    rmlvo.rules = argv[1];
+    rmlvo.model = argv[2];
+    rmlvo.layout = argv[3];
+    rmlvo.variant = argv[4];
+    rmlvo.options = argv[5];
 
     uSetErrorFile(NULL);
     XkbcInitAtoms();
 
-    xkb = XkbcCompileKeymapFromRules(rules, &defs);
+    xkb = XkbcCompileKeymapFromRules(&rmlvo);
 
     if (!xkb) {
         fprintf(stderr, "Failed to compile keymap\n");