summaryrefslogtreecommitdiffstats
path: root/src/search.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 07:39:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 07:39:41 +0000
commit00c068502d170f9f9b59c4a68aa12e8835859f6c (patch)
tree2047fc01b8c70326d9b87b47a575e7e5f2141b62 /src/search.c
parentAdding upstream version 2:9.1.0016. (diff)
downloadvim-00c068502d170f9f9b59c4a68aa12e8835859f6c.tar.xz
vim-00c068502d170f9f9b59c4a68aa12e8835859f6c.zip
Adding upstream version 2:9.1.0199.upstream/2%9.1.0199
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/search.c b/src/search.c
index d4baa91..166ef4a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -660,7 +660,7 @@ searchit(
&& pos->col < MAXCOL - 2)
{
ptr = ml_get_buf(buf, pos->lnum, FALSE);
- if ((int)STRLEN(ptr) <= pos->col)
+ if (ml_get_buf_len(buf, pos->lnum) <= pos->col)
start_char_len = 1;
else
start_char_len = (*mb_ptr2len)(ptr + pos->col);
@@ -966,8 +966,7 @@ searchit(
if (pos->lnum > 1) // just in case
{
--pos->lnum;
- pos->col = (colnr_T)STRLEN(ml_get_buf(buf,
- pos->lnum, FALSE));
+ pos->col = ml_get_buf_len(buf, pos->lnum);
}
}
else
@@ -1102,7 +1101,7 @@ searchit(
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 = ml_get_buf_len(buf, pos->lnum);
if (pos->col > 0)
--pos->col;
}
@@ -1772,7 +1771,7 @@ searchc(cmdarg_T *cap, int t_cmd)
p = ml_get_curline();
col = curwin->w_cursor.col;
- len = (int)STRLEN(p);
+ len = ml_get_curline_len();
while (count--)
{
@@ -2315,7 +2314,7 @@ findmatchlimit(
break;
linep = ml_get(pos.lnum);
- pos.col = (colnr_T)STRLEN(linep); // pos.col on trailing NUL
+ pos.col = ml_get_len(pos.lnum); // pos.col on trailing NUL
do_quotes = -1;
line_breakcheck();
@@ -2492,7 +2491,7 @@ findmatchlimit(
if (pos.lnum > 1)
{
ptr = ml_get(pos.lnum - 1);
- if (*ptr && *(ptr + STRLEN(ptr) - 1) == '\\')
+ if (*ptr && *(ptr + ml_get_len(pos.lnum - 1) - 1) == '\\')
{
do_quotes = 1;
if (start_in_quotes == MAYBE)
@@ -2986,8 +2985,7 @@ current_search(
// 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 = ml_get_len(curwin->w_buffer->b_ml.ml_line_count);
}
}
}
@@ -3292,7 +3290,8 @@ find_pattern_in_path(
long count,
int action, // What to do when we find it
linenr_T start_lnum, // first line to start searching
- linenr_T end_lnum) // last line for searching
+ linenr_T end_lnum, // last line for searching
+ int forceit) // If true, always switch to the found path
{
SearchedFile *files; // Stack of included files
SearchedFile *bigger; // When we need more space
@@ -3829,7 +3828,7 @@ search_line:
break;
if (!GETFILE_SUCCESS(getfile(
curwin_save->w_buffer->b_fnum, NULL,
- NULL, TRUE, lnum, FALSE)))
+ NULL, TRUE, lnum, forceit)))
break; // failed to jump to file
}
else
@@ -3842,7 +3841,7 @@ search_line:
{
if (!GETFILE_SUCCESS(getfile(
0, files[depth].name, NULL, TRUE,
- files[depth].lnum, FALSE)))
+ files[depth].lnum, forceit)))
break; // failed to jump to file
// autocommands may have changed the lnum, we don't
// want that here
@@ -4561,7 +4560,10 @@ fuzzy_match_item_compare(const void *s1, const void *s2)
int idx1 = ((fuzzyItem_T *)s1)->idx;
int idx2 = ((fuzzyItem_T *)s2)->idx;
- return v1 == v2 ? (idx1 - idx2) : v1 > v2 ? -1 : 1;
+ if (v1 == v2)
+ return idx1 == idx2 ? 0 : idx1 > idx2 ? 1 : -1;
+ else
+ return v1 > v2 ? -1 : 1;
}
/*
@@ -4908,7 +4910,10 @@ fuzzy_match_str_compare(const void *s1, const void *s2)
int idx1 = ((fuzmatch_str_T *)s1)->idx;
int idx2 = ((fuzmatch_str_T *)s2)->idx;
- return v1 == v2 ? (idx1 - idx2) : v1 > v2 ? -1 : 1;
+ if (v1 == v2)
+ return idx1 == idx2 ? 0 : idx1 > idx2 ? 1 : -1;
+ else
+ return v1 > v2 ? -1 : 1;
}
/*
@@ -4936,9 +4941,14 @@ fuzzy_match_func_compare(const void *s1, const void *s2)
char_u *str1 = ((fuzmatch_str_T *)s1)->str;
char_u *str2 = ((fuzmatch_str_T *)s2)->str;
- if (*str1 != '<' && *str2 == '<') return -1;
- if (*str1 == '<' && *str2 != '<') return 1;
- return v1 == v2 ? (idx1 - idx2) : v1 > v2 ? -1 : 1;
+ if (*str1 != '<' && *str2 == '<')
+ return -1;
+ if (*str1 == '<' && *str2 != '<')
+ return 1;
+ if (v1 == v2)
+ return idx1 == idx2 ? 0 : idx1 > idx2 ? 1 : -1;
+ else
+ return v1 > v2 ? -1 : 1;
}
/*