diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-12-10 13:48:59 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-12-10 14:29:24 +0800 |
commit | 6c81c16e1b8dd1650960bf1cea57ce05b26f7822 (patch) | |
tree | 54d65f418299efb5382065fdf55cd78275df2e50 /src/nvim/indent_c.c | |
parent | 7a7ed0c8ac2d66d695da5bd3f90536e8c5c11ccc (diff) | |
download | rneovim-6c81c16e1b8dd1650960bf1cea57ce05b26f7822.tar.gz rneovim-6c81c16e1b8dd1650960bf1cea57ce05b26f7822.tar.bz2 rneovim-6c81c16e1b8dd1650960bf1cea57ce05b26f7822.zip |
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#13556
https://github.com/vim/vim/commit/2b0882fa6555b4d0197afbdfc32a4533cf6aacf4
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#13598
https://github.com/vim/vim/commit/fda700cb04612fe2f9301a9ba820309175decabf
Cherry-pick ops.c change from patch 9.1.0608.
Co-authored-by: Ernie Rael <errael@raelity.com>
Diffstat (limited to 'src/nvim/indent_c.c')
-rw-r--r-- | src/nvim/indent_c.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 9b5c80dd09..c9b7a1ba3f 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -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! |