diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:29 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:29 -0800 |
commit | 302e3218b7d487539ec305bf23881a6ee7d5be99 (patch) | |
tree | bf1adafe552a17b3b78522048bb7c24787696dd3 /script.c | |
parent | c7d035ae1a729232579a0fe41ed5affa131d3623 (diff) | |
download | scm-302e3218b7d487539ec305bf23881a6ee7d5be99.tar.gz scm-302e3218b7d487539ec305bf23881a6ee7d5be99.zip |
Import Upstream version 5e1upstream/5e1
Diffstat (limited to 'script.c')
-rw-r--r-- | script.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -60,6 +60,11 @@ # endif /* def __sgi__ */ #endif /* def __SVR4 */ +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN +# include <windows.h> /* GetModuleFileName */ +#endif + /* Concatentate str2 onto str1 at position n and return concatenated string if file exists; 0 otherwise. */ @@ -167,7 +172,22 @@ char *find_impl_file(exec_path, generic_name, initname, sep) char *sepptr = strrchr(exec_path, sep[0]); char *extptr = exec_path + strlen(exec_path); char *path = 0; - /* fprintf(stderr, "dld_find_e %s\n", exec_path); fflush(stderr); */ + +#ifdef _WIN32 + char exec_buf[MAX_PATH]; + HMODULE mod = GetModuleHandle(0); /* Returns module handle to current executable. */ + + if (mod) { + GetModuleFileName(mod, exec_buf, sizeof(exec_buf)); + exec_path = exec_buf; + } +#endif + + /*fprintf(stderr, "dld_find_e %s\n", exec_path); fflush(stderr);*/ + + sepptr = strrchr(exec_path, sep[0]); + extptr = exec_path + strlen(exec_path); + if (sepptr) { long sepind = sepptr - exec_path + 1L; |