summaryrefslogtreecommitdiff
path: root/xkb/ddxLoad.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2008-11-25 14:12:26 -0800
committerAlan Coopersmith <alan.coopersmith@sun.com>2008-11-25 15:51:17 -0800
commitd5ad296869c38ab30136b5a293a0125b76aad994 (patch)
tree9fd5632cb4292d2e6f1ad951bc51a43d1bc94dc4 /xkb/ddxLoad.c
parent2538fc0d893a150e978355d281750f0a989728a7 (diff)
Remove duplication from code paths in XkbDDXCompileKeymapByNames
Diffstat (limited to 'xkb/ddxLoad.c')
-rw-r--r--xkb/ddxLoad.c76
1 files changed, 42 insertions, 34 deletions
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 80da96317..4d5dfb685 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -186,53 +186,61 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
char * nameRtrn,
int nameRtrnLen)
{
-FILE * out;
-char *buf = NULL, keymap[PATH_MAX],xkm_output_dir[PATH_MAX];
+ FILE * out;
+ char *buf = NULL, keymap[PATH_MAX], xkm_output_dir[PATH_MAX];
+
+ const char *emptystring = "";
+ const char *xkbbasedirflag = emptystring;
+ const char *xkbbindir = emptystring;
+ const char *xkbbindirsep = emptystring;
#ifdef WIN32
-char tmpname[PATH_MAX];
-#endif
+ /* WIN32 has no popen. The input must be stored in a file which is
+ used as input for xkbcomp. xkbcomp does not read from stdin. */
+ char tmpname[PATH_MAX];
+ const char *xkmfile = tmpname;
+#else
+ const char *xkmfile = "-";
+#endif
snprintf(keymap, sizeof(keymap), "server-%s", display);
XkbEnsureSafeMapName(keymap);
OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+
#ifdef WIN32
strcpy(tmpname, Win32TempDir());
strcat(tmpname, "\\xkb_XXXXXX");
(void) mktemp(tmpname);
#endif
- if (XkbBaseDirectory!=NULL) {
-#ifndef WIN32
- char *xkmfile = "-";
-#else
- /* WIN32 has no popen. The input must be stored in a file which is used as input
- for xkbcomp. xkbcomp does not read from stdin. */
- char *xkmfile = tmpname;
-#endif
- char *xkbbasedir = XkbBaseDirectory;
- char *xkbbindir = XkbBinDirectory;
-
- buf = Xprintf(
- "\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"",
- xkbbindir,
- ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
- xkbbasedir, xkmfile,
- PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,
- xkm_output_dir,keymap);
+
+ if (XkbBaseDirectory != NULL) {
+ xkbbasedirflag = Xprintf("\"-R%s\"", XkbBaseDirectory);
}
- else {
-#ifndef WIN32
- char *xkmfile = "-";
-#else
- char *xkmfile = tmpname;
-#endif
- buf = Xprintf(
- "xkbcomp -w %d -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"",
- ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
- xkmfile,
- PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,
- xkm_output_dir,keymap);
+
+ if (XkbBinDirectory != NULL) {
+ int ld = strlen(XkbBinDirectory);
+ int lps = strlen(PATHSEPARATOR);
+
+ xkbbindir = XkbBinDirectory;
+
+ if ((ld >= lps) &&
+ (strcmp(xkbbindir + ld - lps, PATHSEPARATOR) != 0)) {
+ xkbbindirsep = PATHSEPARATOR;
+ }
+ }
+
+ buf = Xprintf("\"%s%sxkbcomp\" -w %d %s -xkm \"%s\" "
+ "-em1 %s -emp %s -eml %s \"%s%s.xkm\"",
+ xkbbindir, xkbbindirsep,
+ ( (xkbDebugFlags < 2) ? 1 :
+ ((xkbDebugFlags > 10) ? 10 : (int)xkbDebugFlags) ),
+ xkbbasedirflag, xkmfile,
+ PRE_ERROR_MSG, ERROR_PREFIX, POST_ERROR_MSG1,
+ xkm_output_dir, keymap);
+
+ if (xkbbasedirflag != emptystring) {
+ xfree(xkbbasedirflag);
}
#ifndef WIN32