diff options
author | erw7 <erw7.github@gmail.com> | 2019-01-20 14:12:00 +0900 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-04-01 03:13:11 +0200 |
commit | 70ac7c876bac2151da467b08244c7f98a5d8bf61 (patch) | |
tree | 3121f069c4144442220c8c32ffdd79dfe66c1ba1 | |
parent | 3be5aa1a34f63f4e5e2b384098de2020a4c5b3bc (diff) | |
download | rneovim-70ac7c876bac2151da467b08244c7f98a5d8bf61.tar.gz rneovim-70ac7c876bac2151da467b08244c7f98a5d8bf61.tar.bz2 rneovim-70ac7c876bac2151da467b08244c7f98a5d8bf61.zip |
cleanup: PATHEXT function
-rw-r--r-- | src/nvim/os/fs.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index b75607b7b1..628ef9321f 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -254,10 +254,7 @@ bool os_can_exe(const char_u *name, char_u **abspath, bool use_path) if (no_path) { #ifdef WIN32 - const char *pathext = os_getenv("PATHEXT"); - if (!pathext) { - pathext = ".com;.exe;.bat;.cmd"; - } + const char *pathext = get_pathext(); if ((is_extension_executable((char *)name) && is_executable((char *)name, abspath)) || is_executable_ext((char *)name, pathext, abspath)) { @@ -276,6 +273,15 @@ bool os_can_exe(const char_u *name, char_u **abspath, bool use_path) } #ifdef WIN32 +static const char *get_pathext(void) +{ + const char *pathext = os_getenv("PATHEXT"); + if (!pathext) { + pathext = ".com;.exe;.bat;.cmd"; + } + return pathext; +} + /// Returns true if extension of `name` is executable file exteinsion. static bool is_extension_executable(const char *name) FUNC_ATTR_NONNULL_ALL @@ -296,10 +302,7 @@ static bool is_extension_executable(const char *name) return true; } - const char *pathext = os_getenv("PATHEXT"); - if (!pathext) { - pathext = ".com;.exe;.bat;.cmd"; - } + const char *pathext = get_pathext(); const char *ext_pos = name + STRLEN(name) - 1; while (name != ext_pos) { if (*ext_pos == '\\' || *ext_pos == '/') { @@ -424,10 +427,7 @@ static bool is_executable_in_path(const char_u *name, char_u **abspath) size_t buf_len = STRLEN(name) + strlen(path) + 2; #ifdef WIN32 - const char *pathext = os_getenv("PATHEXT"); - if (!pathext) { - pathext = ".com;.exe;.bat;.cmd"; - } + const char *pathext = get_pathext(); buf_len += strlen(pathext); #endif |