mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 03:28:33 +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:
@@ -120,7 +120,7 @@ ex_menu (
|
||||
break;
|
||||
if (vim_iswhite(*p)) {
|
||||
for (i = 0; i < MENUDEPTH && !vim_iswhite(*arg); ++i) {
|
||||
pri_tab[i] = getdigits(&arg);
|
||||
pri_tab[i] = get_int_digits(&arg);
|
||||
if (pri_tab[i] == 0)
|
||||
pri_tab[i] = 500;
|
||||
if (*arg == '.')
|
||||
|
Reference in New Issue
Block a user