diff options
author | Daniel Stone <daniel@fooishbar.org> | 2008-05-07 23:11:31 +0300 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2008-05-07 23:11:31 +0300 |
commit | 104048501f37b139d4113562ef1711978cc76018 (patch) | |
tree | 2e8ab4f50a3d25872ccf20ebe6d4ab2727e666b9 /xkb | |
parent | b1145a6b428db2037c79ffb36116e7183f30829f (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.
(cherry picked from commit cf20df39cc78203d17b99223908af388ecbf7d0e)
Conflicts:
xkb/ddxLoad.c
Diffstat (limited to 'xkb')
-rw-r--r-- | xkb/ddxLoad.c | 69 |
1 files changed, 34 insertions, 35 deletions
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index d79ae7a7b..ea9c3ff2b 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -385,24 +385,20 @@ char tmpname[PATH_MAX]; xfree (buf); return True; } -#ifdef DEBUG else - ErrorF("Error compiling keymap (%s)\n",keymap); -#endif + LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap); #ifdef WIN32 /* remove the temporary file */ unlink(tmpname); #endif } -#ifdef DEBUG else { #ifndef WIN32 - ErrorF("Could not invoke keymap compiler\n"); + LogMessage(X_ERROR, "XKB: Could not invoke xkbcomp\n"); #else - ErrorF("Could not open file %s\n", tmpname); + LogMessage(X_ERROR, "Could not open file %s\n", tmpname); #endif } -#endif if (nameRtrn) nameRtrn[0]= '\0'; if (buf != NULL) @@ -477,17 +473,14 @@ unsigned missing; return 0; } else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) { -#ifdef NOISY - ErrorF("Couldn't compile keymap file\n"); -#endif + LogMessage(X_ERROR, "Couldn't compile keymap file %s\n", + names->keymap); return 0; } } else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need, - nameRtrn,nameRtrnLen)){ -#ifdef NOISY - ErrorF("Couldn't compile keymap file\n"); -#endif + nameRtrn,nameRtrnLen)){ + LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n"); return 0; } file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX); @@ -502,11 +495,9 @@ unsigned missing; (void) unlink (fileName); return 0; } -#ifdef DEBUG - else if (xkbDebugFlags) { - ErrorF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined); + else { + DebugF("XKB: Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined); } -#endif fclose(file); (void) unlink (fileName); return (need|want)&(~missing); @@ -525,32 +516,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; +} |