diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2015-01-11 12:55:38 +0100 |
---|---|---|
committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2015-01-11 17:18:39 +0100 |
commit | 04c0658024a98a0586997f0ea8af1e3f774cc83e (patch) | |
tree | cb34605b25e040a179de11dbc34cc739c7547d34 /src/nvim/mark.c | |
parent | 28e75d4c453dcf7b1d1630815036d0236cfa0034 (diff) | |
download | rneovim-04c0658024a98a0586997f0ea8af1e3f774cc83e.tar.gz rneovim-04c0658024a98a0586997f0ea8af1e3f774cc83e.tar.bz2 rneovim-04c0658024a98a0586997f0ea8af1e3f774cc83e.zip |
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.
Diffstat (limited to 'src/nvim/mark.c')
-rw-r--r-- | src/nvim/mark.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c index ef9f0ca408..abe05dfb30 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -1226,9 +1226,9 @@ int read_viminfo_filemark(vir_T *virp, int force) } if (fm != NULL && (fm->fmark.mark.lnum == 0 || force)) { str = skipwhite(str + 1); - fm->fmark.mark.lnum = getdigits(&str); + fm->fmark.mark.lnum = get_long_digits(&str); str = skipwhite(str); - fm->fmark.mark.col = getdigits(&str); + fm->fmark.mark.col = get_int_digits(&str); fm->fmark.mark.coladd = 0; fm->fmark.fnum = 0; str = skipwhite(str); |