From 04c0658024a98a0586997f0ea8af1e3f774cc83e Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Sun, 11 Jan 2015 12:55:38 +0100 Subject: 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. --- src/nvim/misc1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/misc1.c') diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 4f17f84e11..912babefb6 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -525,7 +525,7 @@ open_line ( if (*p == COM_RIGHT || *p == COM_LEFT) c = *p++; else if (VIM_ISDIGIT(*p) || *p == '-') - off = getdigits(&p); + off = get_int_digits(&p); else ++p; } -- cgit From 7f7262e93390a1855ac9c687bd492eadfe10cf98 Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Sun, 11 Jan 2015 20:57:33 +0100 Subject: Cleanup: Rename getdigits() family functions. --- src/nvim/misc1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/misc1.c') diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 912babefb6..c0d2e254ac 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -525,7 +525,7 @@ open_line ( if (*p == COM_RIGHT || *p == COM_LEFT) c = *p++; else if (VIM_ISDIGIT(*p) || *p == '-') - off = get_int_digits(&p); + off = getdigits_int(&p); else ++p; } -- cgit