From c42f193bb437af69a9990bafcf336a8a920462e1 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Tue, 5 Jun 2012 15:40:33 -0400 Subject: [PATCH] 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 --- compat/mingw.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 5c1d41fc48..2bdd4859b6 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1008,11 +1008,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; }