mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 05:28:33 +00:00
vim-patch:9.0.1380: CTRL-X on 2**64 subtracts two (#22530)
Problem: CTRL-X on 2**64 subtracts two. (James McCoy)
Solution: Correct computation for large number. (closes vim/vim#12103)
5fb78c3fa5
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -4658,11 +4658,12 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
|
||||
: length);
|
||||
}
|
||||
|
||||
bool overflow = false;
|
||||
vim_str2nr(ptr + col, &pre, &length,
|
||||
0 + (do_bin ? STR2NR_BIN : 0)
|
||||
+ (do_oct ? STR2NR_OCT : 0)
|
||||
+ (do_hex ? STR2NR_HEX : 0),
|
||||
NULL, &n, maxlen, false);
|
||||
NULL, &n, maxlen, false, &overflow);
|
||||
|
||||
// ignore leading '-' for hex, octal and bin numbers
|
||||
if (pre && negative) {
|
||||
@@ -4682,8 +4683,10 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
|
||||
|
||||
oldn = n;
|
||||
|
||||
n = subtract ? n - (uvarnumber_T)Prenum1
|
||||
: n + (uvarnumber_T)Prenum1;
|
||||
if (!overflow) { // if number is too big don't add/subtract
|
||||
n = subtract ? n - (uvarnumber_T)Prenum1
|
||||
: n + (uvarnumber_T)Prenum1;
|
||||
}
|
||||
|
||||
// handle wraparound for decimal numbers
|
||||
if (!pre) {
|
||||
|
Reference in New Issue
Block a user