mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 08:18:17 +00:00
refactor(multibyte): eliminate mb_char2len alias for utf_char2len
This commit is contained in:
@@ -3461,7 +3461,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
|
||||
|
||||
if (fillchar == 0) {
|
||||
fillchar = ' ';
|
||||
} else if (mb_char2len(fillchar) > 1) {
|
||||
} else if (utf_char2len(fillchar) > 1) {
|
||||
// Can't handle a multi-byte fill character yet.
|
||||
fillchar = '-';
|
||||
}
|
||||
|
@@ -477,7 +477,7 @@ char_u *get_special_key_name(int c, int modifiers)
|
||||
* extract modifiers.
|
||||
*/
|
||||
if (c > 0
|
||||
&& (*mb_char2len)(c) == 1) {
|
||||
&& utf_char2len(c) == 1) {
|
||||
if (table_idx < 0
|
||||
&& (!vim_isprintc(c) || (c & 0x7f) == ' ')
|
||||
&& (c & 0x80)) {
|
||||
|
@@ -114,7 +114,6 @@
|
||||
#define MB_COPY_CHAR(f, t) mb_copy_char((const char_u **)(&f), &t);
|
||||
|
||||
#define MB_CHARLEN(p) mb_charlen(p)
|
||||
#define MB_CHAR2LEN(c) mb_char2len(c)
|
||||
#define PTR2CHAR(p) utf_ptr2char(p)
|
||||
|
||||
#define RESET_BINDING(wp) \
|
||||
|
@@ -38,9 +38,6 @@
|
||||
#define ENC_LATIN9 0x400 // Latin9
|
||||
#define ENC_MACROMAN 0x800 // Mac Roman (not Macro Man! :-)
|
||||
|
||||
// TODO(bfredl): eventually we should keep only one of the namings
|
||||
#define mb_char2len utf_char2len
|
||||
|
||||
/// Flags for vimconv_T
|
||||
typedef enum {
|
||||
CONV_NONE = 0,
|
||||
|
@@ -1847,7 +1847,7 @@ int op_replace(oparg_T *oap, int c)
|
||||
|
||||
// Compute bytes needed, move character count to num_chars.
|
||||
num_chars = numc;
|
||||
numc *= (*mb_char2len)(c);
|
||||
numc *= utf_char2len(c);
|
||||
|
||||
oldp = get_cursor_line_ptr();
|
||||
oldlen = (int)STRLEN(oldp);
|
||||
@@ -1926,11 +1926,11 @@ int op_replace(oparg_T *oap, int c)
|
||||
while (ltoreq(curwin->w_cursor, oap->end)) {
|
||||
n = gchar_cursor();
|
||||
if (n != NUL) {
|
||||
if ((*mb_char2len)(c) > 1 || (*mb_char2len)(n) > 1) {
|
||||
if (utf_char2len(c) > 1 || utf_char2len(n) > 1) {
|
||||
// This is slow, but it handles replacing a single-byte
|
||||
// with a multi-byte and the other way around.
|
||||
if (curwin->w_cursor.lnum == oap->end.lnum) {
|
||||
oap->end.col += (*mb_char2len)(c) - (*mb_char2len)(n);
|
||||
oap->end.col += utf_char2len(c) - utf_char2len(n);
|
||||
}
|
||||
replace_character(c);
|
||||
} else {
|
||||
|
@@ -2255,8 +2255,8 @@ collection:
|
||||
if (startc > endc) {
|
||||
EMSG_RET_NULL(_(e_reverse_range));
|
||||
}
|
||||
if ((*mb_char2len)(startc) > 1
|
||||
|| (*mb_char2len)(endc) > 1) {
|
||||
if (utf_char2len(startc) > 1
|
||||
|| utf_char2len(endc) > 1) {
|
||||
// Limit to a range of 256 chars
|
||||
if (endc > startc + 256) {
|
||||
EMSG_RET_NULL(_(e_large_class));
|
||||
|
@@ -543,7 +543,7 @@ static char_u *nfa_get_match_text(nfa_state_T *start)
|
||||
return NULL; /* just in case */
|
||||
p = p->out;
|
||||
while (p->c > 0) {
|
||||
len += MB_CHAR2LEN(p->c);
|
||||
len += utf_char2len(p->c);
|
||||
p = p->out;
|
||||
}
|
||||
if (p->c != NFA_MCLOSE || p->out->c != NFA_MATCH)
|
||||
@@ -1746,8 +1746,8 @@ collection:
|
||||
EMIT(endc);
|
||||
EMIT(NFA_RANGE);
|
||||
EMIT(NFA_CONCAT);
|
||||
} else if ((*mb_char2len)(startc) > 1
|
||||
|| (*mb_char2len)(endc) > 1) {
|
||||
} else if (utf_char2len(startc) > 1
|
||||
|| utf_char2len(endc) > 1) {
|
||||
// Emit the characters in the range.
|
||||
// "startc" was already emitted, so skip it.
|
||||
for (c = startc + 1; c <= endc; c++) {
|
||||
@@ -1828,7 +1828,7 @@ collection:
|
||||
|
||||
nfa_do_multibyte:
|
||||
// plen is length of current char with composing chars
|
||||
if ((*mb_char2len)(c) != (plen = utfc_ptr2len(old_regparse))
|
||||
if (utf_char2len(c) != (plen = utfc_ptr2len(old_regparse))
|
||||
|| utf_iscomposing(c)) {
|
||||
int i = 0;
|
||||
|
||||
@@ -2972,8 +2972,8 @@ static int nfa_max_width(nfa_state_T *startstate, int depth)
|
||||
if (state->c < 0)
|
||||
/* don't know what this is */
|
||||
return -1;
|
||||
/* normal character */
|
||||
len += MB_CHAR2LEN(state->c);
|
||||
// normal character
|
||||
len += utf_char2len(state->c);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5620,7 +5620,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
|
||||
// Only match composing character(s), ignore base
|
||||
// character. Used for ".{composing}" and "{composing}"
|
||||
// (no preceding character).
|
||||
len += mb_char2len(mc);
|
||||
len += utf_char2len(mc);
|
||||
}
|
||||
if (rex.reg_icombine && len == 0) {
|
||||
// If \Z was present, then ignore composing characters.
|
||||
@@ -5636,7 +5636,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
|
||||
} else if (len > 0 || mc == sta->c) {
|
||||
// Check base character matches first, unless ignored.
|
||||
if (len == 0) {
|
||||
len += mb_char2len(mc);
|
||||
len += utf_char2len(mc);
|
||||
sta = sta->out;
|
||||
}
|
||||
|
||||
@@ -5645,10 +5645,11 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
|
||||
while (len < clen) {
|
||||
mc = utf_ptr2char(rex.input + len);
|
||||
cchars[ccount++] = mc;
|
||||
len += mb_char2len(mc);
|
||||
if (ccount == MAX_MCO)
|
||||
len += utf_char2len(mc);
|
||||
if (ccount == MAX_MCO) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that each composing char in the pattern matches a
|
||||
// composing char in the text. We do not check if all
|
||||
|
@@ -3705,7 +3705,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
|
||||
// if n_extra > 0, it gives the number of chars
|
||||
// to use for a tab, else we need to calculate the width
|
||||
// for a tab
|
||||
int len = (tab_len * mb_char2len(wp->w_p_lcs_chars.tab2));
|
||||
int len = (tab_len * utf_char2len(wp->w_p_lcs_chars.tab2));
|
||||
if (n_extra > 0) {
|
||||
len += n_extra - tab_len;
|
||||
}
|
||||
@@ -3728,8 +3728,8 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
|
||||
lcs = wp->w_p_lcs_chars.tab3;
|
||||
}
|
||||
utf_char2bytes(lcs, p);
|
||||
p += mb_char2len(lcs);
|
||||
n_extra += mb_char2len(lcs) - (saved_nextra > 0 ? 1 : 0);
|
||||
p += utf_char2len(lcs);
|
||||
n_extra += utf_char2len(lcs) - (saved_nextra > 0 ? 1 : 0);
|
||||
}
|
||||
p_extra = p_extra_free;
|
||||
|
||||
|
@@ -4644,7 +4644,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
PROF_STORE(sp->ts_state)
|
||||
sp->ts_state = STATE_UNSWAP;
|
||||
depth++;
|
||||
fl = mb_char2len(c2);
|
||||
fl = utf_char2len(c2);
|
||||
memmove(p, p + n, fl);
|
||||
utf_char2bytes(c, p + fl);
|
||||
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
|
||||
@@ -4700,7 +4700,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
PROF_STORE(sp->ts_state)
|
||||
sp->ts_state = STATE_UNSWAP3;
|
||||
depth++;
|
||||
tl = mb_char2len(c3);
|
||||
tl = utf_char2len(c3);
|
||||
memmove(p, p + n + fl, tl);
|
||||
utf_char2bytes(c2, p + tl);
|
||||
utf_char2bytes(c, p + fl + tl);
|
||||
|
@@ -5858,8 +5858,8 @@ static void set_map_str(slang_T *lp, char_u *map)
|
||||
// the hash table. Each entry is the char, a NUL the headchar and
|
||||
// a NUL.
|
||||
if (c >= 256) {
|
||||
int cl = mb_char2len(c);
|
||||
int headcl = mb_char2len(headc);
|
||||
int cl = utf_char2len(c);
|
||||
int headcl = utf_char2len(headc);
|
||||
char_u *b;
|
||||
hash_T hash;
|
||||
hashitem_T *hi;
|
||||
|
Reference in New Issue
Block a user