Mercurial > vim
diff src/tag.c @ 14232:4afe2386aae8 v8.1.0133
patch 8.1.0133: tagfiles() can have duplicate entries
commit https://github.com/vim/vim/commit/46577b5e5445c4aaa1e7ae1764373d11dae71663
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 30 22:40:42 2018 +0200
patch 8.1.0133: tagfiles() can have duplicate entries
Problem: tagfiles() can have duplicate entries.
Solution: Simplify the filename to make checking for duplicates work better.
Add a test. (Dominique Pelle, closes #2979)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 30 Jun 2018 22:45:06 +0200 |
parents | 0e9b2971d7c3 |
children | 3c80092eb211 |
line wrap: on
line diff
--- a/src/tag.c +++ b/src/tag.c @@ -2595,7 +2595,6 @@ findtag_end: } static garray_T tag_fnames = GA_EMPTY; -static void found_tagfile_cb(char_u *fname, void *cookie); /* * Callback function for finding all "tags" and "tags-??" files in @@ -2605,8 +2604,15 @@ static void found_tagfile_cb(char_u *fna found_tagfile_cb(char_u *fname, void *cookie UNUSED) { if (ga_grow(&tag_fnames, 1) == OK) - ((char_u **)(tag_fnames.ga_data))[tag_fnames.ga_len++] = - vim_strsave(fname); + { + char_u *tag_fname = vim_strsave(fname); + +#ifdef BACKSLASH_IN_FILENAME + slash_adjust(tag_fname); +#endif + simplify_filename(tag_fname); + ((char_u **)(tag_fnames.ga_data))[tag_fnames.ga_len++] = tag_fname; + } } #if defined(EXITFREE) || defined(PROTO) @@ -2638,6 +2644,7 @@ get_tagfname( { char_u *fname = NULL; char_u *r_ptr; + int i; if (first) vim_memset(tnp, 0, sizeof(tagname_T)); @@ -2679,6 +2686,14 @@ get_tagfname( ++tnp->tn_hf_idx; STRCPY(buf, p_hf); STRCPY(gettail(buf), "tags"); +#ifdef BACKSLASH_IN_FILENAME + slash_adjust(buf); +#endif + simplify_filename(buf); + + for (i = 0; i < tag_fnames.ga_len; ++i) + if (STRCMP(buf, ((char_u **)(tag_fnames.ga_data))[i]) == 0) + return FAIL; // avoid duplicate file names } else vim_strncpy(buf, ((char_u **)(tag_fnames.ga_data))[