1
0
forked from aniani/vim

patch 8.1.2173: searchit() has too many arguments

Problem:    Searchit() has too many arguments.
Solution:   Move optional arguments to a struct.  Add the "wrapped" argument.
This commit is contained in:
Bram Moolenaar
2019-10-18 20:53:34 +02:00
parent 7751d1d1a3
commit 92ea26b925
13 changed files with 97 additions and 47 deletions

View File

@@ -65,7 +65,7 @@ static void nv_end(cmdarg_T *cap);
static void nv_dollar(cmdarg_T *cap);
static void nv_search(cmdarg_T *cap);
static void nv_next(cmdarg_T *cap);
static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt);
static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt, int *wrapped);
static void nv_csearch(cmdarg_T *cap);
static void nv_brackets(cmdarg_T *cap);
static void nv_percent(cmdarg_T *cap);
@@ -2346,7 +2346,7 @@ find_decl(
for (;;)
{
t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD,
pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL, NULL);
pat, 1L, searchflags, RE_LAST, NULL);
if (curwin->w_cursor.lnum >= old_pos.lnum)
t = FAIL; /* match after start is failure too */
@@ -3730,7 +3730,7 @@ nv_ident(cmdarg_T *cap)
init_history();
add_to_history(HIST_SEARCH, buf, TRUE, NUL);
(void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0);
(void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL);
}
else
{
@@ -4257,7 +4257,7 @@ nv_search(cmdarg_T *cap)
(void)normal_search(cap, cap->cmdchar, cap->searchbuf,
(cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor))
? 0 : SEARCH_MARK);
? 0 : SEARCH_MARK, NULL);
}
/*
@@ -4267,16 +4267,17 @@ nv_search(cmdarg_T *cap)
static void
nv_next(cmdarg_T *cap)
{
pos_T old = curwin->w_cursor;
int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
pos_T old = curwin->w_cursor;
int wrapped = FALSE;
int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, &wrapped);
if (i == 1 && EQUAL_POS(old, curwin->w_cursor))
if (i == 1 && !wrapped && EQUAL_POS(old, curwin->w_cursor))
{
/* Avoid getting stuck on the current cursor position, which can
* happen when an offset is given and the cursor is on the last char
* in the buffer: Repeat with count + 1. */
cap->count1 += 1;
(void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
(void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL);
cap->count1 -= 1;
}
}
@@ -4291,17 +4292,22 @@ normal_search(
cmdarg_T *cap,
int dir,
char_u *pat,
int opt) /* extra flags for do_search() */
int opt, // extra flags for do_search()
int *wrapped)
{
int i;
searchit_arg_T sia;
cap->oap->motion_type = MCHAR;
cap->oap->inclusive = FALSE;
cap->oap->use_reg_one = TRUE;
curwin->w_set_curswant = TRUE;
vim_memset(&sia, 0, sizeof(sia));
i = do_search(cap->oap, dir, pat, cap->count1,
opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, NULL, NULL);
opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia);
if (wrapped != NULL)
*wrapped = sia.sa_wrapped;
if (i == 0)
clearop(cap->oap);
else