mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 09:12:07 +00:00
vim-patch:9.0.2124: INT overflow detection logic can be simplified
Problem: INT overflow logic can be simplified Solution: introduce trim_to_int() function closes: vim/vim#135562b0882fa65
vim-patch:9.0.2138: Overflow logic requires long long Problem: Overflow logic requires long long Solution: Define vimlong_T data type to make life easier for porters closes: vim/vim#13598fda700cb04
Cherry-pick ops.c change from patch 9.1.0608. Co-authored-by: Ernie Rael <errael@raelity.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "nvim/indent_c.h"
|
||||
#include "nvim/macros_defs.h"
|
||||
#include "nvim/mark_defs.h"
|
||||
#include "nvim/math.h"
|
||||
#include "nvim/memline.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/option.h"
|
||||
@@ -1708,7 +1709,7 @@ void parse_cino(buf_T *buf)
|
||||
} else {
|
||||
n *= sw;
|
||||
if (divider) {
|
||||
n += (sw * fraction + divider / 2) / divider;
|
||||
n += ((int64_t)sw * fraction + divider / 2) / divider;
|
||||
}
|
||||
}
|
||||
p++;
|
||||
@@ -1717,11 +1718,7 @@ void parse_cino(buf_T *buf)
|
||||
n = -n;
|
||||
}
|
||||
|
||||
if (n > INT_MAX) {
|
||||
n = INT_MAX;
|
||||
} else if (n < INT_MIN) {
|
||||
n = INT_MIN;
|
||||
}
|
||||
n = trim_to_int(n);
|
||||
|
||||
// When adding an entry here, also update the default 'cinoptions' in
|
||||
// doc/indent.txt, and add explanation for it!
|
||||
|
Reference in New Issue
Block a user