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.
(cherry picked from commit cf20df39cc
)
Conflicts:
xkb/ddxLoad.c
This commit is contained in:
parent
b1145a6b42
commit
104048501f
|
@ -385,24 +385,20 @@ char tmpname[PATH_MAX];
|
||||||
xfree (buf);
|
xfree (buf);
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
|
||||||
else
|
else
|
||||||
ErrorF("Error compiling keymap (%s)\n",keymap);
|
LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap);
|
||||||
#endif
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
/* remove the temporary file */
|
/* remove the temporary file */
|
||||||
unlink(tmpname);
|
unlink(tmpname);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
|
||||||
else {
|
else {
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
ErrorF("Could not invoke keymap compiler\n");
|
LogMessage(X_ERROR, "XKB: Could not invoke xkbcomp\n");
|
||||||
#else
|
#else
|
||||||
ErrorF("Could not open file %s\n", tmpname);
|
LogMessage(X_ERROR, "Could not open file %s\n", tmpname);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (nameRtrn)
|
if (nameRtrn)
|
||||||
nameRtrn[0]= '\0';
|
nameRtrn[0]= '\0';
|
||||||
if (buf != NULL)
|
if (buf != NULL)
|
||||||
|
@ -477,17 +473,14 @@ unsigned missing;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) {
|
else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) {
|
||||||
#ifdef NOISY
|
LogMessage(X_ERROR, "Couldn't compile keymap file %s\n",
|
||||||
ErrorF("Couldn't compile keymap file\n");
|
names->keymap);
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need,
|
else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need,
|
||||||
nameRtrn,nameRtrnLen)){
|
nameRtrn,nameRtrnLen)){
|
||||||
#ifdef NOISY
|
LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n");
|
||||||
ErrorF("Couldn't compile keymap file\n");
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX);
|
file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX);
|
||||||
|
@ -502,11 +495,9 @@ unsigned missing;
|
||||||
(void) unlink (fileName);
|
(void) unlink (fileName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
else {
|
||||||
else if (xkbDebugFlags) {
|
DebugF("XKB: Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined);
|
||||||
ErrorF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
(void) unlink (fileName);
|
(void) unlink (fileName);
|
||||||
return (need|want)&(~missing);
|
return (need|want)&(~missing);
|
||||||
|
@ -525,32 +516,40 @@ XkbRF_RulesPtr rules;
|
||||||
|
|
||||||
if (!rules_name)
|
if (!rules_name)
|
||||||
return False;
|
return False;
|
||||||
if (XkbBaseDirectory==NULL) {
|
|
||||||
if (strlen(rules_name)+7 > PATH_MAX)
|
if (strlen(XkbBaseDirectory) + strlen(rules_name) + 8 > PATH_MAX) {
|
||||||
return False;
|
LogMessage(X_ERROR, "XKB: Rules name is too long\n");
|
||||||
sprintf(buf,"rules/%s",rules_name);
|
return False;
|
||||||
}
|
}
|
||||||
else {
|
sprintf(buf,"%s/rules/%s", XkbBaseDirectory, rules_name);
|
||||||
if (strlen(XkbBaseDirectory)+strlen(rules_name)+8 > PATH_MAX)
|
|
||||||
return False;
|
file = fopen(buf, "r");
|
||||||
sprintf(buf,"%s/rules/%s",XkbBaseDirectory,rules_name);
|
if (!file) {
|
||||||
}
|
LogMessage(X_ERROR, "XKB: Couldn't open rules file %s\n", file);
|
||||||
if ((file= fopen(buf,"r"))==NULL)
|
|
||||||
return False;
|
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);
|
fclose(file);
|
||||||
return False;
|
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);
|
fclose(file);
|
||||||
XkbRF_Free(rules,True);
|
XkbRF_Free(rules,True);
|
||||||
return False;
|
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);
|
fclose(file);
|
||||||
XkbRF_Free(rules,True);
|
XkbRF_Free(rules, True);
|
||||||
|
|
||||||
|
if (!complete)
|
||||||
|
LogMessage(X_ERROR, "XKB: Rules returned no components\n");
|
||||||
|
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user