]>
Commit | Line | Data |
---|---|---|
d57b4abe ER |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.1.211 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.1.211 | |
11 | Problem: The matchparen plugin may take an unexpected amount of time, so | |
12 | that it looks like Vim hangs. | |
13 | Solution: Add a timeout to searchpair(), searchpairpos(), search() and | |
14 | searchpos(). Use half a second timeout in the plugin. | |
15 | Files: runtime/doc/eval.txt, runtime/plugin/matchparen.vim, src/edit.c, | |
16 | src/eval.c, src/ex_cmds2.c, src/ex_docmd.c, src/normal.c, | |
17 | src/proto/eval.pro, src/proto/ex_cmds2.pro, src/proto/search.pro, | |
18 | src/search.c | |
19 | ||
20 | ||
21 | *** ../vim-7.1.210/runtime/doc/eval.txt Sat Jan 5 13:34:01 2008 | |
22 | --- runtime/doc/eval.txt Sun Jan 6 16:27:33 2008 | |
23 | *************** | |
24 | *** 1,4 **** | |
25 | ! *eval.txt* For Vim version 7.1. Last change: 2008 Jan 04 | |
26 | ||
27 | ||
28 | VIM REFERENCE MANUAL by Bram Moolenaar | |
29 | --- 1,4 ---- | |
30 | ! *eval.txt* For Vim version 7.1. Last change: 2008 Jan 06 | |
31 | ||
32 | ||
33 | VIM REFERENCE MANUAL by Bram Moolenaar | |
34 | *************** | |
35 | *** 1733,1746 **** | |
36 | repeat( {expr}, {count}) String repeat {expr} {count} times | |
37 | resolve( {filename}) String get filename a shortcut points to | |
38 | reverse( {list}) List reverse {list} in-place | |
39 | ! search( {pattern} [, {flags}]) Number search for {pattern} | |
40 | searchdecl({name} [, {global} [, {thisblock}]]) | |
41 | Number search for variable declaration | |
42 | ! searchpair( {start}, {middle}, {end} [, {flags} [, {skip} [, {stopline}]]]) | |
43 | Number search for other end of start/end pair | |
44 | ! searchpairpos( {start}, {middle}, {end} [, {flags} [, {skip} [, {stopline}]]]) | |
45 | List search for other end of start/end pair | |
46 | ! searchpos( {pattern} [, {flags} [, {stopline}]]) | |
47 | List search for {pattern} | |
48 | server2client( {clientid}, {string}) | |
49 | Number send reply string | |
50 | --- 1733,1747 ---- | |
51 | repeat( {expr}, {count}) String repeat {expr} {count} times | |
52 | resolve( {filename}) String get filename a shortcut points to | |
53 | reverse( {list}) List reverse {list} in-place | |
54 | ! search( {pattern} [, {flags} [, {stopline} [, {timeout}]]]) | |
55 | ! Number search for {pattern} | |
56 | searchdecl({name} [, {global} [, {thisblock}]]) | |
57 | Number search for variable declaration | |
58 | ! searchpair( {start}, {middle}, {end} [, {flags} [, {skip} [...]]]) | |
59 | Number search for other end of start/end pair | |
60 | ! searchpairpos( {start}, {middle}, {end} [, {flags} [, {skip} [...]]]) | |
61 | List search for other end of start/end pair | |
62 | ! searchpos( {pattern} [, {flags} [, {stopline} [, {timeout}]]]) | |
63 | List search for {pattern} | |
64 | server2client( {clientid}, {string}) | |
65 | Number send reply string | |
66 | *************** | |
67 | *** 4212,4218 **** | |
68 | If you want a list to remain unmodified make a copy first: > | |
69 | :let revlist = reverse(copy(mylist)) | |
70 | ||
71 | ! search({pattern} [, {flags} [, {stopline}]]) *search()* | |
72 | Search for regexp pattern {pattern}. The search starts at the | |
73 | cursor position (you can use |cursor()| to set it). | |
74 | ||
75 | --- 4216,4222 ---- | |
76 | If you want a list to remain unmodified make a copy first: > | |
77 | :let revlist = reverse(copy(mylist)) | |
78 | ||
79 | ! search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()* | |
80 | Search for regexp pattern {pattern}. The search starts at the | |
81 | cursor position (you can use |cursor()| to set it). | |
82 | ||
83 | *************** | |
84 | *** 4240,4245 **** | |
85 | --- 4244,4257 ---- | |
86 | let end = search('END', '', line("w$")) | |
87 | < When {stopline} is used and it is not zero this also implies | |
88 | that the search does not wrap around the end of the file. | |
89 | + A zero value is equal to not giving the argument. | |
90 | + | |
91 | + When the {timeout} argument is given the search stops when | |
92 | + more than this many milli seconds have passed. Thus when | |
93 | + {timeout} is 500 the search stops after half a second. | |
94 | + The value must not be negative. A zero value is like not | |
95 | + giving the argument. | |
96 | + {only available when compiled with the +reltime feature} | |
97 | ||
98 | If there is no match a 0 is returned and the cursor doesn't | |
99 | move. No error message is given. | |
100 | *************** | |
101 | *** 4302,4308 **** | |
102 | endif | |
103 | < | |
104 | *searchpair()* | |
105 | ! searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline}]]]) | |
106 | Search for the match of a nested start-end pair. This can be | |
107 | used to find the "endif" that matches an "if", while other | |
108 | if/endif pairs in between are ignored. | |
109 | --- 4314,4321 ---- | |
110 | endif | |
111 | < | |
112 | *searchpair()* | |
113 | ! searchpair({start}, {middle}, {end} [, {flags} [, {skip} | |
114 | ! [, {stopline} [, {timeout}]]]]) | |
115 | Search for the match of a nested start-end pair. This can be | |
116 | used to find the "endif" that matches an "if", while other | |
117 | if/endif pairs in between are ignored. | |
118 | *************** | |
119 | *** 4337,4343 **** | |
120 | When evaluating {skip} causes an error the search is aborted | |
121 | and -1 returned. | |
122 | ||
123 | ! For {stopline} see |search()|. | |
124 | ||
125 | The value of 'ignorecase' is used. 'magic' is ignored, the | |
126 | patterns are used like it's on. | |
127 | --- 4350,4356 ---- | |
128 | When evaluating {skip} causes an error the search is aborted | |
129 | and -1 returned. | |
130 | ||
131 | ! For {stopline} and {timeout} see |search()|. | |
132 | ||
133 | The value of 'ignorecase' is used. 'magic' is ignored, the | |
134 | patterns are used like it's on. | |
135 | *************** | |
136 | *** 4383,4389 **** | |
137 | \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"') | |
138 | < | |
139 | *searchpairpos()* | |
140 | ! searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline}]]]) | |
141 | Same as searchpair(), but returns a |List| with the line and | |
142 | column position of the match. The first element of the |List| | |
143 | is the line number and the second element is the byte index of | |
144 | --- 4396,4403 ---- | |
145 | \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"') | |
146 | < | |
147 | *searchpairpos()* | |
148 | ! searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} | |
149 | ! [, {stopline} [, {timeout}]]]]) | |
150 | Same as searchpair(), but returns a |List| with the line and | |
151 | column position of the match. The first element of the |List| | |
152 | is the line number and the second element is the byte index of | |
153 | *************** | |
154 | *** 4394,4400 **** | |
155 | < | |
156 | See |match-parens| for a bigger and more useful example. | |
157 | ||
158 | ! searchpos({pattern} [, {flags} [, {stopline}]]) *searchpos()* | |
159 | Same as |search()|, but returns a |List| with the line and | |
160 | column position of the match. The first element of the |List| | |
161 | is the line number and the second element is the byte index of | |
162 | --- 4408,4414 ---- | |
163 | < | |
164 | See |match-parens| for a bigger and more useful example. | |
165 | ||
166 | ! searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *searchpos()* | |
167 | Same as |search()|, but returns a |List| with the line and | |
168 | column position of the match. The first element of the |List| | |
169 | is the line number and the second element is the byte index of | |
170 | *** ../vim-7.1.210/runtime/plugin/matchparen.vim Sat Aug 18 18:20:57 2007 | |
171 | --- runtime/plugin/matchparen.vim Sun Jan 6 16:22:39 2008 | |
172 | *************** | |
173 | *** 1,6 **** | |
174 | " Vim plugin for showing matching parens | |
175 | " Maintainer: Bram Moolenaar <Bram@vim.org> | |
176 | ! " Last Change: 2007 Aug 8 | |
177 | ||
178 | " Exit quickly when: | |
179 | " - this plugin was already loaded (or disabled) | |
180 | --- 1,6 ---- | |
181 | " Vim plugin for showing matching parens | |
182 | " Maintainer: Bram Moolenaar <Bram@vim.org> | |
183 | ! " Last Change: 2008 Jan 06 | |
184 | ||
185 | " Exit quickly when: | |
186 | " - this plugin was already loaded (or disabled) | |
187 | *************** | |
188 | *** 111,117 **** | |
189 | \ '=~? "string\\|character\\|singlequote\\|comment"' | |
190 | execute 'if' s_skip '| let s_skip = 0 | endif' | |
191 | ||
192 | ! let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline) | |
193 | ||
194 | if before > 0 | |
195 | call winrestview(save_cursor) | |
196 | --- 111,122 ---- | |
197 | \ '=~? "string\\|character\\|singlequote\\|comment"' | |
198 | execute 'if' s_skip '| let s_skip = 0 | endif' | |
199 | ||
200 | ! try | |
201 | ! " Limit the search time to 500 msec to avoid a hang on very long lines. | |
202 | ! let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, 500) | |
203 | ! catch /E118/ | |
204 | ! let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline) | |
205 | ! endtry | |
206 | ||
207 | if before > 0 | |
208 | call winrestview(save_cursor) | |
209 | *** ../vim-7.1.210/src/edit.c Wed Jan 2 22:08:43 2008 | |
210 | --- src/edit.c Sun Jan 6 16:08:00 2008 | |
211 | *************** | |
212 | *** 4062,4068 **** | |
213 | found_new_match = searchit(NULL, ins_buf, pos, | |
214 | compl_direction, | |
215 | compl_pattern, 1L, SEARCH_KEEP + SEARCH_NFMSG, | |
216 | ! RE_LAST, (linenr_T)0); | |
217 | --msg_silent; | |
218 | if (!compl_started) | |
219 | { | |
220 | --- 4062,4068 ---- | |
221 | found_new_match = searchit(NULL, ins_buf, pos, | |
222 | compl_direction, | |
223 | compl_pattern, 1L, SEARCH_KEEP + SEARCH_NFMSG, | |
224 | ! RE_LAST, (linenr_T)0, NULL); | |
225 | --msg_silent; | |
226 | if (!compl_started) | |
227 | { | |
228 | *** ../vim-7.1.210/src/eval.c Sat Jan 5 22:15:21 2008 | |
229 | --- src/eval.c Sun Jan 6 16:37:42 2008 | |
230 | *************** | |
231 | *** 7213,7223 **** | |
232 | {"repeat", 2, 2, f_repeat}, | |
233 | {"resolve", 1, 1, f_resolve}, | |
234 | {"reverse", 1, 1, f_reverse}, | |
235 | ! {"search", 1, 3, f_search}, | |
236 | {"searchdecl", 1, 3, f_searchdecl}, | |
237 | ! {"searchpair", 3, 6, f_searchpair}, | |
238 | ! {"searchpairpos", 3, 6, f_searchpairpos}, | |
239 | ! {"searchpos", 1, 3, f_searchpos}, | |
240 | {"server2client", 2, 2, f_server2client}, | |
241 | {"serverlist", 0, 0, f_serverlist}, | |
242 | {"setbufvar", 3, 3, f_setbufvar}, | |
243 | --- 7213,7223 ---- | |
244 | {"repeat", 2, 2, f_repeat}, | |
245 | {"resolve", 1, 1, f_resolve}, | |
246 | {"reverse", 1, 1, f_reverse}, | |
247 | ! {"search", 1, 4, f_search}, | |
248 | {"searchdecl", 1, 3, f_searchdecl}, | |
249 | ! {"searchpair", 3, 7, f_searchpair}, | |
250 | ! {"searchpairpos", 3, 7, f_searchpairpos}, | |
251 | ! {"searchpos", 1, 4, f_searchpos}, | |
252 | {"server2client", 2, 2, f_server2client}, | |
253 | {"serverlist", 0, 0, f_serverlist}, | |
254 | {"setbufvar", 3, 3, f_setbufvar}, | |
255 | *************** | |
256 | *** 14020,14025 **** | |
257 | --- 14020,14029 ---- | |
258 | int dir; | |
259 | int retval = 0; /* default: FAIL */ | |
260 | long lnum_stop = 0; | |
261 | + proftime_T tm; | |
262 | + #ifdef FEAT_RELTIME | |
263 | + long time_limit = 0; | |
264 | + #endif | |
265 | int options = SEARCH_KEEP; | |
266 | int subpatnum; | |
267 | ||
268 | *************** | |
269 | *** 14033,14047 **** | |
270 | if (flags & SP_END) | |
271 | options |= SEARCH_END; | |
272 | ||
273 | ! /* Optional extra argument: line number to stop searching. */ | |
274 | ! if (argvars[1].v_type != VAR_UNKNOWN | |
275 | ! && argvars[2].v_type != VAR_UNKNOWN) | |
276 | { | |
277 | lnum_stop = get_tv_number_chk(&argvars[2], NULL); | |
278 | if (lnum_stop < 0) | |
279 | goto theend; | |
280 | } | |
281 | ||
282 | /* | |
283 | * This function does not accept SP_REPEAT and SP_RETCOUNT flags. | |
284 | * Check to make sure only those flags are set. | |
285 | --- 14037,14063 ---- | |
286 | if (flags & SP_END) | |
287 | options |= SEARCH_END; | |
288 | ||
289 | ! /* Optional arguments: line number to stop searching and timeout. */ | |
290 | ! if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) | |
291 | { | |
292 | lnum_stop = get_tv_number_chk(&argvars[2], NULL); | |
293 | if (lnum_stop < 0) | |
294 | goto theend; | |
295 | + #ifdef FEAT_RELTIME | |
296 | + if (argvars[3].v_type != VAR_UNKNOWN) | |
297 | + { | |
298 | + time_limit = get_tv_number_chk(&argvars[3], NULL); | |
299 | + if (time_limit < 0) | |
300 | + goto theend; | |
301 | + } | |
302 | + #endif | |
303 | } | |
304 | ||
305 | + #ifdef FEAT_RELTIME | |
306 | + /* Set the time limit, if there is one. */ | |
307 | + profile_setlimit(time_limit, &tm); | |
308 | + #endif | |
309 | + | |
310 | /* | |
311 | * This function does not accept SP_REPEAT and SP_RETCOUNT flags. | |
312 | * Check to make sure only those flags are set. | |
313 | *************** | |
314 | *** 14057,14063 **** | |
315 | ||
316 | pos = save_cursor = curwin->w_cursor; | |
317 | subpatnum = searchit(curwin, curbuf, &pos, dir, pat, 1L, | |
318 | ! options, RE_SEARCH, (linenr_T)lnum_stop); | |
319 | if (subpatnum != FAIL) | |
320 | { | |
321 | if (flags & SP_SUBPAT) | |
322 | --- 14073,14079 ---- | |
323 | ||
324 | pos = save_cursor = curwin->w_cursor; | |
325 | subpatnum = searchit(curwin, curbuf, &pos, dir, pat, 1L, | |
326 | ! options, RE_SEARCH, (linenr_T)lnum_stop, &tm); | |
327 | if (subpatnum != FAIL) | |
328 | { | |
329 | if (flags & SP_SUBPAT) | |
330 | *************** | |
331 | *** 14147,14152 **** | |
332 | --- 14163,14169 ---- | |
333 | char_u nbuf3[NUMBUFLEN]; | |
334 | int retval = 0; /* default: FAIL */ | |
335 | long lnum_stop = 0; | |
336 | + long time_limit = 0; | |
337 | ||
338 | /* Get the three pattern arguments: start, middle, end. */ | |
339 | spat = get_tv_string_chk(&argvars[0]); | |
340 | *************** | |
341 | *** 14182,14194 **** | |
342 | lnum_stop = get_tv_number_chk(&argvars[5], NULL); | |
343 | if (lnum_stop < 0) | |
344 | goto theend; | |
345 | } | |
346 | } | |
347 | if (skip == NULL) | |
348 | goto theend; /* type error */ | |
349 | ||
350 | retval = do_searchpair(spat, mpat, epat, dir, skip, flags, | |
351 | ! match_pos, lnum_stop); | |
352 | ||
353 | theend: | |
354 | p_ws = save_p_ws; | |
355 | --- 14199,14219 ---- | |
356 | lnum_stop = get_tv_number_chk(&argvars[5], NULL); | |
357 | if (lnum_stop < 0) | |
358 | goto theend; | |
359 | + #ifdef FEAT_RELTIME | |
360 | + if (argvars[6].v_type != VAR_UNKNOWN) | |
361 | + { | |
362 | + time_limit = get_tv_number_chk(&argvars[6], NULL); | |
363 | + if (time_limit < 0) | |
364 | + goto theend; | |
365 | + } | |
366 | + #endif | |
367 | } | |
368 | } | |
369 | if (skip == NULL) | |
370 | goto theend; /* type error */ | |
371 | ||
372 | retval = do_searchpair(spat, mpat, epat, dir, skip, flags, | |
373 | ! match_pos, lnum_stop, time_limit); | |
374 | ||
375 | theend: | |
376 | p_ws = save_p_ws; | |
377 | *************** | |
378 | *** 14240,14246 **** | |
379 | * Returns 0 or -1 for no match, | |
380 | */ | |
381 | long | |
382 | ! do_searchpair(spat, mpat, epat, dir, skip, flags, match_pos, lnum_stop) | |
383 | char_u *spat; /* start pattern */ | |
384 | char_u *mpat; /* middle pattern */ | |
385 | char_u *epat; /* end pattern */ | |
386 | --- 14265,14272 ---- | |
387 | * Returns 0 or -1 for no match, | |
388 | */ | |
389 | long | |
390 | ! do_searchpair(spat, mpat, epat, dir, skip, flags, match_pos, | |
391 | ! lnum_stop, time_limit) | |
392 | char_u *spat; /* start pattern */ | |
393 | char_u *mpat; /* middle pattern */ | |
394 | char_u *epat; /* end pattern */ | |
395 | *************** | |
396 | *** 14249,14254 **** | |
397 | --- 14275,14281 ---- | |
398 | int flags; /* SP_SETPCMARK and other SP_ values */ | |
399 | pos_T *match_pos; | |
400 | linenr_T lnum_stop; /* stop at this line if not zero */ | |
401 | + long time_limit; /* stop after this many msec */ | |
402 | { | |
403 | char_u *save_cpo; | |
404 | char_u *pat, *pat2 = NULL, *pat3 = NULL; | |
405 | *************** | |
406 | *** 14263,14273 **** | |
407 | --- 14290,14306 ---- | |
408 | int nest = 1; | |
409 | int err; | |
410 | int options = SEARCH_KEEP; | |
411 | + proftime_T tm; | |
412 | ||
413 | /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ | |
414 | save_cpo = p_cpo; | |
415 | p_cpo = (char_u *)""; | |
416 | ||
417 | + #ifdef FEAT_RELTIME | |
418 | + /* Set the time limit, if there is one. */ | |
419 | + profile_setlimit(time_limit, &tm); | |
420 | + #endif | |
421 | + | |
422 | /* Make two search patterns: start/end (pat2, for in nested pairs) and | |
423 | * start/middle/end (pat3, for the top pair). */ | |
424 | pat2 = alloc((unsigned)(STRLEN(spat) + STRLEN(epat) + 15)); | |
425 | *************** | |
426 | *** 14291,14297 **** | |
427 | for (;;) | |
428 | { | |
429 | n = searchit(curwin, curbuf, &pos, dir, pat, 1L, | |
430 | ! options, RE_SEARCH, lnum_stop); | |
431 | if (n == FAIL || (firstpos.lnum != 0 && equalpos(pos, firstpos))) | |
432 | /* didn't find it or found the first match again: FAIL */ | |
433 | break; | |
434 | --- 14324,14330 ---- | |
435 | for (;;) | |
436 | { | |
437 | n = searchit(curwin, curbuf, &pos, dir, pat, 1L, | |
438 | ! options, RE_SEARCH, lnum_stop, &tm); | |
439 | if (n == FAIL || (firstpos.lnum != 0 && equalpos(pos, firstpos))) | |
440 | /* didn't find it or found the first match again: FAIL */ | |
441 | break; | |
442 | *** ../vim-7.1.210/src/ex_cmds2.c Fri Jan 4 16:00:10 2008 | |
443 | --- src/ex_cmds2.c Sun Jan 6 18:22:28 2008 | |
444 | *************** | |
445 | *** 895,913 **** | |
446 | sprintf(buf, "%10.6lf", (double)tm->QuadPart / (double)fr.QuadPart); | |
447 | # else | |
448 | sprintf(buf, "%3ld.%06ld", (long)tm->tv_sec, (long)tm->tv_usec); | |
449 | ! #endif | |
450 | return buf; | |
451 | } | |
452 | ||
453 | ! # endif /* FEAT_PROFILE || FEAT_RELTIME */ | |
454 | ||
455 | - # if defined(FEAT_PROFILE) || defined(PROTO) | |
456 | /* | |
457 | ! * Functions for profiling. | |
458 | */ | |
459 | ! static void script_do_profile __ARGS((scriptitem_T *si)); | |
460 | ! static void script_dump_profile __ARGS((FILE *fd)); | |
461 | ! static proftime_T prof_wait_time; | |
462 | ||
463 | /* | |
464 | * Set the time in "tm" to zero. | |
465 | --- 895,955 ---- | |
466 | sprintf(buf, "%10.6lf", (double)tm->QuadPart / (double)fr.QuadPart); | |
467 | # else | |
468 | sprintf(buf, "%3ld.%06ld", (long)tm->tv_sec, (long)tm->tv_usec); | |
469 | ! # endif | |
470 | return buf; | |
471 | } | |
472 | ||
473 | ! /* | |
474 | ! * Put the time "msec" past now in "tm". | |
475 | ! */ | |
476 | ! void | |
477 | ! profile_setlimit(msec, tm) | |
478 | ! long msec; | |
479 | ! proftime_T *tm; | |
480 | ! { | |
481 | ! if (msec <= 0) /* no limit */ | |
482 | ! profile_zero(tm); | |
483 | ! else | |
484 | ! { | |
485 | ! # ifdef WIN3264 | |
486 | ! LARGE_INTEGER fr; | |
487 | ! | |
488 | ! QueryPerformanceCounter(tm); | |
489 | ! QueryPerformanceFrequency(&fr); | |
490 | ! tm->QuadPart += (double)msec / 1000.0 * (double)fr.QuadPart; | |
491 | ! # else | |
492 | ! long usec; | |
493 | ! | |
494 | ! gettimeofday(tm, NULL); | |
495 | ! usec = (long)tm->tv_usec + (long)msec * 1000; | |
496 | ! tm->tv_usec = usec % 1000000L; | |
497 | ! tm->tv_sec += usec / 1000000L; | |
498 | ! # endif | |
499 | ! } | |
500 | ! } | |
501 | ||
502 | /* | |
503 | ! * Return TRUE if the current time is past "tm". | |
504 | */ | |
505 | ! int | |
506 | ! profile_passed_limit(tm) | |
507 | ! proftime_T *tm; | |
508 | ! { | |
509 | ! proftime_T now; | |
510 | ! | |
511 | ! # ifdef WIN3264 | |
512 | ! if (tm->QuadPart == 0) /* timer was not set */ | |
513 | ! return FALSE; | |
514 | ! QueryPerformanceCounter(&now); | |
515 | ! return (now.QuadPart > tm->QuadPart); | |
516 | ! # else | |
517 | ! if (tm->tv_sec == 0) /* timer was not set */ | |
518 | ! return FALSE; | |
519 | ! gettimeofday(&now, NULL); | |
520 | ! return (now.tv_sec > tm->tv_sec | |
521 | ! || (now.tv_sec == tm->tv_sec && now.tv_usec > tm->tv_usec)); | |
522 | ! # endif | |
523 | ! } | |
524 | ||
525 | /* | |
526 | * Set the time in "tm" to zero. | |
527 | *************** | |
528 | *** 923,928 **** | |
529 | --- 965,980 ---- | |
530 | tm->tv_sec = 0; | |
531 | # endif | |
532 | } | |
533 | + | |
534 | + # endif /* FEAT_PROFILE || FEAT_RELTIME */ | |
535 | + | |
536 | + # if defined(FEAT_PROFILE) || defined(PROTO) | |
537 | + /* | |
538 | + * Functions for profiling. | |
539 | + */ | |
540 | + static void script_do_profile __ARGS((scriptitem_T *si)); | |
541 | + static void script_dump_profile __ARGS((FILE *fd)); | |
542 | + static proftime_T prof_wait_time; | |
543 | ||
544 | /* | |
545 | * Add the time "tm2" to "tm". | |
546 | *** ../vim-7.1.210/src/ex_docmd.c Fri Jan 4 16:00:10 2008 | |
547 | --- src/ex_docmd.c Sun Jan 6 16:08:29 2008 | |
548 | *************** | |
549 | *** 3979,3985 **** | |
550 | *cmd == '?' ? BACKWARD : FORWARD, | |
551 | (char_u *)"", 1L, | |
552 | SEARCH_MSG + SEARCH_START, | |
553 | ! i, (linenr_T)0) != FAIL) | |
554 | lnum = pos.lnum; | |
555 | else | |
556 | { | |
557 | --- 3980,3986 ---- | |
558 | *cmd == '?' ? BACKWARD : FORWARD, | |
559 | (char_u *)"", 1L, | |
560 | SEARCH_MSG + SEARCH_START, | |
561 | ! i, (linenr_T)0, NULL) != FAIL) | |
562 | lnum = pos.lnum; | |
563 | else | |
564 | { | |
565 | *** ../vim-7.1.210/src/normal.c Sat Jan 5 13:34:01 2008 | |
566 | --- src/normal.c Sun Jan 6 16:08:54 2008 | |
567 | *************** | |
568 | *** 4194,4200 **** | |
569 | for (;;) | |
570 | { | |
571 | t = searchit(curwin, curbuf, &curwin->w_cursor, FORWARD, | |
572 | ! pat, 1L, searchflags, RE_LAST, (linenr_T)0); | |
573 | if (curwin->w_cursor.lnum >= old_pos.lnum) | |
574 | t = FAIL; /* match after start is failure too */ | |
575 | ||
576 | --- 4194,4200 ---- | |
577 | for (;;) | |
578 | { | |
579 | t = searchit(curwin, curbuf, &curwin->w_cursor, FORWARD, | |
580 | ! pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL); | |
581 | if (curwin->w_cursor.lnum >= old_pos.lnum) | |
582 | t = FAIL; /* match after start is failure too */ | |
583 | ||
584 | *** ../vim-7.1.210/src/proto/eval.pro Sun May 6 15:18:09 2007 | |
585 | --- src/proto/eval.pro Sun Jan 6 15:55:47 2008 | |
586 | *************** | |
587 | *** 54,60 **** | |
588 | long get_dict_number __ARGS((dict_T *d, char_u *key)); | |
589 | char_u *get_function_name __ARGS((expand_T *xp, int idx)); | |
590 | char_u *get_expr_name __ARGS((expand_T *xp, int idx)); | |
591 | ! long do_searchpair __ARGS((char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop)); | |
592 | void set_vim_var_nr __ARGS((int idx, long val)); | |
593 | long get_vim_var_nr __ARGS((int idx)); | |
594 | char_u *get_vim_var_str __ARGS((int idx)); | |
595 | --- 54,60 ---- | |
596 | long get_dict_number __ARGS((dict_T *d, char_u *key)); | |
597 | char_u *get_function_name __ARGS((expand_T *xp, int idx)); | |
598 | char_u *get_expr_name __ARGS((expand_T *xp, int idx)); | |
599 | ! long do_searchpair __ARGS((char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit)); | |
600 | void set_vim_var_nr __ARGS((int idx, long val)); | |
601 | long get_vim_var_nr __ARGS((int idx)); | |
602 | char_u *get_vim_var_str __ARGS((int idx)); | |
603 | *** ../vim-7.1.210/src/proto/ex_cmds2.pro Sat May 5 20:21:13 2007 | |
604 | --- src/proto/ex_cmds2.pro Sun Jan 6 16:42:24 2008 | |
605 | *************** | |
606 | *** 14,19 **** | |
607 | --- 14,21 ---- | |
608 | void profile_end __ARGS((proftime_T *tm)); | |
609 | void profile_sub __ARGS((proftime_T *tm, proftime_T *tm2)); | |
610 | char *profile_msg __ARGS((proftime_T *tm)); | |
611 | + void profile_setlimit __ARGS((long msec, proftime_T *tm)); | |
612 | + int profile_passed_limit __ARGS((proftime_T *tm)); | |
613 | void profile_zero __ARGS((proftime_T *tm)); | |
614 | void profile_add __ARGS((proftime_T *tm, proftime_T *tm2)); | |
615 | void profile_self __ARGS((proftime_T *self, proftime_T *total, proftime_T *children)); | |
616 | *** ../vim-7.1.210/src/proto/search.pro Wed Aug 8 22:48:16 2007 | |
617 | --- src/proto/search.pro Sun Jan 6 16:11:53 2008 | |
618 | *************** | |
619 | *** 10,16 **** | |
620 | void reset_search_dir __ARGS((void)); | |
621 | void set_last_search_pat __ARGS((char_u *s, int idx, int magic, int setlast)); | |
622 | void last_pat_prog __ARGS((regmmatch_T *regmatch)); | |
623 | ! int searchit __ARGS((win_T *win, buf_T *buf, pos_T *pos, int dir, char_u *pat, long count, int options, int pat_use, linenr_T stop_lnum)); | |
624 | int do_search __ARGS((oparg_T *oap, int dirc, char_u *pat, long count, int options)); | |
625 | int search_for_exact_line __ARGS((buf_T *buf, pos_T *pos, int dir, char_u *pat)); | |
626 | int searchc __ARGS((cmdarg_T *cap, int t_cmd)); | |
627 | --- 10,16 ---- | |
628 | void reset_search_dir __ARGS((void)); | |
629 | void set_last_search_pat __ARGS((char_u *s, int idx, int magic, int setlast)); | |
630 | void last_pat_prog __ARGS((regmmatch_T *regmatch)); | |
631 | ! int searchit __ARGS((win_T *win, buf_T *buf, pos_T *pos, int dir, char_u *pat, long count, int options, int pat_use, linenr_T stop_lnum, proftime_T *tm)); | |
632 | int do_search __ARGS((oparg_T *oap, int dirc, char_u *pat, long count, int options)); | |
633 | int search_for_exact_line __ARGS((buf_T *buf, pos_T *pos, int dir, char_u *pat)); | |
634 | int searchc __ARGS((cmdarg_T *cap, int t_cmd)); | |
635 | *** ../vim-7.1.210/src/search.c Tue Jan 1 15:42:45 2008 | |
636 | --- src/search.c Sun Jan 6 18:23:37 2008 | |
637 | *************** | |
638 | *** 494,501 **** | |
639 | * When FEAT_EVAL is defined, returns the index of the first matching | |
640 | * subpattern plus one; one if there was none. | |
641 | */ | |
642 | int | |
643 | ! searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum) | |
644 | win_T *win; /* window to search in; can be NULL for a | |
645 | buffer without a window! */ | |
646 | buf_T *buf; | |
647 | --- 494,502 ---- | |
648 | * When FEAT_EVAL is defined, returns the index of the first matching | |
649 | * subpattern plus one; one if there was none. | |
650 | */ | |
651 | + /*ARGSUSED*/ | |
652 | int | |
653 | ! searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm) | |
654 | win_T *win; /* window to search in; can be NULL for a | |
655 | buffer without a window! */ | |
656 | buf_T *buf; | |
657 | *************** | |
658 | *** 506,511 **** | |
659 | --- 507,513 ---- | |
660 | int options; | |
661 | int pat_use; /* which pattern to use when "pat" is empty */ | |
662 | linenr_T stop_lnum; /* stop after this line number when != 0 */ | |
663 | + proftime_T *tm; /* timeout limit or NULL */ | |
664 | { | |
665 | int found; | |
666 | linenr_T lnum; /* no init to shut up Apollo cc */ | |
667 | *************** | |
668 | *** 594,599 **** | |
669 | --- 596,606 ---- | |
670 | if (stop_lnum != 0 && (dir == FORWARD | |
671 | ? lnum > stop_lnum : lnum < stop_lnum)) | |
672 | break; | |
673 | + #ifdef FEAT_RELTIME | |
674 | + /* Stop after passing the "tm" time limit. */ | |
675 | + if (tm != NULL && profile_passed_limit(tm)) | |
676 | + break; | |
677 | + #endif | |
678 | ||
679 | /* | |
680 | * Look for a match somewhere in line "lnum". | |
681 | *************** | |
682 | *** 1249,1255 **** | |
683 | (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS | |
684 | + SEARCH_MSG + SEARCH_START | |
685 | + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))), | |
686 | ! RE_LAST, (linenr_T)0); | |
687 | ||
688 | if (dircp != NULL) | |
689 | *dircp = dirc; /* restore second '/' or '?' for normal_cmd() */ | |
690 | --- 1256,1262 ---- | |
691 | (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS | |
692 | + SEARCH_MSG + SEARCH_START | |
693 | + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))), | |
694 | ! RE_LAST, (linenr_T)0, NULL); | |
695 | ||
696 | if (dircp != NULL) | |
697 | *dircp = dirc; /* restore second '/' or '?' for normal_cmd() */ | |
698 | *************** | |
699 | *** 3780,3786 **** | |
700 | if (do_searchpair((char_u *)"<[^ \t>/!]\\+\\%(\\_s\\_[^>]\\{-}[^/]>\\|$\\|\\_s\\=>\\)", | |
701 | (char_u *)"", | |
702 | (char_u *)"</[^>]*>", BACKWARD, (char_u *)"", 0, | |
703 | ! NULL, (linenr_T)0) <= 0) | |
704 | { | |
705 | curwin->w_cursor = old_pos; | |
706 | goto theend; | |
707 | --- 3787,3793 ---- | |
708 | if (do_searchpair((char_u *)"<[^ \t>/!]\\+\\%(\\_s\\_[^>]\\{-}[^/]>\\|$\\|\\_s\\=>\\)", | |
709 | (char_u *)"", | |
710 | (char_u *)"</[^>]*>", BACKWARD, (char_u *)"", 0, | |
711 | ! NULL, (linenr_T)0, 0L) <= 0) | |
712 | { | |
713 | curwin->w_cursor = old_pos; | |
714 | goto theend; | |
715 | *************** | |
716 | *** 3814,3820 **** | |
717 | sprintf((char *)epat, "</%.*s>\\c", len, p); | |
718 | ||
719 | r = do_searchpair(spat, (char_u *)"", epat, FORWARD, (char_u *)"", | |
720 | ! 0, NULL, (linenr_T)0); | |
721 | ||
722 | vim_free(spat); | |
723 | vim_free(epat); | |
724 | --- 3821,3827 ---- | |
725 | sprintf((char *)epat, "</%.*s>\\c", len, p); | |
726 | ||
727 | r = do_searchpair(spat, (char_u *)"", epat, FORWARD, (char_u *)"", | |
728 | ! 0, NULL, (linenr_T)0, 0L); | |
729 | ||
730 | vim_free(spat); | |
731 | vim_free(epat); | |
732 | *** ../vim-7.1.210/src/version.c Sun Jan 6 17:18:16 2008 | |
733 | --- src/version.c Sun Jan 6 20:00:03 2008 | |
734 | *************** | |
735 | *** 668,669 **** | |
736 | --- 668,671 ---- | |
737 | { /* Add new patch number below this line */ | |
738 | + /**/ | |
739 | + 211, | |
740 | /**/ | |
741 | ||
742 | -- | |
743 | No letters of the alphabet were harmed in the creation of this message. | |
744 | ||
745 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
746 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
747 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
748 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |