comparison src/search.c @ 7358:6fbeef3b65e6 v7.4.984

commit https://github.com/vim/vim/commit/ad4d8a192abf44b89371af87d70b971cd654b799 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 28 19:20:36 2015 +0100 patch 7.4.984 Problem: searchpos() always starts searching in the first column, which is not what some people expect. (Brett Stahlman) Solution: Add the 'z' flag: start at the specified column.
author Christian Brabandt <cb@256bit.org>
date Mon, 28 Dec 2015 19:30:04 +0100
parents d92910c0c415
children 0b6c37dd858d
comparison
equal deleted inserted replaced
7357:f14b5b957521 7358:6fbeef3b65e6
576 * if (options & SEARCH_END) return position at end of match 576 * if (options & SEARCH_END) return position at end of match
577 * if (options & SEARCH_START) accept match at pos itself 577 * if (options & SEARCH_START) accept match at pos itself
578 * if (options & SEARCH_KEEP) keep previous search pattern 578 * if (options & SEARCH_KEEP) keep previous search pattern
579 * if (options & SEARCH_FOLD) match only once in a closed fold 579 * if (options & SEARCH_FOLD) match only once in a closed fold
580 * if (options & SEARCH_PEEK) check for typed char, cancel search 580 * if (options & SEARCH_PEEK) check for typed char, cancel search
581 * if (options & SEARCH_COL) start at pos->col instead of zero
581 * 582 *
582 * Return FAIL (zero) for failure, non-zero for success. 583 * Return FAIL (zero) for failure, non-zero for success.
583 * When FEAT_EVAL is defined, returns the index of the first matching 584 * When FEAT_EVAL is defined, returns the index of the first matching
584 * subpattern plus one; one if there was none. 585 * subpattern plus one; one if there was none.
585 */ 586 */
597 linenr_T stop_lnum; /* stop after this line number when != 0 */ 598 linenr_T stop_lnum; /* stop after this line number when != 0 */
598 proftime_T *tm UNUSED; /* timeout limit or NULL */ 599 proftime_T *tm UNUSED; /* timeout limit or NULL */
599 { 600 {
600 int found; 601 int found;
601 linenr_T lnum; /* no init to shut up Apollo cc */ 602 linenr_T lnum; /* no init to shut up Apollo cc */
603 colnr_T col;
602 regmmatch_T regmatch; 604 regmmatch_T regmatch;
603 char_u *ptr; 605 char_u *ptr;
604 colnr_T matchcol; 606 colnr_T matchcol;
605 lpos_T endpos; 607 lpos_T endpos;
606 lpos_T matchpos; 608 lpos_T matchpos;
709 #endif 711 #endif
710 712
711 /* 713 /*
712 * Look for a match somewhere in line "lnum". 714 * Look for a match somewhere in line "lnum".
713 */ 715 */
716 col = at_first_line && (options & SEARCH_COL) ? pos->col
717 : (colnr_T)0;
714 nmatched = vim_regexec_multi(&regmatch, win, buf, 718 nmatched = vim_regexec_multi(&regmatch, win, buf,
715 lnum, (colnr_T)0, 719 lnum, col,
716 #ifdef FEAT_RELTIME 720 #ifdef FEAT_RELTIME
717 tm 721 tm
718 #else 722 #else
719 NULL 723 NULL
720 #endif 724 #endif
721 ); 725 );
722 /* Abort searching on an error (e.g., out of stack). */ 726 /* Abort searching on an error (e.g., out of stack). */
723 if (called_emsg) 727 if (called_emsg)
724 break; 728 break;
1096 set_vim_var_nr(VV_SEARCHFORWARD, (long)(spats[0].off.dir == '/')); 1100 set_vim_var_nr(VV_SEARCHFORWARD, (long)(spats[0].off.dir == '/'));
1097 } 1101 }
1098 1102
1099 /* 1103 /*
1100 * Return the number of the first subpat that matched. 1104 * Return the number of the first subpat that matched.
1105 * Return zero if none of them matched.
1101 */ 1106 */
1102 static int 1107 static int
1103 first_submatch(rp) 1108 first_submatch(rp)
1104 regmmatch_T *rp; 1109 regmmatch_T *rp;
1105 { 1110 {