diff options
author | erw7 <erw7.github@gmail.com> | 2019-04-02 05:08:40 +0900 |
---|---|---|
committer | erw7 <erw7.github@gmail.com> | 2019-04-02 05:08:40 +0900 |
commit | 70a0a12b5397b8b787a3196e9196f5fdbf979cf6 (patch) | |
tree | c8c613284db4396c6d183308c8ec28a7ee50ecb9 | |
parent | a062d307fb79a36488641c0815813297efa614d0 (diff) | |
download | rneovim-70a0a12b5397b8b787a3196e9196f5fdbf979cf6.tar.gz rneovim-70a0a12b5397b8b787a3196e9196f5fdbf979cf6.tar.bz2 rneovim-70a0a12b5397b8b787a3196e9196f5fdbf979cf6.zip |
fs.c: fix is_executable_ext()
- Corresponds to the case where pathext contains a zero-length
extension.
- Remove unnecessary break statements.
- Fix function attributes.
-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; } |