]> git.ipfire.org Git - ipfire-3.x.git/blob - vim/patches/vim-7.3.509.patch0
python3: Update to 3.6.3
[ipfire-3.x.git] / vim / patches / vim-7.3.509.patch0
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.509
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.509
11 Problem: ":vimgrep" fails when 'autochdir' is set.
12 Solution: A more generic solution for changing directory. (Ben Fritz)
13 Files: src/quickfix.c
14
15
16 *** ../vim-7.3.508/src/quickfix.c 2012-03-07 20:13:44.000000000 +0100
17 --- src/quickfix.c 2012-04-25 18:52:24.000000000 +0200
18 ***************
19 *** 130,138 ****
20 static void qf_fill_buffer __ARGS((qf_info_T *qi));
21 #endif
22 static char_u *get_mef_name __ARGS((void));
23 ! static buf_T *load_dummy_buffer __ARGS((char_u *fname));
24 ! static void wipe_dummy_buffer __ARGS((buf_T *buf));
25 ! static void unload_dummy_buffer __ARGS((buf_T *buf));
26 static qf_info_T *ll_get_or_alloc_list __ARGS((win_T *));
27
28 /* Quickfix window check helper macro */
29 --- 130,139 ----
30 static void qf_fill_buffer __ARGS((qf_info_T *qi));
31 #endif
32 static char_u *get_mef_name __ARGS((void));
33 ! static void restore_start_dir __ARGS((char_u *dirname_start));
34 ! static buf_T *load_dummy_buffer __ARGS((char_u *fname, char_u *dirname_start, char_u *resulting_dir));
35 ! static void wipe_dummy_buffer __ARGS((buf_T *buf, char_u *dirname_start));
36 ! static void unload_dummy_buffer __ARGS((buf_T *buf, char_u *dirname_start));
37 static qf_info_T *ll_get_or_alloc_list __ARGS((win_T *));
38
39 /* Quickfix window check helper macro */
40 ***************
41 *** 3237,3255 ****
42
43 /* Load file into a buffer, so that 'fileencoding' is detected,
44 * autocommands applied, etc. */
45 ! buf = load_dummy_buffer(fname);
46 !
47 ! /* When autocommands changed directory: go back. We assume it was
48 ! * ":lcd %:p:h". */
49 ! mch_dirname(dirname_now, MAXPATHL);
50 ! if (STRCMP(dirname_start, dirname_now) != 0)
51 ! {
52 ! exarg_T ea;
53 !
54 ! ea.arg = dirname_start;
55 ! ea.cmdidx = CMD_lcd;
56 ! ex_cd(&ea);
57 ! }
58
59 p_mls = save_mls;
60 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
61 --- 3238,3244 ----
62
63 /* Load file into a buffer, so that 'fileencoding' is detected,
64 * autocommands applied, etc. */
65 ! buf = load_dummy_buffer(fname, dirname_start, dirname_now);
66
67 p_mls = save_mls;
68 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
69 ***************
70 *** 3320,3326 ****
71 {
72 /* Never keep a dummy buffer if there is another buffer
73 * with the same name. */
74 ! wipe_dummy_buffer(buf);
75 buf = NULL;
76 }
77 else if (!cmdmod.hide
78 --- 3309,3315 ----
79 {
80 /* Never keep a dummy buffer if there is another buffer
81 * with the same name. */
82 ! wipe_dummy_buffer(buf, dirname_start);
83 buf = NULL;
84 }
85 else if (!cmdmod.hide
86 ***************
87 *** 3336,3347 ****
88 * many swap files. */
89 if (!found_match)
90 {
91 ! wipe_dummy_buffer(buf);
92 buf = NULL;
93 }
94 else if (buf != first_match_buf || (flags & VGR_NOJUMP))
95 {
96 ! unload_dummy_buffer(buf);
97 buf = NULL;
98 }
99 }
100 --- 3325,3336 ----
101 * many swap files. */
102 if (!found_match)
103 {
104 ! wipe_dummy_buffer(buf, dirname_start);
105 buf = NULL;
106 }
107 else if (buf != first_match_buf || (flags & VGR_NOJUMP))
108 {
109 ! unload_dummy_buffer(buf, dirname_start);
110 buf = NULL;
111 }
112 }
113 ***************
114 *** 3487,3499 ****
115 }
116
117 /*
118 ! * Load file "fname" into a dummy buffer and return the buffer pointer.
119 * Returns NULL if it fails.
120 - * Must call unload_dummy_buffer() or wipe_dummy_buffer() later!
121 */
122 static buf_T *
123 ! load_dummy_buffer(fname)
124 char_u *fname;
125 {
126 buf_T *newbuf;
127 buf_T *newbuf_to_wipe = NULL;
128 --- 3476,3523 ----
129 }
130
131 /*
132 ! * Restore current working directory to "dirname_start" if they differ, taking
133 ! * into account whether it is set locally or globally.
134 ! */
135 ! static void
136 ! restore_start_dir(dirname_start)
137 ! char_u *dirname_start;
138 ! {
139 ! char_u *dirname_now = alloc(MAXPATHL);
140 !
141 ! if (NULL != dirname_now)
142 ! {
143 ! mch_dirname(dirname_now, MAXPATHL);
144 ! if (STRCMP(dirname_start, dirname_now) != 0)
145 ! {
146 ! /* If the directory has changed, change it back by building up an
147 ! * appropriate ex command and executing it. */
148 ! exarg_T ea;
149 !
150 ! ea.arg = dirname_start;
151 ! ea.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd;
152 ! ex_cd(&ea);
153 ! }
154 ! }
155 ! }
156 !
157 ! /*
158 ! * Load file "fname" into a dummy buffer and return the buffer pointer,
159 ! * placing the directory resulting from the buffer load into the
160 ! * "resulting_dir" pointer. "resulting_dir" must be allocated by the caller
161 ! * prior to calling this function. Restores directory to "dirname_start" prior
162 ! * to returning, if autocmds or the 'autochdir' option have changed it.
163 ! *
164 ! * If creating the dummy buffer does not fail, must call unload_dummy_buffer()
165 ! * or wipe_dummy_buffer() later!
166 ! *
167 * Returns NULL if it fails.
168 */
169 static buf_T *
170 ! load_dummy_buffer(fname, dirname_start, resulting_dir)
171 char_u *fname;
172 + char_u *dirname_start; /* in: old directory */
173 + char_u *resulting_dir; /* out: new directory */
174 {
175 buf_T *newbuf;
176 buf_T *newbuf_to_wipe = NULL;
177 ***************
178 *** 3548,3569 ****
179 wipe_buffer(newbuf_to_wipe, FALSE);
180 }
181
182 if (!buf_valid(newbuf))
183 return NULL;
184 if (failed)
185 {
186 ! wipe_dummy_buffer(newbuf);
187 return NULL;
188 }
189 return newbuf;
190 }
191
192 /*
193 ! * Wipe out the dummy buffer that load_dummy_buffer() created.
194 */
195 static void
196 ! wipe_dummy_buffer(buf)
197 buf_T *buf;
198 {
199 if (curbuf != buf) /* safety check */
200 {
201 --- 3572,3604 ----
202 wipe_buffer(newbuf_to_wipe, FALSE);
203 }
204
205 + /*
206 + * When autocommands/'autochdir' option changed directory: go back.
207 + * Let the caller know what the resulting dir was first, in case it is
208 + * important.
209 + */
210 + mch_dirname(resulting_dir, MAXPATHL);
211 + restore_start_dir(dirname_start);
212 +
213 if (!buf_valid(newbuf))
214 return NULL;
215 if (failed)
216 {
217 ! wipe_dummy_buffer(newbuf, dirname_start);
218 return NULL;
219 }
220 return newbuf;
221 }
222
223 /*
224 ! * Wipe out the dummy buffer that load_dummy_buffer() created. Restores
225 ! * directory to "dirname_start" prior to returning, if autocmds or the
226 ! * 'autochdir' option have changed it.
227 */
228 static void
229 ! wipe_dummy_buffer(buf, dirname_start)
230 buf_T *buf;
231 + char_u *dirname_start;
232 {
233 if (curbuf != buf) /* safety check */
234 {
235 ***************
236 *** 3583,3600 ****
237 * new aborting error, interrupt, or uncaught exception. */
238 leave_cleanup(&cs);
239 #endif
240 }
241 }
242
243 /*
244 ! * Unload the dummy buffer that load_dummy_buffer() created.
245 */
246 static void
247 ! unload_dummy_buffer(buf)
248 buf_T *buf;
249 {
250 if (curbuf != buf) /* safety check */
251 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE);
252 }
253
254 #if defined(FEAT_EVAL) || defined(PROTO)
255 --- 3618,3645 ----
256 * new aborting error, interrupt, or uncaught exception. */
257 leave_cleanup(&cs);
258 #endif
259 + /* When autocommands/'autochdir' option changed directory: go back. */
260 + restore_start_dir(dirname_start);
261 }
262 }
263
264 /*
265 ! * Unload the dummy buffer that load_dummy_buffer() created. Restores
266 ! * directory to "dirname_start" prior to returning, if autocmds or the
267 ! * 'autochdir' option have changed it.
268 */
269 static void
270 ! unload_dummy_buffer(buf, dirname_start)
271 buf_T *buf;
272 + char_u *dirname_start;
273 {
274 if (curbuf != buf) /* safety check */
275 + {
276 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE);
277 +
278 + /* When autocommands/'autochdir' option changed directory: go back. */
279 + restore_start_dir(dirname_start);
280 + }
281 }
282
283 #if defined(FEAT_EVAL) || defined(PROTO)
284 *** ../vim-7.3.508/src/version.c 2012-04-25 18:24:24.000000000 +0200
285 --- src/version.c 2012-04-25 18:43:10.000000000 +0200
286 ***************
287 *** 716,717 ****
288 --- 716,719 ----
289 { /* Add new patch number below this line */
290 + /**/
291 + 509,
292 /**/
293
294 --
295 Arthur pulls Pin out. The MONK blesses the grenade as ...
296 ARTHUR: (quietly) One, two, five ...
297 GALAHAD: Three, sir!
298 ARTHUR: Three.
299 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
300
301 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
302 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
303 \\\ an exciting new programming language -- http://www.Zimbu.org ///
304 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///