From 35874208b86d52b22476ce2a7770b5317fea8694 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 14 Nov 2020 17:14:30 -0500 Subject: [PATCH] globals: eliminate "has_mbyte" macro "has_mbyte" always evaluates to "true". Continue dead code removal, started in https://github.com/neovim/neovim/pull/13275. --- src/nvim/globals.h | 1 - src/nvim/main.c | 3 --- src/nvim/spell_defs.h | 2 +- src/nvim/version.c | 13 +++++-------- test/symbolic/klee/nvim/keymap.c | 2 +- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 657afeaf4c..7247c7e4d0 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -602,7 +602,6 @@ EXTERN int inhibit_delete_count INIT(= 0); // 'encoding' is always "utf-8". Code that use them can be refactored to // remove dead code. #define enc_utf8 true -#define has_mbyte true /// Encoding used when 'fencs' is set to "default" EXTERN char_u *fenc_default INIT(= NULL); diff --git a/src/nvim/main.c b/src/nvim/main.c index 6ff5216a84..941258fa79 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -188,9 +188,6 @@ void early_init(mparm_T *paramp) global_alist.id = 0; // Set the default values for the options. - // NOTE: Non-latin1 translated messages are working only after this, - // because this is where "has_mbyte" will be set, which is used by - // msg_outtrans_len_attr(). // First find out the home directory, needed to expand "~" in options. init_homedir(); // find real value of $HOME set_init_1(paramp != NULL ? paramp->clean : false); diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h index 05667f060e..e2c9ab7ae8 100644 --- a/src/nvim/spell_defs.h +++ b/src/nvim/spell_defs.h @@ -162,7 +162,7 @@ struct slang_S { bool sl_collapse; // SAL collapse_result bool sl_rem_accents; // SAL remove_accents bool sl_sofo; // SOFOFROM and SOFOTO instead of SAL items: - // "sl_sal_first" maps chars, when has_mbyte + // "sl_sal_first" maps chars // "sl_sal" is a list of wide char lists. garray_T sl_repsal; // list of fromto_T entries from REPSAL lines int16_t sl_repsal_first[256]; // sl_rep_first for REPSAL lines diff --git a/src/nvim/version.c b/src/nvim/version.c index 7296c74109..6be2a61c6a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -2301,14 +2301,11 @@ static void do_intro_line(long row, char_u *mesg, int attr) for (p = mesg; *p != NUL; p += l) { clen = 0; - for (l = 0; p[l] != NUL - && (l == 0 || (p[l] != '<' && p[l - 1] != '>')); ++l) { - if (has_mbyte) { - clen += ptr2cells(p + l); - l += (*mb_ptr2len)(p + l) - 1; - } else { - clen += byte2cells(p[l]); - } + for (l = 0; + p[l] != NUL && (l == 0 || (p[l] != '<' && p[l - 1] != '>')); + l++) { + clen += ptr2cells(p + l); + l += utfc_ptr2len(p + l) - 1; } assert(row <= INT_MAX && col <= INT_MAX); grid_puts_len(&default_grid, p, l, (int)row, (int)col, diff --git a/test/symbolic/klee/nvim/keymap.c b/test/symbolic/klee/nvim/keymap.c index 07eb4fa70a..ed5f95a344 100644 --- a/test/symbolic/klee/nvim/keymap.c +++ b/test/symbolic/klee/nvim/keymap.c @@ -545,7 +545,7 @@ 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)(*mb_char2bytes)(key, dst + dlen); } else if (keycode) { char_u *after = add_char2buf(key, dst + dlen);