patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Problem: More code can use ml_get_buf_len() instead of STRLEN().
Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not
set ml_line_textlen in ml_replace_len() if "has_props" is set,
because "len_arg" also includes the size of text properties in
that case. (zeertzjq)
closes: #14183
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/search.c b/src/search.c
index 83aaf0a..166ef4a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -660,7 +660,7 @@
&& 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 @@
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 @@
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 @@
p = ml_get_curline();
col = curwin->w_cursor.col;
- len = (int)STRLEN(p);
+ len = ml_get_curline_len();
while (count--)
{
@@ -2315,7 +2314,7 @@
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 @@
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 @@
// 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);
}
}
}