summaryrefslogtreecommitdiff
path: root/xkb
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2008-05-07 22:24:19 +0300
committerDaniel Stone <daniel@fooishbar.org>2008-05-07 22:56:03 +0300
commitcf20df39cc78203d17b99223908af388ecbf7d0e (patch)
treed3a2af886501dc9ebaf41fe4d781b36278595433 /xkb
parent641a5f955b7b3ae04eeb6bc45fb30b0b531898e4 (diff)
XKB: Actually explain keymap failures
When something went wrong building a keymap, try to explain to the user what it actually was, instead of the dreaded 'Failed to load XKB keymap' catch-all.
Diffstat (limited to 'xkb')
-rw-r--r--xkb/ddxLoad.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index d80ce62b8..1fb097987 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -274,7 +274,7 @@ char tmpname[PATH_MAX];
return True;
}
else
- DebugF("Error compiling keymap (%s)\n",keymap);
+ LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap);
#ifdef WIN32
/* remove the temporary file */
unlink(tmpname);
@@ -282,9 +282,9 @@ char tmpname[PATH_MAX];
}
else {
#ifndef WIN32
- DebugF("Could not invoke keymap compiler\n");
+ LogMessage(X_ERROR, "XKB: Could not invoke xkbcomp\n");
#else
- DebugF("Could not open file %s\n", tmpname);
+ LogMessage(X_ERROR, "Could not open file %s\n", tmpname);
#endif
}
if (nameRtrn)
@@ -350,11 +350,13 @@ unsigned missing;
if ((names->keycodes==NULL)&&(names->types==NULL)&&
(names->compat==NULL)&&(names->symbols==NULL)&&
(names->geometry==NULL)) {
+ LogMessage(X_ERROR, "XKB: No components provided for device %s\n",
+ keybd->name);
return 0;
}
else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need,
nameRtrn,nameRtrnLen)){
- DebugF("Couldn't compile keymap file\n");
+ LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n");
return 0;
}
file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX);
@@ -369,7 +371,7 @@ unsigned missing;
(void) unlink (fileName);
return 0;
}
- else if (xkbDebugFlags) {
+ else {
DebugF("Loaded XKB keymap %s, defined=0x%x\n",fileName,(*xkbRtrn)->defined);
}
fclose(file);
@@ -390,32 +392,40 @@ XkbRF_RulesPtr rules;
if (!rules_name)
return False;
- if (XkbBaseDirectory==NULL) {
- if (strlen(rules_name)+7 > PATH_MAX)
- return False;
- sprintf(buf,"rules/%s",rules_name);
- }
- else {
- if (strlen(XkbBaseDirectory)+strlen(rules_name)+8 > PATH_MAX)
- return False;
- sprintf(buf,"%s/rules/%s",XkbBaseDirectory,rules_name);
+
+ if (strlen(XkbBaseDirectory) + strlen(rules_name) + 8 > PATH_MAX) {
+ LogMessage(X_ERROR, "XKB: Rules name is too long\n");
+ return False;
}
- if ((file= fopen(buf,"r"))==NULL)
+ sprintf(buf,"%s/rules/%s", XkbBaseDirectory, rules_name);
+
+ file = fopen(buf, "r");
+ if (!file) {
+ LogMessage(X_ERROR, "XKB: Couldn't open rules file %s\n", file);
return False;
- if ((rules= XkbRF_Create(0,0))==NULL) {
+ }
+
+ rules = XkbRF_Create(0, 0);
+ if (!rules) {
+ LogMessage(X_ERROR, "XKB: Couldn't create rules struct\n");
fclose(file);
return False;
}
- if (!XkbRF_LoadRules(file,rules)) {
+
+ if (!XkbRF_LoadRules(file, rules)) {
+ LogMessage(X_ERROR, "XKB: Couldn't parse rules file %s\n", rules_name);
fclose(file);
XkbRF_Free(rules,True);
return False;
}
- bzero((char *)names,sizeof(XkbComponentNamesRec));
- complete= XkbRF_GetComponents(rules,defs,names);
+
+ memset(names, 0, sizeof(*names));
+ complete = XkbRF_GetComponents(rules,defs,names);
fclose(file);
- XkbRF_Free(rules,True);
- return complete;
-}
+ XkbRF_Free(rules, True);
+ if (!complete)
+ LogMessage(X_ERROR, "XKB: Rules returned no components\n");
+ return complete;
+}