comparison src/normal.c @ 18358:34d5cd432cac v8.1.2173

patch 8.1.2173: searchit() has too many arguments Commit: https://github.com/vim/vim/commit/92ea26b925a0835badb0af2d5887238a4198cabb Author: Bram Moolenaar <Bram@vim.org> Date: Fri Oct 18 20:53:34 2019 +0200 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.
author Bram Moolenaar <Bram@vim.org>
date Fri, 18 Oct 2019 21:00:04 +0200
parents 9f51d0cef8da
children 709c6b0dc78f
comparison
equal deleted inserted replaced
18357:ffe2ff94a3e0 18358:34d5cd432cac
63 static void nv_down(cmdarg_T *cap); 63 static void nv_down(cmdarg_T *cap);
64 static void nv_end(cmdarg_T *cap); 64 static void nv_end(cmdarg_T *cap);
65 static void nv_dollar(cmdarg_T *cap); 65 static void nv_dollar(cmdarg_T *cap);
66 static void nv_search(cmdarg_T *cap); 66 static void nv_search(cmdarg_T *cap);
67 static void nv_next(cmdarg_T *cap); 67 static void nv_next(cmdarg_T *cap);
68 static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt); 68 static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt, int *wrapped);
69 static void nv_csearch(cmdarg_T *cap); 69 static void nv_csearch(cmdarg_T *cap);
70 static void nv_brackets(cmdarg_T *cap); 70 static void nv_brackets(cmdarg_T *cap);
71 static void nv_percent(cmdarg_T *cap); 71 static void nv_percent(cmdarg_T *cap);
72 static void nv_brace(cmdarg_T *cap); 72 static void nv_brace(cmdarg_T *cap);
73 static void nv_mark(cmdarg_T *cap); 73 static void nv_mark(cmdarg_T *cap);
2344 /* Search forward for the identifier, ignore comment lines. */ 2344 /* Search forward for the identifier, ignore comment lines. */
2345 CLEAR_POS(&found_pos); 2345 CLEAR_POS(&found_pos);
2346 for (;;) 2346 for (;;)
2347 { 2347 {
2348 t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, 2348 t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD,
2349 pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL, NULL); 2349 pat, 1L, searchflags, RE_LAST, NULL);
2350 if (curwin->w_cursor.lnum >= old_pos.lnum) 2350 if (curwin->w_cursor.lnum >= old_pos.lnum)
2351 t = FAIL; /* match after start is failure too */ 2351 t = FAIL; /* match after start is failure too */
2352 2352
2353 if (thisblock && t != FAIL) 2353 if (thisblock && t != FAIL)
2354 { 2354 {
3728 3728
3729 // put pattern in search history 3729 // put pattern in search history
3730 init_history(); 3730 init_history();
3731 add_to_history(HIST_SEARCH, buf, TRUE, NUL); 3731 add_to_history(HIST_SEARCH, buf, TRUE, NUL);
3732 3732
3733 (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0); 3733 (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL);
3734 } 3734 }
3735 else 3735 else
3736 { 3736 {
3737 g_tag_at_cursor = TRUE; 3737 g_tag_at_cursor = TRUE;
3738 do_cmdline_cmd(buf); 3738 do_cmdline_cmd(buf);
4255 return; 4255 return;
4256 } 4256 }
4257 4257
4258 (void)normal_search(cap, cap->cmdchar, cap->searchbuf, 4258 (void)normal_search(cap, cap->cmdchar, cap->searchbuf,
4259 (cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor)) 4259 (cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor))
4260 ? 0 : SEARCH_MARK); 4260 ? 0 : SEARCH_MARK, NULL);
4261 } 4261 }
4262 4262
4263 /* 4263 /*
4264 * Handle "N" and "n" commands. 4264 * Handle "N" and "n" commands.
4265 * cap->arg is SEARCH_REV for "N", 0 for "n". 4265 * cap->arg is SEARCH_REV for "N", 0 for "n".
4266 */ 4266 */
4267 static void 4267 static void
4268 nv_next(cmdarg_T *cap) 4268 nv_next(cmdarg_T *cap)
4269 { 4269 {
4270 pos_T old = curwin->w_cursor; 4270 pos_T old = curwin->w_cursor;
4271 int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg); 4271 int wrapped = FALSE;
4272 4272 int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, &wrapped);
4273 if (i == 1 && EQUAL_POS(old, curwin->w_cursor)) 4273
4274 if (i == 1 && !wrapped && EQUAL_POS(old, curwin->w_cursor))
4274 { 4275 {
4275 /* Avoid getting stuck on the current cursor position, which can 4276 /* Avoid getting stuck on the current cursor position, which can
4276 * happen when an offset is given and the cursor is on the last char 4277 * happen when an offset is given and the cursor is on the last char
4277 * in the buffer: Repeat with count + 1. */ 4278 * in the buffer: Repeat with count + 1. */
4278 cap->count1 += 1; 4279 cap->count1 += 1;
4279 (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg); 4280 (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL);
4280 cap->count1 -= 1; 4281 cap->count1 -= 1;
4281 } 4282 }
4282 } 4283 }
4283 4284
4284 /* 4285 /*
4289 static int 4290 static int
4290 normal_search( 4291 normal_search(
4291 cmdarg_T *cap, 4292 cmdarg_T *cap,
4292 int dir, 4293 int dir,
4293 char_u *pat, 4294 char_u *pat,
4294 int opt) /* extra flags for do_search() */ 4295 int opt, // extra flags for do_search()
4296 int *wrapped)
4295 { 4297 {
4296 int i; 4298 int i;
4299 searchit_arg_T sia;
4297 4300
4298 cap->oap->motion_type = MCHAR; 4301 cap->oap->motion_type = MCHAR;
4299 cap->oap->inclusive = FALSE; 4302 cap->oap->inclusive = FALSE;
4300 cap->oap->use_reg_one = TRUE; 4303 cap->oap->use_reg_one = TRUE;
4301 curwin->w_set_curswant = TRUE; 4304 curwin->w_set_curswant = TRUE;
4302 4305
4306 vim_memset(&sia, 0, sizeof(sia));
4303 i = do_search(cap->oap, dir, pat, cap->count1, 4307 i = do_search(cap->oap, dir, pat, cap->count1,
4304 opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, NULL, NULL); 4308 opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia);
4309 if (wrapped != NULL)
4310 *wrapped = sia.sa_wrapped;
4305 if (i == 0) 4311 if (i == 0)
4306 clearop(cap->oap); 4312 clearop(cap->oap);
4307 else 4313 else
4308 { 4314 {
4309 if (i == 2) 4315 if (i == 2)