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/ui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 9c58193e8c..a0b45c1077 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -344,14 +344,14 @@ static void parse_abstract_ui_codes(uint8_t *ptr, int len) assert(p != end); if (VIM_ISDIGIT(*p)) { - arg1 = (int)getdigits(&p); + arg1 = get_int_digits(&p); if (p >= end) { break; } if (*p == ';') { p++; - arg2 = (int)getdigits(&p); + arg2 = get_int_digits(&p); if (p >= end) break; } -- 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/ui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index a0b45c1077..25d6a81960 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -344,14 +344,14 @@ static void parse_abstract_ui_codes(uint8_t *ptr, int len) assert(p != end); if (VIM_ISDIGIT(*p)) { - arg1 = get_int_digits(&p); + arg1 = getdigits_int(&p); if (p >= end) { break; } if (*p == ';') { p++; - arg2 = get_int_digits(&p); + arg2 = getdigits_int(&p); if (p >= end) break; } -- cgit