diff options
Diffstat (limited to 'src/nvim/file_search.c')
-rw-r--r-- | src/nvim/file_search.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 5c5839cb08..d0280b3571 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -288,7 +288,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i && rel_fname != NULL) { size_t len = (size_t)(path_tail(rel_fname) - rel_fname); - if (!vim_isAbsName((char_u *)rel_fname) && len + 1 < MAXPATHL) { + if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) { // Make the start dir an absolute path name. xstrlcpy(ff_expand_buffer, rel_fname, len + 1); search_ctx->ffsc_start_dir = FullName_save(ff_expand_buffer, false); @@ -298,7 +298,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i if (*++path != NUL) { path++; } - } else if (*path == NUL || !vim_isAbsName((char_u *)path)) { + } else if (*path == NUL || !vim_isAbsName(path)) { #ifdef BACKSLASH_IN_FILENAME // "c:dir" needs "c:" to be expanded, otherwise use current dir if (*path != NUL && path[1] == ':') { @@ -347,7 +347,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i } size_t dircount = 1; - search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *)); + search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char *)); do { char *helper; @@ -355,7 +355,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i helper = walker; ptr = xrealloc(search_ctx->ffsc_stopdirs_v, - (dircount + 1) * sizeof(char_u *)); + (dircount + 1) * sizeof(char *)); search_ctx->ffsc_stopdirs_v = ptr; walker = vim_strchr(walker, ';'); if (walker) { @@ -447,11 +447,11 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i add_pathsep(ff_expand_buffer); { size_t eb_len = strlen(ff_expand_buffer); - char_u *buf = xmalloc(eb_len + strlen(search_ctx->ffsc_fix_path) + 1); + char *buf = xmalloc(eb_len + strlen(search_ctx->ffsc_fix_path) + 1); STRCPY(buf, ff_expand_buffer); STRCPY(buf + eb_len, search_ctx->ffsc_fix_path); - if (os_isdir((char *)buf)) { + if (os_isdir(buf)) { STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path); add_pathsep(ff_expand_buffer); } else { @@ -504,9 +504,9 @@ error_return: } /// @return the stopdir string. Check that ';' is not escaped. -char_u *vim_findfile_stopdir(char_u *buf) +char_u *vim_findfile_stopdir(char *buf) { - char_u *r_ptr = buf; + char_u *r_ptr = (char_u *)buf; while (*r_ptr != NUL && *r_ptr != ';') { if (r_ptr[0] == '\\' && r_ptr[1] == ';') { @@ -555,7 +555,7 @@ char_u *vim_findfile(void *search_ctx_arg) { char *file_path; char *rest_of_wildcards; - char_u *path_end = NULL; + char *path_end = NULL; ff_stack_T *stackp = NULL; size_t len; char *p; @@ -574,7 +574,7 @@ char_u *vim_findfile(void *search_ctx_arg) // store the end of the start dir -- needed for upward search if (search_ctx->ffsc_start_dir != NULL) { - path_end = (char_u *)&search_ctx->ffsc_start_dir[strlen(search_ctx->ffsc_start_dir)]; + path_end = &search_ctx->ffsc_start_dir[strlen(search_ctx->ffsc_start_dir)]; } // upward search loop @@ -654,7 +654,7 @@ char_u *vim_findfile(void *search_ctx_arg) dirptrs[1] = NULL; // if we have a start dir copy it in - if (!vim_isAbsName((char_u *)stackp->ffs_fix_path) + if (!vim_isAbsName(stackp->ffs_fix_path) && search_ctx->ffsc_start_dir) { if (strlen(search_ctx->ffsc_start_dir) + 1 >= MAXPATHL) { ff_free_stack_element(stackp); @@ -813,7 +813,7 @@ char_u *vim_findfile(void *search_ctx_arg) ff_push(search_ctx, stackp); if (!path_with_url(file_path)) { - simplify_filename((char_u *)file_path); + simplify_filename(file_path); } if (os_dirname(ff_expand_buffer, MAXPATHL) == OK) { p = path_shorten_fname(file_path, ff_expand_buffer); @@ -886,16 +886,16 @@ char_u *vim_findfile(void *search_ctx_arg) // is the last starting directory in the stop list? if (ff_path_in_stoplist(search_ctx->ffsc_start_dir, - (int)(path_end - (char_u *)search_ctx->ffsc_start_dir), + (int)(path_end - search_ctx->ffsc_start_dir), search_ctx->ffsc_stopdirs_v) == true) { break; } // cut of last dir - while (path_end > (char_u *)search_ctx->ffsc_start_dir && vim_ispathsep(*path_end)) { + while (path_end > search_ctx->ffsc_start_dir && vim_ispathsep(*path_end)) { path_end--; } - while (path_end > (char_u *)search_ctx->ffsc_start_dir && !vim_ispathsep(path_end[-1])) { + while (path_end > search_ctx->ffsc_start_dir && !vim_ispathsep(path_end[-1])) { path_end--; } *path_end = 0; @@ -1025,7 +1025,7 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char *filename, /// - char by char comparison is OK /// - the only differences are in the counters behind a '**', so /// '**\20' is equal to '**\24' -static bool ff_wc_equal(char_u *s1, char_u *s2) +static bool ff_wc_equal(char *s1, char *s2) { int i, j; int c1 = NUL; @@ -1042,8 +1042,8 @@ static bool ff_wc_equal(char_u *s1, char_u *s2) } for (i = 0, j = 0; s1[i] != NUL && s2[j] != NUL;) { - c1 = utf_ptr2char((char *)s1 + i); - c2 = utf_ptr2char((char *)s2 + j); + c1 = utf_ptr2char(s1 + i); + c2 = utf_ptr2char(s2 + j); if ((p_fic ? mb_tolower(c1) != mb_tolower(c2) : c1 != c2) && (prev1 != '*' || prev2 != '*')) { @@ -1052,8 +1052,8 @@ static bool ff_wc_equal(char_u *s1, char_u *s2) prev2 = prev1; prev1 = c1; - i += utfc_ptr2len((char *)s1 + i); - j += utfc_ptr2len((char *)s2 + j); + i += utfc_ptr2len(s1 + i); + j += utfc_ptr2len(s2 + j); } return s1[i] == s2[j]; } @@ -1086,7 +1086,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char *fname, char *wc_p || (!url && vp->file_id_valid && os_fileid_equal(&(vp->file_id), &file_id))) { // are the wildcard parts equal - if (ff_wc_equal((char_u *)vp->ffv_wc_path, (char_u *)wc_path)) { + if (ff_wc_equal(vp->ffv_wc_path, wc_path)) { // already visited return FAIL; } @@ -1287,13 +1287,13 @@ static int ff_path_in_stoplist(char *path, int path_len, char **stopdirs_v) /// @param rel_fname file name searching relative to /// /// @return an allocated string for the file name. NULL for error. -char_u *find_file_in_path(char_u *ptr, size_t len, int options, int first, char_u *rel_fname) +char_u *find_file_in_path(char *ptr, size_t len, int options, int first, char *rel_fname) { - return (char_u *)find_file_in_path_option((char *)ptr, len, options, first, + return (char_u *)find_file_in_path_option(ptr, len, options, first, (*curbuf->b_p_path == NUL ? (char *)p_path : curbuf->b_p_path), - FINDFILE_BOTH, (char *)rel_fname, curbuf->b_p_sua); + FINDFILE_BOTH, rel_fname, curbuf->b_p_sua); } static char *ff_file_to_find = NULL; @@ -1379,7 +1379,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch || (ff_file_to_find[1] == '.' && (ff_file_to_find[2] == NUL || vim_ispathsep(ff_file_to_find[2]))))); - if (vim_isAbsName((char_u *)ff_file_to_find) + if (vim_isAbsName(ff_file_to_find) // "..", "../path", "." and "./path": don't use the path_option || rel_to_curdir #if defined(MSWIN) @@ -1453,7 +1453,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch did_findfile_init = false; } else { - char_u *r_ptr; + char *r_ptr; if (dir == NULL || *dir == NUL) { // We searched all paths of the option, now we can free the search context. @@ -1469,9 +1469,9 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch copy_option_part(&dir, buf, MAXPATHL, " ,"); // get the stopdir string - r_ptr = vim_findfile_stopdir((char_u *)buf); + r_ptr = (char *)vim_findfile_stopdir(buf); fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find, - (char *)r_ptr, 100, false, find_what, + r_ptr, 100, false, find_what, fdip_search_ctx, false, rel_fname); if (fdip_search_ctx != NULL) { did_findfile_init = true; |