refactor: change type of linenr_T from long to int32_t

The size of long varies depending on architecture, in contrast to the
MAXLNUM constant which sets the maximum allowable number of lines to
2^32-1. This discrepancy may lead to hard to detect bugs, for example
https://github.com/neovim/neovim/issues/18454. Setting linenr_T to a
fix maximum size of 2^32-1 will prevent this type of errors in the
future.

Also change the variables `amount` and `amount_after` to be linenr_T
since they're referring to "the line number difference" between two
texts.
This commit is contained in:
Dundar Goc 2022-05-07 12:53:37 +02:00
parent e15d31b530
commit a732c253b7
30 changed files with 165 additions and 148 deletions

View File

@ -8,6 +8,7 @@ include(CheckCSourceCompiles)
check_type_size("int" SIZEOF_INT LANGUAGE C)
check_type_size("long" SIZEOF_LONG LANGUAGE C)
check_type_size("intmax_t" SIZEOF_INTMAX_T LANGUAGE C)
check_type_size("int32_t" SIZEOF_INT32_T LANGUAGE C)
check_type_size("size_t" SIZEOF_SIZE_T LANGUAGE C)
check_type_size("long long" SIZEOF_LONG_LONG LANGUAGE C)
check_type_size("void *" SIZEOF_VOID_PTR LANGUAGE C)

View File

@ -5,6 +5,7 @@
#cmakedefine SIZEOF_INT @SIZEOF_INT@
#cmakedefine SIZEOF_INTMAX_T @SIZEOF_INTMAX_T@
#cmakedefine SIZEOF_INT32_T @SIZEOF_INT32_T@
#cmakedefine SIZEOF_LONG @SIZEOF_LONG@
#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@
#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@

View File

@ -420,7 +420,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
goto end;
}
bcount_t deleted_bytes = get_region_bytecount(curbuf, start, end, 0, 0);
bcount_t deleted_bytes = get_region_bytecount(curbuf, (linenr_T)start, (linenr_T)end, 0, 0);
// If the size of the range is reducing (ie, new_len < old_len) we
// need to delete some old_len. We do this at the start, by
@ -490,14 +490,14 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
mark_adjust((linenr_T)start,
(linenr_T)(end - 1),
MAXLNUM,
(long)extra,
(linenr_T)extra,
kExtmarkNOOP);
extmark_splice(curbuf, (int)start - 1, 0, (int)(end - start), 0,
deleted_bytes, (int)new_len, 0, inserted_bytes,
kExtmarkUndo);
changed_lines((linenr_T)start, 0, (linenr_T)end, (long)extra, true);
changed_lines((linenr_T)start, 0, (linenr_T)end, (linenr_T)extra, true);
fix_cursor((linenr_T)start, (linenr_T)end, (linenr_T)extra);
end:
@ -564,13 +564,13 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
return;
}
char *str_at_start = (char *)ml_get_buf(buf, start_row, false);
char *str_at_start = (char *)ml_get_buf(buf, (linenr_T)start_row, false);
if (start_col < 0 || (size_t)start_col > strlen(str_at_start)) {
api_set_error(err, kErrorTypeValidation, "start_col out of bounds");
return;
}
char *str_at_end = (char *)ml_get_buf(buf, end_row, false);
char *str_at_end = (char *)ml_get_buf(buf, (linenr_T)end_row, false);
size_t len_at_end = strlen(str_at_end);
if (end_col < 0 || (size_t)end_col > len_at_end) {
api_set_error(err, kErrorTypeValidation, "end_col out of bounds");
@ -600,7 +600,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 = (char *)ml_get_buf(buf, lnum, false);
const char *bufline = (char *)ml_get_buf(buf, (linenr_T)lnum, false);
old_byte += (bcount_t)(strlen(bufline)) + 1;
}
old_byte += (bcount_t)end_col + 1;
@ -725,7 +725,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
mark_adjust((linenr_T)start_row,
(linenr_T)end_row,
MAXLNUM,
(long)extra,
(linenr_T)extra,
kExtmarkNOOP);
colnr_T col_extent = (colnr_T)(end_col
@ -735,8 +735,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
(int)new_len - 1, (colnr_T)last_item.size, new_byte,
kExtmarkUndo);
changed_lines((linenr_T)start_row, 0, (linenr_T)end_row + 1,
(long)extra, true);
changed_lines((linenr_T)start_row, 0, (linenr_T)end_row + 1, (linenr_T)extra, true);
// adjust cursor like an extmark ( i e it was inside last_part_len)
if (curwin->w_cursor.lnum == end_row && curwin->w_cursor.col > end_col) {

View File

@ -1397,7 +1397,8 @@ bool set_mark(buf_T *buf, String name, Integer line, Integer col, Error *err)
return res;
}
}
pos_T pos = { line, (int)col, (int)col };
assert(INT32_MIN <= line && line <= INT32_MAX);
pos_T pos = { (linenr_T)line, (int)col, (int)col };
res = setmark_pos(*name.data, &pos, buf->handle);
if (!res) {
if (deleting) {
@ -1773,9 +1774,9 @@ void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdinfo, cha
// Command range / count.
if (eap->argt & EX_RANGE) {
if (eap->addr_count == 1) {
kv_printf(cmdline, "%ld", eap->line2);
kv_printf(cmdline, "%" PRIdLINENR, eap->line2);
} else if (eap->addr_count > 1) {
kv_printf(cmdline, "%ld,%ld", eap->line1, eap->line2);
kv_printf(cmdline, "%" PRIdLINENR ",%" PRIdLINENR, eap->line1, eap->line2);
eap->addr_count = 2; // Make sure address count is not greater than 2
}
}

View File

@ -1155,8 +1155,8 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
}
if (range.size > 0) {
ea.line1 = range.items[0].data.integer;
ea.line2 = range.items[range.size - 1].data.integer;
ea.line1 = (linenr_T)range.items[0].data.integer;
ea.line2 = (linenr_T)range.items[range.size - 1].data.integer;
}
if (invalid_range(&ea) != NULL) {

View File

@ -325,7 +325,7 @@ static bool parse_float_bufpos(Array bufpos, lpos_T *out)
|| bufpos.items[1].type != kObjectTypeInteger) {
return false;
}
out->lnum = bufpos.items[0].data.integer;
out->lnum = (linenr_T)bufpos.items[0].data.integer;
out->col = (colnr_T)bufpos.items[1].data.integer;
return true;
}

View File

@ -138,7 +138,7 @@ void changed_internal(void)
/// Common code for when a change was made.
/// See changed_lines() for the arguments.
/// Careful: may trigger autocommands that reload the buffer.
static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra)
static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, linenr_T xtra)
{
// mark the buffer as modified
changed();
@ -349,7 +349,7 @@ static void changedOneline(buf_T *buf, linenr_T lnum)
void changed_bytes(linenr_T lnum, colnr_T col)
{
changedOneline(curbuf, lnum);
changed_common(lnum, col, lnum + 1, 0L);
changed_common(lnum, col, lnum + 1, 0);
// notify any channels that are watching
buf_updates_send_changes(curbuf, lnum, 1, 1);
@ -382,7 +382,7 @@ void inserted_bytes(linenr_T lnum, colnr_T col, int old, int new)
/// Appended "count" lines below line "lnum" in the current buffer.
/// Must be called AFTER the change and after mark_adjust().
/// Takes care of marking the buffer to be redrawn and sets the changed flag.
void appended_lines(linenr_T lnum, long count)
void appended_lines(linenr_T lnum, linenr_T count)
{
changed_lines(lnum + 1, 0, lnum + 1, count, true);
}
@ -393,18 +393,18 @@ void appended_lines_mark(linenr_T lnum, long count)
// Skip mark_adjust when adding a line after the last one, there can't
// be marks there. But it's still needed in diff mode.
if (lnum + count < curbuf->b_ml.ml_line_count || curwin->w_p_diff) {
mark_adjust(lnum + 1, (linenr_T)MAXLNUM, count, 0L, kExtmarkUndo);
mark_adjust(lnum + 1, (linenr_T)MAXLNUM, (linenr_T)count, 0L, kExtmarkUndo);
} else {
extmark_adjust(curbuf, lnum + 1, (linenr_T)MAXLNUM, count, 0L,
extmark_adjust(curbuf, lnum + 1, (linenr_T)MAXLNUM, (linenr_T)count, 0L,
kExtmarkUndo);
}
changed_lines(lnum + 1, 0, lnum + 1, count, true);
changed_lines(lnum + 1, 0, lnum + 1, (linenr_T)count, true);
}
/// Deleted "count" lines at line "lnum" in the current buffer.
/// Must be called AFTER the change and after mark_adjust().
/// Takes care of marking the buffer to be redrawn and sets the changed flag.
void deleted_lines(linenr_T lnum, long count)
void deleted_lines(linenr_T lnum, linenr_T count)
{
changed_lines(lnum, 0, lnum + count, -count, true);
}
@ -418,9 +418,9 @@ void deleted_lines_mark(linenr_T lnum, long count)
bool made_empty = (count > 0) && curbuf->b_ml.ml_flags & ML_EMPTY;
mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM,
-count + (made_empty?1:0),
-(linenr_T)count + (made_empty?1:0),
kExtmarkUndo);
changed_lines(lnum, 0, lnum + count, -count, true);
changed_lines(lnum, 0, lnum + (linenr_T)count, (linenr_T)(-count), true);
}
/// Marks the area to be redrawn after a change.
@ -429,7 +429,7 @@ void deleted_lines_mark(linenr_T lnum, long count)
/// @param lnum first line with change
/// @param lnume line below last changed line
/// @param xtra number of extra lines (negative when deleting)
void changed_lines_buf(buf_T *buf, linenr_T lnum, linenr_T lnume, long xtra)
void changed_lines_buf(buf_T *buf, linenr_T lnum, linenr_T lnume, linenr_T xtra)
{
if (buf->b_mod_set) {
// find the maximum area that must be redisplayed
@ -474,7 +474,7 @@ void changed_lines_buf(buf_T *buf, linenr_T lnum, linenr_T lnume, long xtra)
/// @param do_buf_event some callers like undo/redo call changed_lines() and
/// then increment changedtick *again*. This flag allows these callers to send
/// the nvim_buf_lines_event events after they're done modifying changedtick.
void changed_lines(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra, bool do_buf_event)
void changed_lines(linenr_T lnum, colnr_T col, linenr_T lnume, linenr_T xtra, bool do_buf_event)
{
changed_lines_buf(curbuf, lnum, lnume, xtra);

View File

@ -1392,6 +1392,22 @@ long getdigits_long(char_u **pp, bool strict, long def)
return (long)number;
}
/// Gets a int32_t number from a string.
///
/// @see getdigits
int32_t getdigits_int32(char **pp, bool strict, long def)
{
intmax_t number = getdigits((char_u **)pp, strict, def);
#if SIZEOF_INTMAX_T > SIZEOF_INT32_T
if (strict) {
assert(number >= INT32_MIN && number <= INT32_MAX);
} else if (!(number >= INT32_MIN && number <= INT32_MAX)) {
return (int32_t)def;
}
#endif
return (int32_t)number;
}
/// Check that "lbuf" is empty or only contains blanks.
///
/// @param lbuf line buffer to check

View File

@ -506,7 +506,7 @@ static int dbg_parsearg(char_u *arg, garray_T *gap)
if (here) {
bp->dbg_lnum = curwin->w_cursor.lnum;
} else if (gap != &prof_ga && ascii_isdigit(*p)) {
bp->dbg_lnum = getdigits_long((char_u **)&p, true, 0);
bp->dbg_lnum = getdigits_int32(&p, true, 0);
p = skipwhite(p);
} else {
bp->dbg_lnum = 0;

View File

@ -248,7 +248,7 @@ void diff_invalidate(buf_T *buf)
/// @param line2
/// @param amount
/// @param amount_after
void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after)
void diff_mark_adjust(linenr_T line1, linenr_T line2, linenr_T amount, linenr_T amount_after)
{
// Handle all tab pages that use the current buffer in a diff.
FOR_ALL_TABS(tp) {
@ -272,8 +272,8 @@ void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_a
/// @param line2
/// @param amount
/// @amount_after
static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T line2, long amount,
long amount_after)
static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T line2,
linenr_T amount, linenr_T amount_after)
{
if (diff_internal()) {
// Will update diffs before redrawing. Set _invalid to update the
@ -284,8 +284,8 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T
tp->tp_diff_update = true;
}
long inserted;
long deleted;
linenr_T inserted;
linenr_T deleted;
if (line2 == MAXLNUM) {
// mark_adjust(99, MAXLNUM, 9, 0): insert lines
inserted = amount;
@ -1539,7 +1539,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio)
diffout_T *dout = &dio->dio_diff;
char_u linebuf[LBUFLEN]; // only need to hold the diff line
char_u *line;
long off;
linenr_T off;
int i;
int notset = true; // block "*dp" not set yet
diffhunk_T *hunk = NULL; // init to avoid gcc warning
@ -1662,14 +1662,14 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio)
}
}
dp->df_lnum[idx_new] = hunk->lnum_new;
dp->df_count[idx_new] = hunk->count_new;
dp->df_count[idx_new] = (linenr_T)hunk->count_new;
} else if (notset) {
// new block inside existing one, adjust new block
dp->df_lnum[idx_new] = hunk->lnum_new + off;
dp->df_count[idx_new] = hunk->count_new - off;
dp->df_count[idx_new] = (linenr_T)hunk->count_new - off;
} else {
// second overlap of new block with existing block
dp->df_count[idx_new] += hunk->count_new - hunk->count_orig
dp->df_count[idx_new] += (linenr_T)hunk->count_new - (linenr_T)hunk->count_orig
+ dpl->df_lnum[idx_orig] +
dpl->df_count[idx_orig]
- (dp->df_lnum[idx_orig] +
@ -1678,7 +1678,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio)
// Adjust the size of the block to include all the lines to the
// end of the existing block or the new diff, whatever ends last.
off = (hunk->lnum_orig + hunk->count_orig)
off = (hunk->lnum_orig + (linenr_T)hunk->count_orig)
- (dpl->df_lnum[idx_orig] + dpl->df_count[idx_orig]);
if (off < 0) {
@ -1711,9 +1711,9 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio)
dp = diff_alloc_new(curtab, dprev, dp);
dp->df_lnum[idx_orig] = hunk->lnum_orig;
dp->df_count[idx_orig] = hunk->count_orig;
dp->df_count[idx_orig] = (linenr_T)hunk->count_orig;
dp->df_lnum[idx_new] = hunk->lnum_new;
dp->df_count[idx_new] = hunk->count_new;
dp->df_count[idx_new] = (linenr_T)hunk->count_new;
// Set values for other buffers, these must be equal to the
// original buffer, otherwise there would have been a change
@ -1754,7 +1754,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio)
/// @param idx_new
static void diff_copy_entry(diff_T *dprev, diff_T *dp, int idx_orig, int idx_new)
{
long off;
linenr_T off;
if (dprev == NULL) {
off = 0;
@ -1896,7 +1896,7 @@ int diff_check(win_T *wp, linenr_T lnum)
maxcount = dp->df_count[i];
}
}
return (int)(maxcount - dp->df_count[idx]);
return maxcount - dp->df_count[idx];
}
/// Compare two entries in diff "dp" and return true if they are equal.
@ -2097,7 +2097,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin)
towin->w_topfill = fromwin->w_topfill;
} else {
// fromwin has some diff lines
towin->w_topfill = (int)(dp->df_lnum[fromidx] + max_count - lnum);
towin->w_topfill = dp->df_lnum[fromidx] + max_count - lnum;
}
}
}
@ -2670,7 +2670,7 @@ void ex_diffgetput(exarg_T *eap)
// range ends above end of current/from diff block
if (idx_cur == idx_from) {
// :diffput
i = (int)(dp->df_count[idx_cur] - start_skip - end_skip);
i = dp->df_count[idx_cur] - start_skip - end_skip;
if (count > i) {
count = i;
@ -2745,7 +2745,7 @@ void ex_diffgetput(exarg_T *eap)
// Adjust marks. This will change the following entries!
if (added != 0) {
mark_adjust(lnum, lnum + count - 1, (long)MAXLNUM, (long)added,
mark_adjust(lnum, lnum + count - 1, (long)MAXLNUM, added,
kExtmarkUndo);
if (curwin->w_cursor.lnum >= lnum) {
// Adjust the cursor position if it's in/after the changed
@ -2757,7 +2757,7 @@ void ex_diffgetput(exarg_T *eap)
}
}
}
changed_lines(lnum, 0, lnum + count, (long)added, true);
changed_lines(lnum, 0, lnum + count, added, true);
if (dfree != NULL) {
// Diff is deleted, update folds in other windows.
@ -3044,7 +3044,7 @@ static int parse_diff_ed(char_u *line, diffhunk_T *hunk)
// append: {first}a{first}[,{last}]
// delete: {first}[,{last}]d{first}
char_u *p = line;
long f1 = getdigits(&p, true, 0);
linenr_T f1 = getdigits_int32((char **)&p, true, 0);
if (*p == ',') {
p++;
l1 = getdigits(&p, true, 0);
@ -3074,10 +3074,10 @@ static int parse_diff_ed(char_u *line, diffhunk_T *hunk)
hunk->count_orig = l1 - f1 + 1;
}
if (difftype == 'd') {
hunk->lnum_new = f2 + 1;
hunk->lnum_new = (linenr_T)f2 + 1;
hunk->count_new = 0;
} else {
hunk->lnum_new = f2;
hunk->lnum_new = (linenr_T)f2;
hunk->count_new = l2 - f2 + 1;
}
return OK;
@ -3125,9 +3125,9 @@ static int parse_diff_unified(char_u *line, diffhunk_T *hunk)
newline = 1;
}
hunk->lnum_orig = oldline;
hunk->lnum_orig = (linenr_T)oldline;
hunk->count_orig = oldcount;
hunk->lnum_new = newline;
hunk->lnum_new = (linenr_T)newline;
hunk->count_new = newcount;
return OK;
@ -3146,9 +3146,9 @@ static int xdiff_out(long start_a, long count_a, long start_b, long count_b, voi
diffhunk_T *p = xmalloc(sizeof(*p));
ga_grow(&dout->dout_ga, 1);
p->lnum_orig = start_a + 1;
p->lnum_orig = (linenr_T)start_a + 1;
p->count_orig = count_a;
p->lnum_new = start_b + 1;
p->lnum_new = (linenr_T)start_b + 1;
p->count_new = count_b;
((diffhunk_T **)dout->dout_ga.ga_data)[dout->dout_ga.ga_len++] = p;
return 0;

View File

@ -6956,7 +6956,7 @@ int cursor_up(long n, int upd_topline)
lnum = 1;
}
} else {
lnum -= n;
lnum -= (linenr_T)n;
}
curwin->w_cursor.lnum = lnum;
}
@ -7007,7 +7007,7 @@ int cursor_down(long n, int upd_topline)
lnum = curbuf->b_ml.ml_line_count;
}
} else {
lnum += n;
lnum += (linenr_T)n;
}
curwin->w_cursor.lnum = lnum;
}

View File

@ -439,7 +439,7 @@ static int sort_compare(const void *s1, const void *s2)
// If two lines have the same value, preserve the original line order.
if (result == 0) {
return (int)(l1.lnum - l2.lnum);
return l1.lnum - l2.lnum;
}
return result;
}
@ -451,7 +451,7 @@ void ex_sort(exarg_T *eap)
int len;
linenr_T lnum;
long maxlen = 0;
size_t count = (size_t)(eap->line2 - eap->line1 + 1);
size_t count = eap->line2 - eap->line1 + 1;
size_t i;
char *p;
char *s;
@ -5934,7 +5934,7 @@ static int show_sub(exarg_T *eap, pos_T old_cusr, PreviewLines *preview_lines, i
}
}
// Put "|lnum| line" into `str` and append it to the preview buffer.
snprintf(str, line_size, "|%*ld| %s", col_width - 3,
snprintf(str, line_size, "|%*" PRIdLINENR "| %s", col_width - 3,
next_linenr, line);
// Temporarily switch to preview buffer
aucmd_prepbuf(&aco, cmdpreview_buf);

View File

@ -1355,13 +1355,13 @@ static void parse_register(exarg_T *eap)
void set_cmd_count(exarg_T *eap, long count, bool validate)
{
if (eap->addr_type != ADDR_LINES) { // e.g. :buffer 2, :sleep 3
eap->line2 = count;
eap->line2 = (linenr_T)count;
if (eap->addr_count == 0) {
eap->addr_count = 1;
}
} else {
eap->line1 = eap->line2;
eap->line2 += count - 1;
eap->line2 += (linenr_T)count - 1;
eap->addr_count++;
// Be vi compatible: no error message for out of range.
if (validate && eap->line2 > curbuf->b_ml.ml_line_count) {
@ -4243,7 +4243,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int
{
int c;
int i;
long n;
linenr_T n;
char *cmd;
pos_T pos;
pos_T *fp;
@ -4458,7 +4458,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int
default:
if (ascii_isdigit(*cmd)) { // absolute line number
lnum = getdigits_long((char_u **)&cmd, false, 0);
lnum = (linenr_T)getdigits((char_u **)&cmd, false, 0);
}
}
@ -4512,7 +4512,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int
if (!ascii_isdigit(*cmd)) { // '+' is '+1', but '+0' is not '+1'
n = 1;
} else {
n = getdigits((char_u **)&cmd, false, MAXLNUM);
n = getdigits_int32(&cmd, false, MAXLNUM);
if (n == MAXLNUM) {
emsg(_(e_line_number_out_of_range));
goto error;
@ -4535,7 +4535,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int
if (i == '-') {
lnum -= n;
} else {
if (n >= LONG_MAX - lnum) {
if (n >= INT32_MAX - lnum) {
emsg(_(e_line_number_out_of_range));
goto error;
}
@ -8551,11 +8551,11 @@ static void ex_copymove(exarg_T *eap)
}
if (eap->cmdidx == CMD_move) {
if (do_move(eap->line1, eap->line2, n) == FAIL) {
if (do_move(eap->line1, eap->line2, (linenr_T)n) == FAIL) {
return;
}
} else {
ex_copy(eap->line1, eap->line2, n);
ex_copy(eap->line1, eap->line2, (linenr_T)n);
}
u_clearline();
beginline(BL_SOL | BL_FIX);

View File

@ -499,8 +499,8 @@ void extmark_apply_undo(ExtmarkUndoObject undo_info, bool undo)
}
/// Adjust extmark row for inserted/deleted rows (columns stay fixed).
void extmark_adjust(buf_T *buf, linenr_T line1, linenr_T line2, long amount, long amount_after,
ExtmarkOp undo)
void extmark_adjust(buf_T *buf, linenr_T line1, linenr_T line2, linenr_T amount,
linenr_T amount_after, ExtmarkOp undo)
{
if (curbuf_splice_pending) {
return;

View File

@ -1370,7 +1370,8 @@ void deleteFoldRecurse(buf_T *bp, garray_T *gap)
// foldMarkAdjust() {{{2
/// Update line numbers of folds for inserted/deleted lines.
void foldMarkAdjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long amount_after)
void foldMarkAdjust(win_T *wp, linenr_T line1, linenr_T line2, linenr_T amount,
linenr_T amount_after)
{
// If deleting marks from line1 to line2, but not deleting all those
// lines, set line2 so that only deleted lines have their folds removed.
@ -1387,7 +1388,7 @@ void foldMarkAdjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long
// foldMarkAdjustRecurse() {{{2
static void foldMarkAdjustRecurse(win_T *wp, garray_T *gap, linenr_T line1, linenr_T line2,
long amount, long amount_after)
linenr_T amount, linenr_T amount_after)
{
fold_T *fp;
linenr_T last;
@ -2886,7 +2887,7 @@ static void foldMerge(win_T *const wp, fold_T *fp1, garray_T *gap, fold_T *fp2)
// If the last nested fold in fp1 touches the first nested fold in fp2,
// merge them recursively.
if (foldFind(gap1, fp1->fd_len - 1L, &fp3) && foldFind(gap2, 0L, &fp4)) {
if (foldFind(gap1, fp1->fd_len - 1, &fp3) && foldFind(gap2, 0L, &fp4)) {
foldMerge(wp, fp3, gap2, fp4);
}
@ -3256,7 +3257,7 @@ static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off
/// @return FAIL when writing failed.
static int put_fold_open_close(FILE *fd, fold_T *fp, linenr_T off)
{
if (fprintf(fd, "%" PRId64, (int64_t)(fp->fd_top + off)) < 0
if (fprintf(fd, "%" PRIdLINENR, fp->fd_top + off) < 0
|| put_eol(fd) == FAIL
|| fprintf(fd, "normal! z%c",
fp->fd_flags == FD_CLOSED ? 'c' : 'o') < 0

View File

@ -89,7 +89,7 @@ static int regex_match_line(lua_State *lstate)
}
long bufnr = luaL_checkinteger(lstate, 2);
long rownr = luaL_checkinteger(lstate, 3);
linenr_T rownr = (linenr_T)luaL_checkinteger(lstate, 3);
long start = 0, end = -1;
if (narg >= 4) {
start = luaL_checkinteger(lstate, 4);

View File

@ -732,7 +732,7 @@ static void show_one_mark(int c, char_u *arg, pos_T *p, char_u *name_arg, int cu
}
msg_putchar('\n');
if (!got_int) {
snprintf((char *)IObuff, IOSIZE, " %c %6ld %4d ", c, p->lnum, p->col);
snprintf((char *)IObuff, IOSIZE, " %c %6" PRIdLINENR " %4d ", c, p->lnum, p->col);
msg_outtrans(IObuff);
if (name != NULL) {
msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0);
@ -860,12 +860,10 @@ void ex_jumps(exarg_T *eap)
xfree(name);
break;
}
sprintf((char *)IObuff, "%c %2d %5ld %4d ",
snprintf((char *)IObuff, IOSIZE, "%c %2d %5" PRIdLINENR " %4d ",
i == curwin->w_jumplistidx ? '>' : ' ',
i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx
: curwin->w_jumplistidx - i,
curwin->w_jumplist[i].fmark.mark.lnum,
curwin->w_jumplist[i].fmark.mark.col);
i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx : curwin->w_jumplistidx - i,
curwin->w_jumplist[i].fmark.mark.lnum, curwin->w_jumplist[i].fmark.mark.col);
msg_outtrans(IObuff);
msg_outtrans_attr(name,
curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum
@ -963,7 +961,8 @@ void ex_changes(exarg_T *eap)
* Example: Insert two lines below 55: mark_adjust(56, MAXLNUM, 2, 0);
* or: mark_adjust(56, 55, MAXLNUM, 2);
*/
void mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after, ExtmarkOp op)
void mark_adjust(linenr_T line1, linenr_T line2, linenr_T amount, linenr_T amount_after,
ExtmarkOp op)
{
mark_adjust_internal(line1, line2, amount, amount_after, true, op);
}
@ -973,14 +972,14 @@ void mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after,
// This is only useful when folds need to be moved in a way different to
// calling foldMarkAdjust() with arguments line1, line2, amount, amount_after,
// for an example of why this may be necessary, see do_move().
void mark_adjust_nofold(linenr_T line1, linenr_T line2, long amount, long amount_after,
void mark_adjust_nofold(linenr_T line1, linenr_T line2, linenr_T amount, linenr_T amount_after,
ExtmarkOp op)
{
mark_adjust_internal(line1, line2, amount, amount_after, false, op);
}
static void mark_adjust_internal(linenr_T line1, linenr_T line2, long amount, long amount_after,
bool adjust_folds, ExtmarkOp op)
static void mark_adjust_internal(linenr_T line1, linenr_T line2, linenr_T amount,
linenr_T amount_after, bool adjust_folds, ExtmarkOp op)
{
int i;
int fnum = curbuf->b_fnum;
@ -1153,7 +1152,7 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, long amount, lo
// position.
// "spaces_removed" is the number of spaces that were removed, matters when the
// cursor is inside them.
void mark_col_adjust(linenr_T lnum, colnr_T mincol, long lnum_amount, long col_amount,
void mark_col_adjust(linenr_T lnum, colnr_T mincol, linenr_T lnum_amount, long col_amount,
int spaces_removed)
{
int i;

View File

@ -116,7 +116,7 @@ static int match_add(win_T *wp, const char *const grp, const char *const pat, in
(int)tv_list_idx_of_item(pos_list, li));
goto fail;
}
lnum = tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error);
lnum = (linenr_T)tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error);
if (error) {
goto fail;
}
@ -150,7 +150,7 @@ static int match_add(win_T *wp, const char *const grp, const char *const pat, in
if (TV_LIST_ITEM_TV(li)->vval.v_number <= 0) {
continue;
}
m->pos.pos[i].lnum = TV_LIST_ITEM_TV(li)->vval.v_number;
m->pos.pos[i].lnum = (linenr_T)TV_LIST_ITEM_TV(li)->vval.v_number;
m->pos.pos[i].col = 0;
m->pos.pos[i].len = 0;
} else {

View File

@ -1146,8 +1146,8 @@ bool scrollup(long line_count, int byfold)
curwin->w_botline += lnum - curwin->w_topline;
curwin->w_topline = lnum;
} else {
curwin->w_topline += line_count;
curwin->w_botline += line_count; // approximate w_botline
curwin->w_topline += (linenr_T)line_count;
curwin->w_botline += (linenr_T)line_count; // approximate w_botline
}
if (curwin->w_topline > curbuf->b_ml.ml_line_count) {
@ -1903,7 +1903,7 @@ int onepage(Direction dir, long count)
if (p_window <= 2) {
++curwin->w_topline;
} else {
curwin->w_topline += p_window - 2;
curwin->w_topline += (linenr_T)p_window - 2;
}
if (curwin->w_topline > curbuf->b_ml.ml_line_count) {
curwin->w_topline = curbuf->b_ml.ml_line_count;
@ -1939,12 +1939,12 @@ int onepage(Direction dir, long count)
if (p_window <= 2) {
--curwin->w_topline;
} else {
curwin->w_topline -= p_window - 2;
curwin->w_topline -= (linenr_T)p_window - 2;
}
if (curwin->w_topline < 1) {
curwin->w_topline = 1;
}
curwin->w_cursor.lnum = curwin->w_topline + p_window - 1;
curwin->w_cursor.lnum = curwin->w_topline + (linenr_T)p_window - 1;
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
}

View File

@ -2818,7 +2818,7 @@ void do_check_scrollbind(bool check)
// resync is performed, some of the other 'scrollbind' windows may
// need to jump so that the current window's relative position is
// visible on-screen.
check_scrollbind(curwin->w_topline - curwin->w_scbind_pos, 0L);
check_scrollbind(curwin->w_topline - (linenr_T)curwin->w_scbind_pos, 0L);
}
curwin->w_scbind_pos = curwin->w_topline;
}
@ -2935,7 +2935,7 @@ static void nv_addsub(cmdarg_T *cap)
} else if (!VIsual_active && cap->oap->op_type == OP_NOP) {
prep_redo_cmd(cap);
cap->oap->op_type = cap->cmdchar == Ctrl_A ? OP_NR_ADD : OP_NR_SUB;
op_addsub(cap->oap, cap->count1, cap->arg);
op_addsub(cap->oap, (linenr_T)cap->count1, cap->arg);
cap->oap->op_type = OP_NOP;
} else if (VIsual_active) {
nv_operator(cap);
@ -3486,7 +3486,7 @@ dozet:
if (cap->count0 > curbuf->b_ml.ml_line_count) {
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
} else {
curwin->w_cursor.lnum = cap->count0;
curwin->w_cursor.lnum = (linenr_T)cap->count0;
}
check_cursor_col();
}
@ -4359,7 +4359,7 @@ static void nv_scroll(cmdarg_T *cap)
curwin->w_cursor.lnum--;
}
} else {
curwin->w_cursor.lnum -= cap->count1 - 1;
curwin->w_cursor.lnum -= (linenr_T)cap->count1 - 1;
}
}
} else {
@ -4372,15 +4372,15 @@ static void nv_scroll(cmdarg_T *cap)
for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; n++) {
// Count half the number of filler lines to be "below this
// line" and half to be "above the next line".
if (n > 0 && used + win_get_fill(curwin, curwin->w_topline + n) / 2 >= half) {
if (n > 0 && used + win_get_fill(curwin, curwin->w_topline + (linenr_T)n) / 2 >= half) {
n--;
break;
}
used += plines_win(curwin, curwin->w_topline + n, true);
used += plines_win(curwin, curwin->w_topline + (linenr_T)n, true);
if (used >= half) {
break;
}
if (hasFolding(curwin->w_topline + n, NULL, &lnum)) {
if (hasFolding(curwin->w_topline + (linenr_T)n, NULL, &lnum)) {
n = lnum - curwin->w_topline;
}
}
@ -4399,7 +4399,7 @@ static void nv_scroll(cmdarg_T *cap)
n = lnum - curwin->w_topline;
}
}
curwin->w_cursor.lnum = curwin->w_topline + n;
curwin->w_cursor.lnum = curwin->w_topline + (linenr_T)n;
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
}
@ -5049,11 +5049,11 @@ static void nv_percent(cmdarg_T *cap)
// overflow on 32-bits, so use a formula with less accuracy
// to avoid overflows.
if (curbuf->b_ml.ml_line_count >= 21474836) {
curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99L)
/ 100L * cap->count0;
curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99)
/ 100 * (linenr_T)cap->count0;
} else {
curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count *
cap->count0 + 99L) / 100L;
(linenr_T)cap->count0 + 99) / 100;
}
if (curwin->w_cursor.lnum < 1) {
curwin->w_cursor.lnum = 1;
@ -5705,7 +5705,7 @@ static void nv_visual(cmdarg_T *cap)
// For V and ^V, we multiply the number of lines even if there
// was only one -- webb
if (resel_VIsual_mode != 'v' || resel_VIsual_line_count > 1) {
curwin->w_cursor.lnum += resel_VIsual_line_count * cap->count0 - 1;
curwin->w_cursor.lnum += resel_VIsual_line_count * (linenr_T)cap->count0 - 1;
check_cursor();
}
VIsual_mode = resel_VIsual_mode;
@ -6709,7 +6709,7 @@ static void nv_goto(cmdarg_T *cap)
// When a count is given, use it instead of the default lnum
if (cap->count0 != 0) {
lnum = cap->count0;
lnum = (linenr_T)cap->count0;
}
if (lnum < 1L) {
lnum = 1L;
@ -7024,7 +7024,7 @@ static void nv_halfpage(cmdarg_T *cap)
&& curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)) {
clearopbeep(cap->oap);
} else if (!checkclearop(cap->oap)) {
halfpage(cap->cmdchar == Ctrl_D, cap->count0);
halfpage(cap->cmdchar == Ctrl_D, (linenr_T)cap->count0);
}
}

View File

@ -637,8 +637,8 @@ void op_reindent(oparg_T *oap, Indenter how)
// Save for undo. Do this once for all lines, much faster than doing this
// for each line separately, especially when undoing.
if (u_savecommon(curbuf, start_lnum - 1, start_lnum + oap->line_count,
start_lnum + oap->line_count, false) == OK) {
if (u_savecommon(curbuf, start_lnum - 1, start_lnum + (linenr_T)oap->line_count,
start_lnum + (linenr_T)oap->line_count, false) == OK) {
for (i = oap->line_count - 1; i >= 0 && !got_int; i--) {
// it's a slow thing to do, so give feedback so there's no worry
// that the computer's just hung.
@ -681,7 +681,7 @@ void op_reindent(oparg_T *oap, Indenter how)
* there is no change still need to remove the Visual highlighting. */
if (last_changed != 0) {
changed_lines(first_changed, 0,
oap->is_VIsual ? start_lnum + oap->line_count :
oap->is_VIsual ? start_lnum + (linenr_T)oap->line_count :
last_changed + 1, 0L, true);
} else if (oap->is_VIsual) {
redraw_curbuf_later(INVERTED);
@ -2954,7 +2954,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
int incr = 0;
struct block_def bd;
char_u **y_array = NULL;
long nr_lines = 0;
linenr_T nr_lines = 0;
pos_T new_cursor;
int indent;
int orig_indent = 0; // init for gcc
@ -3395,7 +3395,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
}
changed_lines(lnum, 0, curbuf->b_op_start.lnum + (linenr_T)y_size
- (linenr_T)nr_lines, nr_lines, true);
- nr_lines, nr_lines, true);
// Set '[ mark.
curbuf->b_op_start = curwin->w_cursor;
@ -4151,7 +4151,7 @@ int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions
const int spaces_removed = (int)((curr - curr_start) - spaces[t]);
linenr_T lnum = curwin->w_cursor.lnum + t;
colnr_T mincol = (colnr_T)0;
long lnum_amount = -t;
linenr_T lnum_amount = -t;
long col_amount = (cend - newp - spaces_removed);
mark_col_adjust(lnum, mincol, lnum_amount, col_amount, spaces_removed);
@ -4292,7 +4292,7 @@ static int same_leader(linenr_T lnum, int leader1_len, char_u *leader1_flags, in
/// @param keep_cursor keep cursor on same text char
static void op_format(oparg_T *oap, int keep_cursor)
{
long old_line_count = curbuf->b_ml.ml_line_count;
linenr_T old_line_count = curbuf->b_ml.ml_line_count;
// Place the cursor where the "gq" or "gw" command was given, so that "u"
// can put it back there.
@ -4320,7 +4320,7 @@ static void op_format(oparg_T *oap, int keep_cursor)
saved_cursor = oap->cursor_start;
}
format_lines(oap->line_count, keep_cursor);
format_lines((linenr_T)oap->line_count, keep_cursor);
/*
* Leave the cursor at the first non-blank of the last formatted line.
@ -6452,7 +6452,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
resel_VIsual_vcol = oap->end_vcol;
}
}
resel_VIsual_line_count = oap->line_count;
resel_VIsual_line_count = (linenr_T)oap->line_count;
}
// can't redo yank (unless 'y' is in 'cpoptions') and ":"
@ -6827,7 +6827,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
} else {
VIsual_active = true;
curwin->w_p_lbr = lbr_saved;
op_addsub(oap, cap->count1, redo_VIsual_arg);
op_addsub(oap, (linenr_T)cap->count1, redo_VIsual_arg);
VIsual_active = false;
}
check_cursor_col();

View File

@ -763,7 +763,7 @@ static int pum_set_selected(int n, int repeat)
// text, but no more than 'previewheight' lines.
if (repeat == 0) {
if (lnum > p_pvh) {
lnum = p_pvh;
lnum = (linenr_T)p_pvh;
}
if (curwin->w_height < lnum) {

View File

@ -1,10 +1,12 @@
#ifndef NVIM_POS_H
#define NVIM_POS_H
#include <inttypes.h>
/// Line number type
typedef long linenr_T;
typedef int32_t linenr_T;
/// Format used to print values which have linenr_T type
#define PRIdLINENR "ld"
#define PRIdLINENR PRId32
/// Column number type
typedef int colnr_T;

View File

@ -198,8 +198,8 @@ typedef struct {
char *module;
char *errmsg;
size_t errmsglen;
long lnum;
long end_lnum;
linenr_T lnum;
linenr_T end_lnum;
int col;
int end_col;
bool use_viscol;
@ -1295,7 +1295,7 @@ static int qf_parse_fmt_l(regmatch_T *rmp, int midx, qffields_T *fields)
if (rmp->startp[midx] == NULL) {
return QF_FAIL;
}
fields->lnum = atol((char *)rmp->startp[midx]);
fields->lnum = (linenr_T)atol((char *)rmp->startp[midx]);
return QF_OK;
}
@ -1306,7 +1306,7 @@ static int qf_parse_fmt_e(regmatch_T *rmp, int midx, qffields_T *fields)
if (rmp->startp[midx] == NULL) {
return QF_FAIL;
}
fields->end_lnum = atol((char *)rmp->startp[midx]);
fields->end_lnum = (linenr_T)atol((char *)rmp->startp[midx]);
return QF_OK;
}
@ -1833,8 +1833,8 @@ void check_quickfix_busy(void)
///
/// @returns QF_OK or QF_FAIL.
static int qf_add_entry(qf_list_T *qfl, char *dir, char *fname, char *module, int bufnum,
char *mesg, long lnum, long end_lnum, int col, int end_col, char vis_col,
char *pattern, int nr, char type, char valid)
char *mesg, linenr_T lnum, linenr_T end_lnum, int col, int end_col,
char vis_col, char *pattern, int nr, char type, char valid)
{
qfline_T *qfp = xmalloc(sizeof(qfline_T));
qfline_T **lastp; // pointer to qf_last or NULL
@ -3357,7 +3357,7 @@ void qf_history(exarg_T *eap)
// Jump to the specified quickfix list
if (eap->line2 > 0 && eap->line2 <= qi->qf_listcount) {
qi->qf_curlist = (int)(eap->line2 - 1);
qi->qf_curlist = eap->line2 - 1;
qf_msg(qi, qi->qf_curlist, "");
qf_update_buffer(qi, NULL);
} else {
@ -3436,7 +3436,8 @@ static void qf_free(qf_list_T *qfl)
}
// qf_mark_adjust: adjust marks
bool qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long amount_after)
bool qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, linenr_T amount,
linenr_T amount_after)
{
int i;
qfline_T *qfp;
@ -5262,7 +5263,7 @@ static bool vgr_match_buflines(qf_list_T *qfl, char *fname, buf_T *buf, char *sp
{
bool found_match = false;
for (long lnum = 1; lnum <= buf->b_ml.ml_line_count && *tomatch > 0; lnum++) {
for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count && *tomatch > 0; lnum++) {
colnr_T col = 0;
if (!(flags & VGR_FUZZY)) {
// Regular expression match
@ -6361,8 +6362,8 @@ static int qf_add_entry_from_dict(qf_list_T *qfl, const dict_T *d, bool first_en
char *const filename = tv_dict_get_string(d, "filename", true);
char *const module = tv_dict_get_string(d, "module", true);
int bufnum = (int)tv_dict_get_number(d, "bufnr");
const long lnum = (long)tv_dict_get_number(d, "lnum");
const long end_lnum = (long)tv_dict_get_number(d, "end_lnum");
const linenr_T lnum = (linenr_T)tv_dict_get_number(d, "lnum");
const linenr_T end_lnum = (linenr_T)tv_dict_get_number(d, "end_lnum");
const int col = (int)tv_dict_get_number(d, "col");
const int end_col = (int)tv_dict_get_number(d, "end_col");
const char vcol = (char)tv_dict_get_number(d, "vcol");
@ -7096,7 +7097,7 @@ static void hgr_search_file(qf_list_T *qfl, char *fname, regmatch_T *p_regmatch)
return;
}
long lnum = 1;
linenr_T lnum = 1;
while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) {
char *line = (char *)IObuff;

View File

@ -5933,7 +5933,7 @@ static void show_pat_in_path(char_u *line, int type, bool did_show, int action,
if (action == ACTION_SHOW_ALL) {
snprintf((char *)IObuff, IOSIZE, "%3ld: ", count); // Show match nr.
msg_puts((const char *)IObuff);
snprintf((char *)IObuff, IOSIZE, "%4ld", *lnum); // Show line nr.
snprintf((char *)IObuff, IOSIZE, "%4" PRIdLINENR, *lnum); // Show line nr.
// Highlight line numbers.
msg_puts_attr((const char *)IObuff, HL_ATTR(HLF_N));
msg_puts(" ");

View File

@ -3376,8 +3376,6 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, const
i64, proc)
#define INTEGER_KEY(un, entry_name, name, tgt) \
INT_KEY(un, entry_name, name, tgt, TOINT)
#define LONG_KEY(un, entry_name, name, tgt) \
INT_KEY(un, entry_name, name, tgt, TOLONG)
#define ADDITIONAL_KEY(un) \
else { /* NOLINT(readability/braces) */ \
ga_grow(&ad_ga, 1); \
@ -3641,7 +3639,7 @@ shada_read_next_item_start:
"mark", unpacked.data.via.map.ptr[i].val,
entry->data.filemark.name, u64, TOCHAR);
}
LONG_KEY(unpacked, "mark", KEY_LNUM, entry->data.filemark.mark.lnum)
INTEGER_KEY(unpacked, "mark", KEY_LNUM, entry->data.filemark.mark.lnum)
INTEGER_KEY(unpacked, "mark", KEY_COL, entry->data.filemark.mark.col)
STRING_KEY(unpacked, "mark", KEY_FILE, entry->data.filemark.fname)
ADDITIONAL_KEY(unpacked)
@ -3888,7 +3886,7 @@ shada_read_next_item_start:
{
for (i = 0; i < unpacked_2.data.via.map.size; i++) { // -V535
CHECK_KEY_IS_STR(unpacked_2, "buffer list entry")
LONG_KEY(unpacked_2, "buffer list entry", KEY_LNUM,
INTEGER_KEY(unpacked_2, "buffer list entry", KEY_LNUM,
entry->data.buffer_list.buffers[j].pos.lnum)
INTEGER_KEY(unpacked_2, "buffer list entry", KEY_COL,
entry->data.buffer_list.buffers[j].pos.col)
@ -3957,7 +3955,6 @@ shada_read_next_item_error:
#undef TYPED_KEY
#undef INT_KEY
#undef INTEGER_KEY
#undef LONG_KEY
#undef TOU8
#undef TOSIZE
#undef SET_ADDITIONAL_DATA

View File

@ -727,7 +727,7 @@ static void sign_list_placed(buf_T *rbuf, char_u *sign_group)
}
/// Adjust a placed sign for inserted/deleted lines.
void sign_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after)
void sign_mark_adjust(linenr_T line1, linenr_T line2, linenr_T amount, linenr_T amount_after)
{
sign_entry_T *sign; // a sign in a b_signlist
sign_entry_T *next; // the next sign in a b_signlist

View File

@ -1044,7 +1044,7 @@ void do_tags(exarg_T *eap)
}
msg_putchar('\n');
vim_snprintf((char *)IObuff, IOSIZE, "%c%2d %2d %-15s %5ld ",
vim_snprintf((char *)IObuff, IOSIZE, "%c%2d %2d %-15s %5" PRIdLINENR " ",
i == tagstackidx ? '>' : ' ',
i + 1,
tagstack[i].cur_match + 1,

View File

@ -1511,7 +1511,7 @@ static void adjust_scrollback(Terminal *term, buf_T *buf)
term->sb_current--;
xfree(term->sb_buffer[term->sb_current]);
}
deleted_lines(1, (long)diff);
deleted_lines(1, (linenr_T)diff);
}
// Resize the scrollback storage.

View File

@ -272,7 +272,7 @@ int u_inssub(linenr_T lnum)
*/
int u_savedel(linenr_T lnum, long nlines)
{
return u_savecommon(curbuf, lnum - 1, lnum + nlines,
return u_savecommon(curbuf, lnum - 1, lnum + (linenr_T)nlines,
nlines == curbuf->b_ml.ml_line_count ? 2 : lnum, false);
}
@ -2337,7 +2337,7 @@ static void u_undoredo(int undo, bool do_buf_event)
}
oldsize = bot - top - 1; // number of lines before undo
newsize = uep->ue_size; // number of lines after undo
newsize = (linenr_T)uep->ue_size; // number of lines after undo
if (top < newlnum) {
/* If the saved cursor is somewhere in this undo block, move it to
@ -2351,8 +2351,8 @@ static void u_undoredo(int undo, bool do_buf_event)
/* Use the first line that actually changed. Avoids that
* undoing auto-formatting puts the cursor in the previous
* line. */
for (i = 0; i < newsize && i < oldsize; ++i) {
if (STRCMP(uep->ue_array[i], ml_get(top + 1 + i)) != 0) {
for (i = 0; i < newsize && i < oldsize; i++) {
if (STRCMP(uep->ue_array[i], ml_get(top + 1 + (linenr_T)i)) != 0) {
break;
}
}
@ -2360,7 +2360,7 @@ static void u_undoredo(int undo, bool do_buf_event)
newlnum = top;
curwin->w_cursor.lnum = newlnum + 1;
} else if (i < newsize) {
newlnum = top + i;
newlnum = top + (linenr_T)i;
curwin->w_cursor.lnum = newlnum + 1;
}
}
@ -2405,8 +2405,7 @@ static void u_undoredo(int undo, bool do_buf_event)
// Adjust marks
if (oldsize != newsize) {
mark_adjust(top + 1, top + oldsize, (long)MAXLNUM,
(long)newsize - (long)oldsize, kExtmarkNOOP);
mark_adjust(top + 1, top + oldsize, MAXLNUM, newsize - oldsize, kExtmarkNOOP);
if (curbuf->b_op_start.lnum > top + oldsize) {
curbuf->b_op_start.lnum += newsize - oldsize;
}
@ -2916,7 +2915,7 @@ static void u_getbot(buf_T *buf)
* old line count subtracted from the current line count.
*/
extra = buf->b_ml.ml_line_count - uep->ue_lcount;
uep->ue_bot = uep->ue_top + uep->ue_size + 1 + extra;
uep->ue_bot = uep->ue_top + (linenr_T)uep->ue_size + 1 + extra;
if (uep->ue_bot < 1 || uep->ue_bot > buf->b_ml.ml_line_count) {
iemsg(_("E440: undo line missing"));
uep->ue_bot = uep->ue_top + 1; // assume all lines deleted, will