aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-08-24 15:14:23 +0200
committerbfredl <bjorn.linse@gmail.com>2023-08-24 22:40:56 +0200
commitcefd774fac76b91f5368833555818c80c992c3b1 (patch)
tree146d6cb8fde01d28c5b03b9640f9e2515c4a89b7 /src
parentdaf7abbc4238dc269e22dd431bc4b1627ef9b6a1 (diff)
downloadrneovim-cefd774fac76b91f5368833555818c80c992c3b1.tar.gz
rneovim-cefd774fac76b91f5368833555818c80c992c3b1.tar.bz2
rneovim-cefd774fac76b91f5368833555818c80c992c3b1.zip
refactor(memline): distinguish mutating uses of ml_get_buf()
ml_get_buf() takes a third parameters to indicate whether the caller wants to mutate the memline data in place. However the vast majority of the call sites is using this function just to specify a buffer but without any mutation. This makes it harder to grep for the places which actually perform mutation. Solution: Remove the bool param from ml_get_buf(). it now works like ml_get() except for a non-current buffer. Add a new ml_get_buf_mut() function for the mutating use-case, which can be grepped along with the other ml_replace() etc functions which can modify the memline.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/buffer.c8
-rw-r--r--src/nvim/api/extmark.c4
-rw-r--r--src/nvim/api/private/helpers.c2
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/buffer.h2
-rw-r--r--src/nvim/bufwrite.c2
-rw-r--r--src/nvim/change.c2
-rw-r--r--src/nvim/charset.c4
-rw-r--r--src/nvim/cursor.c13
-rw-r--r--src/nvim/diff.c23
-rw-r--r--src/nvim/drawline.c16
-rw-r--r--src/nvim/drawscreen.c4
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/eval.c8
-rw-r--r--src/nvim/eval/buffer.c4
-rw-r--r--src/nvim/ex_cmds.c2
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/fold.c8
-rw-r--r--src/nvim/help.c10
-rw-r--r--src/nvim/indent.c5
-rw-r--r--src/nvim/insexpand.c6
-rw-r--r--src/nvim/lua/executor.c2
-rw-r--r--src/nvim/lua/stdlib.c2
-rw-r--r--src/nvim/lua/treesitter.c2
-rw-r--r--src/nvim/mark.c2
-rw-r--r--src/nvim/match.c6
-rw-r--r--src/nvim/mbyte.c2
-rw-r--r--src/nvim/memfile.c2
-rw-r--r--src/nvim/memline.c30
-rw-r--r--src/nvim/mouse.c2
-rw-r--r--src/nvim/move.c2
-rw-r--r--src/nvim/normal.c2
-rw-r--r--src/nvim/ops.c8
-rw-r--r--src/nvim/plines.c6
-rw-r--r--src/nvim/quickfix.c8
-rw-r--r--src/nvim/regexp.c2
-rw-r--r--src/nvim/search.c16
-rw-r--r--src/nvim/spell.c10
-rw-r--r--src/nvim/spellfile.c2
-rw-r--r--src/nvim/spellsuggest.c2
-rw-r--r--src/nvim/statusline.c4
-rw-r--r--src/nvim/syntax.c10
-rw-r--r--src/nvim/undo.c6
43 files changed, 134 insertions, 123 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index e6c91df521..4e3468f8d1 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -546,7 +546,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
char *str_at_end = NULL;
// Another call to ml_get_buf() may free the line, so make a copy.
- str_at_start = xstrdup(ml_get_buf(buf, (linenr_T)start_row, false));
+ str_at_start = xstrdup(ml_get_buf(buf, (linenr_T)start_row));
size_t len_at_start = strlen(str_at_start);
start_col = start_col < 0 ? (int64_t)len_at_start + start_col + 1 : start_col;
VALIDATE_RANGE((start_col >= 0 && (size_t)start_col <= len_at_start), "start_col", {
@@ -554,7 +554,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
});
// Another call to ml_get_buf() may free the line, so make a copy.
- str_at_end = xstrdup(ml_get_buf(buf, (linenr_T)end_row, false));
+ str_at_end = xstrdup(ml_get_buf(buf, (linenr_T)end_row));
size_t len_at_end = strlen(str_at_end);
end_col = end_col < 0 ? (int64_t)len_at_end + end_col + 1 : end_col;
VALIDATE_RANGE((end_col >= 0 && (size_t)end_col <= len_at_end), "end_col", {
@@ -584,7 +584,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
for (int64_t i = 1; i < end_row - start_row; i++) {
int64_t lnum = start_row + i;
- const char *bufline = ml_get_buf(buf, (linenr_T)lnum, false);
+ const char *bufline = ml_get_buf(buf, (linenr_T)lnum);
old_byte += (bcount_t)(strlen(bufline)) + 1;
}
old_byte += (bcount_t)end_col + 1;
@@ -1415,7 +1415,7 @@ bool buf_collect_lines(buf_T *buf, size_t n, linenr_T start, int start_idx, bool
return false;
}
- char *bufstr = ml_get_buf(buf, lnum, false);
+ char *bufstr = ml_get_buf(buf, lnum);
push_linestr(lstate, l, bufstr, strlen(bufstr), start_idx + (int)i, replace_nl);
}
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index 8a60d81649..30e39cd7aa 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -783,7 +783,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
});
line = buf->b_ml.ml_line_count;
} else if (line < buf->b_ml.ml_line_count) {
- len = opts->ephemeral ? MAXCOL : strlen(ml_get_buf(buf, (linenr_T)line + 1, false));
+ len = opts->ephemeral ? MAXCOL : strlen(ml_get_buf(buf, (linenr_T)line + 1));
}
if (col == -1) {
@@ -801,7 +801,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
if (col2 >= 0) {
if (line2 >= 0 && line2 < buf->b_ml.ml_line_count) {
- len = opts->ephemeral ? MAXCOL : strlen(ml_get_buf(buf, (linenr_T)line2 + 1, false));
+ len = opts->ephemeral ? MAXCOL : strlen(ml_get_buf(buf, (linenr_T)line2 + 1));
} else if (line2 == buf->b_ml.ml_line_count) {
// We are trying to add an extmark past final newline
len = 0;
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index bbc87422d0..8fcabb3605 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -517,7 +517,7 @@ String buf_get_text(buf_T *buf, int64_t lnum, int64_t start_col, int64_t end_col
return rv;
}
- char *bufstr = ml_get_buf(buf, (linenr_T)lnum, false);
+ char *bufstr = ml_get_buf(buf, (linenr_T)lnum);
size_t line_length = strlen(bufstr);
start_col = start_col < 0 ? (int64_t)line_length + start_col + 1 : start_col;
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index fd912a65e0..1e093916d3 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -4250,7 +4250,7 @@ bool buf_contents_changed(buf_T *buf)
if (buf->b_ml.ml_line_count == curbuf->b_ml.ml_line_count) {
differ = false;
for (linenr_T lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) {
- if (strcmp(ml_get_buf(buf, lnum, false), ml_get(lnum)) != 0) {
+ if (strcmp(ml_get_buf(buf, lnum), ml_get(lnum)) != 0) {
differ = true;
break;
}
diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h
index 1bca08e357..10d35ffc7e 100644
--- a/src/nvim/buffer.h
+++ b/src/nvim/buffer.h
@@ -138,7 +138,7 @@ static inline void buf_inc_changedtick(buf_T *const buf)
static inline bool buf_is_empty(buf_T *buf)
{
return buf->b_ml.ml_line_count == 1
- && *ml_get_buf(buf, (linenr_T)1, false) == '\0';
+ && *ml_get_buf(buf, (linenr_T)1) == '\0';
}
#endif // NVIM_BUFFER_H
diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c
index cfa3ea5bf3..2796ed1f0b 100644
--- a/src/nvim/bufwrite.c
+++ b/src/nvim/bufwrite.c
@@ -1524,7 +1524,7 @@ restore_backup:
for (lnum = start; lnum <= end; lnum++) {
// The next while loop is done once for each character written.
// Keep it fast!
- char *ptr = ml_get_buf(buf, lnum, false) - 1;
+ char *ptr = ml_get_buf(buf, lnum) - 1;
if (write_undo_file) {
sha256_update(&sha_ctx, (uint8_t *)ptr + 1, (uint32_t)(strlen(ptr + 1) + 1));
}
diff --git a/src/nvim/change.c b/src/nvim/change.c
index 599e319dde..36f0fc70a1 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -609,7 +609,7 @@ bool file_ff_differs(buf_T *buf, bool ignore_empty)
if (ignore_empty
&& (buf->b_flags & BF_NEW)
&& buf->b_ml.ml_line_count == 1
- && *ml_get_buf(buf, (linenr_T)1, false) == NUL) {
+ && *ml_get_buf(buf, (linenr_T)1) == NUL) {
return false;
}
if (buf->b_start_ffc != *buf->b_p_ff) {
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index d11cbddccf..ce49f2ad86 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -971,7 +971,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
int ts = (int)wp->w_buffer->b_p_ts;
colnr_T vcol = 0;
- char *line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, false); // start of the line
+ char *line = ptr = ml_get_buf(wp->w_buffer, pos->lnum); // start of the line
if (pos->col == MAXCOL) {
// continue until the NUL
@@ -1141,7 +1141,7 @@ void getvvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *e
colnr_T endadd = 0;
// Cannot put the cursor on part of a wide character.
- char *ptr = ml_get_buf(wp->w_buffer, pos->lnum, false);
+ char *ptr = ml_get_buf(wp->w_buffer, pos->lnum);
if (pos->col < (colnr_T)strlen(ptr)) {
int c = utf_ptr2char(ptr + pos->col);
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index a837618f5b..f7a456f4c7 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -108,7 +108,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
|| (VIsual_active && *p_sel != 'o')
|| ((get_ve_flags() & VE_ONEMORE) && wcol < MAXCOL);
- char *line = ml_get_buf(curbuf, pos->lnum, false);
+ char *line = ml_get_buf(curbuf, pos->lnum);
if (wcol >= MAXCOL) {
idx = (int)strlen(line) - 1 + one_more;
@@ -315,7 +315,7 @@ void check_pos(buf_T *buf, pos_T *pos)
}
if (pos->col > 0) {
- char *line = ml_get_buf(buf, pos->lnum, false);
+ char *line = ml_get_buf(buf, pos->lnum);
colnr_T len = (colnr_T)strlen(line);
if (pos->col > len) {
pos->col = len;
@@ -353,7 +353,7 @@ void check_cursor_col_win(win_T *win)
colnr_T oldcoladd = win->w_cursor.col + win->w_cursor.coladd;
unsigned cur_ve_flags = get_ve_flags();
- colnr_T len = (colnr_T)strlen(ml_get_buf(win->w_buffer, win->w_cursor.lnum, false));
+ colnr_T len = (colnr_T)strlen(ml_get_buf(win->w_buffer, win->w_cursor.lnum));
if (len == 0) {
win->w_cursor.col = 0;
} else if (win->w_cursor.col >= len) {
@@ -501,18 +501,17 @@ int gchar_cursor(void)
/// It is directly written into the block.
void pchar_cursor(char c)
{
- *(ml_get_buf(curbuf, curwin->w_cursor.lnum, true)
- + curwin->w_cursor.col) = c;
+ *(ml_get_buf_mut(curbuf, curwin->w_cursor.lnum) + curwin->w_cursor.col) = c;
}
/// @return pointer to cursor line.
char *get_cursor_line_ptr(void)
{
- return ml_get_buf(curbuf, curwin->w_cursor.lnum, false);
+ return ml_get_buf(curbuf, curwin->w_cursor.lnum);
}
/// @return pointer to cursor position.
char *get_cursor_pos_ptr(void)
{
- return ml_get_buf(curbuf, curwin->w_cursor.lnum, false) + curwin->w_cursor.col;
+ return ml_get_buf(curbuf, curwin->w_cursor.lnum) + curwin->w_cursor.col;
}
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 1f8d21220b..d3bd9f7754 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -596,9 +596,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp)
if (dir == BACKWARD) {
off_org = dp->df_count[i_org] - 1;
}
- char *line_org = xstrdup(ml_get_buf(tp->tp_diffbuf[i_org],
- dp->df_lnum[i_org] + off_org,
- false));
+ char *line_org = xstrdup(ml_get_buf(tp->tp_diffbuf[i_org], dp->df_lnum[i_org] + off_org));
int i_new;
for (i_new = i_org + 1; i_new < DB_COUNT; i_new++) {
@@ -616,8 +614,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp)
}
if (diff_cmp(line_org, ml_get_buf(tp->tp_diffbuf[i_new],
- dp->df_lnum[i_new] + off_new,
- false)) != 0) {
+ dp->df_lnum[i_new] + off_new)) != 0) {
break;
}
}
@@ -756,7 +753,7 @@ static int diff_write_buffer(buf_T *buf, mmfile_t *m, linenr_T start, linenr_T e
// xdiff requires one big block of memory with all the text.
for (linenr_T lnum = start; lnum <= end; lnum++) {
- len += strlen(ml_get_buf(buf, lnum, false)) + 1;
+ len += strlen(ml_get_buf(buf, lnum)) + 1;
}
char *ptr = try_malloc(len);
if (ptr == NULL) {
@@ -777,7 +774,7 @@ static int diff_write_buffer(buf_T *buf, mmfile_t *m, linenr_T start, linenr_T e
len = 0;
for (linenr_T lnum = start; lnum <= end; lnum++) {
- char *s = ml_get_buf(buf, lnum, false);
+ char *s = ml_get_buf(buf, lnum);
if (diff_flags & DIFF_ICASE) {
while (*s != NUL) {
char cbuf[MB_MAXBYTES + 1];
@@ -2244,11 +2241,9 @@ static bool diff_equal_entry(diff_T *dp, int idx1, int idx2)
}
for (int i = 0; i < dp->df_count[idx1]; i++) {
- char *line = xstrdup(ml_get_buf(curtab->tp_diffbuf[idx1],
- dp->df_lnum[idx1] + i, false));
+ char *line = xstrdup(ml_get_buf(curtab->tp_diffbuf[idx1], dp->df_lnum[idx1] + i));
- int cmp = diff_cmp(line, ml_get_buf(curtab->tp_diffbuf[idx2],
- dp->df_lnum[idx2] + i, false));
+ int cmp = diff_cmp(line, ml_get_buf(curtab->tp_diffbuf[idx2], dp->df_lnum[idx2] + i));
xfree(line);
if (cmp != 0) {
@@ -2617,7 +2612,7 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
// Make a copy of the line, the next ml_get() will invalidate it.
- char *line_org = xstrdup(ml_get_buf(wp->w_buffer, lnum, false));
+ char *line_org = xstrdup(ml_get_buf(wp->w_buffer, lnum));
int idx = diff_buf_idx(wp->w_buffer);
if (idx == DB_COUNT) {
@@ -2661,7 +2656,7 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
continue;
}
added = false;
- char *line_new = ml_get_buf(curtab->tp_diffbuf[i], dp->df_lnum[i] + off, false);
+ char *line_new = ml_get_buf(curtab->tp_diffbuf[i], dp->df_lnum[i] + off);
// Search for start of difference
si_org = si_new = 0;
@@ -3097,7 +3092,7 @@ static void diffgetput(const int addr_count, const int idx_cur, const int idx_fr
if (nr > curtab->tp_diffbuf[idx_from]->b_ml.ml_line_count) {
break;
}
- char *p = xstrdup(ml_get_buf(curtab->tp_diffbuf[idx_from], nr, false));
+ char *p = xstrdup(ml_get_buf(curtab->tp_diffbuf[idx_from], nr));
ml_append(lnum + i - 1, p, 0, false);
xfree(p);
added++;
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 3638ea19f4..31ca9b16ce 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -770,7 +770,7 @@ static void handle_breakindent(win_T *wp, winlinevars_T *wlv)
wlv->p_extra = NULL;
wlv->c_extra = ' ';
wlv->c_final = NUL;
- wlv->n_extra = get_breakindent_win(wp, ml_get_buf(wp->w_buffer, wlv->lnum, false));
+ wlv->n_extra = get_breakindent_win(wp, ml_get_buf(wp->w_buffer, wlv->lnum));
if (wlv->row == wlv->startrow) {
wlv->n_extra -= win_col_off2(wp);
if (wlv->n_extra < 0) {
@@ -1431,11 +1431,11 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
// Trick: skip a few chars for C/shell/Vim comments
nextline[SPWORDLEN] = NUL;
if (lnum < wp->w_buffer->b_ml.ml_line_count) {
- line = ml_get_buf(wp->w_buffer, lnum + 1, false);
+ line = ml_get_buf(wp->w_buffer, lnum + 1);
spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN);
}
assert(!end_fill);
- line = ml_get_buf(wp->w_buffer, lnum, false);
+ line = ml_get_buf(wp->w_buffer, lnum);
// If current line is empty, check first word in next line for capital.
ptr = skipwhite(line);
@@ -1470,7 +1470,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
}
}
- line = end_fill ? "" : ml_get_buf(wp->w_buffer, lnum, false);
+ line = end_fill ? "" : ml_get_buf(wp->w_buffer, lnum);
ptr = line;
colnr_T trailcol = MAXCOL; // start of trailing spaces
@@ -1567,7 +1567,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
len = spell_move_to(wp, FORWARD, true, true, &spell_hlf);
// spell_move_to() may call ml_get() and make "line" invalid
- line = ml_get_buf(wp->w_buffer, lnum, false);
+ line = ml_get_buf(wp->w_buffer, lnum);
ptr = line + linecol;
if (len == 0 || (int)wp->w_cursor.col > ptr - line) {
@@ -1712,7 +1712,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
get_statuscol_str(wp, lnum, wlv.row - startrow - wlv.filler_lines, &statuscol);
if (!end_fill) {
// Get the line again as evaluating 'statuscolumn' may free it.
- line = ml_get_buf(wp->w_buffer, lnum, false);
+ line = ml_get_buf(wp->w_buffer, lnum);
ptr = line + v;
}
if (wp->w_redr_statuscol) {
@@ -1912,7 +1912,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
wlv.p_extra[wlv.n_extra] = NUL;
// Get the line again as evaluating 'foldtext' may free it.
- line = ml_get_buf(wp->w_buffer, lnum, false);
+ line = ml_get_buf(wp->w_buffer, lnum);
ptr = line + v;
}
@@ -2166,7 +2166,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
// Need to get the line again, a multi-line regexp may
// have made it invalid.
- line = ml_get_buf(wp->w_buffer, lnum, false);
+ line = ml_get_buf(wp->w_buffer, lnum);
ptr = line + v;
// no concealing past the end of the line, it interferes
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index bf6094846a..9e25676d4e 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -823,7 +823,7 @@ void show_cursor_info_later(bool force)
{
int state = get_real_state();
int empty_line = (State & MODE_INSERT) == 0
- && *ml_get_buf(curwin->w_buffer, curwin->w_cursor.lnum, false) == NUL;
+ && *ml_get_buf(curwin->w_buffer, curwin->w_cursor.lnum) == NUL;
// Only draw when something changed.
validate_virtcol_win(curwin);
@@ -1875,7 +1875,7 @@ static void win_update(win_T *wp, DecorProviders *providers)
pos.lnum += cursor_above ? 1 : -1) {
colnr_T t;
- pos.col = (colnr_T)strlen(ml_get_buf(wp->w_buffer, pos.lnum, false));
+ pos.col = (colnr_T)strlen(ml_get_buf(wp->w_buffer, pos.lnum));
getvvcol(wp, &pos, NULL, NULL, &t);
if (toc < t) {
toc = t;
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 869b226856..6a6f44f0c7 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -3775,7 +3775,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
// again when auto-formatting.
if (has_format_option(FO_AUTO)
&& has_format_option(FO_WHITE_PAR)) {
- char *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, true);
+ char *ptr = ml_get_buf_mut(curbuf, curwin->w_cursor.lnum);
int len;
len = (int)strlen(ptr);
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 052d67b05f..e7a28cfe67 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -6423,7 +6423,7 @@ char *save_tv_as_string(typval_T *tv, ptrdiff_t *const len, bool endnl, bool crl
buf_T *buf = buflist_findnr((int)tv->vval.v_number);
if (buf) {
for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) {
- for (char *p = ml_get_buf(buf, lnum, false); *p != NUL; p++) {
+ for (char *p = ml_get_buf(buf, lnum); *p != NUL; p++) {
*len += 1;
}
*len += 1;
@@ -6441,7 +6441,7 @@ char *save_tv_as_string(typval_T *tv, ptrdiff_t *const len, bool endnl, bool crl
char *ret = xmalloc((size_t)(*len) + 1);
char *end = ret;
for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) {
- for (char *p = ml_get_buf(buf, lnum, false); *p != NUL; p++) {
+ for (char *p = ml_get_buf(buf, lnum); *p != NUL; p++) {
*end++ = (*p == '\n') ? NUL : *p;
}
*end++ = '\n';
@@ -6493,7 +6493,7 @@ int buf_byteidx_to_charidx(buf_T *buf, linenr_T lnum, int byteidx)
lnum = buf->b_ml.ml_line_count;
}
- char *str = ml_get_buf(buf, lnum, false);
+ char *str = ml_get_buf(buf, lnum);
if (*str == NUL) {
return 0;
@@ -6531,7 +6531,7 @@ int buf_charidx_to_byteidx(buf_T *buf, linenr_T lnum, int charidx)
lnum = buf->b_ml.ml_line_count;
}
- char *str = ml_get_buf(buf, lnum, false);
+ char *str = ml_get_buf(buf, lnum);
// Convert the character offset to a byte offset
char *t = str;
diff --git a/src/nvim/eval/buffer.c b/src/nvim/eval/buffer.c
index 256adfd44f..4dbfcd2938 100644
--- a/src/nvim/eval/buffer.c
+++ b/src/nvim/eval/buffer.c
@@ -604,12 +604,12 @@ static void get_buffer_lines(buf_T *buf, linenr_T start, linenr_T end, int retli
}
tv_list_alloc_ret(rettv, end - start + 1);
while (start <= end) {
- tv_list_append_string(rettv->vval.v_list, ml_get_buf(buf, start++, false), -1);
+ tv_list_append_string(rettv->vval.v_list, ml_get_buf(buf, start++), -1);
}
} else {
rettv->v_type = VAR_STRING;
rettv->vval.v_string = ((start >= 1 && start <= buf->b_ml.ml_line_count)
- ? xstrdup(ml_get_buf(buf, start, false)) : NULL);
+ ? xstrdup(ml_get_buf(buf, start)) : NULL);
}
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 68f9aa87ee..b4d07cc78a 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -4644,7 +4644,7 @@ static int show_sub(exarg_T *eap, pos_T old_cusr, PreviewLines *preview_lines, i
if (next_linenr == orig_buf->b_ml.ml_line_count + 1) {
line = "";
} else {
- line = ml_get_buf(orig_buf, next_linenr, false);
+ line = ml_get_buf(orig_buf, next_linenr);
line_size = strlen(line) + (size_t)col_width + 1;
// Reallocate if line not long enough
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index e22bb609b6..1cbfcff9f4 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -2842,7 +2842,7 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf)
// Copy the lines in "frombuf" to "tobuf".
curbuf = tobuf;
for (linenr_T lnum = 1; lnum <= frombuf->b_ml.ml_line_count; lnum++) {
- char *p = xstrdup(ml_get_buf(frombuf, lnum, false));
+ char *p = xstrdup(ml_get_buf(frombuf, lnum));
if (ml_append(lnum - 1, p, 0, false) == FAIL) {
xfree(p);
retval = FAIL;
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index bdf2e26ac6..595136d590 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -1601,7 +1601,7 @@ static void foldAddMarker(buf_T *buf, pos_T pos, const char *marker, size_t mark
linenr_T lnum = pos.lnum;
// Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end
- char *line = ml_get_buf(buf, lnum, false);
+ char *line = ml_get_buf(buf, lnum);
size_t line_len = strlen(line);
size_t added = 0;
@@ -1661,7 +1661,7 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char *marker, size_t marker
}
char *cms = buf->b_p_cms;
- char *line = ml_get_buf(buf, lnum, false);
+ char *line = ml_get_buf(buf, lnum);
for (char *p = line; *p != NUL; p++) {
if (strncmp(p, marker, markerlen) != 0) {
continue;
@@ -2874,7 +2874,7 @@ static void foldlevelIndent(fline_T *flp)
linenr_T lnum = flp->lnum + flp->off;
buf_T *buf = flp->wp->w_buffer;
- char *s = skipwhite(ml_get_buf(buf, lnum, false));
+ char *s = skipwhite(ml_get_buf(buf, lnum));
// empty line or lines starting with a character in 'foldignore': level
// depends on surrounding lines
@@ -3036,7 +3036,7 @@ static void foldlevelMarker(fline_T *flp)
flp->start = 0;
flp->lvl_next = flp->lvl;
- char *s = ml_get_buf(flp->wp->w_buffer, flp->lnum + flp->off, false);
+ char *s = ml_get_buf(flp->wp->w_buffer, flp->lnum + flp->off);
while (*s) {
if (*s == cstart
&& strncmp(s + 1, startmarker, foldstartmarkerlen - 1) == 0) {
diff --git a/src/nvim/help.c b/src/nvim/help.c
index dc384e3d14..1e21dbba4d 100644
--- a/src/nvim/help.c
+++ b/src/nvim/help.c
@@ -660,13 +660,13 @@ void fix_help_buffer(void)
if (!syntax_present(curwin)) {
bool in_example = false;
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) {
- line = ml_get_buf(curbuf, lnum, false);
+ line = ml_get_buf(curbuf, lnum);
const size_t len = strlen(line);
if (in_example && len > 0 && !ascii_iswhite(line[0])) {
// End of example: non-white or '<' in first column.
if (line[0] == '<') {
// blank-out a '<' in the first column
- line = ml_get_buf(curbuf, lnum, true);
+ line = ml_get_buf_mut(curbuf, lnum);
line[0] = ' ';
}
in_example = false;
@@ -674,12 +674,12 @@ void fix_help_buffer(void)
if (!in_example && len > 0) {
if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' ')) {
// blank-out a '>' in the last column (start of example)
- line = ml_get_buf(curbuf, lnum, true);
+ line = ml_get_buf_mut(curbuf, lnum);
line[len - 1] = ' ';
in_example = true;
} else if (line[len - 1] == '~') {
// blank-out a '~' at the end of line (header marker)
- line = ml_get_buf(curbuf, lnum, true);
+ line = ml_get_buf_mut(curbuf, lnum);
line[len - 1] = ' ';
}
}
@@ -696,7 +696,7 @@ void fix_help_buffer(void)
&& TOLOWER_ASC(fname[7]) == 'x'
&& fname[8] == NUL)) {
for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; lnum++) {
- line = ml_get_buf(curbuf, lnum, false);
+ line = ml_get_buf(curbuf, lnum);
if (strstr(line, "*local-additions*") == NULL) {
continue;
}
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 7e12637c6d..fb6228ae2d 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -378,10 +378,7 @@ int get_indent_lnum(linenr_T lnum)
// "buf".
int get_indent_buf(buf_T *buf, linenr_T lnum)
{
- return get_indent_str_vtab(ml_get_buf(buf, lnum, false),
- buf->b_p_ts,
- buf->b_p_vts_array,
- false);
+ return get_indent_str_vtab(ml_get_buf(buf, lnum), buf->b_p_ts, buf->b_p_vts_array, false);
}
/// Count the size (in window cells) of the indent in line "ptr", with
diff