To: vim-dev@vim.org Subject: Patch 6.1.074 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.074 Problem: When 'cdpath' includes "../..", changing to a directory in which we currently already are doesn't work. ff_check_visited() adds the directory both when using it as the root for searching and for the actual matches. (Stephen Rasku) Solution: Use a separate list for the already searched directories. Files: src/misc2.c *** ../vim61.073/src/misc2.c Sun May 5 22:51:14 2002 --- src/misc2.c Sun May 5 21:48:59 2002 *************** *** 3318,3324 **** /* * We might have to manage several visited lists during a search. ! * This is expecially needed for * the tags option. If tags is set to: * "./++/tags,./++/TAGS,++/tags" (replace + with *) * So we have to do 3 searches: * 1) search from the current files directory downward for the file "tags" --- 3318,3324 ---- /* * We might have to manage several visited lists during a search. ! * This is expecially needed for the tags option. If tags is set to: * "./++/tags,./++/TAGS,++/tags" (replace + with *) * So we have to do 3 searches: * 1) search from the current files directory downward for the file "tags" *************** *** 3351,3357 **** --- 3351,3359 ---- * The search context: * ffsc_stack_ptr: the stack for the dirs to search * ffsc_visited_list: the currently active visited list + * ffsc_dir_visited_list: the currently active visited list for search dirs * ffsc_visited_lists_list: the list of all visited lists + * ffsc_dir_visited_lists_list: the list of all visited lists for search dirs * ffsc_file_to_search: the file to search for * ffsc_start_dir: the starting directory, if search path was relative * ffsc_fix_path: the fix part of the given path (without wildcards) *************** *** 3365,3371 **** --- 3367,3375 ---- { ff_stack_T *ffsc_stack_ptr; ff_visited_list_hdr_T *ffsc_visited_list; + ff_visited_list_hdr_T *ffsc_dir_visited_list; ff_visited_list_hdr_T *ffsc_visited_lists_list; + ff_visited_list_hdr_T *ffsc_dir_visited_lists_list; char_u *ffsc_file_to_search; char_u *ffsc_start_dir; char_u *ffsc_fix_path; *************** *** 3387,3394 **** #else static int ff_check_visited __ARGS((ff_visited_T **, char_u *)); #endif static void ff_free_visited_list __ARGS((ff_visited_T *vl)); ! static ff_visited_list_hdr_T* ff_get_visited_list __ARGS((char_u *)); #ifdef FEAT_PATH_EXTRA static int ff_wc_equal __ARGS((char_u *s1, char_u *s2)); #endif --- 3391,3399 ---- #else static int ff_check_visited __ARGS((ff_visited_T **, char_u *)); #endif + static void vim_findfile_free_visited_list __ARGS((ff_visited_list_hdr_T **list_headp)); static void ff_free_visited_list __ARGS((ff_visited_T *vl)); ! static ff_visited_list_hdr_T* ff_get_visited_list __ARGS((char_u *, ff_visited_list_hdr_T **list_headp)); #ifdef FEAT_PATH_EXTRA static int ff_wc_equal __ARGS((char_u *s1, char_u *s2)); #endif *************** *** 3541,3549 **** * filename. If no list for the current filename exists, creates a new * one. */ ! ff_search_ctx->ffsc_visited_list = ff_get_visited_list(filename); if (ff_search_ctx->ffsc_visited_list == NULL) goto error_return; } if (ff_expand_buffer == NULL) --- 3546,3559 ---- * filename. If no list for the current filename exists, creates a new * one. */ ! ff_search_ctx->ffsc_visited_list = ff_get_visited_list(filename, ! &ff_search_ctx->ffsc_visited_lists_list); if (ff_search_ctx->ffsc_visited_list == NULL) goto error_return; + ff_search_ctx->ffsc_dir_visited_list = ff_get_visited_list(filename, + &ff_search_ctx->ffsc_dir_visited_lists_list); + if (ff_search_ctx->ffsc_dir_visited_list == NULL) + goto error_return; } if (ff_expand_buffer == NULL) *************** *** 3915,3921 **** * first time (hence ctx->ff_filearray == NULL) */ if (ctx->ffs_filearray == NULL ! && ff_check_visited(&ff_search_ctx->ffsc_visited_list ->ffvl_visited_list, ctx->ffs_fix_path #ifdef FEAT_PATH_EXTRA --- 3925,3931 ---- * first time (hence ctx->ff_filearray == NULL) */ if (ctx->ffs_filearray == NULL ! && ff_check_visited(&ff_search_ctx->ffsc_dir_visited_list ->ffvl_visited_list, ctx->ffs_fix_path #ifdef FEAT_PATH_EXTRA *************** *** 4282,4305 **** vim_findfile_free_visited(search_ctx) void *search_ctx; { ! ff_visited_list_hdr_T *vp; ! ! if (NULL == search_ctx) return; ! ff_search_ctx = (ff_search_ctx_T*)search_ctx; ! while (NULL != ff_search_ctx->ffsc_visited_lists_list) { ! vp = ff_search_ctx->ffsc_visited_lists_list->ffvl_next; ! ff_free_visited_list( ! ff_search_ctx->ffsc_visited_lists_list->ffvl_visited_list); ! ! vim_free(ff_search_ctx->ffsc_visited_lists_list->ffvl_filename); ! vim_free(ff_search_ctx->ffsc_visited_lists_list); ! ff_search_ctx->ffsc_visited_lists_list = vp; } ! ff_search_ctx->ffsc_visited_lists_list = NULL; } static void --- 4292,4322 ---- vim_findfile_free_visited(search_ctx) void *search_ctx; { ! if (search_ctx == NULL) return; ! ff_search_ctx = (ff_search_ctx_T *)search_ctx; ! ! vim_findfile_free_visited_list(&ff_search_ctx->ffsc_visited_lists_list); ! vim_findfile_free_visited_list(&ff_search_ctx->ffsc_dir_visited_lists_list); ! } ! static void ! vim_findfile_free_visited_list(list_headp) ! ff_visited_list_hdr_T **list_headp; ! { ! ff_visited_list_hdr_T *vp; ! ! while (*list_headp != NULL) { ! vp = (*list_headp)->ffvl_next; ! ff_free_visited_list((*list_headp)->ffvl_visited_list); ! ! vim_free((*list_headp)->ffvl_filename); ! vim_free(*list_headp); ! *list_headp = vp; } ! *list_headp = NULL; } static void *************** *** 4322,4336 **** * allocates a new one. */ static ff_visited_list_hdr_T* ! ff_get_visited_list(filename) ! char_u *filename; { ff_visited_list_hdr_T *retptr = NULL; /* check if a visited list for the given filename exists */ ! if (ff_search_ctx->ffsc_visited_lists_list!= NULL) { ! retptr = ff_search_ctx->ffsc_visited_lists_list; while (retptr != NULL) { if (fnamecmp(filename, retptr->ffvl_filename) == 0) --- 4339,4354 ---- * allocates a new one. */ static ff_visited_list_hdr_T* ! ff_get_visited_list(filename, list_headp) ! char_u *filename; ! ff_visited_list_hdr_T **list_headp; { ff_visited_list_hdr_T *retptr = NULL; /* check if a visited list for the given filename exists */ ! if (*list_headp != NULL) { ! retptr = *list_headp; while (retptr != NULL) { if (fnamecmp(filename, retptr->ffvl_filename) == 0) *************** *** 4380,4387 **** vim_free(retptr); return NULL; } ! retptr->ffvl_next = ff_search_ctx->ffsc_visited_lists_list; ! ff_search_ctx->ffsc_visited_lists_list = retptr; return retptr; } --- 4398,4405 ---- vim_free(retptr); return NULL; } ! retptr->ffvl_next = *list_headp; ! *list_headp = retptr; return retptr; } *** ../vim61.073/src/version.c Thu May 16 22:08:09 2002 --- src/version.c Thu May 16 22:10:38 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 74, /**/ -- How To Keep A Healthy Level Of Insanity: 6. In the memo field of all your checks, write "for sexual favors". /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///