diff options
Diffstat (limited to 'src/nvim/search.c')
-rw-r--r-- | src/nvim/search.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index 490e79ebb0..336dd50292 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -175,11 +175,11 @@ int search_regcomp(char_u *pat, int pat_save, int pat_use, int options, regmmatc if (!(options & SEARCH_KEEP) && (cmdmod.cmod_flags & CMOD_KEEPPATTERNS) == 0) { // search or global command if (pat_save == RE_SEARCH || pat_save == RE_BOTH) { - save_re_pat(RE_SEARCH, pat, magic); + save_re_pat(RE_SEARCH, (char *)pat, magic); } // substitute or global command if (pat_save == RE_SUBST || pat_save == RE_BOTH) { - save_re_pat(RE_SUBST, pat, magic); + save_re_pat(RE_SUBST, (char *)pat, magic); } } @@ -198,11 +198,11 @@ char_u *get_search_pat(void) return mr_pattern; } -void save_re_pat(int idx, char_u *pat, int magic) +void save_re_pat(int idx, char *pat, int magic) { - if (spats[idx].pat != pat) { + if (spats[idx].pat != (char_u *)pat) { free_spat(&spats[idx]); - spats[idx].pat = vim_strsave(pat); + spats[idx].pat = (char_u *)xstrdup(pat); spats[idx].magic = magic; spats[idx].no_scs = no_smartcase; spats[idx].timestamp = os_time(); @@ -225,11 +225,11 @@ void save_search_patterns(void) if (save_level++ == 0) { saved_spats[0] = spats[0]; if (spats[0].pat != NULL) { - saved_spats[0].pat = vim_strsave(spats[0].pat); + saved_spats[0].pat = (char_u *)xstrdup((char *)spats[0].pat); } saved_spats[1] = spats[1]; if (spats[1].pat != NULL) { - saved_spats[1].pat = vim_strsave(spats[1].pat); + saved_spats[1].pat = (char_u *)xstrdup((char *)spats[1].pat); } saved_spats_last_idx = last_idx; saved_spats_no_hlsearch = no_hlsearch; @@ -296,7 +296,7 @@ void save_last_search_pattern(void) saved_last_search_spat = spats[RE_SEARCH]; if (spats[RE_SEARCH].pat != NULL) { - saved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat); + saved_last_search_spat.pat = (char_u *)xstrdup((char *)spats[RE_SEARCH].pat); } saved_last_idx = last_idx; saved_no_hlsearch = no_hlsearch; @@ -474,7 +474,7 @@ void set_last_search_pat(const char_u *s, int idx, int magic, int setlast) if (spats[idx].pat == NULL) { saved_spats[idx].pat = NULL; } else { - saved_spats[idx].pat = vim_strsave(spats[idx].pat); + saved_spats[idx].pat = (char_u *)xstrdup((char *)spats[idx].pat); } saved_spats_last_idx = last_idx; } @@ -571,7 +571,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, && pos->lnum <= buf->b_ml.ml_line_count && pos->col < MAXCOL - 2) { // Watch out for the "col" being MAXCOL - 2, used in a closed fold. - ptr = ml_get_buf(buf, pos->lnum, false); + ptr = (char_u *)ml_get_buf(buf, pos->lnum, false); if ((int)STRLEN(ptr) <= pos->col) { start_char_len = 1; } else { @@ -642,7 +642,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) { ptr = (char_u *)""; } else { - ptr = ml_get_buf(buf, lnum + matchpos.lnum, false); + ptr = (char_u *)ml_get_buf(buf, lnum + matchpos.lnum, false); } // Forward search in the first line: match should be after @@ -711,7 +711,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, } // Need to get the line pointer again, a multi-line search may // have made it invalid. - ptr = ml_get_buf(buf, lnum, false); + ptr = (char_u *)ml_get_buf(buf, lnum, false); } if (!match_ok) { continue; @@ -794,7 +794,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, } // Need to get the line pointer again, a // multi-line search may have made it invalid. - ptr = ml_get_buf(buf, lnum + matchpos.lnum, false); + ptr = (char_u *)ml_get_buf(buf, lnum + matchpos.lnum, false); } // If there is only a match after the cursor, skip @@ -817,12 +817,12 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, if (endpos.col == 0) { if (pos->lnum > 1) { // just in case pos->lnum--; - pos->col = (colnr_T)STRLEN(ml_get_buf(buf, pos->lnum, false)); + pos->col = (colnr_T)strlen(ml_get_buf(buf, pos->lnum, false)); } } else { pos->col--; if (pos->lnum <= buf->b_ml.ml_line_count) { - ptr = ml_get_buf(buf, pos->lnum, false); + ptr = (char_u *)ml_get_buf(buf, pos->lnum, false); pos->col -= utf_head_off((char *)ptr, (char *)ptr + pos->col); } } @@ -934,7 +934,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, // A pattern like "\n\zs" may go past the last line. if (pos->lnum > buf->b_ml.ml_line_count) { pos->lnum = buf->b_ml.ml_line_count; - pos->col = (int)STRLEN(ml_get_buf(buf, pos->lnum, false)); + pos->col = (int)strlen(ml_get_buf(buf, pos->lnum, false)); if (pos->col > 0) { pos->col--; } @@ -1085,7 +1085,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, p = (char_u *)skip_regexp((char *)pat, search_delim, p_magic, &strcopy); if (strcopy != (char *)ps) { // made a copy of "pat" to change "\?" to "?" - searchcmdlen += (int)(STRLEN(pat) - STRLEN(strcopy)); + searchcmdlen += (int)(STRLEN(pat) - strlen(strcopy)); pat = (char_u *)strcopy; searchstr = (char_u *)strcopy; } @@ -1443,7 +1443,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, Direction dir, char_u *pat) if (start == 0) { start = pos->lnum; } - ptr = ml_get_buf(buf, pos->lnum, false); + ptr = (char_u *)ml_get_buf(buf, pos->lnum, false); p = (char_u *)skipwhite((char *)ptr); pos->col = (colnr_T)(p - ptr); @@ -2444,7 +2444,7 @@ int current_search(long count, bool forward) } else { // try again from end of buffer // searching backwards, so set pos to last line and col pos.lnum = curwin->w_buffer->b_ml.ml_line_count; - pos.col = (colnr_T)STRLEN(ml_get(curwin->w_buffer->b_ml.ml_line_count)); + pos.col = (colnr_T)strlen(ml_get(curwin->w_buffer->b_ml.ml_line_count)); } } } @@ -2717,7 +2717,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst } if (done_search) { xfree(lastpat); - lastpat = vim_strsave(spats[last_idx].pat); + lastpat = (char_u *)xstrdup((char *)spats[last_idx].pat); chgtick = (int)buf_get_changedtick(curbuf); lbuf = curbuf; lastpos = p; @@ -2827,7 +2827,7 @@ void f_searchcount(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) goto the_end; } xfree(spats[last_idx].pat); - spats[last_idx].pat = vim_strsave(pattern); + spats[last_idx].pat = (char_u *)xstrdup((char *)pattern); } if (spats[last_idx].pat == NULL || *spats[last_idx].pat == NUL) { goto the_end; // the previous pattern was never defined @@ -3103,7 +3103,7 @@ bool fuzzy_match(char_u *const str, const char_u *const pat_arg, const bool matc *outScore = 0; - char_u *const save_pat = vim_strsave(pat_arg); + char_u *const save_pat = (char_u *)xstrdup((char *)pat_arg); char_u *pat = save_pat; char_u *p = pat; @@ -3508,14 +3508,14 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo if (inc_opt != NULL && strstr(inc_opt, "\\zs") != NULL) { // Use text from '\zs' to '\ze' (or end) of 'include'. - new_fname = (char_u *)find_file_name_in_path((char *)incl_regmatch.startp[0], + new_fname = (char_u *)find_file_name_in_path(incl_regmatch.startp[0], (size_t)(incl_regmatch.endp[0] - incl_regmatch.startp[0]), FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, (char *)p_fname); } else { // Use text after match with 'include'. - new_fname = file_name_in_line(incl_regmatch.endp[0], 0, + new_fname = file_name_in_line((char_u *)incl_regmatch.endp[0], 0, FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname, NULL); } already_searched = false; @@ -3583,19 +3583,19 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo if (inc_opt != NULL && strstr(inc_opt, "\\zs") != NULL) { // pattern contains \zs, use the match - p = incl_regmatch.startp[0]; + p = (char_u *)incl_regmatch.startp[0]; i = (int)(incl_regmatch.endp[0] - incl_regmatch.startp[0]); } else { // find the file name after the end of the match - for (p = incl_regmatch.endp[0]; + for (p = (char_u *)incl_regmatch.endp[0]; *p && !vim_isfilec(*p); p++) {} for (i = 0; vim_isfilec(p[i]); i++) {} } if (i == 0) { // Nothing found, use the rest of the line. - p = incl_regmatch.endp[0]; + p = (char_u *)incl_regmatch.endp[0]; i = (int)STRLEN(p); } else if (p > line) { // Avoid checking before the start of the line, can @@ -3681,7 +3681,7 @@ search_line: // Pattern must be first identifier after 'define', so skip // to that position before checking for match of pattern. Also // don't let it match beyond the end of this identifier. - p = def_regmatch.endp[0]; + p = (char_u *)def_regmatch.endp[0]; while (*p && !vim_iswordc(*p)) { p++; } @@ -3706,7 +3706,7 @@ search_line: } else if (regmatch.regprog != NULL && vim_regexec(®match, (char *)line, (colnr_T)(p - line))) { matched = true; - startp = regmatch.startp[0]; + startp = (char_u *)regmatch.startp[0]; // Check if the line is not a comment line (unless we are // looking for a define). A line starting with "# define" // is not considered to be a comment line. @@ -3810,7 +3810,7 @@ search_line: cont_s_ipos = true; } IObuff[i] = NUL; - aux = IObuff; + aux = (char_u *)IObuff; if (i == ins_compl_len()) { goto exit_matched; |