From b0a565de930df8dc4fd8f00cbfe3a585391cb05a Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 28 Feb 2018 16:48:33 +0000 Subject: win32: don't add extensions to filenames ending with a dot A filename ending with a dot is a signal to spawnve not to try adding extensions but to use the name unmodified. The add_win32_extension function should follow the same rule. --- include/mingw.h | 3 ++- win32/mingw.c | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/mingw.h b/include/mingw.h index c116e551a..b0e1fa53c 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -474,8 +474,9 @@ char **env_setenv(char **env, const char *name); const char *get_busybox_exec_path(void); void init_winsock(void); -int has_exe_suffix(const char *p); int has_bat_suffix(const char *p); +int has_exe_suffix(const char *p); +int has_exe_suffix_or_dot(const char *name); char *add_win32_extension(const char *p); int has_exec_format(const char *name); diff --git a/win32/mingw.c b/win32/mingw.c index 22e62232d..260bc82d7 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -1033,6 +1033,12 @@ int has_exe_suffix(const char *name) return has_win_suffix(name, 0); } +int has_exe_suffix_or_dot(const char *name) +{ + int len = strlen(name); + return (len > 0 && name[len-1] == '.') || has_win_suffix(name, 0); +} + /* check if path can be made into an executable by adding a suffix; * return an allocated string containing the path if it can; * return NULL if not. @@ -1044,7 +1050,7 @@ char *add_win32_extension(const char *p) char *path; int i, len; - if (has_exe_suffix(p)) { + if (has_exe_suffix_or_dot(p)) { return NULL; } -- cgit v1.2.3-55-g6feb