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:
Eliseo Martínez
2015-01-11 12:55:38 +01:00
parent 28e75d4c45
commit 04c0658024
23 changed files with 105 additions and 106 deletions

View File

@@ -4611,7 +4611,7 @@ int read_viminfo_search_pattern(vir_T *virp, int force)
if (lp[4] == 'E')
off_end = SEARCH_END;
lp += 5;
off = getdigits(&lp);
off = get_long_digits(&lp);
}
if (lp[0] == '~') { /* use this pattern for last-used pattern */
setlast = TRUE;