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

@@ -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;
}