aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/search.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/search.c')
-rw-r--r--src/nvim/search.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 403e2f3aa4..c820817a71 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -15,12 +15,14 @@
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
+#include "nvim/cmdhist.h"
#include "nvim/cursor.h"
+#include "nvim/drawscreen.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/funcs.h"
#include "nvim/ex_cmds.h"
-#include "nvim/ex_cmds2.h"
+#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
@@ -42,8 +44,8 @@
#include "nvim/os/input.h"
#include "nvim/os/time.h"
#include "nvim/path.h"
+#include "nvim/profile.h"
#include "nvim/regexp.h"
-#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
@@ -271,7 +273,7 @@ void free_search_patterns(void)
free_spat(&spats[0]);
free_spat(&spats[1]);
- memset(spats, 0, sizeof(spats));
+ CLEAR_FIELD(spats);
if (mr_pattern_alloced) {
xfree(mr_pattern);
@@ -431,7 +433,7 @@ void set_last_csearch(int c, char_u *s, int len)
if (len) {
memcpy(lastc_bytes, s, (size_t)len);
} else {
- memset(lastc_bytes, 0, sizeof(lastc_bytes));
+ CLEAR_FIELD(lastc_bytes);
}
}
@@ -513,7 +515,7 @@ void last_pat_prog(regmmatch_T *regmatch)
}
++emsg_off; // So it doesn't beep if bad expr
(void)search_regcomp((char_u *)"", 0, last_idx, SEARCH_KEEP, regmatch);
- --emsg_off;
+ emsg_off--;
}
/// Lowest level search function.
@@ -1036,7 +1038,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
char_u *p;
long c;
char_u *dircp;
- char_u *strcopy = NULL;
+ char *strcopy = NULL;
char_u *ps;
char_u *msgbuf = NULL;
size_t len;
@@ -1123,13 +1125,13 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
* Find end of regular expression.
* If there is a matching '/' or '?', toss it.
*/
- ps = strcopy;
+ ps = (char_u *)strcopy;
p = skip_regexp(pat, search_delim, p_magic, &strcopy);
- if (strcopy != ps) {
+ if (strcopy != (char *)ps) {
// made a copy of "pat" to change "\?" to "?"
searchcmdlen += (int)(STRLEN(pat) - STRLEN(strcopy));
- pat = strcopy;
- searchstr = strcopy;
+ pat = (char_u *)strcopy;
+ searchstr = (char_u *)strcopy;
}
if (*p == search_delim) {
dircp = p; // remember where we put the NUL
@@ -1160,9 +1162,9 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
} else { // single '+'
spats[0].off.off = 1;
}
- ++p;
+ p++;
while (ascii_isdigit(*p)) { // skip number
- ++p;
+ p++;
}
}
@@ -1426,7 +1428,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
emsg(_("E386: Expected '?' or '/' after ';'"));
goto end_do_search;
}
- ++pat;
+ pat++;
}
if (options & SEARCH_MARK) {
@@ -2136,10 +2138,10 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
}
if (*ptr == '"'
&& (ptr == linep || ptr[-1] != '\'' || ptr[1] != '\'')) {
- ++do_quotes;
+ do_quotes++;
}
if (*ptr == '\\' && ptr[1] != NUL) {
- ++ptr;
+ ptr++;
}
}
do_quotes &= 1; // result is 1 with even number of quotes
@@ -2342,7 +2344,7 @@ int check_linecomment(const char_u *line)
&& !is_pos_in_string(line, (colnr_T)(p - line))) {
break;
}
- ++p;
+ p++;
}
}
@@ -2629,7 +2631,7 @@ bool findpar(bool *pincl, int dir, long count, int what, int both)
}
setpcmark();
if (both && *ml_get(curr) == '}') { // include line with '}'
- ++curr;
+ curr++;
}
curwin->w_cursor.lnum = curr;
if (curr == curbuf->b_ml.ml_line_count && what != '}') {
@@ -2667,7 +2669,7 @@ static int inmacro(char_u *opt, char_u *s)
&& (s[0] == NUL || s[1] == NUL || s[1] == ' ')))) {
break;
}
- ++macro;
+ macro++;
if (macro[0] == NUL) {
break;
}
@@ -3110,7 +3112,7 @@ int current_word(oparg_T *oap, long count, int include, int bigword)
oap->start = start_pos;
oap->motion_type = kMTCharWise;
}
- --count;
+ count--;
}
/*
@@ -3160,7 +3162,7 @@ int current_word(oparg_T *oap, long count, int include, int bigword)
}
}
}
- --count;
+ count--;
}
if (include_white && (cls() != 0
@@ -3323,7 +3325,7 @@ extend:
} else {
ncount = count;
if (start_blank) {
- --ncount;
+ ncount--;
}
}
if (ncount > 0) {
@@ -3851,7 +3853,7 @@ extend:
break;
}
}
- --start_lnum;
+ start_lnum--;
}
/*
@@ -3859,13 +3861,13 @@ extend:
*/
end_lnum = start_lnum;
while (end_lnum <= curbuf->b_ml.ml_line_count && linewhite(end_lnum)) {
- ++end_lnum;
+ end_lnum++;
}
end_lnum--;
i = (int)count;
if (!include && white_in_front) {
- --i;
+ i--;
}
while (i--) {
if (end_lnum == curbuf->b_ml.ml_line_count) {
@@ -3877,14 +3879,12 @@ extend:
}
if (include || !do_white) {
- ++end_lnum;
- /*
- * skip to end of paragraph
- */
+ end_lnum++;
+ // skip to end of paragraph
while (end_lnum < curbuf->b_ml.ml_line_count
&& !linewhite(end_lnum + 1)
&& !startPS(end_lnum + 1, 0, 0)) {
- ++end_lnum;
+ end_lnum++;
}
}
@@ -3898,7 +3898,7 @@ extend:
if (include || do_white) {
while (end_lnum < curbuf->b_ml.ml_line_count
&& linewhite(end_lnum + 1)) {
- ++end_lnum;
+ end_lnum++;
}
}
}
@@ -3909,7 +3909,7 @@ extend:
*/
if (!white_in_front && !linewhite(end_lnum) && include) {
while (start_lnum > 1 && linewhite(start_lnum - 1)) {
- --start_lnum;
+ start_lnum--;
}
}
@@ -3983,7 +3983,7 @@ static int find_prev_quote(char_u *line, int col_start, int quotechar, char_u *e
if (escape != NULL) {
while (col_start - n > 0 && vim_strchr((char *)escape,
line[col_start - n - 1]) != NULL) {
- ++n;
+ n++;
}
}
if (n & 1) {
@@ -4169,11 +4169,11 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
if (include) {
if (ascii_iswhite(line[col_end + 1])) {
while (ascii_iswhite(line[col_end + 1])) {
- ++col_end;
+ col_end++;
}
} else {
while (col_start > 0 && ascii_iswhite(line[col_start - 1])) {
- --col_start;
+ col_start--;
}
}
}
@@ -4551,7 +4551,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst
static buf_T *lbuf = NULL;
proftime_T start;
- memset(stat, 0, sizeof(searchstat_T));
+ CLEAR_POINTER(stat);
if (dirc == 0 && !recompute && !EMPTY_POS(lastpos)) {
stat->cur = cur;
@@ -5467,7 +5467,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
}
did_show = true;
while (depth_displayed < depth && !got_int) {
- ++depth_displayed;
+ depth_displayed++;
for (i = 0; i < depth_displayed; i++) {
msg_puts(" ");
}
@@ -5509,11 +5509,11 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
// Avoid checking before the start of the line, can
// happen if \zs appears in the regexp.
if (p[-1] == '"' || p[-1] == '<') {
- --p;
- ++i;
+ p--;
+ i++;
}
if (p[i] == '"' || p[i] == '>') {
- ++i;
+ i++;
}
}
save_char = p[i];
@@ -5561,7 +5561,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
// Something wrong. We will forget one of our already visited files
// now.
xfree(files[old_files].name);
- ++old_files;
+ old_files++;
}
files[depth].name = curr_fname = new_fname;
files[depth].lnum = 0;
@@ -5860,7 +5860,7 @@ exit_matched:
while (depth >= 0 && !already
&& vim_fgets(line = file_line, LSIZE, files[depth].fp)) {
fclose(files[depth].fp);
- --old_files;
+ old_files--;
files[old_files].name = files[depth].name;
files[old_files].matched = files[depth].matched;
depth--;
@@ -5948,10 +5948,10 @@ static void show_pat_in_path(char_u *line, int type, bool did_show, int action,
if (fp != NULL) {
// We used fgets(), so get rid of newline at end
if (p >= line && *p == '\n') {
- --p;
+ p--;
}
if (p >= line && *p == '\r') {
- --p;
+ p--;
}
*(p + 1) = NUL;
}
@@ -5996,7 +5996,7 @@ void get_search_pattern(SearchPattern *const pat)
void get_substitute_pattern(SearchPattern *const pat)
{
memcpy(pat, &(spats[1]), sizeof(spats[1]));
- memset(&(pat->off), 0, sizeof(pat->off));
+ CLEAR_FIELD(pat->off);
}
/// Set last search pattern
@@ -6012,7 +6012,7 @@ void set_substitute_pattern(const SearchPattern pat)
{
free_spat(&spats[1]);
memcpy(&(spats[1]), &pat, sizeof(spats[1]));
- memset(&(spats[1].off), 0, sizeof(spats[1].off));
+ CLEAR_FIELD(spats[1].off);
}
/// Set last used search pattern