aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.c
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2015-01-11 12:55:38 +0100
committerEliseo Martínez <eliseomarmol@gmail.com>2015-01-11 17:18:39 +0100
commit04c0658024a98a0586997f0ea8af1e3f774cc83e (patch)
treecb34605b25e040a179de11dbc34cc739c7547d34 /src/nvim/ex_cmds.c
parent28e75d4c453dcf7b1d1630815036d0236cfa0034 (diff)
downloadrneovim-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/ex_cmds.c')
-rw-r--r--src/nvim/ex_cmds.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 3278de3561..6bd9da0c28 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -569,7 +569,7 @@ void ex_retab(exarg_T *eap)
save_list = curwin->w_p_list;
curwin->w_p_list = 0; /* don't want list mode here */
- new_ts = getdigits(&(eap->arg));
+ new_ts = get_int_digits(&(eap->arg));
if (new_ts < 0) {
EMSG(_(e_positive));
return;
@@ -3674,7 +3674,7 @@ void do_sub(exarg_T *eap)
*/
cmd = skipwhite(cmd);
if (VIM_ISDIGIT(*cmd)) {
- i = getdigits(&cmd);
+ i = get_long_digits(&cmd);
if (i <= 0 && !eap->skip && do_error) {
EMSG(_(e_zerocount));
return;
@@ -5920,7 +5920,7 @@ void ex_sign(exarg_T *eap)
arg1 = arg;
if (VIM_ISDIGIT(*arg))
{
- id = getdigits(&arg);
+ id = get_int_digits(&arg);
if (!vim_iswhite(*arg) && *arg != NUL)
{
id = -1;
@@ -5985,7 +5985,7 @@ void ex_sign(exarg_T *eap)
else if (STRNCMP(arg, "buffer=", 7) == 0)
{
arg += 7;
- buf = buflist_findnr((int)getdigits(&arg));
+ buf = buflist_findnr(get_int_digits(&arg));
if (*skipwhite(arg) != NUL)
EMSG(_(e_trailing));
break;