mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.1380: CTRL-X on 2**64 subtracts two
Problem: CTRL-X on 2**64 subtracts two. (James McCoy) Solution: Correct computation for large number. (closes #12103)
This commit is contained in:
15
src/ops.c
15
src/ops.c
@@ -2781,11 +2781,12 @@ do_addsub(
|
||||
? (int)STRLEN(ptr) - col
|
||||
: length);
|
||||
|
||||
int 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 and octal and bin numbers
|
||||
if (pre && negative)
|
||||
@@ -2802,10 +2803,14 @@ do_addsub(
|
||||
subtract ^= TRUE;
|
||||
|
||||
oldn = n;
|
||||
if (subtract)
|
||||
n -= (uvarnumber_T)Prenum1;
|
||||
else
|
||||
n += (uvarnumber_T)Prenum1;
|
||||
if (!overflow) // if number is too big don't add/subtract
|
||||
{
|
||||
if (subtract)
|
||||
n -= (uvarnumber_T)Prenum1;
|
||||
else
|
||||
n += (uvarnumber_T)Prenum1;
|
||||
}
|
||||
|
||||
// handle wraparound for decimal numbers
|
||||
if (!pre)
|
||||
{
|
||||
|
Reference in New Issue
Block a user