diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
commit | d5f194ce780c95821a855aca3c19426576d28ae0 (patch) | |
tree | d45f461b19f9118ad2bb1f440a7a08973ad18832 /src/nvim/path.c | |
parent | c5d770d311841ea5230426cc4c868e8db27300a8 (diff) | |
parent | 44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff) | |
download | rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.gz rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.bz2 rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.zip |
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r-- | src/nvim/path.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c index 80890acb7d..3df77571a1 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -8,6 +8,7 @@ #include "auto/config.h" #include "nvim/ascii_defs.h" +#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" #include "nvim/eval.h" @@ -1874,11 +1875,12 @@ void path_fix_case(char *name) return; } + size_t taillen = strlen(tail); const char *entry; while ((entry = os_scandir_next(&dir))) { // Only accept names that differ in case and are the same byte // length. TODO: accept different length name. - if (STRICMP(tail, entry) == 0 && strlen(tail) == strlen(entry)) { + if (STRICMP(tail, entry) == 0 && taillen == strlen(entry)) { char newname[MAXPATHL + 1]; // Verify the inode is equal. @@ -2071,7 +2073,7 @@ char *path_shorten_fname(char *full_path, char *dir_name) /// @param[in] flags Flags passed to expand_wildcards(). /// /// @returns OK when *file is set to allocated array of matches -/// and *num_file(can be zero) to the number of matches. +/// and *num_file (can be zero) to the number of matches. /// If FAIL is returned, *num_file and *file are either /// unchanged or *num_file is set to 0 and *file is set /// to NULL or points to "". @@ -2269,14 +2271,12 @@ int append_path(char *path, const char *to_append, size_t max_len) // Combine the path segments, separated by a slash. if (current_length > 0 && !vim_ispathsep_nocolon(path[current_length - 1])) { - current_length += 1; // Count the trailing slash. - // +1 for the NUL at the end. - if (current_length + 1 > max_len) { - return FAIL; + if (current_length + STRLEN_LITERAL(PATHSEPSTR) + 1 > max_len) { + return FAIL; // No space for trailing slash. } - - xstrlcat(path, PATHSEPSTR, max_len); + xstrlcpy(path + current_length, PATHSEPSTR, max_len - current_length); + current_length += STRLEN_LITERAL(PATHSEPSTR); } // +1 for the NUL at the end. @@ -2284,7 +2284,7 @@ int append_path(char *path, const char *to_append, size_t max_len) return FAIL; } - xstrlcat(path, to_append, max_len); + xstrlcpy(path + current_length, to_append, max_len - current_length); return OK; } |