Mercurial > vim
comparison src/search.c @ 1496:29c09fa57168 v7.1.211
updated for version 7.1-211
author | vimboss |
---|---|
date | Sun, 06 Jan 2008 19:07:36 +0000 |
parents | e6a8d55a1626 |
children | cc4fe241baa3 |
comparison
equal
deleted
inserted
replaced
1495:04265ffbda1f | 1496:29c09fa57168 |
---|---|
492 * | 492 * |
493 * Return FAIL (zero) for failure, non-zero for success. | 493 * Return FAIL (zero) for failure, non-zero for success. |
494 * When FEAT_EVAL is defined, returns the index of the first matching | 494 * When FEAT_EVAL is defined, returns the index of the first matching |
495 * subpattern plus one; one if there was none. | 495 * subpattern plus one; one if there was none. |
496 */ | 496 */ |
497 /*ARGSUSED*/ | |
497 int | 498 int |
498 searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum) | 499 searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm) |
499 win_T *win; /* window to search in; can be NULL for a | 500 win_T *win; /* window to search in; can be NULL for a |
500 buffer without a window! */ | 501 buffer without a window! */ |
501 buf_T *buf; | 502 buf_T *buf; |
502 pos_T *pos; | 503 pos_T *pos; |
503 int dir; | 504 int dir; |
504 char_u *pat; | 505 char_u *pat; |
505 long count; | 506 long count; |
506 int options; | 507 int options; |
507 int pat_use; /* which pattern to use when "pat" is empty */ | 508 int pat_use; /* which pattern to use when "pat" is empty */ |
508 linenr_T stop_lnum; /* stop after this line number when != 0 */ | 509 linenr_T stop_lnum; /* stop after this line number when != 0 */ |
510 proftime_T *tm; /* timeout limit or NULL */ | |
509 { | 511 { |
510 int found; | 512 int found; |
511 linenr_T lnum; /* no init to shut up Apollo cc */ | 513 linenr_T lnum; /* no init to shut up Apollo cc */ |
512 regmmatch_T regmatch; | 514 regmmatch_T regmatch; |
513 char_u *ptr; | 515 char_u *ptr; |
592 { | 594 { |
593 /* Stop after checking "stop_lnum", if it's set. */ | 595 /* Stop after checking "stop_lnum", if it's set. */ |
594 if (stop_lnum != 0 && (dir == FORWARD | 596 if (stop_lnum != 0 && (dir == FORWARD |
595 ? lnum > stop_lnum : lnum < stop_lnum)) | 597 ? lnum > stop_lnum : lnum < stop_lnum)) |
596 break; | 598 break; |
599 #ifdef FEAT_RELTIME | |
600 /* Stop after passing the "tm" time limit. */ | |
601 if (tm != NULL && profile_passed_limit(tm)) | |
602 break; | |
603 #endif | |
597 | 604 |
598 /* | 605 /* |
599 * Look for a match somewhere in line "lnum". | 606 * Look for a match somewhere in line "lnum". |
600 */ | 607 */ |
601 nmatched = vim_regexec_multi(®match, win, buf, | 608 nmatched = vim_regexec_multi(®match, win, buf, |
1247 c = searchit(curwin, curbuf, &pos, dirc == '/' ? FORWARD : BACKWARD, | 1254 c = searchit(curwin, curbuf, &pos, dirc == '/' ? FORWARD : BACKWARD, |
1248 searchstr, count, spats[0].off.end + (options & | 1255 searchstr, count, spats[0].off.end + (options & |
1249 (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS | 1256 (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS |
1250 + SEARCH_MSG + SEARCH_START | 1257 + SEARCH_MSG + SEARCH_START |
1251 + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))), | 1258 + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))), |
1252 RE_LAST, (linenr_T)0); | 1259 RE_LAST, (linenr_T)0, NULL); |
1253 | 1260 |
1254 if (dircp != NULL) | 1261 if (dircp != NULL) |
1255 *dircp = dirc; /* restore second '/' or '?' for normal_cmd() */ | 1262 *dircp = dirc; /* restore second '/' or '?' for normal_cmd() */ |
1256 if (c == FAIL) | 1263 if (c == FAIL) |
1257 { | 1264 { |
3778 for (n = 0; n < count; ++n) | 3785 for (n = 0; n < count; ++n) |
3779 { | 3786 { |
3780 if (do_searchpair((char_u *)"<[^ \t>/!]\\+\\%(\\_s\\_[^>]\\{-}[^/]>\\|$\\|\\_s\\=>\\)", | 3787 if (do_searchpair((char_u *)"<[^ \t>/!]\\+\\%(\\_s\\_[^>]\\{-}[^/]>\\|$\\|\\_s\\=>\\)", |
3781 (char_u *)"", | 3788 (char_u *)"", |
3782 (char_u *)"</[^>]*>", BACKWARD, (char_u *)"", 0, | 3789 (char_u *)"</[^>]*>", BACKWARD, (char_u *)"", 0, |
3783 NULL, (linenr_T)0) <= 0) | 3790 NULL, (linenr_T)0, 0L) <= 0) |
3784 { | 3791 { |
3785 curwin->w_cursor = old_pos; | 3792 curwin->w_cursor = old_pos; |
3786 goto theend; | 3793 goto theend; |
3787 } | 3794 } |
3788 } | 3795 } |
3812 } | 3819 } |
3813 sprintf((char *)spat, "<%.*s\\%%(\\_[^>]\\{-}[^/]>\\|>\\)\\c", len, p); | 3820 sprintf((char *)spat, "<%.*s\\%%(\\_[^>]\\{-}[^/]>\\|>\\)\\c", len, p); |
3814 sprintf((char *)epat, "</%.*s>\\c", len, p); | 3821 sprintf((char *)epat, "</%.*s>\\c", len, p); |
3815 | 3822 |
3816 r = do_searchpair(spat, (char_u *)"", epat, FORWARD, (char_u *)"", | 3823 r = do_searchpair(spat, (char_u *)"", epat, FORWARD, (char_u *)"", |
3817 0, NULL, (linenr_T)0); | 3824 0, NULL, (linenr_T)0, 0L); |
3818 | 3825 |
3819 vim_free(spat); | 3826 vim_free(spat); |
3820 vim_free(epat); | 3827 vim_free(epat); |
3821 | 3828 |
3822 if (r < 1 || lt(curwin->w_cursor, old_end)) | 3829 if (r < 1 || lt(curwin->w_cursor, old_end)) |