mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user