diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-07-21 16:44:15 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-07-21 20:51:37 +0200 |
commit | 1fde79eedf0091af1b04ce3d91045672cb3c233e (patch) | |
tree | 365f8c6e17b593e5350bdd927ecf237363724de4 | |
parent | b08dc3ec195feb4ab69c898ab816c104d2aa1aa1 (diff) | |
download | rneovim-1fde79eedf0091af1b04ce3d91045672cb3c233e.tar.gz rneovim-1fde79eedf0091af1b04ce3d91045672cb3c233e.tar.bz2 rneovim-1fde79eedf0091af1b04ce3d91045672cb3c233e.zip |
os_can_exe: remove char_u
-rw-r--r-- | src/nvim/eval.c | 14 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 24 | ||||
-rw-r--r-- | src/nvim/os_unix.c | 2 | ||||
-rw-r--r-- | src/nvim/path.c | 12 |
4 files changed, 26 insertions, 26 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f27e73a7a2..1bddafbee3 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8466,9 +8466,9 @@ static void f_executable(typval_T *argvars, typval_T *rettv, FunPtr fptr) // Check in $PATH and also check directly if there is a directory name rettv->vval.v_number = ( - os_can_exe((const char_u *)name, NULL, true) + os_can_exe(name, NULL, true) || (gettail_dir(name) != name - && os_can_exe((const char_u *)name, NULL, false))); + && os_can_exe(name, NULL, false))); } typedef struct { @@ -8573,12 +8573,12 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_exepath(typval_T *argvars, typval_T *rettv, FunPtr fptr) { const char *arg = tv_get_string(&argvars[0]); - char_u *path = NULL; + char *path = NULL; - (void)os_can_exe((const char_u *)arg, &path, true); + (void)os_can_exe(arg, &path, true); rettv->v_type = VAR_STRING; - rettv->vval.v_string = path; + rettv->vval.v_string = (char_u *)path; } /// Find a window: When using a Window ID in any tab page, when using a number @@ -12109,8 +12109,8 @@ static char **tv_to_argv(typval_T *cmd_tv, const char **cmd, bool *executable) } const char *arg0 = tv_get_string_chk(TV_LIST_ITEM_TV(tv_list_first(argl))); - char_u *exe_resolved = NULL; - if (!arg0 || !os_can_exe((const char_u *)arg0, &exe_resolved, true)) { + char *exe_resolved = NULL; + if (!arg0 || !os_can_exe(arg0, &exe_resolved, true)) { if (arg0 && executable) { *executable = false; } diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index f34592d107..57a864b7ec 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -239,10 +239,10 @@ int os_exepath(char *buffer, size_t *size) /// - is absolute. /// /// @return `false` otherwise. -bool os_can_exe(const char_u *name, char_u **abspath, bool use_path) +bool os_can_exe(const char *name, char **abspath, bool use_path) FUNC_ATTR_NONNULL_ARG(1) { - bool no_path = !use_path || path_is_absolute(name); + bool no_path = !use_path || path_is_absolute((char_u *)name); // If the filename is "qualified" (relative or absolute) do not check $PATH. #ifdef WIN32 no_path |= (name[0] == '.' @@ -255,11 +255,11 @@ bool os_can_exe(const char_u *name, char_u **abspath, bool use_path) if (no_path) { #ifdef WIN32 - if (is_executable_ext((char *)name, abspath)) { + if (is_executable_ext(name, abspath)) { #else // Must have path separator, cannot execute files in the current directory. - if ((const char_u *)gettail_dir((const char *)name) != name - && is_executable((char *)name, abspath)) { + if (gettail_dir(name) != name + && is_executable(name, abspath)) { #endif return true; } else { @@ -274,10 +274,10 @@ bool os_can_exe(const char_u *name, char_u **abspath, bool use_path) /// /// @param[in] name Filename to check. /// @param[out,allocated] abspath Returns full exe path, if not NULL. -static bool is_executable(const char *name, char_u **abspath) +static bool is_executable(const char *name, char **abspath) FUNC_ATTR_NONNULL_ARG(1) { - int32_t mode = os_getperm((const char *)name); + int32_t mode = os_getperm(name); if (mode < 0) { return false; @@ -295,7 +295,7 @@ static bool is_executable(const char *name, char_u **abspath) const bool ok = (r == 0); #endif if (ok && abspath != NULL) { - *abspath = save_abs_path((char_u *)name); + *abspath = save_abs_path(name); } return ok; } @@ -304,7 +304,7 @@ static bool is_executable(const char *name, char_u **abspath) /// Checks if file `name` is executable under any of these conditions: /// - extension is in $PATHEXT and `name` is executable /// - 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 **abspath) FUNC_ATTR_NONNULL_ARG(1) { const bool is_unix_shell = strstr((char *)path_tail(p_sh), "sh") != NULL; @@ -356,7 +356,7 @@ static bool is_executable_ext(char *name, char_u **abspath) /// @param[out] abspath Returns resolved executable path, if not NULL. /// /// @return `true` if `name` is an executable inside `$PATH`. -static bool is_executable_in_path(const char_u *name, char_u **abspath) +static bool is_executable_in_path(const char *name, char **abspath) FUNC_ATTR_NONNULL_ARG(1) { const char *path_env = os_getenv("PATH"); @@ -373,7 +373,7 @@ static bool is_executable_in_path(const char_u *name, char_u **abspath) char *path = xstrdup(path_env); #endif - size_t buf_len = STRLEN(name) + strlen(path) + 2; + size_t buf_len = strlen(name) + strlen(path) + 2; char *buf = xmalloc(buf_len); // Walk through all entries in $PATH to check if "name" exists there and @@ -385,7 +385,7 @@ static bool is_executable_in_path(const char_u *name, char_u **abspath) // Combine the $PATH segment with `name`. STRLCPY(buf, p, e - p + 1); - append_path(buf, (char *)name, buf_len); + append_path(buf, name, buf_len); #ifdef WIN32 if (is_executable_ext(buf, abspath)) { diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index fa9f721ee2..ded575529f 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -535,7 +535,7 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, // Skip files that are not executable if we check for that. if (!dir && (flags & EW_EXEC) - && !os_can_exe((*file)[i], NULL, !(flags & EW_SHELLCMD))) { + && !os_can_exe((char *)(*file)[i], NULL, !(flags & EW_SHELLCMD))) { continue; } diff --git a/src/nvim/path.c b/src/nvim/path.c index b43a172991..75a26d88c1 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -453,13 +453,13 @@ char *FullName_save(const char *fname, bool force) /// Saves the absolute path. /// @param name An absolute or relative path. /// @return The absolute path of `name`. -char_u *save_abs_path(const char_u *name) +char *save_abs_path(const char *name) FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL { - if (!path_is_absolute(name)) { - return (char_u *)FullName_save((char *)name, true); + if (!path_is_absolute((char_u *)name)) { + return FullName_save(name, true); } - return vim_strsave((char_u *) name); + return (char *)vim_strsave((char_u *)name); } /// Checks if a path has a wildcard character including '~', unless at the end. @@ -1401,7 +1401,7 @@ void addfile( // If the file isn't executable, may not add it. Do accept directories. // When invoked from expand_shellcmd() do not use $PATH. if (!isdir && (flags & EW_EXEC) - && !os_can_exe(f, NULL, !(flags & EW_SHELLCMD))) { + && !os_can_exe((char *)f, NULL, !(flags & EW_SHELLCMD))) { return; } @@ -2306,7 +2306,7 @@ void path_guess_exepath(const char *argv0, char *buf, size_t bufsize) xstrlcpy((char *)NameBuff, dir, dir_len + 1); xstrlcat((char *)NameBuff, PATHSEPSTR, sizeof(NameBuff)); xstrlcat((char *)NameBuff, argv0, sizeof(NameBuff)); - if (os_can_exe(NameBuff, NULL, false)) { + if (os_can_exe((char *)NameBuff, NULL, false)) { xstrlcpy(buf, (char *)NameBuff, bufsize); return; } |