summaryrefslogtreecommitdiffstats
path: root/src/textformat.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-12 21:50:32 +0100
committerChristian Brabandt <cb@256bit.org>2024-03-12 21:50:32 +0100
commit94b7c3233ef534acc669b3083ed1fe59cf3a090b (patch)
treeb7d882e3b2cf90034e730023c01214b7b17294af /src/textformat.c
parent5cac1a9bee0798d70a7fd80363a1f697759638e8 (diff)
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()v9.1.0172
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>
Diffstat (limited to 'src/textformat.c')
-rw-r--r--src/textformat.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/textformat.c b/src/textformat.c
index 500e8895c8..14acc53cd0 100644
--- a/src/textformat.c
+++ b/src/textformat.c
@@ -455,7 +455,7 @@ internal_format(
// Check if cursor is not past the NUL off the line, cindent
// may have added or removed indent.
curwin->w_cursor.col += startcol;
- len = (colnr_T)STRLEN(ml_get_curline());
+ len = ml_get_curline_len();
if (curwin->w_cursor.col > len)
curwin->w_cursor.col = len;
}
@@ -531,9 +531,7 @@ ends_in_white(linenr_T lnum)
if (*s == NUL)
return FALSE;
- // Don't use STRLEN() inside VIM_ISWHITE(), SAS/C complains: "macro
- // invocation may call function multiple times".
- l = STRLEN(s) - 1;
+ l = ml_get_len(lnum) - 1;
return VIM_ISWHITE(s[l]);
}
@@ -573,7 +571,7 @@ same_leader(
return FALSE;
if (*p == COM_START)
{
- int line_len = (int)STRLEN(ml_get(lnum));
+ int line_len = ml_get_len(lnum);
if (line_len <= leader1_len)
return FALSE;
if (leader2_flags == NULL || leader2_len == 0)
@@ -684,7 +682,7 @@ auto_format(
// in 'formatoptions' and there is a single character before the cursor.
// Otherwise the line would be broken and when typing another non-white
// next they are not joined back together.
- wasatend = (pos.col == (colnr_T)STRLEN(old));
+ wasatend = (pos.col == ml_get_curline_len());
if (*old != NUL && !trailblank && wasatend)
{
dec_cursor();
@@ -740,7 +738,7 @@ auto_format(
if (!wasatend && has_format_option(FO_WHITE_PAR))
{
new = ml_get_curline();
- len = (colnr_T)STRLEN(new);
+ len = ml_get_curline_len();
if (curwin->w_cursor.col == len)
{
pnew = vim_strnsave(new, len + 2);
@@ -1217,7 +1215,7 @@ format_lines(
}
first_par_line = FALSE;
// If the line is getting long, format it next time
- if (STRLEN(ml_get_curline()) > (size_t)max_len)
+ if (ml_get_curline_len() > max_len)
force_format = TRUE;
else
force_format = FALSE;