From e6bc551e3451efe4fcbb55475d6d0ff53fcc9807 Mon Sep 17 00:00:00 2001 From: Alexander Gottwald Date: Mon, 15 Nov 2004 18:13:41 +0000 Subject: [PATCH] Use CreateProcess instead of system() to spawn xkbcomp on windows. system() can not handle spaces in the path component. Quoted all filenames on the commandline. --- xkb/ddxLoad.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index f346afd78..f0b942322 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -72,6 +72,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define POST_ERROR_MSG2 "\"End of messages from xkbcomp\"" #ifdef WIN32 + +#include static const char* Win32TempDir() { @@ -82,6 +84,38 @@ Win32TempDir() else return "/tmp"; } + +static int +Win32System(const char *cmdline) +{ + STARTUPINFO si; + PROCESS_INFORMATION pi; + DWORD dwExitCode; + char *cmd = xstrdup(cmdline); + + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + + if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) + { + xfree(cmd); + return -1; + } + // Wait until child process exits. + WaitForSingleObject( pi.hProcess, INFINITE ); + + GetExitCodeProcess( pi.hProcess, &dwExitCode); + + // Close process and thread handles. + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); + xfree(cmd); + + return dwExitCode; +} +#undef System +#define System(x) Win32System(x) #endif static void @@ -284,12 +318,10 @@ int i; #endif #else sprintf(buf, - "%s/xkbcomp -w %d -R%s -xkm - -em1 %s -emp %s -eml %s \"%s%s.xkm\" < %s", + "\"%s\\xkbcomp\" -w %d \"-R%s\" -xkm \"%s\" \"%s%s.xkm\"", XkbBaseDirectory, ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), - XkbBaseDirectory, - PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1, - xkm_output_dir,keymap,tmpname); + XkbBaseDirectory, tmpname, xkm_output_dir,keymap); #endif } else {