mirror of
https://github.com/neovim/neovim.git
synced 2025-12-07 23:22:39 +00:00
Cleanup: Refactor getdigits().
Problem : getdigits() currently returns a long, but at most places,
return value is casted (unsafely) into an int. Making casts
safe would introduce a lot of fuss in the form of assertions
checking for limits.
Note : We cannot just change return type to int, because, at some
places, legitimate long values are used. For example, in
diff.c, for line numbers.
Solution : Introduce new functions:
- get_digits() : Gets an intmax_t from a string.
- get_int_digits() : Wrapper for ints.
- get_long_digits() : Wrapper for longs.
And replace getdigits() invocations by the appropiate
wrapper invocations.
This commit is contained in:
@@ -2750,7 +2750,7 @@ void ex_lockvar(exarg_T *eap)
|
||||
if (eap->forceit)
|
||||
deep = -1;
|
||||
else if (vim_isdigit(*arg)) {
|
||||
deep = getdigits(&arg);
|
||||
deep = get_int_digits(&arg);
|
||||
arg = skipwhite(arg);
|
||||
}
|
||||
|
||||
@@ -13370,7 +13370,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv)
|
||||
yank_type = MBLOCK;
|
||||
if (VIM_ISDIGIT(stropt[1])) {
|
||||
++stropt;
|
||||
block_len = getdigits(&stropt) - 1;
|
||||
block_len = get_long_digits(&stropt) - 1;
|
||||
--stropt;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user