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)
diff --git a/src/ops.c b/src/ops.c
index 01d2e95..33fedba 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -2781,11 +2781,12 @@
? (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 @@
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)
{