summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0133
blob: b1f6d2253253d74be5ceaa2bb14456fbb01f1888 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0133
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0133
Problem:    tagfiles() can have duplicate entries.
Solution:   Simplify the filename to make checking for duplicates work better.
            Add a test. (Dominique Pelle, closes #2979)
Files:	    src/tag.c, src/testdir/test_taglist.vim


*** ../vim-8.1.0132/src/tag.c	2018-04-27 22:44:39.000000000 +0200
--- src/tag.c	2018-06-30 22:40:27.157629813 +0200
***************
*** 2595,2601 ****
  }
  
  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
--- 2595,2600 ----
***************
*** 2605,2612 ****
  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);
  }
  
  #if defined(EXITFREE) || defined(PROTO)
--- 2604,2618 ----
  found_tagfile_cb(char_u *fname, void *cookie UNUSED)
  {
      if (ga_grow(&tag_fnames, 1) == OK)
!     {
! 	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,2643 ****
--- 2644,2650 ----
  {
      char_u		*fname = NULL;
      char_u		*r_ptr;
+     int			i;
  
      if (first)
  	vim_memset(tnp, 0, sizeof(tagname_T));
***************
*** 2679,2684 ****
--- 2686,2699 ----
  	    ++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))[
*** ../vim-8.1.0132/src/testdir/test_taglist.vim	2018-02-09 18:25:21.000000000 +0100
--- src/testdir/test_taglist.vim	2018-06-30 22:33:05.044664951 +0200
***************
*** 1,4 ****
! " test 'taglist' function and :tags command
  
  func Test_taglist()
    call writefile([
--- 1,4 ----
! " test taglist(), tagfiles() functions and :tags command
  
  func Test_taglist()
    call writefile([
***************
*** 61,63 ****
--- 61,86 ----
    call assert_fails('tag ' . repeat('x', 1020), 'E426')
    tags
  endfunc
+ 
+ func Test_tagfiles()
+   call assert_equal([], tagfiles())
+ 
+   call writefile(["FFoo\tXfoo\t1"], 'Xtags1')
+   call writefile(["FBar\tXbar\t1"], 'Xtags2')
+   set tags=Xtags1,Xtags2
+   call assert_equal(['Xtags1', 'Xtags2'], tagfiles())
+ 
+   help
+   let tf = tagfiles()
+   call assert_equal(1, len(tf))
+   call assert_equal(fnamemodify(expand('$VIMRUNTIME/doc/tags'), ':p:gs?\\?/?'),
+ 	\           fnamemodify(tf[0], ':p:gs?\\?/?'))
+   helpclose
+   call assert_equal(['Xtags1', 'Xtags2'], tagfiles())
+   set tags&
+   call assert_equal([], tagfiles())
+ 
+   call delete('Xtags1')
+   call delete('Xtags2')
+   bd
+ endfunc
*** ../vim-8.1.0132/src/version.c	2018-06-30 21:50:16.856674912 +0200
--- src/version.c	2018-06-30 22:33:36.756434678 +0200
***************
*** 791,792 ****
--- 791,794 ----
  {   /* Add new patch number below this line */
+ /**/
+     133,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
158. You get a tuner card so you can watch TV while surfing.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///