comparison src/search.c @ 1521:cc4fe241baa3 v7.1.236

updated for version 7.1-236
author vimboss
date Sat, 19 Jan 2008 14:59:58 +0000
parents 29c09fa57168
children 03ec0f2b9a40
comparison
equal deleted inserted replaced
1520:cd6175cc27d9 1521:cc4fe241baa3
604 604
605 /* 605 /*
606 * Look for a match somewhere in line "lnum". 606 * Look for a match somewhere in line "lnum".
607 */ 607 */
608 nmatched = vim_regexec_multi(&regmatch, win, buf, 608 nmatched = vim_regexec_multi(&regmatch, win, buf,
609 lnum, (colnr_T)0); 609 lnum, (colnr_T)0,
610 #ifdef FEAT_RELTIME
611 tm
612 #else
613 NULL
614 #endif
615 );
610 /* Abort searching on an error (e.g., out of stack). */ 616 /* Abort searching on an error (e.g., out of stack). */
611 if (called_emsg) 617 if (called_emsg)
612 break; 618 break;
613 if (nmatched > 0) 619 if (nmatched > 0)
614 { 620 {
615 /* match may actually be in another line when using \zs */ 621 /* match may actually be in another line when using \zs */
616 matchpos = regmatch.startpos[0]; 622 matchpos = regmatch.startpos[0];
617 endpos = regmatch.endpos[0]; 623 endpos = regmatch.endpos[0];
618 # ifdef FEAT_EVAL 624 #ifdef FEAT_EVAL
619 submatch = first_submatch(&regmatch); 625 submatch = first_submatch(&regmatch);
620 # endif 626 #endif
621 /* Line me be past end of buffer for "\n\zs". */ 627 /* Line me be past end of buffer for "\n\zs". */
622 if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) 628 if (lnum + matchpos.lnum > buf->b_ml.ml_line_count)
623 ptr = (char_u *)""; 629 ptr = (char_u *)"";
624 else 630 else
625 ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE); 631 ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
691 } 697 }
692 } 698 }
693 if (ptr[matchcol] == NUL 699 if (ptr[matchcol] == NUL
694 || (nmatched = vim_regexec_multi(&regmatch, 700 || (nmatched = vim_regexec_multi(&regmatch,
695 win, buf, lnum + matchpos.lnum, 701 win, buf, lnum + matchpos.lnum,
696 matchcol)) == 0) 702 matchcol,
703 #ifdef FEAT_RELTIME
704 tm
705 #else
706 NULL
707 #endif
708 )) == 0)
697 { 709 {
698 match_ok = FALSE; 710 match_ok = FALSE;
699 break; 711 break;
700 } 712 }
701 matchpos = regmatch.startpos[0]; 713 matchpos = regmatch.startpos[0];
797 } 809 }
798 } 810 }
799 if (ptr[matchcol] == NUL 811 if (ptr[matchcol] == NUL
800 || (nmatched = vim_regexec_multi(&regmatch, 812 || (nmatched = vim_regexec_multi(&regmatch,
801 win, buf, lnum + matchpos.lnum, 813 win, buf, lnum + matchpos.lnum,
802 matchcol)) == 0) 814 matchcol,
815 #ifdef FEAT_RELTIME
816 tm
817 #else
818 NULL
819 #endif
820 )) == 0)
803 break; 821 break;
804 822
805 /* Need to get the line pointer again, a 823 /* Need to get the line pointer again, a
806 * multi-line search may have made it invalid. */ 824 * multi-line search may have made it invalid. */
807 ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE); 825 ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
975 * makes the movement linewise without moving the match position. 993 * makes the movement linewise without moving the match position.
976 * 994 *
977 * return 0 for failure, 1 for found, 2 for found and line offset added 995 * return 0 for failure, 1 for found, 2 for found and line offset added
978 */ 996 */
979 int 997 int
980 do_search(oap, dirc, pat, count, options) 998 do_search(oap, dirc, pat, count, options, tm)
981 oparg_T *oap; /* can be NULL */ 999 oparg_T *oap; /* can be NULL */
982 int dirc; /* '/' or '?' */ 1000 int dirc; /* '/' or '?' */
983 char_u *pat; 1001 char_u *pat;
984 long count; 1002 long count;
985 int options; 1003 int options;
1004 proftime_T *tm; /* timeout limit or NULL */
986 { 1005 {
987 pos_T pos; /* position of the last match */ 1006 pos_T pos; /* position of the last match */
988 char_u *searchstr; 1007 char_u *searchstr;
989 struct soffset old_off; 1008 struct soffset old_off;
990 int retval; /* Return value */ 1009 int retval; /* Return value */
1254 c = searchit(curwin, curbuf, &pos, dirc == '/' ? FORWARD : BACKWARD, 1273 c = searchit(curwin, curbuf, &pos, dirc == '/' ? FORWARD : BACKWARD,
1255 searchstr, count, spats[0].off.end + (options & 1274 searchstr, count, spats[0].off.end + (options &
1256 (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS 1275 (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS
1257 + SEARCH_MSG + SEARCH_START 1276 + SEARCH_MSG + SEARCH_START
1258 + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))), 1277 + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))),
1259 RE_LAST, (linenr_T)0, NULL); 1278 RE_LAST, (linenr_T)0, tm);
1260 1279
1261 if (dircp != NULL) 1280 if (dircp != NULL)
1262 *dircp = dirc; /* restore second '/' or '?' for normal_cmd() */ 1281 *dircp = dirc; /* restore second '/' or '?' for normal_cmd() */
1263 if (c == FAIL) 1282 if (c == FAIL)
1264 { 1283 {