mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 07:58:35 +00:00
fs.c: fix is_executable_ext()
- Corresponds to the case where pathext contains a zero-length extension. - Remove unnecessary break statements. - Fix function attributes.
This commit is contained in:
@@ -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 file extension is in $PATHEXT and `name` is executable
|
||||||
/// - if the result of any $PATHEXT extension appended to `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)
|
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;
|
const bool is_unix_shell = strstr((char *)path_tail(p_sh), "sh") != NULL;
|
||||||
char *nameext = strrchr(name, '.');
|
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);
|
const char *ext_end = xstrchrnul(ext, ENV_SEPCHAR);
|
||||||
size_t ext_len = (size_t)(ext_end - ext);
|
size_t ext_len = (size_t)(ext_end - ext);
|
||||||
STRLCPY(buf_end, ext, ext_len + 1);
|
if (ext_len != 0) {
|
||||||
bool in_pathext = nameext_len == ext_len
|
STRLCPY(buf_end, ext, ext_len + 1);
|
||||||
&& 0 == mb_strnicmp((char_u *)nameext, (char_u *)ext, ext_len);
|
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))
|
if (((in_pathext || is_unix_shell) && is_executable(name, abspath))
|
||||||
|| is_executable(os_buf, abspath)) {
|
|| is_executable(os_buf, abspath)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*ext_end != ENV_SEPCHAR) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
ext = ext_end;
|
ext = ext_end;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user