Merge pull request #4325 from watiko/vim-7.4.984

vim-patch:7.4.{984,1093}
This commit is contained in:
Justin M. Keyes
2016-04-25 04:17:45 -04:00
6 changed files with 122 additions and 77 deletions

View File

@@ -8304,12 +8304,12 @@ static void f_cscope_connection(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = cs_connection(num, dbpath, prepend);
}
/*
* "cursor(lnum, col)" function
*
* Moves the cursor to the specified line and column.
* Returns 0 when the position could be set, -1 otherwise.
*/
/// "cursor(lnum, col)" function, or
/// "cursor(list)"
///
/// Moves the cursor to the specified line and column.
///
/// @returns 0 when the position could be set, -1 otherwise.
static void f_cursor(typval_T *argvars, typval_T *rettv)
{
long line, col;
@@ -8321,8 +8321,10 @@ static void f_cursor(typval_T *argvars, typval_T *rettv)
colnr_T curswant = -1;
if (list2fpos(argvars, &pos, NULL, &curswant) == FAIL) {
EMSG(_(e_invarg));
return;
}
line = pos.lnum;
col = pos.col;
coladd = pos.coladd;
@@ -13536,14 +13538,14 @@ static void f_reverse(typval_T *argvars, typval_T *rettv)
}
}
#define SP_NOMOVE 0x01 /* don't move cursor */
#define SP_REPEAT 0x02 /* repeat to find outer pair */
#define SP_RETCOUNT 0x04 /* return matchcount */
#define SP_SETPCMARK 0x08 /* set previous context mark */
#define SP_START 0x10 /* accept match at start position */
#define SP_SUBPAT 0x20 /* return nr of matching sub-pattern */
#define SP_END 0x40 /* leave cursor at end of match */
#define SP_NOMOVE 0x01 ///< don't move cursor
#define SP_REPEAT 0x02 ///< repeat to find outer pair
#define SP_RETCOUNT 0x04 ///< return matchcount
#define SP_SETPCMARK 0x08 ///< set previous context mark
#define SP_START 0x10 ///< accept match at start position
#define SP_SUBPAT 0x20 ///< return nr of matching sub-pattern
#define SP_END 0x40 ///< leave cursor at end of match
#define SP_COLUMN 0x80 ///< start at cursor column
/*
* Get flags for a search function.
@@ -13569,13 +13571,14 @@ static int get_search_arg(typval_T *varp, int *flagsp)
default: mask = 0;
if (flagsp != NULL)
switch (*flags) {
case 'c': mask = SP_START; break;
case 'e': mask = SP_END; break;
case 'm': mask = SP_RETCOUNT; break;
case 'n': mask = SP_NOMOVE; break;
case 'p': mask = SP_SUBPAT; break;
case 'r': mask = SP_REPEAT; break;
case 's': mask = SP_SETPCMARK; break;
case 'c': mask = SP_START; break;
case 'e': mask = SP_END; break;
case 'm': mask = SP_RETCOUNT; break;
case 'n': mask = SP_NOMOVE; break;
case 'p': mask = SP_SUBPAT; break;
case 'r': mask = SP_REPEAT; break;
case 's': mask = SP_SETPCMARK; break;
case 'z': mask = SP_COLUMN; break;
}
if (mask == 0) {
EMSG2(_(e_invarg2), flags);
@@ -13591,9 +13594,7 @@ static int get_search_arg(typval_T *varp, int *flagsp)
return dir;
}
/*
* Shared by search() and searchpos() functions
*/
// Shared by search() and searchpos() functions.
static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
{
int flags;
@@ -13614,10 +13615,15 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
if (dir == 0)
goto theend;
flags = *flagsp;
if (flags & SP_START)
if (flags & SP_START) {
options |= SEARCH_START;
if (flags & SP_END)
}
if (flags & SP_END) {
options |= SEARCH_END;
}
if (flags & SP_COLUMN) {
options |= SEARCH_COL;
}
/* Optional arguments: line number to stop searching and timeout. */
if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) {

View File

@@ -453,25 +453,24 @@ void last_pat_prog(regmmatch_T *regmatch)
--emsg_off;
}
/*
* lowest level search function.
* Search for 'count'th occurrence of pattern 'pat' in direction 'dir'.
* Start at position 'pos' and return the found position in 'pos'.
*
* if (options & SEARCH_MSG) == 0 don't give any messages
* if (options & SEARCH_MSG) == SEARCH_NFMSG don't give 'notfound' messages
* if (options & SEARCH_MSG) == SEARCH_MSG give all messages
* if (options & SEARCH_HIS) put search pattern in history
* if (options & SEARCH_END) return position at end of match
* if (options & SEARCH_START) accept match at pos itself
* if (options & SEARCH_KEEP) keep previous search pattern
* if (options & SEARCH_FOLD) match only once in a closed fold
* if (options & SEARCH_PEEK) check for typed char, cancel search
*
* Return FAIL (zero) for failure, non-zero for success.
* Returns the index of the first matching
* subpattern plus one; one if there was none.
*/
/// lowest level search function.
/// Search for 'count'th occurrence of pattern 'pat' in direction 'dir'.
/// Start at position 'pos' and return the found position in 'pos'.
///
/// if (options & SEARCH_MSG) == 0 don't give any messages
/// if (options & SEARCH_MSG) == SEARCH_NFMSG don't give 'notfound' messages
/// if (options & SEARCH_MSG) == SEARCH_MSG give all messages
/// if (options & SEARCH_HIS) put search pattern in history
/// if (options & SEARCH_END) return position at end of match
/// if (options & SEARCH_START) accept match at pos itself
/// if (options & SEARCH_KEEP) keep previous search pattern
/// if (options & SEARCH_FOLD) match only once in a closed fold
/// if (options & SEARCH_PEEK) check for typed char, cancel search
/// if (options & SEARCH_COL) start at pos->col instead of zero
///
/// @returns FAIL (zero) for failure, non-zero for success.
/// the index of the first matching
/// subpattern plus one; one if there was none.
int searchit(
win_T *win, /* window to search in, can be NULL for a
buffer without a window! */
@@ -571,16 +570,14 @@ int searchit(
if (tm != NULL && profile_passed_limit(*tm))
break;
/*
* Look for a match somewhere in line "lnum".
*/
// Look for a match somewhere in line "lnum".
colnr_T col = at_first_line && (options & SEARCH_COL) ? pos->col : 0;
nmatched = vim_regexec_multi(&regmatch, win, buf,
lnum, (colnr_T)0,
tm
);
/* Abort searching on an error (e.g., out of stack). */
if (called_emsg)
lnum, col, tm);
// Abort searching on an error (e.g., out of stack).
if (called_emsg) {
break;
}
if (nmatched > 0) {
/* match may actually be in another line when using \zs */
matchpos = regmatch.startpos[0];
@@ -881,9 +878,8 @@ static void set_vv_searchforward(void)
set_vim_var_nr(VV_SEARCHFORWARD, (long)(spats[0].off.dir == '/'));
}
/*
* Return the number of the first subpat that matched.
*/
// Return the number of the first subpat that matched.
// Return zero if none of them matched.
static int first_submatch(regmmatch_T *rp)
{
int submatch;

View File

@@ -15,19 +15,20 @@
#define ACTION_SHOW_ALL 4
#define ACTION_EXPAND 5
/* Values for 'options' argument in do_search() and searchit() */
#define SEARCH_REV 0x01 /* go in reverse of previous dir. */
#define SEARCH_ECHO 0x02 /* echo the search command and handle options */
#define SEARCH_MSG 0x0c /* give messages (yes, it's not 0x04) */
#define SEARCH_NFMSG 0x08 /* give all messages except not found */
#define SEARCH_OPT 0x10 /* interpret optional flags */
#define SEARCH_HIS 0x20 /* put search pattern in history */
#define SEARCH_END 0x40 /* put cursor at end of match */
#define SEARCH_NOOF 0x80 /* don't add offset to position */
#define SEARCH_START 0x100 /* start search without col offset */
#define SEARCH_MARK 0x200 /* set previous context mark */
#define SEARCH_KEEP 0x400 /* keep previous search pattern */
#define SEARCH_PEEK 0x800 /* peek for typed char, cancel search */
// Values for 'options' argument in do_search() and searchit()
#define SEARCH_REV 0x01 ///< go in reverse of previous dir.
#define SEARCH_ECHO 0x02 ///< echo the search command and handle options
#define SEARCH_MSG 0x0c ///< give messages (yes, it's not 0x04)
#define SEARCH_NFMSG 0x08 ///< give all messages except not found
#define SEARCH_OPT 0x10 ///< interpret optional flags
#define SEARCH_HIS 0x20 ///< put search pattern in history
#define SEARCH_END 0x40 ///< put cursor at end of match
#define SEARCH_NOOF 0x80 ///< don't add offset to position
#define SEARCH_START 0x100 ///< start search without col offset
#define SEARCH_MARK 0x200 ///< set previous context mark
#define SEARCH_KEEP 0x400 ///< keep previous search pattern
#define SEARCH_PEEK 0x800 ///< peek for typed char, cancel search
#define SEARCH_COL 0x1000 ///< start at specified column instead of zero
/* Values for flags argument for findmatchlimit() */
#define FM_BACKWARD 0x01 /* search backwards */

View File

@@ -584,7 +584,7 @@ static int included_patches[] = {
// 1096,
// 1095 NA
// 1094,
// 1093,
1093,
// 1092,
// 1091,
// 1090,
@@ -693,7 +693,7 @@ static int included_patches[] = {
// 987 NA
// 986 NA
// 985 NA
// 984,
984,
// 983,
// 982 NA
981,