diff options
-rw-r--r-- | src/nvim/os/fs.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 2621d9da74..91ed639a1b 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -301,7 +301,7 @@ static bool is_executable(const char *name, char_u **abspath) /// - if the file extension is in $PATHEXT and `name` is executable /// - if the result of any $PATHEXT extension appended to `name` is executable static bool is_executable_ext(char *name, char_u **abspath) - FUNC_ATTR_NONNULL_ARG(1, 2) + FUNC_ATTR_NONNULL_ARG(1) { const bool is_unix_shell = strstr((char *)path_tail(p_sh), "sh") != NULL; char *nameext = strrchr(name, '.'); @@ -325,17 +325,15 @@ static bool is_executable_ext(char *name, char_u **abspath) const char *ext_end = xstrchrnul(ext, ENV_SEPCHAR); size_t ext_len = (size_t)(ext_end - ext); - STRLCPY(buf_end, ext, ext_len + 1); - bool in_pathext = nameext_len == ext_len - && 0 == mb_strnicmp((char_u *)nameext, (char_u *)ext, ext_len); - - if (((in_pathext || is_unix_shell) && is_executable(name, abspath)) - || is_executable(os_buf, abspath)) { - return true; - } + if (ext_len != 0) { + STRLCPY(buf_end, ext, ext_len + 1); + bool in_pathext = nameext_len == ext_len + && 0 == mb_strnicmp((char_u *)nameext, (char_u *)ext, ext_len); - if (*ext_end != ENV_SEPCHAR) { - break; + if (((in_pathext || is_unix_shell) && is_executable(name, abspath)) + || is_executable(os_buf, abspath)) { + return true; + } } ext = ext_end; } |