From: Adam Roben Date: Tue, 5 Jun 2012 19:40:33 +0000 (-0400) Subject: Make non-.exe externals work again X-Git-Url: https://repo.or.cz/w/git/dscho.git/commitdiff_plain/9b934226028168eaf9d8162087e229b184db9ea7 Make non-.exe externals work again 7ebac8cb94f3a06d3fbdde469414a1443ca45510 made launching of .exe externals work when installed in Unicode paths. But it broke launching of non-.exe externals, no matter where they were installed. We now correctly maintain the UTF-8 and UTF-16 paths in tandem in lookup_prog. This fixes t5526, among others. Signed-off-by: Adam Roben --- diff --git a/compat/mingw.c b/compat/mingw.c index 6f6158f6f0..e6d15a4d40 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -989,11 +989,12 @@ static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_on if (!isexe && _waccess(wpath, F_OK) == 0) return xstrdup(path); - path[strlen(path)-4] = '\0'; + wpath[wcslen(wpath)-4] = '\0'; if ((!exe_only || isexe) && _waccess(wpath, F_OK) == 0) { - - if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) + if (!(GetFileAttributesW(wpath) & FILE_ATTRIBUTE_DIRECTORY)) { + path[strlen(path)-4] = '\0'; return xstrdup(path); + } } return NULL; }