aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/ops.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index ef440a27a2..b5408fab9a 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -1966,23 +1966,20 @@ static int swapchars(int op_type, pos_T *pos, int length)
return did_change;
}
-/*
- * If op_type == OP_UPPER: make uppercase,
- * if op_type == OP_LOWER: make lowercase,
- * if op_type == OP_ROT13: do rot13 encoding,
- * else swap case of character at 'pos'
- * returns TRUE when something actually changed.
- */
-int swapchar(int op_type, pos_T *pos)
+// If op_type == OP_UPPER: make uppercase,
+// if op_type == OP_LOWER: make lowercase,
+// if op_type == OP_ROT13: do rot13 encoding,
+// else swap case of character at 'pos'
+// returns true when something actually changed.
+bool swapchar(int op_type, pos_T *pos)
+ FUNC_ATTR_NONNULL_ARG(2)
{
- int c;
- int nc;
-
- c = gchar_pos(pos);
+ const int c = gchar_pos(pos);
- /* Only do rot13 encoding for ASCII characters. */
- if (c >= 0x80 && op_type == OP_ROT13)
- return FALSE;
+ // Only do rot13 encoding for ASCII characters.
+ if (c >= 0x80 && op_type == OP_ROT13) {
+ return false;
+ }
if (op_type == OP_UPPER && c == 0xdf) {
pos_T sp = curwin->w_cursor;
@@ -1996,7 +1993,7 @@ int swapchar(int op_type, pos_T *pos)
inc(pos);
}
- nc = c;
+ int nc = c;
if (mb_islower(c)) {
if (op_type == OP_ROT13) {
nc = ROT13(c, 'a');
@@ -2011,7 +2008,7 @@ int swapchar(int op_type, pos_T *pos)
}
}
if (nc != c) {
- if (enc_utf8 && (c >= 0x80 || nc >= 0x80)) {
+ if (c >= 0x80 || nc >= 0x80) {
pos_T sp = curwin->w_cursor;
curwin->w_cursor = *pos;
@@ -2019,11 +2016,12 @@ int swapchar(int op_type, pos_T *pos)
del_bytes(utf_ptr2len(get_cursor_pos_ptr()), FALSE, FALSE);
ins_char(nc);
curwin->w_cursor = sp;
- } else
+ } else {
pbyte(*pos, nc);
- return TRUE;
+ }
+ return true;
}
- return FALSE;
+ return false;
}
/*