]> git.ipfire.org Git - ipfire-3.x.git/blob - vim/patches/vim-7.3.180.patch0
Merge remote-tracking branch 'stevee/dracut'
[ipfire-3.x.git] / vim / patches / vim-7.3.180.patch0
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.180
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.180
11 Problem: When both a middle part of 'comments' matches and an end part, the
12 middle part was used errornously.
13 Solution: After finding the middle part match continue looking for a better
14 end part match. (partly by Lech Lorens)
15 Files: src/misc1.c, src/testdir/test3.in, src/testdir/test3.ok
16
17
18 *** ../vim-7.3.179/src/misc1.c 2011-05-10 11:56:26.000000000 +0200
19 --- src/misc1.c 2011-05-10 13:24:38.000000000 +0200
20 ***************
21 *** 1561,1566 ****
22 --- 1561,1569 ----
23 char_u part_buf[COM_MAX_LEN]; /* buffer for one option part */
24 char_u *string; /* pointer to comment string */
25 char_u *list;
26 + int middle_match_len = 0;
27 + char_u *prev_list;
28 + char_u *saved_flags;
29
30 i = 0;
31 while (vim_iswhite(line[i])) /* leading white space is ignored */
32 ***************
33 *** 1569,1575 ****
34 /*
35 * Repeat to match several nested comment strings.
36 */
37 ! while (line[i])
38 {
39 /*
40 * scan through the 'comments' option for a match
41 --- 1572,1578 ----
42 /*
43 * Repeat to match several nested comment strings.
44 */
45 ! while (line[i] != NUL)
46 {
47 /*
48 * scan through the 'comments' option for a match
49 ***************
50 *** 1577,1658 ****
51 found_one = FALSE;
52 for (list = curbuf->b_p_com; *list; )
53 {
54 ! /*
55 ! * Get one option part into part_buf[]. Advance list to next one.
56 ! * put string at start of string.
57 ! */
58 ! if (!got_com && flags != NULL) /* remember where flags started */
59 ! *flags = list;
60 (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
61 string = vim_strchr(part_buf, ':');
62 if (string == NULL) /* missing ':', ignore this part */
63 continue;
64 *string++ = NUL; /* isolate flags from string */
65
66 ! /*
67 ! * When already found a nested comment, only accept further
68 ! * nested comments.
69 ! */
70 if (got_com && vim_strchr(part_buf, COM_NEST) == NULL)
71 continue;
72
73 ! /* When 'O' flag used don't use for "O" command */
74 if (backward && vim_strchr(part_buf, COM_NOBACK) != NULL)
75 continue;
76
77 ! /*
78 ! * Line contents and string must match.
79 * When string starts with white space, must have some white space
80 * (but the amount does not need to match, there might be a mix of
81 ! * TABs and spaces).
82 ! */
83 if (vim_iswhite(string[0]))
84 {
85 if (i == 0 || !vim_iswhite(line[i - 1]))
86 ! continue;
87 while (vim_iswhite(string[0]))
88 ++string;
89 }
90 for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j)
91 ;
92 if (string[j] != NUL)
93 ! continue;
94
95 ! /*
96 ! * When 'b' flag used, there must be white space or an
97 ! * end-of-line after the string in the line.
98 ! */
99 if (vim_strchr(part_buf, COM_BLANK) != NULL
100 && !vim_iswhite(line[i + j]) && line[i + j] != NUL)
101 continue;
102
103 ! /*
104 ! * We have found a match, stop searching.
105 ! */
106 ! i += j;
107 ! got_com = TRUE;
108 found_one = TRUE;
109 break;
110 }
111
112 ! /*
113 ! * No match found, stop scanning.
114 ! */
115 if (!found_one)
116 break;
117
118 ! /*
119 ! * Include any trailing white space.
120 ! */
121 while (vim_iswhite(line[i]))
122 ++i;
123
124 ! /*
125 ! * If this comment doesn't nest, stop here.
126 ! */
127 if (vim_strchr(part_buf, COM_NEST) == NULL)
128 break;
129 }
130 return (got_com ? i : 0);
131 }
132 #endif
133 --- 1580,1683 ----
134 found_one = FALSE;
135 for (list = curbuf->b_p_com; *list; )
136 {
137 ! /* Get one option part into part_buf[]. Advance "list" to next
138 ! * one. Put "string" at start of string. */
139 ! if (!got_com && flags != NULL)
140 ! *flags = list; /* remember where flags started */
141 ! prev_list = list;
142 (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
143 string = vim_strchr(part_buf, ':');
144 if (string == NULL) /* missing ':', ignore this part */
145 continue;
146 *string++ = NUL; /* isolate flags from string */
147
148 ! /* If we found a middle match previously, use that match when this
149 ! * is not a middle or end. */
150 ! if (middle_match_len != 0
151 ! && vim_strchr(part_buf, COM_MIDDLE) == NULL
152 ! && vim_strchr(part_buf, COM_END) == NULL)
153 ! break;
154 !
155 ! /* When we already found a nested comment, only accept further
156 ! * nested comments. */
157 if (got_com && vim_strchr(part_buf, COM_NEST) == NULL)
158 continue;
159
160 ! /* When 'O' flag present and using "O" command skip this one. */
161 if (backward && vim_strchr(part_buf, COM_NOBACK) != NULL)
162 continue;
163
164 ! /* Line contents and string must match.
165 * When string starts with white space, must have some white space
166 * (but the amount does not need to match, there might be a mix of
167 ! * TABs and spaces). */
168 if (vim_iswhite(string[0]))
169 {
170 if (i == 0 || !vim_iswhite(line[i - 1]))
171 ! continue; /* missing shite space */
172 while (vim_iswhite(string[0]))
173 ++string;
174 }
175 for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j)
176 ;
177 if (string[j] != NUL)
178 ! continue; /* string doesn't match */
179
180 ! /* When 'b' flag used, there must be white space or an
181 ! * end-of-line after the string in the line. */
182 if (vim_strchr(part_buf, COM_BLANK) != NULL
183 && !vim_iswhite(line[i + j]) && line[i + j] != NUL)
184 continue;
185
186 ! /* We have found a match, stop searching unless this is a middle
187 ! * comment. The middle comment can be a substring of the end
188 ! * comment in which case it's better to return the length of the
189 ! * end comment and its flags. Thus we keep searching with middle
190 ! * and end matches and use an end match if it matches better. */
191 ! if (vim_strchr(part_buf, COM_MIDDLE) != NULL)
192 ! {
193 ! if (middle_match_len == 0)
194 ! {
195 ! middle_match_len = j;
196 ! saved_flags = prev_list;
197 ! }
198 ! continue;
199 ! }
200 ! if (middle_match_len != 0 && j > middle_match_len)
201 ! /* Use this match instead of the middle match, since it's a
202 ! * longer thus better match. */
203 ! middle_match_len = 0;
204 !
205 ! if (middle_match_len == 0)
206 ! i += j;
207 found_one = TRUE;
208 break;
209 }
210
211 ! if (middle_match_len != 0)
212 ! {
213 ! /* Use the previously found middle match after failing to find a
214 ! * match with an end. */
215 ! if (!got_com && flags != NULL)
216 ! *flags = saved_flags;
217 ! i += middle_match_len;
218 ! found_one = TRUE;
219 ! }
220 !
221 ! /* No match found, stop scanning. */
222 if (!found_one)
223 break;
224
225 ! /* Include any trailing white space. */
226 while (vim_iswhite(line[i]))
227 ++i;
228
229 ! /* If this comment doesn't nest, stop here. */
230 ! got_com = TRUE;
231 if (vim_strchr(part_buf, COM_NEST) == NULL)
232 break;
233 }
234 +
235 return (got_com ? i : 0);
236 }
237 #endif
238 *** ../vim-7.3.179/src/testdir/test3.in 2011-05-10 11:56:26.000000000 +0200
239 --- src/testdir/test3.in 2011-05-10 12:05:50.000000000 +0200
240 ***************
241 *** 1373,1378 ****
242 --- 1373,1390 ----
243 }
244
245 STARTTEST
246 + :set com=s1:/*,m:*,ex:*/
247 + ]]3jofoo();\e
248 + ENDTEST
249 +
250 + void func(void)
251 + {
252 + /*
253 + * This is a comment.
254 + */
255 + }
256 +
257 + STARTTEST
258 :g/^STARTTEST/.,/^ENDTEST/d
259 :1;/start of AUTO/,$wq! test.out
260 ENDTEST
261 *** ../vim-7.3.179/src/testdir/test3.ok 2011-05-10 11:56:26.000000000 +0200
262 --- src/testdir/test3.ok 2011-05-10 12:05:50.000000000 +0200
263 ***************
264 *** 1225,1227 ****
265 --- 1225,1236 ----
266 << "c";
267 }
268
269 +
270 + void func(void)
271 + {
272 + /*
273 + * This is a comment.
274 + */
275 + foo();
276 + }
277 +
278 *** ../vim-7.3.179/src/version.c 2011-05-10 11:56:26.000000000 +0200
279 --- src/version.c 2011-05-10 13:37:28.000000000 +0200
280 ***************
281 *** 716,717 ****
282 --- 716,719 ----
283 { /* Add new patch number below this line */
284 + /**/
285 + 180,
286 /**/
287
288 --
289 "Thou shalt not follow the Null Pointer, for at its end Chaos and
290 Madness lie."
291
292 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
293 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
294 \\\ an exciting new programming language -- http://www.Zimbu.org ///
295 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///