Merge pull request #18302 from dundargoc/refactor/enable-conversion-warning/edit

refactor: enable -Wconversion warning for edit.c
This commit is contained in:
bfredl
2022-05-06 15:00:40 +02:00
committed by GitHub
8 changed files with 59 additions and 68 deletions

View File

@@ -157,7 +157,6 @@ list(REMOVE_ITEM NVIM_SOURCES ${to_remove})
# Legacy files that do not yet pass -Wconversion. # Legacy files that do not yet pass -Wconversion.
set(CONV_SOURCES set(CONV_SOURCES
edit.c
eval.c eval.c
ex_cmds.c ex_cmds.c
fileio.c fileio.c

View File

@@ -299,7 +299,7 @@ void buf_updates_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added,
kv_size(buf->update_callbacks) = j; kv_size(buf->update_callbacks) = j;
} }
void buf_updates_send_splice(buf_T *buf, int start_row, colnr_T start_col, bcount_t start_byte, void buf_updates_send_splice(buf_T *buf, linenr_T start_row, colnr_T start_col, bcount_t start_byte,
int old_row, colnr_T old_col, bcount_t old_byte, int new_row, int old_row, colnr_T old_col, bcount_t old_byte, int new_row,
colnr_T new_col, bcount_t new_byte) colnr_T new_col, bcount_t new_byte)
{ {

View File

@@ -1793,7 +1793,6 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang
int last_vcol; int last_vcol;
int insstart_less; // reduction for Insstart.col int insstart_less; // reduction for Insstart.col
int new_cursor_col; int new_cursor_col;
int i;
char_u *ptr; char_u *ptr;
int save_p_list; int save_p_list;
int start_col; int start_col;
@@ -1906,10 +1905,10 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang
*/ */
if (vcol != (int)curwin->w_virtcol) { if (vcol != (int)curwin->w_virtcol) {
curwin->w_cursor.col = (colnr_T)new_cursor_col; curwin->w_cursor.col = (colnr_T)new_cursor_col;
i = (int)curwin->w_virtcol - vcol; size_t i = (size_t)(curwin->w_virtcol - vcol);
ptr = xmallocz(i); ptr = xmallocz(i);
memset(ptr, ' ', i); memset(ptr, ' ', i);
new_cursor_col += i; new_cursor_col += (int)i;
ins_str(ptr); ins_str(ptr);
xfree(ptr); xfree(ptr);
} }
@@ -2289,7 +2288,7 @@ int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname,
? actual_len : actual_compl_length; ? actual_len : actual_compl_length;
// Allocate wide character array for the completion and fill it. // Allocate wide character array for the completion and fill it.
int *const wca = xmalloc(actual_len * sizeof(*wca)); int *const wca = xmalloc((size_t)actual_len * sizeof(*wca));
{ {
const char_u *p = str; const char_u *p = str;
for (i = 0; i < actual_len; i++) { for (i = 0; i < actual_len; i++) {
@@ -2449,7 +2448,7 @@ static int ins_compl_add(char_u *const str, int len, char_u *const fname,
if (flags & CP_ORIGINAL_TEXT) { if (flags & CP_ORIGINAL_TEXT) {
match->cp_number = 0; match->cp_number = 0;
} }
match->cp_str = vim_strnsave(str, len); match->cp_str = vim_strnsave(str, (size_t)len);
// match-fname is: // match-fname is:
// - compl_curr_match->cp_fname if it is a string equal to fname. // - compl_curr_match->cp_fname if it is a string equal to fname.
@@ -2682,7 +2681,7 @@ void set_completion(colnr_T startcol, list_T *list)
compl_length = (int)curwin->w_cursor.col - (int)startcol; compl_length = (int)curwin->w_cursor.col - (int)startcol;
// compl_pattern doesn't need to be set // compl_pattern doesn't need to be set
compl_orig_text = vim_strnsave(get_cursor_line_ptr() + compl_col, compl_orig_text = vim_strnsave(get_cursor_line_ptr() + compl_col,
compl_length); (size_t)compl_length);
if (p_ic) { if (p_ic) {
flags |= CP_ICASE; flags |= CP_ICASE;
} }
@@ -2840,7 +2839,7 @@ void ins_compl_show_pum(void)
do { do {
if ((compl->cp_flags & CP_ORIGINAL_TEXT) == 0 if ((compl->cp_flags & CP_ORIGINAL_TEXT) == 0
&& (compl_leader == NULL && (compl_leader == NULL
|| ins_compl_equal(compl, compl_leader, lead_len))) { || ins_compl_equal(compl, compl_leader, (size_t)lead_len))) {
compl_match_arraysize++; compl_match_arraysize++;
} }
compl = compl->cp_next; compl = compl->cp_next;
@@ -2850,9 +2849,9 @@ void ins_compl_show_pum(void)
} }
assert(compl_match_arraysize >= 0); assert(compl_match_arraysize >= 0);
compl_match_array = xcalloc(compl_match_arraysize, sizeof(pumitem_T)); compl_match_array = xcalloc((size_t)compl_match_arraysize, sizeof(pumitem_T));
/* If the current match is the original text don't find the first // If the current match is the original text don't find the first
* match after it, don't highlight anything. */ // match after it, don't highlight anything.
if (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) { if (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) {
shown_match_ok = true; shown_match_ok = true;
} }
@@ -2862,7 +2861,7 @@ void ins_compl_show_pum(void)
do { do {
if ((compl->cp_flags & CP_ORIGINAL_TEXT) == 0 if ((compl->cp_flags & CP_ORIGINAL_TEXT) == 0
&& (compl_leader == NULL && (compl_leader == NULL
|| ins_compl_equal(compl, compl_leader, lead_len))) { || ins_compl_equal(compl, compl_leader, (size_t)lead_len))) {
if (!shown_match_ok) { if (!shown_match_ok) {
if (compl == compl_shown_match || did_find_shown_match) { if (compl == compl_shown_match || did_find_shown_match) {
/* This item is the shown match or this is the /* This item is the shown match or this is the
@@ -3429,7 +3428,7 @@ static int ins_compl_bs(void)
line = get_cursor_line_ptr(); line = get_cursor_line_ptr();
xfree(compl_leader); xfree(compl_leader);
compl_leader = vim_strnsave(line + compl_col, (int)p_off - compl_col); compl_leader = vim_strnsave(line + compl_col, (size_t)(p_off - (ptrdiff_t)compl_col));
ins_compl_new_leader(); ins_compl_new_leader();
if (compl_shown_match != NULL) { if (compl_shown_match != NULL) {
// Make sure current match is not a hidden item. // Make sure current match is not a hidden item.
@@ -3518,7 +3517,7 @@ static void ins_compl_addleader(int c)
utf_char2bytes(c, buf); utf_char2bytes(c, buf);
buf[cc] = NUL; buf[cc] = NUL;
ins_char_bytes(buf, cc); ins_char_bytes(buf, (size_t)cc);
} else { } else {
ins_char(c); ins_char(c);
} }
@@ -3530,7 +3529,7 @@ static void ins_compl_addleader(int c)
xfree(compl_leader); xfree(compl_leader);
compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col, compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col,
curwin->w_cursor.col - compl_col); (size_t)(curwin->w_cursor.col - compl_col));
ins_compl_new_leader(); ins_compl_new_leader();
} }
@@ -3590,8 +3589,7 @@ static void ins_compl_addfrommatch(void)
for (cp = compl_shown_match->cp_next; cp != NULL for (cp = compl_shown_match->cp_next; cp != NULL
&& cp != compl_first_match; cp = cp->cp_next) { && cp != compl_first_match; cp = cp->cp_next) {
if (compl_leader == NULL if (compl_leader == NULL
|| ins_compl_equal(cp, compl_leader, || ins_compl_equal(cp, compl_leader, STRLEN(compl_leader))) {
(int)STRLEN(compl_leader))) {
p = cp->cp_str; p = cp->cp_str;
break; break;
} }
@@ -4753,12 +4751,10 @@ static int ins_compl_next(int allow_get_expansion, int count, int insert_match,
/* If we didn't find it searching forward, and compl_shows_dir is /* If we didn't find it searching forward, and compl_shows_dir is
* backward, find the last match. */ * backward, find the last match. */
if (compl_shows_dir == BACKWARD if (compl_shows_dir == BACKWARD
&& !ins_compl_equal(compl_shown_match, && !ins_compl_equal(compl_shown_match, compl_leader, STRLEN(compl_leader))
compl_leader, (int)STRLEN(compl_leader))
&& (compl_shown_match->cp_next == NULL && (compl_shown_match->cp_next == NULL
|| compl_shown_match->cp_next == compl_first_match)) { || compl_shown_match->cp_next == compl_first_match)) {
while (!ins_compl_equal(compl_shown_match, while (!ins_compl_equal(compl_shown_match, compl_leader, STRLEN(compl_leader))
compl_leader, (int)STRLEN(compl_leader))
&& compl_shown_match->cp_prev != NULL && compl_shown_match->cp_prev != NULL
&& compl_shown_match->cp_prev != compl_first_match) { && compl_shown_match->cp_prev != compl_first_match) {
compl_shown_match = compl_shown_match->cp_prev; compl_shown_match = compl_shown_match->cp_prev;
@@ -5183,7 +5179,7 @@ static int ins_complete(int c, bool enable_pum)
if (p_ic) { if (p_ic) {
compl_pattern = str_foldcase(line + compl_col, compl_length, NULL, 0); compl_pattern = str_foldcase(line + compl_col, compl_length, NULL, 0);
} else { } else {
compl_pattern = vim_strnsave(line + compl_col, compl_length); compl_pattern = vim_strnsave(line + compl_col, (size_t)compl_length);
} }
} else if (compl_cont_status & CONT_ADDING) { } else if (compl_cont_status & CONT_ADDING) {
char_u *prefix = (char_u *)"\\<"; char_u *prefix = (char_u *)"\\<";
@@ -5247,7 +5243,7 @@ static int ins_complete(int c, bool enable_pum)
if (p_ic) { if (p_ic) {
compl_pattern = str_foldcase(line + compl_col, compl_length, NULL, 0); compl_pattern = str_foldcase(line + compl_col, compl_length, NULL, 0);
} else { } else {
compl_pattern = vim_strnsave(line + compl_col, compl_length); compl_pattern = vim_strnsave(line + compl_col, (size_t)compl_length);
} }
} else if (ctrl_x_mode == CTRL_X_FILES) { } else if (ctrl_x_mode == CTRL_X_FILES) {
// Go back to just before the first filename character. // Go back to just before the first filename character.
@@ -5267,9 +5263,9 @@ static int ins_complete(int c, bool enable_pum)
compl_col += startcol; compl_col += startcol;
compl_length = (int)curs_col - startcol; compl_length = (int)curs_col - startcol;
compl_pattern = addstar(line + compl_col, compl_length, EXPAND_FILES); compl_pattern = addstar(line + compl_col, (size_t)compl_length, EXPAND_FILES);
} else if (ctrl_x_mode == CTRL_X_CMDLINE || ctrl_x_mode == CTRL_X_CMDLINE_CTRL_X) { } else if (ctrl_x_mode == CTRL_X_CMDLINE || ctrl_x_mode == CTRL_X_CMDLINE_CTRL_X) {
compl_pattern = vim_strnsave(line, curs_col); compl_pattern = vim_strnsave(line, (size_t)curs_col);
set_cmd_context(&compl_xp, compl_pattern, set_cmd_context(&compl_xp, compl_pattern,
(int)STRLEN(compl_pattern), curs_col, false); (int)STRLEN(compl_pattern), curs_col, false);
if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL
@@ -5311,7 +5307,7 @@ static int ins_complete(int c, bool enable_pum)
pos = curwin->w_cursor; pos = curwin->w_cursor;
curwin_save = curwin; curwin_save = curwin;
curbuf_save = curbuf; curbuf_save = curbuf;
int col = call_func_retnr((char *)funcname, 2, args); colnr_T col = (colnr_T)call_func_retnr((char *)funcname, 2, args);
State = save_State; State = save_State;
if (curwin_save != curwin || curbuf_save != curbuf) { if (curwin_save != curwin || curbuf_save != curbuf) {
@@ -5356,7 +5352,7 @@ static int ins_complete(int c, bool enable_pum)
* it may have become invalid. */ * it may have become invalid. */
line = ml_get(curwin->w_cursor.lnum); line = ml_get(curwin->w_cursor.lnum);
compl_length = curs_col - compl_col; compl_length = curs_col - compl_col;
compl_pattern = vim_strnsave(line + compl_col, compl_length); compl_pattern = vim_strnsave(line + compl_col, (size_t)compl_length);
} else if (ctrl_x_mode == CTRL_X_SPELL) { } else if (ctrl_x_mode == CTRL_X_SPELL) {
if (spell_bad_len > 0) { if (spell_bad_len > 0) {
assert(spell_bad_len <= INT_MAX); assert(spell_bad_len <= INT_MAX);
@@ -5373,7 +5369,7 @@ static int ins_complete(int c, bool enable_pum)
} }
// Need to obtain "line" again, it may have become invalid. // Need to obtain "line" again, it may have become invalid.
line = ml_get(curwin->w_cursor.lnum); line = ml_get(curwin->w_cursor.lnum);
compl_pattern = vim_strnsave(line + compl_col, compl_length); compl_pattern = vim_strnsave(line + compl_col, (size_t)compl_length);
} else { } else {
internal_error("ins_complete()"); internal_error("ins_complete()");
return FAIL; return FAIL;
@@ -5410,7 +5406,7 @@ static int ins_complete(int c, bool enable_pum)
// Always add completion for the original text. // Always add completion for the original text.
xfree(compl_orig_text); xfree(compl_orig_text);
compl_orig_text = vim_strnsave(line + compl_col, compl_length); compl_orig_text = vim_strnsave(line + compl_col, (size_t)compl_length);
if (p_ic) { if (p_ic) {
flags |= CP_ICASE; flags |= CP_ICASE;
} }
@@ -5840,7 +5836,6 @@ void insertchar(int c, int flags, int second_indent)
if (did_ai && c == end_comment_pending) { if (did_ai && c == end_comment_pending) {
char_u *line; char_u *line;
char_u lead_end[COM_MAX_LEN]; // end-comment string char_u lead_end[COM_MAX_LEN]; // end-comment string
int middle_len, end_len;
int i; int i;
/* /*
@@ -5853,7 +5848,7 @@ void insertchar(int c, int flags, int second_indent)
while (*p && p[-1] != ':') { // find end of middle flags while (*p && p[-1] != ':') { // find end of middle flags
p++; p++;
} }
middle_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); int middle_len = (int)copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
// Don't count trailing white space for middle_len // Don't count trailing white space for middle_len
while (middle_len > 0 && ascii_iswhite(lead_end[middle_len - 1])) { while (middle_len > 0 && ascii_iswhite(lead_end[middle_len - 1])) {
middle_len--; middle_len--;
@@ -5863,7 +5858,7 @@ void insertchar(int c, int flags, int second_indent)
while (*p && p[-1] != ':') { // find end of end flags while (*p && p[-1] != ':') { // find end of end flags
p++; p++;
} }
end_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); int end_len = (int)copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
// Skip white space before the cursor // Skip white space before the cursor
i = curwin->w_cursor.col; i = curwin->w_cursor.col;
@@ -5880,7 +5875,7 @@ void insertchar(int c, int flags, int second_indent)
// Insert the end-comment string, except for the last // Insert the end-comment string, except for the last
// character, which will get inserted as normal later. // character, which will get inserted as normal later.
ins_bytes_len(lead_end, end_len - 1); ins_bytes_len(lead_end, (size_t)(end_len - 1));
} }
} }
} }
@@ -5912,7 +5907,7 @@ void insertchar(int c, int flags, int second_indent)
int i; int i;
colnr_T virtcol = 0; colnr_T virtcol = 0;
buf[0] = c; buf[0] = (char_u)c;
i = 1; i = 1;
if (textwidth > 0) { if (textwidth > 0) {
virtcol = get_nolist_virtcol(); virtcol = get_nolist_virtcol();
@@ -5934,7 +5929,7 @@ void insertchar(int c, int flags, int second_indent)
if (p_hkmap && KeyTyped) { if (p_hkmap && KeyTyped) {
c = hkmap(c); // Hebrew mode mapping c = hkmap(c); // Hebrew mode mapping
} }
buf[i++] = c; buf[i++] = (char_u)c;
} }
do_digraph(-1); // clear digraphs do_digraph(-1); // clear digraphs
@@ -5958,7 +5953,7 @@ void insertchar(int c, int flags, int second_indent)
utf_char2bytes(c, buf); utf_char2bytes(c, buf);
buf[cc] = NUL; buf[cc] = NUL;
ins_char_bytes(buf, cc); ins_char_bytes(buf, (size_t)cc);
AppendCharToRedobuff(c); AppendCharToRedobuff(c);
} else { } else {
ins_char(c); ins_char(c);
@@ -6372,7 +6367,7 @@ static void internal_format(int textwidth, int second_indent, int flags, int for
} }
if (save_char != NUL) { // put back space after cursor if (save_char != NUL) { // put back space after cursor
pchar_cursor(save_char); pchar_cursor((char_u)save_char);
} }
curwin->w_p_lbr = has_lbr; curwin->w_p_lbr = has_lbr;
@@ -6475,7 +6470,7 @@ void auto_format(bool trailblank, bool prev_line)
new = get_cursor_line_ptr(); new = get_cursor_line_ptr();
len = (colnr_T)STRLEN(new); len = (colnr_T)STRLEN(new);
if (curwin->w_cursor.col == len) { if (curwin->w_cursor.col == len) {
pnew = vim_strnsave(new, len + 2); pnew = vim_strnsave(new, (size_t)len + 2);
pnew[len] = ' '; pnew[len] = ' ';
pnew[len + 1] = NUL; pnew[len + 1] = NUL;
ml_replace(curwin->w_cursor.lnum, (char *)pnew, false); ml_replace(curwin->w_cursor.lnum, (char *)pnew, false);
@@ -6529,11 +6524,11 @@ static void check_auto_format(bool end_insert)
/// @param ff force formatting (for "gq" command) /// @param ff force formatting (for "gq" command)
int comp_textwidth(bool ff) int comp_textwidth(bool ff)
{ {
int textwidth = curbuf->b_p_tw; int textwidth = (int)curbuf->b_p_tw;
if (textwidth == 0 && curbuf->b_p_wm) { if (textwidth == 0 && curbuf->b_p_wm) {
// The width is the window width minus 'wrapmargin' minus all the // The width is the window width minus 'wrapmargin' minus all the
// things that add to the margin. // things that add to the margin.
textwidth = curwin->w_width_inner - curbuf->b_p_wm; textwidth = curwin->w_width_inner - (int)curbuf->b_p_wm;
if (cmdwin_type != 0) { if (cmdwin_type != 0) {
textwidth -= 1; textwidth -= 1;
} }
@@ -6857,7 +6852,7 @@ char_u *add_char2buf(int c, char_u *s)
*s++ = KS_SPECIAL; *s++ = KS_SPECIAL;
*s++ = KE_FILLER; *s++ = KE_FILLER;
} else { } else {
*s++ = c; *s++ = (char_u)c;
} }
} }
return s; return s;
@@ -7237,11 +7232,11 @@ void replace_push(int c)
if (replace_stack_len <= replace_stack_nr) { if (replace_stack_len <= replace_stack_nr) {
replace_stack_len += 50; replace_stack_len += 50;
replace_stack = xrealloc(replace_stack, replace_stack_len); replace_stack = xrealloc(replace_stack, (size_t)replace_stack_len);
} }
char_u *p = replace_stack + replace_stack_nr - replace_offset; char_u *p = replace_stack + replace_stack_nr - replace_offset;
if (replace_offset) { if (replace_offset) {
memmove(p + 1, p, replace_offset); memmove(p + 1, p, (size_t)replace_offset);
} }
*p = (char_u)c; *p = (char_u)c;
++replace_stack_nr; ++replace_stack_nr;
@@ -7277,9 +7272,7 @@ static int replace_pop(void)
/// @param off offset for which NUL to remove /// @param off offset for which NUL to remove
static void replace_join(int off) static void replace_join(int off)
{ {
int i; for (ssize_t i = replace_stack_nr; --i >= 0;) {
for (i = replace_stack_nr; --i >= 0;) {
if (replace_stack[i] == NUL && off-- <= 0) { if (replace_stack[i] == NUL && off-- <= 0) {
--replace_stack_nr; --replace_stack_nr;
memmove(replace_stack + i, replace_stack + i + 1, memmove(replace_stack + i, replace_stack + i + 1,
@@ -7318,11 +7311,11 @@ static void mb_replace_pop_ins(int cc)
int c; int c;
if ((n = MB_BYTE2LEN(cc)) > 1) { if ((n = MB_BYTE2LEN(cc)) > 1) {
buf[0] = cc; buf[0] = (char_u)cc;
for (i = 1; i < n; ++i) { for (i = 1; i < n; i++) {
buf[i] = replace_pop(); buf[i] = (char_u)replace_pop();
} }
ins_bytes_len(buf, n); ins_bytes_len(buf, (size_t)n);
} else { } else {
ins_char(cc); ins_char(cc);
} }
@@ -7339,13 +7332,13 @@ static void mb_replace_pop_ins(int cc)
break; break;
} }
buf[0] = c; buf[0] = (char_u)c;
assert(n > 1); assert(n > 1);
for (i = 1; i < n; i++) { for (i = 1; i < n; i++) {
buf[i] = replace_pop(); buf[i] = (char_u)replace_pop();
} }
if (utf_iscomposing(utf_ptr2char(buf))) { if (utf_iscomposing(utf_ptr2char(buf))) {
ins_bytes_len(buf, n); ins_bytes_len(buf, (size_t)n);
} else { } else {
// Not a composing char, put it back. // Not a composing char, put it back.
for (i = n - 1; i >= 0; i--) { for (i = n - 1; i >= 0; i--) {
@@ -9143,8 +9136,7 @@ static bool ins_tab(void)
// Insert each char in saved_line from changed_col to // Insert each char in saved_line from changed_col to
// ptr-cursor // ptr-cursor
ins_bytes_len(saved_line + change_col, ins_bytes_len(saved_line + change_col, (size_t)(cursor->col - change_col));
cursor->col - change_col);
} }
} }

View File

@@ -417,7 +417,7 @@ static void u_extmark_set(buf_T *buf, uint64_t mark, int row, colnr_T col)
/// ///
/// useful when we cannot simply reverse the operation. This will do nothing on /// useful when we cannot simply reverse the operation. This will do nothing on
/// redo, enforces correct position when undo. /// redo, enforces correct position when undo.
void u_extmark_copy(buf_T *buf, int l_row, colnr_T l_col, int u_row, colnr_T u_col) void u_extmark_copy(buf_T *buf, linenr_T l_row, colnr_T l_col, linenr_T u_row, colnr_T u_col)
{ {
u_header_T *uhp = u_force_get_undo_header(buf); u_header_T *uhp = u_force_get_undo_header(buf);
if (!uhp) { if (!uhp) {
@@ -427,7 +427,7 @@ void u_extmark_copy(buf_T *buf, int l_row, colnr_T l_col, int u_row, colnr_T u_c
ExtmarkUndoObject undo; ExtmarkUndoObject undo;
MarkTreeIter itr[1] = { 0 }; MarkTreeIter itr[1] = { 0 };
marktree_itr_get(buf->b_marktree, l_row, l_col, itr); marktree_itr_get(buf->b_marktree, (int32_t)l_row, l_col, itr);
while (true) { while (true) {
mtkey_t mark = marktree_itr_current(itr); mtkey_t mark = marktree_itr_current(itr);
if (mark.pos.row < 0 if (mark.pos.row < 0
@@ -553,7 +553,7 @@ void extmark_adjust(buf_T *buf, linenr_T line1, linenr_T line2, long amount, lon
// the end column of the new region. // the end column of the new region.
// @param new_byte Byte extent of the new region. // @param new_byte Byte extent of the new region.
// @param undo // @param undo
void extmark_splice(buf_T *buf, int start_row, colnr_T start_col, int old_row, colnr_T old_col, void extmark_splice(buf_T *buf, linenr_T start_row, colnr_T start_col, int old_row, colnr_T old_col,
bcount_t old_byte, int new_row, colnr_T new_col, bcount_t new_byte, bcount_t old_byte, int new_row, colnr_T new_col, bcount_t new_byte,
ExtmarkOp undo) ExtmarkOp undo)
{ {
@@ -573,7 +573,7 @@ void extmark_splice(buf_T *buf, int start_row, colnr_T start_col, int old_row, c
undo); undo);
} }
void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t start_byte, void extmark_splice_impl(buf_T *buf, linenr_T start_row, colnr_T start_col, bcount_t start_byte,
int old_row, colnr_T old_col, bcount_t old_byte, int new_row, int old_row, colnr_T old_col, bcount_t old_byte, int new_row,
colnr_T new_col, bcount_t new_byte, ExtmarkOp undo) colnr_T new_col, bcount_t new_byte, ExtmarkOp undo)
{ {
@@ -588,13 +588,13 @@ void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t
// beginning and right-gravity at the end need not be preserved. // beginning and right-gravity at the end need not be preserved.
// Also be smart about marks that already have been saved (important for // Also be smart about marks that already have been saved (important for
// merge!) // merge!)
int end_row = start_row + old_row; linenr_T end_row = start_row + old_row;
int end_col = (old_row ? 0 : start_col) + old_col; int end_col = (old_row ? 0 : start_col) + old_col;
u_extmark_copy(buf, start_row, start_col, end_row, end_col); u_extmark_copy(buf, start_row, start_col, end_row, end_col);
} }
marktree_splice(buf->b_marktree, start_row, start_col, marktree_splice(buf->b_marktree, (int32_t)start_row, start_col,
old_row, old_col, old_row, old_col,
new_row, new_col); new_row, new_col);
@@ -656,7 +656,7 @@ void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t
} }
} }
void extmark_splice_cols(buf_T *buf, int start_row, colnr_T start_col, colnr_T old_col, void extmark_splice_cols(buf_T *buf, linenr_T start_row, colnr_T start_col, colnr_T old_col,
colnr_T new_col, ExtmarkOp undo) colnr_T new_col, ExtmarkOp undo)
{ {
extmark_splice(buf, start_row, start_col, extmark_splice(buf, start_row, start_col,

View File

@@ -29,7 +29,7 @@ typedef ptrdiff_t bcount_t;
// delete the columns between mincol and endcol // delete the columns between mincol and endcol
typedef struct { typedef struct {
int start_row; linenr_T start_row;
colnr_T start_col; colnr_T start_col;
int old_row; int old_row;
colnr_T old_col; colnr_T old_col;

View File

@@ -606,7 +606,7 @@ EXTERN pos_T Insstart; // This is where the latest
EXTERN pos_T Insstart_orig; EXTERN pos_T Insstart_orig;
// Stuff for VREPLACE mode. // Stuff for VREPLACE mode.
EXTERN int orig_line_count INIT(= 0); // Line count when "gR" started EXTERN linenr_T orig_line_count INIT(= 0); // Line count when "gR" started
EXTERN int vr_lines_changed INIT(= 0); // #Lines changed by "gR" so far EXTERN int vr_lines_changed INIT(= 0); // #Lines changed by "gR" so far
// increase around internal delete/replace // increase around internal delete/replace

View File

@@ -583,7 +583,7 @@ void marktree_move(MarkTree *b, MarkTreeIter *itr, int row, int col)
// itr functions // itr functions
// TODO(bfredl): static inline? // TODO(bfredl): static inline?
bool marktree_itr_get(MarkTree *b, int row, int col, MarkTreeIter *itr) bool marktree_itr_get(MarkTree *b, int32_t row, int col, MarkTreeIter *itr)
{ {
return marktree_itr_get_ext(b, (mtpos_t){ row, col }, return marktree_itr_get_ext(b, (mtpos_t){ row, col },
itr, false, false, NULL); itr, false, false, NULL);
@@ -832,7 +832,7 @@ static void itr_swap(MarkTreeIter *itr1, MarkTreeIter *itr2)
rawkey(itr2).pos = key2.pos; rawkey(itr2).pos = key2.pos;
} }
bool marktree_splice(MarkTree *b, int start_line, int start_col, int old_extent_line, bool marktree_splice(MarkTree *b, int32_t start_line, int start_col, int old_extent_line,
int old_extent_col, int new_extent_line, int new_extent_col) int old_extent_col, int new_extent_line, int new_extent_col)
{ {
mtpos_t start = { start_line, start_col }; mtpos_t start = { start_line, start_col };

View File

@@ -408,7 +408,7 @@ size_t xstrnlen(const char *s, size_t n)
if (end == NULL) { if (end == NULL) {
return n; return n;
} }
return end - s; return (size_t)(end - s);
} }
#endif #endif