From 944a39e9d17b9cd88985553cfb304df6e99a7720 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 21 Nov 2009 02:05:56 +0000 Subject: Use execvp() rather than execv(), to look up Doom binary in the PATH if necessary. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1735 --- setup/execute.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setup/execute.c') diff --git a/setup/execute.c b/setup/execute.c index fb9885fa..8c4580e8 100644 --- a/setup/execute.c +++ b/setup/execute.c @@ -301,7 +301,7 @@ static int ExecuteCommand(const char *program, const char *arg) argv[1] = arg; argv[2] = NULL; - execv(argv[0], (char **) argv); + execvp(argv[0], (char **) argv); exit(-1); } -- cgit v1.2.3 From 4f540343e63eb60f209ce7e8ce26db10c16ab4e6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 14 Dec 2009 20:57:04 +0000 Subject: Use GetModuleFileNameW to get the (Unicode) path to the Doom executable. This hopefully fixes problems with Unicode directory names. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1747 --- setup/execute.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'setup/execute.c') diff --git a/setup/execute.c b/setup/execute.c index 8c4580e8..59f561be 100644 --- a/setup/execute.c +++ b/setup/execute.c @@ -185,29 +185,38 @@ static void ConcatWCString(wchar_t *buf, const char *value) static wchar_t *BuildCommandLine(const char *program, const char *arg) { + wchar_t exe_path[MAX_PATH]; wchar_t *result; - char *sep; + wchar_t *sep; + + // Get the path to this .exe file. + + GetModuleFileNameW(NULL, exe_path, MAX_PATH); - result = calloc(strlen(myargv[0]) + strlen(program) + strlen(arg) + 6, + // Allocate buffer to contain result string. + + result = calloc(wcslen(exe_path) + strlen(program) + strlen(arg) + 6, sizeof(wchar_t)); wcscpy(result, L"\""); - sep = strrchr(myargv[0], DIR_SEPARATOR); + // Copy the path part of the filename (including ending \) + // into the result buffer: + + sep = wcsrchr(exe_path, DIR_SEPARATOR); if (sep != NULL) { - ConcatWCString(result, myargv[0]); - - // Cut off the string after the last directory separator, - // before appending the actual program. - - result[sep - myargv[0] + 2] = '\0'; - + wcsncpy(result + 1, exe_path, sep - exe_path + 1); + result[sep - exe_path + 2] = '\0'; } + // Concatenate the name of the program: + ConcatWCString(result, program); + // End of program name, start of argument: + wcscat(result, L"\" \""); ConcatWCString(result, arg); -- cgit v1.2.3 From e81acc7df5f7939d93c6724e422f823111dfeba0 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 18 Dec 2009 21:10:35 +0000 Subject: Make ExecuteCommand() under Unix return a failure when the executable cannot be executed. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1748 --- setup/execute.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setup/execute.c') diff --git a/setup/execute.c b/setup/execute.c index 59f561be..8e753f60 100644 --- a/setup/execute.c +++ b/setup/execute.c @@ -312,7 +312,7 @@ static int ExecuteCommand(const char *program, const char *arg) execvp(argv[0], (char **) argv); - exit(-1); + exit(0x80); } else { @@ -321,7 +321,7 @@ static int ExecuteCommand(const char *program, const char *arg) waitpid(childpid, &result, 0); - if (WIFEXITED(result)) + if (WIFEXITED(result) && WEXITSTATUS(result) != 0x80) { return WEXITSTATUS(result); } -- cgit v1.2.3