From cbdbc4f63d68a6b17b9eea5c67130e37d3d0f278 Mon Sep 17 00:00:00 2001 From: ZviRackover Date: Sun, 2 Sep 2018 00:58:30 +0300 Subject: Refactor: Remove occurences of mb_char2bytes --- src/nvim/keymap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/keymap.c') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 3cc74c0044..fad4722661 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -466,7 +466,7 @@ char_u *get_special_key_name(int c, int modifiers) /* Not a special key, only modifiers, output directly */ else { if (has_mbyte && (*mb_char2len)(c) > 1) - idx += (*mb_char2bytes)(c, string + idx); + idx += utf_char2bytes(c, string + idx); else if (vim_isprintc(c)) string[idx++] = (char_u)c; else { @@ -525,7 +525,7 @@ unsigned int trans_special(const char_u **srcp, const size_t src_len, dst[dlen++] = (char_u)KEY2TERMCAP0(key); dst[dlen++] = KEY2TERMCAP1(key); } else if (has_mbyte && !keycode) { - dlen += (unsigned int)(*mb_char2bytes)(key, dst + dlen); + dlen += (unsigned int)utf_char2bytes(key, dst + dlen); } else if (keycode) { char_u *after = add_char2buf(key, dst + dlen); assert(after >= dst && (uintmax_t)(after - dst) <= UINT_MAX); -- cgit From ac13e65ae0ce98516e816ba4fcf468d19e750c30 Mon Sep 17 00:00:00 2001 From: ZviRackover Date: Sun, 2 Sep 2018 01:36:18 +0300 Subject: Remove has_mbytes local to lines changed in parent commit --- src/nvim/keymap.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/nvim/keymap.c') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index fad4722661..ea1e84452e 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -465,7 +465,7 @@ char_u *get_special_key_name(int c, int modifiers) } /* Not a special key, only modifiers, output directly */ else { - if (has_mbyte && (*mb_char2len)(c) > 1) + if (utf_char2len(c) > 1) idx += utf_char2bytes(c, string + idx); else if (vim_isprintc(c)) string[idx++] = (char_u)c; @@ -524,14 +524,12 @@ unsigned int trans_special(const char_u **srcp, const size_t src_len, dst[dlen++] = K_SPECIAL; dst[dlen++] = (char_u)KEY2TERMCAP0(key); dst[dlen++] = KEY2TERMCAP1(key); - } else if (has_mbyte && !keycode) { + } else if (!keycode) { dlen += (unsigned int)utf_char2bytes(key, dst + dlen); - } else if (keycode) { + } else { char_u *after = add_char2buf(key, dst + dlen); assert(after >= dst && (uintmax_t)(after - dst) <= UINT_MAX); dlen = (unsigned int)(after - dst); - } else { - dst[dlen++] = (char_u)key; } return dlen; -- cgit From 329cfc3303cffd5c9aad7b2ad7f4323354d68b0d Mon Sep 17 00:00:00 2001 From: ZviRackover Date: Sun, 2 Sep 2018 02:14:47 +0300 Subject: lint: clean-up after parent commits --- src/nvim/keymap.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/nvim/keymap.c') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index ea1e84452e..ade5487ec8 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -462,14 +462,13 @@ char_u *get_special_key_name(int c, int modifiers) string[idx++] = '_'; string[idx++] = (char_u)KEY2TERMCAP0(c); string[idx++] = KEY2TERMCAP1(c); - } - /* Not a special key, only modifiers, output directly */ - else { - if (utf_char2len(c) > 1) + } else { + // Not a special key, only modifiers, output directly. + if (utf_char2len(c) > 1) { idx += utf_char2bytes(c, string + idx); - else if (vim_isprintc(c)) + } else if (vim_isprintc(c)) { string[idx++] = (char_u)c; - else { + } else { s = transchar(c); while (*s) string[idx++] = *s++; -- cgit