mirror of
https://github.com/neovim/neovim.git
synced 2025-10-16 06:46:07 +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:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user