diff options
author | Ernie Rael <errael@raelity.com> | 2023-11-23 20:21:45 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-11-23 20:33:05 +0100 |
commit | 2b0882fa6555b4d0197afbdfc32a4533cf6aacf4 (patch) | |
tree | b8467231938c30e9391beb2f363f2a82fe872cb3 /src/ops.c | |
parent | df63da98d8dc284b1c76cfe1b17fa0acbd6094d8 (diff) |
patch 9.0.2124: INT overflow detection logic can be simplifiedv9.0.2124
Problem: INT overflow logic can be simplified
Solution: introduce trim_to_int() function
closes: #13556
Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/ops.c')
-rw-r--r-- | src/ops.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -230,8 +230,8 @@ shift_line( int call_changed_bytes) // call changed_bytes() { long long count; - long i, j; - long sw_val = get_sw_value_indent(curbuf); + int i, j; + int sw_val = trim_to_int(get_sw_value_indent(curbuf)); count = (long long)get_indent(); // get current indent @@ -263,14 +263,11 @@ shift_line( count += (long long)sw_val * (long long)amount; } - if (count > INT_MAX) - count = INT_MAX; - // Set new indent if (State & VREPLACE_FLAG) - change_indent(INDENT_SET, (int)count, FALSE, NUL, call_changed_bytes); + change_indent(INDENT_SET, trim_to_int(count), FALSE, NUL, call_changed_bytes); else - (void)set_indent((int)count, call_changed_bytes ? SIN_CHANGED : 0); + (void)set_indent(trim_to_int(count), call_changed_bytes ? SIN_CHANGED : 0); } /* |