]> granicus.if.org Git - vim/commitdiff
patch 8.1.2173: searchit() has too many arguments v8.1.2173
authorBram Moolenaar <Bram@vim.org>
Fri, 18 Oct 2019 18:53:34 +0000 (20:53 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 18 Oct 2019 18:53:34 +0000 (20:53 +0200)
Problem:    Searchit() has too many arguments.
Solution:   Move optional arguments to a struct.  Add the "wrapped" argument.

13 files changed:
src/evalfunc.c
src/ex_docmd.c
src/ex_getln.c
src/gui.c
src/insexpand.c
src/normal.c
src/proto/search.pro
src/quickfix.c
src/search.c
src/spell.c
src/structs.h
src/tag.c
src/version.c

index c43c8839bd629b32f563fa67264f7437b645d75b..62a7f06070ebef264ac891868e360902df39e036 100644 (file)
@@ -5694,12 +5694,13 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
     int                dir;
     int                retval = 0;     /* default: FAIL */
     long       lnum_stop = 0;
-    proftime_T tm;
 #ifdef FEAT_RELTIME
+    proftime_T tm;
     long       time_limit = 0;
 #endif
     int                options = SEARCH_KEEP;
     int                subpatnum;
+    searchit_arg_T sia;
 
     pat = tv_get_string(&argvars[0]);
     dir = get_search_arg(&argvars[1], flagsp); /* may set p_ws */
@@ -5748,8 +5749,13 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
     }
 
     pos = save_cursor = curwin->w_cursor;
+    vim_memset(&sia, 0, sizeof(sia));
+    sia.sa_stop_lnum = (linenr_T)lnum_stop;
+#ifdef FEAT_RELTIME
+    sia.sa_tm = &tm;
+#endif
     subpatnum = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L,
-                          options, RE_SEARCH, (linenr_T)lnum_stop, &tm, NULL);
+                                                    options, RE_SEARCH, &sia);
     if (subpatnum != FAIL)
     {
        if (flags & SP_SUBPAT)
@@ -6147,7 +6153,9 @@ do_searchpair(
     int                use_skip = FALSE;
     int                err;
     int                options = SEARCH_KEEP;
+#ifdef FEAT_RELTIME
     proftime_T tm;
+#endif
 
     /* Make 'cpoptions' empty, the 'l' flag should not be used here. */
     save_cpo = p_cpo;
@@ -6188,8 +6196,15 @@ do_searchpair(
     pat = pat3;
     for (;;)
     {
+       searchit_arg_T sia;
+
+       vim_memset(&sia, 0, sizeof(sia));
+       sia.sa_stop_lnum = lnum_stop;
+#ifdef FEAT_RELTIME
+       sia.sa_tm = &tm;
+#endif
        n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L,
-                                    options, RE_SEARCH, lnum_stop, &tm, NULL);
+                                                    options, RE_SEARCH, &sia);
        if (n == FAIL || (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos)))
            /* didn't find it or found the first match again: FAIL */
            break;
index f4c327140d6aac7f912cd5481174fc49ba3ccd5d..4dd7ba23d8134c8a9d208f29bfc87c2a93802287 100644 (file)
@@ -3600,7 +3600,7 @@ get_address(
                        curwin->w_cursor.col = 0;
                    searchcmdlen = 0;
                    flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG;
-                   if (!do_search(NULL, c, cmd, 1L, flags, NULL, NULL))
+                   if (!do_search(NULL, c, cmd, 1L, flags, NULL))
                    {
                        curwin->w_cursor = pos;
                        cmd = NULL;
@@ -3654,8 +3654,7 @@ get_address(
                    pos.coladd = 0;
                    if (searchit(curwin, curbuf, &pos, NULL,
                                *cmd == '?' ? BACKWARD : FORWARD,
-                               (char_u *)"", 1L, SEARCH_MSG,
-                                       i, (linenr_T)0, NULL, NULL) != FAIL)
+                               (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL)
                        lnum = pos.lnum;
                    else
                    {
index 5816f3f9e7e1fcd22d4b5bf5e45fe2b3acb25602..45a0a3632150fb80fc4520dcb5a5b16c6777be78 100644 (file)
@@ -373,6 +373,7 @@ may_do_incsearch_highlighting(
     pos_T      end_pos;
 #ifdef FEAT_RELTIME
     proftime_T tm;
+    searchit_arg_T sia;
 #endif
     int                next_char;
     int                use_last_pat;
@@ -445,12 +446,16 @@ may_do_incsearch_highlighting(
        if (search_first_line != 0)
            search_flags += SEARCH_START;
        ccline.cmdbuff[skiplen + patlen] = NUL;
+#ifdef FEAT_RELTIME
+       vim_memset(&sia, 0, sizeof(sia));
+       sia.sa_tm = &tm;
+#endif
        found = do_search(NULL, firstc == ':' ? '/' : firstc,
                                 ccline.cmdbuff + skiplen, count, search_flags,
 #ifdef FEAT_RELTIME
-               &tm, NULL
+               &sia
 #else
-               NULL, NULL
+               NULL
 #endif
                );
        ccline.cmdbuff[skiplen + patlen] = next_char;
@@ -597,8 +602,7 @@ may_adjust_incsearch_highlighting(
     pat[patlen] = NUL;
     i = searchit(curwin, curbuf, &t, NULL,
                 c == Ctrl_G ? FORWARD : BACKWARD,
-                pat, count, search_flags,
-                RE_SEARCH, 0, NULL, NULL);
+                pat, count, search_flags, RE_SEARCH, NULL);
     --emsg_off;
     pat[patlen] = save;
     if (i)
index 860add2b43aece9af61c85931136519135654b9f..31be46c7f29432a449954d6c58c585560a38e5b8 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
@@ -5383,7 +5383,7 @@ gui_do_findrepl(
        i = msg_scroll;
        if (down)
        {
-           (void)do_search(NULL, '/', ga.ga_data, 1L, searchflags, NULL, NULL);
+           (void)do_search(NULL, '/', ga.ga_data, 1L, searchflags, NULL);
        }
        else
        {
@@ -5391,7 +5391,7 @@ gui_do_findrepl(
             * direction */
            p = vim_strsave_escaped(ga.ga_data, (char_u *)"?");
            if (p != NULL)
-               (void)do_search(NULL, '?', p, 1L, searchflags, NULL, NULL);
+               (void)do_search(NULL, '?', p, 1L, searchflags, NULL);
            vim_free(p);
        }
 
index 644542e94f90f97fc9127632b6407047c6e8d6a2..31b952bf5996e5d3b0b0d369deb5e4a66cb2ddf7 100644 (file)
@@ -2881,7 +2881,7 @@ ins_compl_get_exp(pos_T *ini)
                    found_new_match = searchit(NULL, ins_buf, pos, NULL,
                                                              compl_direction,
                                 compl_pattern, 1L, SEARCH_KEEP + SEARCH_NFMSG,
-                                            RE_LAST, (linenr_T)0, NULL, NULL);
+                                                               RE_LAST, NULL);
                --msg_silent;
                if (!compl_started || set_match_pos)
                {
index 87754eb40e447e8f7f5209d0f9508d460e13dedf..f66a97c34b9e53f854fcde135d69f978bbc73a49 100644 (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
index 143333d4677d496bbb81c656b4670ab0faa727de..e6ac11b2cb2e549fe6736905d08e1a1b2a7a9168 100644 (file)
@@ -22,9 +22,9 @@ char_u *last_search_pat(void);
 void reset_search_dir(void);
 void set_last_search_pat(char_u *s, int idx, int magic, int setlast);
 void last_pat_prog(regmmatch_T *regmatch);
-int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, int dir, char_u *pat, long count, int options, int pat_use, linenr_T stop_lnum, proftime_T *tm, int *timed_out);
+int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, int dir, char_u *pat, long count, int options, int pat_use, searchit_arg_T *extra_arg);
 void set_search_direction(int cdir);
-int do_search(oparg_T *oap, int dirc, char_u *pat, long count, int options, proftime_T *tm, int *timed_out);
+int do_search(oparg_T *oap, int dirc, char_u *pat, long count, int options, searchit_arg_T *sia);
 int search_for_exact_line(buf_T *buf, pos_T *pos, int dir, char_u *pat);
 int searchc(cmdarg_T *cap, int t_cmd);
 pos_T *findmatch(oparg_T *oap, int initc);
@@ -46,6 +46,6 @@ int current_quote(oparg_T *oap, long count, int include, int quotechar);
 int current_search(long count, int forward);
 int linewhite(linenr_T lnum);
 void find_pattern_in_path(char_u *ptr, int dir, int len, int whole, int skip_comments, int type, long count, int action, linenr_T start_lnum, linenr_T end_lnum);
-struct spat *get_spat(int idx);
+spat_T *get_spat(int idx);
 int get_spat_last_idx(void);
 /* vim: set ft=c : */
index 36456ed4ffdf96b4fde904fe1f8aa606bcec6d8e..067dbffd08c7b30a88d60986472f81d8acd2dde0 100644 (file)
@@ -3207,8 +3207,7 @@ qf_jump_goto_line(
        // Move the cursor to the first line in the buffer
        save_cursor = curwin->w_cursor;
        curwin->w_cursor.lnum = 0;
-       if (!do_search(NULL, '/', qf_pattern, (long)1,
-                   SEARCH_KEEP, NULL, NULL))
+       if (!do_search(NULL, '/', qf_pattern, (long)1, SEARCH_KEEP, NULL))
            curwin->w_cursor = save_cursor;
     }
 }
index 77c3aa492292c2aa3f7a8b24351c26215bf1faa9..91f53c606d5228f45ca218972cfd0bcc61518dba 100644 (file)
@@ -595,8 +595,8 @@ last_pat_prog(regmmatch_T *regmatch)
  */
     int
 searchit(
-    win_T      *win,           /* window to search in; can be NULL for a
-                                  buffer without a window! */
+    win_T      *win,           // window to search in; can be NULL for a
+                               // buffer without a window!
     buf_T      *buf,
     pos_T      *pos,
     pos_T      *end_pos,       // set to end of the match, unless NULL
@@ -604,10 +604,8 @@ searchit(
     char_u     *pat,
     long       count,
     int                options,
-    int                pat_use,        /* which pattern to use when "pat" is empty */
-    linenr_T   stop_lnum,      /* stop after this line number when != 0 */
-    proftime_T *tm UNUSED,     /* timeout limit or NULL */
-    int                *timed_out UNUSED)  /* set when timed out or NULL */
+    int                pat_use,        // which pattern to use when "pat" is empty
+    searchit_arg_T *extra_arg) // optional extra arguments, can be NULL
 {
     int                found;
     linenr_T   lnum;           /* no init to shut up Apollo cc */
@@ -630,6 +628,20 @@ searchit(
 #ifdef FEAT_SEARCH_EXTRA
     int                break_loop = FALSE;
 #endif
+    linenr_T   stop_lnum = 0;  // stop after this line number when != 0
+#ifdef FEAT_RELTIME
+    proftime_T *tm = NULL;     // timeout limit or NULL
+    int                *timed_out = NULL;  // set when timed out or NULL
+#endif
+
+    if (extra_arg != NULL)
+    {
+       stop_lnum = extra_arg->sa_stop_lnum;
+#ifdef FEAT_RELTIME
+       tm = extra_arg->sa_tm;
+       timed_out = &extra_arg->sa_timed_out;
+#endif
+    }
 
     if (search_regcomp(pat, RE_SEARCH, pat_use,
                   (options & (SEARCH_HIS + SEARCH_KEEP)), &regmatch) == FAIL)
@@ -1067,6 +1079,8 @@ searchit(
            if (!shortmess(SHM_SEARCH) && (options & SEARCH_MSG))
                give_warning((char_u *)_(dir == BACKWARD
                                          ? top_bot_msg : bot_top_msg), TRUE);
+           if (extra_arg != NULL)
+               extra_arg->sa_wrapped = TRUE;
        }
        if (got_int || called_emsg
 #ifdef FEAT_RELTIME
@@ -1178,8 +1192,7 @@ do_search(
     char_u         *pat,
     long           count,
     int                    options,
-    proftime_T     *tm,        /* timeout limit or NULL */
-    int                    *timed_out) /* flag set on timeout or NULL */
+    searchit_arg_T  *sia)      // optional arguments or NULL
 {
     pos_T          pos;        /* position of the last match */
     char_u         *searchstr;
@@ -1269,7 +1282,7 @@ do_search(
      */
     for (;;)
     {
-       int     show_top_bot_msg = FALSE;
+       int             show_top_bot_msg = FALSE;
 
        searchstr = pat;
        dircp = NULL;
@@ -1511,7 +1524,7 @@ do_search(
                       (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS
                        + SEARCH_MSG + SEARCH_START
                        + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))),
-               RE_LAST, (linenr_T)0, tm, timed_out);
+               RE_LAST, sia);
 
        if (dircp != NULL)
            *dircp = dirc;      // restore second '/' or '?' for normal_cmd()
@@ -4741,7 +4754,7 @@ current_search(
        result = searchit(curwin, curbuf, &pos, &end_pos,
                (dir ? FORWARD : BACKWARD),
                spats[last_idx].pat, (long) (i ? count : 1),
-               SEARCH_KEEP | flags, RE_SEARCH, 0, NULL, NULL);
+               SEARCH_KEEP | flags, RE_SEARCH, NULL);
 
        /* First search may fail, but then start searching from the
         * beginning of the file (cursor might be on the search match)
@@ -4854,7 +4867,7 @@ is_one_char(char_u *pattern, int move, pos_T *cur, int direction)
     }
 
     if (searchit(curwin, curbuf, &pos, NULL, direction, pattern, 1,
-                        SEARCH_KEEP + flag, RE_SEARCH, 0, NULL, NULL) != FAIL)
+                        SEARCH_KEEP + flag, RE_SEARCH, NULL) != FAIL)
     {
        /* Zero-width pattern should match somewhere, then we can check if
         * start and end are in the same position. */
@@ -4954,8 +4967,7 @@ search_stat(
        profile_setlimit(20L, &start);
 #endif
        while (!got_int && searchit(curwin, curbuf, &lastpos, NULL,
-                                       FORWARD, NULL, 1, SEARCH_KEEP, RE_LAST,
-                                             (linenr_T)0, NULL, NULL) != FAIL)
+                        FORWARD, NULL, 1, SEARCH_KEEP, RE_LAST, NULL) != FAIL)
        {
 #ifdef FEAT_RELTIME
            // Stop after passing the time limit.
index 04e4af601ffef323ce6a5f4eb14495f869e32b45..46209077c60baced5356c38bc3a7ed57da5d58f6 100644 (file)
@@ -2861,7 +2861,7 @@ ex_spellrepall(exarg_T *eap UNUSED)
     curwin->w_cursor.lnum = 0;
     while (!got_int)
     {
-       if (do_search(NULL, '/', frompat, 1L, SEARCH_KEEP, NULL, NULL) == 0
+       if (do_search(NULL, '/', frompat, 1L, SEARCH_KEEP, NULL) == 0
                                                   || u_save_cursor() == FAIL)
            break;
 
index 7c0bfce8fde3fe1c885a237d66ab5717d2f33cac..9cc2452528f7086d4349d40248538c1715658747 100644 (file)
@@ -3871,6 +3871,19 @@ typedef struct spat
     soffset_T      off;
 } spat_T;
 
+/*
+ * Optional extra arguments for searchit().
+ */
+typedef struct
+{
+    linenr_T   sa_stop_lnum;   // stop after this line number when != 0
+#ifdef FEAT_RELTIME
+    proftime_T *sa_tm;         // timeout limit or NULL
+    int                sa_timed_out;   // set when timed out
+#endif
+    int                sa_wrapped;     // search wrapped around
+} searchit_arg_T;
+
 #define WRITEBUFSIZE   8192    // size of normal write buffer
 
 #define FIO_LATIN1     0x01    // convert Latin1
index 75ff026c557b9432c20f700ecfabdac57640bb39..136fea520470f748f841958941ecfc00c3544550 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -3542,7 +3542,7 @@ jumpto_tag(
            save_lnum = curwin->w_cursor.lnum;
            curwin->w_cursor.lnum = 0;  /* start search before first line */
            if (do_search(NULL, pbuf[0], pbuf + 1, (long)1,
-                                                  search_options, NULL, NULL))
+                                                        search_options, NULL))
                retval = OK;
            else
            {
@@ -3554,7 +3554,7 @@ jumpto_tag(
                 */
                p_ic = TRUE;
                if (!do_search(NULL, pbuf[0], pbuf + 1, (long)1,
-                                                  search_options, NULL, NULL))
+                                                        search_options, NULL))
                {
                    /*
                     * Failed to find pattern, take a guess: "^func  ("
@@ -3565,13 +3565,13 @@ jumpto_tag(
                    *tagp.tagname_end = NUL;
                    sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname);
                    if (!do_search(NULL, '/', pbuf, (long)1,
-                                                  search_options, NULL, NULL))
+                                                        search_options, NULL))
                    {
                        /* Guess again: "^char * \<func  (" */
                        sprintf((char *)pbuf, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(",
                                                                tagp.tagname);
                        if (!do_search(NULL, '/', pbuf, (long)1,
-                                                  search_options, NULL, NULL))
+                                                        search_options, NULL))
                            found = 0;
                    }
                    *tagp.tagname_end = cc;
index 901bf32ccfc167f5e8d3eabd6dabfff0e01669d9..73e7e532d10a29fa1dc2d19432aef120fa673811 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2173,
 /**/
     2172,
 /**/