Files
neovim/src/nvim/pos.h
Dundar Goc a732c253b7 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.
2022-06-10 16:16:41 +02:00

44 lines
1019 B
C

#ifndef NVIM_POS_H
#define NVIM_POS_H
#include <inttypes.h>
/// Line number type
typedef int32_t linenr_T;
/// Format used to print values which have linenr_T type
#define PRIdLINENR PRId32
/// Column number type
typedef int colnr_T;
/// Format used to print values which have colnr_T type
#define PRIdCOLNR "d"
/// Maximal (invalid) line number
enum { MAXLNUM = 0x7fffffff, };
/// Maximal column number
/// MAXCOL used to be INT_MAX, but with 64 bit ints that results in running
/// out of memory when trying to allocate a very long line.
enum { MAXCOL = 0x7fffffff, };
/// Minimum line number
enum { MINLNUM = 1, };
/// Minimum column number
enum { MINCOL = 1, };
/// position in file or buffer
typedef struct {
linenr_T lnum; ///< line number
colnr_T col; ///< column number
colnr_T coladd;
} pos_T;
/// position in file or buffer, but without coladd
typedef struct {
linenr_T lnum; ///< line number
colnr_T col; ///< column number
} lpos_T;
#endif // NVIM_POS_H