mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
Remove has_mbytes local to lines changed in parent commit
This commit is contained in:
@@ -2131,11 +2131,7 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int
|
|||||||
char_u *p = IObuff;
|
char_u *p = IObuff;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < actual_len && (p - IObuff + 6) < IOSIZE) {
|
while (i < actual_len && (p - IObuff + 6) < IOSIZE) {
|
||||||
if (has_mbyte) {
|
|
||||||
p += utf_char2bytes(wca[i++], p);
|
p += utf_char2bytes(wca[i++], p);
|
||||||
} else {
|
|
||||||
*(p++) = wca[i++];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*p = NUL;
|
*p = NUL;
|
||||||
}
|
}
|
||||||
@@ -3084,7 +3080,7 @@ static void ins_compl_addleader(int c)
|
|||||||
if (stop_arrow() == FAIL) {
|
if (stop_arrow() == FAIL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (has_mbyte && (cc = (*mb_char2len)(c)) > 1) {
|
if ((cc = utf_char2len(c)) > 1) {
|
||||||
char_u buf[MB_MAXBYTES + 1];
|
char_u buf[MB_MAXBYTES + 1];
|
||||||
|
|
||||||
utf_char2bytes(c, buf);
|
utf_char2bytes(c, buf);
|
||||||
@@ -5334,7 +5330,7 @@ insertchar (
|
|||||||
} else {
|
} else {
|
||||||
int cc;
|
int cc;
|
||||||
|
|
||||||
if (has_mbyte && (cc = (*mb_char2len)(c)) > 1) {
|
if ((cc = utf_char2len(c)) > 1) {
|
||||||
char_u buf[MB_MAXBYTES + 1];
|
char_u buf[MB_MAXBYTES + 1];
|
||||||
|
|
||||||
utf_char2bytes(c, buf);
|
utf_char2bytes(c, buf);
|
||||||
@@ -8660,12 +8656,7 @@ static char_u *do_insert_char_pre(int c)
|
|||||||
if (!has_event(EVENT_INSERTCHARPRE)) {
|
if (!has_event(EVENT_INSERTCHARPRE)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (has_mbyte) {
|
|
||||||
buf[utf_char2bytes(c, (char_u *) buf)] = NUL;
|
buf[utf_char2bytes(c, (char_u *) buf)] = NUL;
|
||||||
} else {
|
|
||||||
buf[0] = c;
|
|
||||||
buf[1] = NUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lock the text to avoid weird things from happening.
|
// Lock the text to avoid weird things from happening.
|
||||||
textlock++;
|
textlock++;
|
||||||
|
@@ -9477,10 +9477,8 @@ static void f_getchar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
temp[i++] = K_SPECIAL;
|
temp[i++] = K_SPECIAL;
|
||||||
temp[i++] = K_SECOND(n);
|
temp[i++] = K_SECOND(n);
|
||||||
temp[i++] = K_THIRD(n);
|
temp[i++] = K_THIRD(n);
|
||||||
} else if (has_mbyte)
|
} else
|
||||||
i += utf_char2bytes(n, temp + i);
|
i += utf_char2bytes(n, temp + i);
|
||||||
else
|
|
||||||
temp[i++] = n;
|
|
||||||
temp[i++] = NUL;
|
temp[i++] = NUL;
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
rettv->vval.v_string = vim_strsave(temp);
|
rettv->vval.v_string = vim_strsave(temp);
|
||||||
@@ -18346,12 +18344,8 @@ void set_vim_var_char(int c)
|
|||||||
{
|
{
|
||||||
char buf[MB_MAXBYTES + 1];
|
char buf[MB_MAXBYTES + 1];
|
||||||
|
|
||||||
if (has_mbyte) {
|
|
||||||
buf[utf_char2bytes(c, (char_u *) buf)] = NUL;
|
buf[utf_char2bytes(c, (char_u *) buf)] = NUL;
|
||||||
} else {
|
|
||||||
buf[0] = c;
|
|
||||||
buf[1] = NUL;
|
|
||||||
}
|
|
||||||
set_vim_var_string(VV_CHAR, buf, -1);
|
set_vim_var_string(VV_CHAR, buf, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1762,14 +1762,10 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
if (IS_SPECIAL(s->c) || mod_mask != 0) {
|
if (IS_SPECIAL(s->c) || mod_mask != 0) {
|
||||||
put_on_cmdline(get_special_key_name(s->c, mod_mask), -1, true);
|
put_on_cmdline(get_special_key_name(s->c, mod_mask), -1, true);
|
||||||
} else {
|
} else {
|
||||||
if (has_mbyte) {
|
|
||||||
s->j = utf_char2bytes(s->c, IObuff);
|
s->j = utf_char2bytes(s->c, IObuff);
|
||||||
IObuff[s->j] = NUL; // exclude composing chars
|
IObuff[s->j] = NUL; // exclude composing chars
|
||||||
put_on_cmdline(IObuff, s->j, true);
|
put_on_cmdline(IObuff, s->j, true);
|
||||||
} else {
|
|
||||||
IObuff[0] = s->c;
|
|
||||||
put_on_cmdline(IObuff, 1, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return command_line_changed(s);
|
return command_line_changed(s);
|
||||||
}
|
}
|
||||||
@@ -2372,12 +2368,7 @@ redraw:
|
|||||||
if (IS_SPECIAL(c1)) {
|
if (IS_SPECIAL(c1)) {
|
||||||
c1 = '?';
|
c1 = '?';
|
||||||
}
|
}
|
||||||
if (has_mbyte) {
|
|
||||||
len = utf_char2bytes(c1, (char_u *)line_ga.ga_data + line_ga.ga_len);
|
len = utf_char2bytes(c1, (char_u *)line_ga.ga_data + line_ga.ga_len);
|
||||||
} else {
|
|
||||||
len = 1;
|
|
||||||
((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1;
|
|
||||||
}
|
|
||||||
if (c1 == '\n')
|
if (c1 == '\n')
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
else if (c1 == TAB) {
|
else if (c1 == TAB) {
|
||||||
|
@@ -3657,14 +3657,10 @@ int check_abbr(int c, char_u *ptr, int col, int mincol)
|
|||||||
} else {
|
} else {
|
||||||
if (c < ABBR_OFF && (c < ' ' || c > '~'))
|
if (c < ABBR_OFF && (c < ' ' || c > '~'))
|
||||||
tb[j++] = Ctrl_V; /* special char needs CTRL-V */
|
tb[j++] = Ctrl_V; /* special char needs CTRL-V */
|
||||||
if (has_mbyte) {
|
|
||||||
/* if ABBR_OFF has been added, remove it here */
|
/* if ABBR_OFF has been added, remove it here */
|
||||||
if (c >= ABBR_OFF)
|
if (c >= ABBR_OFF)
|
||||||
c -= ABBR_OFF;
|
c -= ABBR_OFF;
|
||||||
j += utf_char2bytes(c, tb + j);
|
j += utf_char2bytes(c, tb + j);
|
||||||
} else {
|
|
||||||
tb[j++] = (char_u)c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tb[j] = NUL;
|
tb[j] = NUL;
|
||||||
/* insert the last typed char */
|
/* insert the last typed char */
|
||||||
|
@@ -465,7 +465,7 @@ char_u *get_special_key_name(int c, int modifiers)
|
|||||||
}
|
}
|
||||||
/* Not a special key, only modifiers, output directly */
|
/* Not a special key, only modifiers, output directly */
|
||||||
else {
|
else {
|
||||||
if (has_mbyte && (*mb_char2len)(c) > 1)
|
if (utf_char2len(c) > 1)
|
||||||
idx += utf_char2bytes(c, string + idx);
|
idx += utf_char2bytes(c, string + idx);
|
||||||
else if (vim_isprintc(c))
|
else if (vim_isprintc(c))
|
||||||
string[idx++] = (char_u)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++] = K_SPECIAL;
|
||||||
dst[dlen++] = (char_u)KEY2TERMCAP0(key);
|
dst[dlen++] = (char_u)KEY2TERMCAP0(key);
|
||||||
dst[dlen++] = KEY2TERMCAP1(key);
|
dst[dlen++] = KEY2TERMCAP1(key);
|
||||||
} else if (has_mbyte && !keycode) {
|
} else if (!keycode) {
|
||||||
dlen += (unsigned int)utf_char2bytes(key, dst + dlen);
|
dlen += (unsigned int)utf_char2bytes(key, dst + dlen);
|
||||||
} else if (keycode) {
|
} else {
|
||||||
char_u *after = add_char2buf(key, dst + dlen);
|
char_u *after = add_char2buf(key, dst + dlen);
|
||||||
assert(after >= dst && (uintmax_t)(after - dst) <= UINT_MAX);
|
assert(after >= dst && (uintmax_t)(after - dst) <= UINT_MAX);
|
||||||
dlen = (unsigned int)(after - dst);
|
dlen = (unsigned int)(after - dst);
|
||||||
} else {
|
|
||||||
dst[dlen++] = (char_u)key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dlen;
|
return dlen;
|
||||||
|
@@ -1737,14 +1737,9 @@ int op_replace(oparg_T *oap, int c)
|
|||||||
if (had_ctrl_v_cr || (c != '\r' && c != '\n')) {
|
if (had_ctrl_v_cr || (c != '\r' && c != '\n')) {
|
||||||
// strlen(newp) at this point
|
// strlen(newp) at this point
|
||||||
int newp_len = bd.textcol + bd.startspaces;
|
int newp_len = bd.textcol + bd.startspaces;
|
||||||
if (has_mbyte) {
|
|
||||||
while (--num_chars >= 0) {
|
while (--num_chars >= 0) {
|
||||||
newp_len += utf_char2bytes(c, newp + newp_len);
|
newp_len += utf_char2bytes(c, newp + newp_len);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
memset(newp + newp_len, c, (size_t)numc);
|
|
||||||
newp_len += numc;
|
|
||||||
}
|
|
||||||
if (!bd.is_short) {
|
if (!bd.is_short) {
|
||||||
// insert post-spaces
|
// insert post-spaces
|
||||||
memset(newp + newp_len, ' ', (size_t)bd.endspaces);
|
memset(newp + newp_len, ' ', (size_t)bd.endspaces);
|
||||||
|
@@ -2538,10 +2538,8 @@ static void regc(int b)
|
|||||||
*/
|
*/
|
||||||
static void regmbc(int c)
|
static void regmbc(int c)
|
||||||
{
|
{
|
||||||
if (!has_mbyte && c > 0xff)
|
|
||||||
return;
|
|
||||||
if (regcode == JUST_CALC_SIZE)
|
if (regcode == JUST_CALC_SIZE)
|
||||||
regsize += (*mb_char2len)(c);
|
regsize += utf_char2len(c);
|
||||||
else
|
else
|
||||||
regcode += utf_char2bytes(c, regcode);
|
regcode += utf_char2bytes(c, regcode);
|
||||||
}
|
}
|
||||||
@@ -6759,13 +6757,11 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
cc = c;
|
cc = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_mbyte) {
|
int totlen = utfc_ptr2len(src - 1);
|
||||||
int totlen = mb_ptr2len(src - 1);
|
|
||||||
|
|
||||||
if (copy)
|
if (copy)
|
||||||
utf_char2bytes(cc, dst);
|
utf_char2bytes(cc, dst);
|
||||||
dst += mb_char2len(cc) - 1;
|
dst += utf_char2len(cc) - 1;
|
||||||
if (enc_utf8) {
|
|
||||||
int clen = utf_ptr2len(src - 1);
|
int clen = utf_ptr2len(src - 1);
|
||||||
|
|
||||||
/* If the character length is shorter than "totlen", there
|
/* If the character length is shorter than "totlen", there
|
||||||
@@ -6776,10 +6772,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
(size_t)(totlen - clen));
|
(size_t)(totlen - clen));
|
||||||
dst += totlen - clen;
|
dst += totlen - clen;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
src += totlen - 1;
|
src += totlen - 1;
|
||||||
} else if (copy)
|
|
||||||
*dst = cc;
|
|
||||||
dst++;
|
dst++;
|
||||||
} else {
|
} else {
|
||||||
if (REG_MULTI) {
|
if (REG_MULTI) {
|
||||||
@@ -6861,13 +6854,13 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
if (enc_utf8)
|
if (enc_utf8)
|
||||||
l = utf_ptr2len(s) - 1;
|
l = utf_ptr2len(s) - 1;
|
||||||
else
|
else
|
||||||
l = mb_ptr2len(s) - 1;
|
l = utfc_ptr2len(s) - 1;
|
||||||
|
|
||||||
s += l;
|
s += l;
|
||||||
len -= l;
|
len -= l;
|
||||||
if (copy)
|
if (copy)
|
||||||
utf_char2bytes(cc, dst);
|
utf_char2bytes(cc, dst);
|
||||||
dst += mb_char2len(cc) - 1;
|
dst += utf_char2len(cc) - 1;
|
||||||
} else if (copy)
|
} else if (copy)
|
||||||
*dst = cc;
|
*dst = cc;
|
||||||
dst++;
|
dst++;
|
||||||
|
@@ -563,10 +563,7 @@ static char_u *nfa_get_match_text(nfa_state_T *start)
|
|||||||
p = start->out->out; /* skip first char, it goes into regstart */
|
p = start->out->out; /* skip first char, it goes into regstart */
|
||||||
s = ret;
|
s = ret;
|
||||||
while (p->c > 0) {
|
while (p->c > 0) {
|
||||||
if (has_mbyte)
|
|
||||||
s += utf_char2bytes(p->c, s);
|
s += utf_char2bytes(p->c, s);
|
||||||
else
|
|
||||||
*s++ = p->c;
|
|
||||||
p = p->out;
|
p = p->out;
|
||||||
}
|
}
|
||||||
*s = NUL;
|
*s = NUL;
|
||||||
|
@@ -6954,10 +6954,7 @@ static void win_redr_ruler(win_T *wp, int always)
|
|||||||
if (this_ru_col + o < width) {
|
if (this_ru_col + o < width) {
|
||||||
// Need at least 3 chars left for get_rel_pos() + NUL.
|
// Need at least 3 chars left for get_rel_pos() + NUL.
|
||||||
while (this_ru_col + o < width && RULER_BUF_LEN > i + 4) {
|
while (this_ru_col + o < width && RULER_BUF_LEN > i + 4) {
|
||||||
if (has_mbyte)
|
|
||||||
i += utf_char2bytes(fillchar, buffer + i);
|
i += utf_char2bytes(fillchar, buffer + i);
|
||||||
else
|
|
||||||
buffer[i++] = fillchar;
|
|
||||||
++o;
|
++o;
|
||||||
}
|
}
|
||||||
get_rel_pos(wp, buffer + i, RULER_BUF_LEN - i);
|
get_rel_pos(wp, buffer + i, RULER_BUF_LEN - i);
|
||||||
|
@@ -3433,12 +3433,7 @@ void onecap_copy(char_u *word, char_u *wcopy, bool upper)
|
|||||||
} else {
|
} else {
|
||||||
c = SPELL_TOFOLD(c);
|
c = SPELL_TOFOLD(c);
|
||||||
}
|
}
|
||||||
if (has_mbyte) {
|
|
||||||
l = utf_char2bytes(c, wcopy);
|
l = utf_char2bytes(c, wcopy);
|
||||||
} else {
|
|
||||||
l = 1;
|
|
||||||
wcopy[0] = c;
|
|
||||||
}
|
|
||||||
STRLCPY(wcopy + l, p, MAXWLEN - l);
|
STRLCPY(wcopy + l, p, MAXWLEN - l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3466,15 +3461,9 @@ static void allcap_copy(char_u *word, char_u *wcopy)
|
|||||||
} else
|
} else
|
||||||
c = SPELL_TOUPPER(c);
|
c = SPELL_TOUPPER(c);
|
||||||
|
|
||||||
if (has_mbyte) {
|
|
||||||
if (d - wcopy >= MAXWLEN - MB_MAXBYTES)
|
if (d - wcopy >= MAXWLEN - MB_MAXBYTES)
|
||||||
break;
|
break;
|
||||||
d += utf_char2bytes(c, d);
|
d += utf_char2bytes(c, d);
|
||||||
} else {
|
|
||||||
if (d - wcopy >= MAXWLEN - 1)
|
|
||||||
break;
|
|
||||||
*d++ = c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*d = NUL;
|
*d = NUL;
|
||||||
}
|
}
|
||||||
@@ -4543,16 +4532,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
PROF_STORE(sp->ts_state)
|
PROF_STORE(sp->ts_state)
|
||||||
sp->ts_state = STATE_UNSWAP;
|
sp->ts_state = STATE_UNSWAP;
|
||||||
++depth;
|
++depth;
|
||||||
if (has_mbyte) {
|
|
||||||
fl = mb_char2len(c2);
|
fl = mb_char2len(c2);
|
||||||
memmove(p, p + n, fl);
|
memmove(p, p + n, fl);
|
||||||
utf_char2bytes(c, p + fl);
|
utf_char2bytes(c, p + fl);
|
||||||
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
|
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
|
||||||
} else {
|
|
||||||
p[0] = c2;
|
|
||||||
p[1] = c;
|
|
||||||
stack[depth].ts_fidxtry = sp->ts_fidx + 2;
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
// If this swap doesn't work then SWAP3 won't either.
|
// If this swap doesn't work then SWAP3 won't either.
|
||||||
PROF_STORE(sp->ts_state)
|
PROF_STORE(sp->ts_state)
|
||||||
@@ -4604,17 +4587,11 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
PROF_STORE(sp->ts_state)
|
PROF_STORE(sp->ts_state)
|
||||||
sp->ts_state = STATE_UNSWAP3;
|
sp->ts_state = STATE_UNSWAP3;
|
||||||
++depth;
|
++depth;
|
||||||
if (has_mbyte) {
|
|
||||||
tl = mb_char2len(c3);
|
tl = mb_char2len(c3);
|
||||||
memmove(p, p + n + fl, tl);
|
memmove(p, p + n + fl, tl);
|
||||||
utf_char2bytes(c2, p + tl);
|
utf_char2bytes(c2, p + tl);
|
||||||
utf_char2bytes(c, p + fl + tl);
|
utf_char2bytes(c, p + fl + tl);
|
||||||
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl;
|
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl;
|
||||||
} else {
|
|
||||||
p[0] = p[2];
|
|
||||||
p[2] = c;
|
|
||||||
stack[depth].ts_fidxtry = sp->ts_fidx + 3;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
PROF_STORE(sp->ts_state)
|
PROF_STORE(sp->ts_state)
|
||||||
sp->ts_state = STATE_REP_INI;
|
sp->ts_state = STATE_REP_INI;
|
||||||
|
@@ -1459,10 +1459,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
|
|||||||
} else { // normal char, "[abc]" and '*' are copied as-is
|
} else { // normal char, "[abc]" and '*' are copied as-is
|
||||||
if (c == '?' || c == '+' || c == '~')
|
if (c == '?' || c == '+' || c == '~')
|
||||||
*pp++ = '\\'; // "a?" becomes "a\?", "a+" becomes "a\+"
|
*pp++ = '\\'; // "a?" becomes "a\?", "a+" becomes "a\+"
|
||||||
if (enc_utf8)
|
|
||||||
pp += utf_char2bytes(c, pp);
|
pp += utf_char2bytes(c, pp);
|
||||||
else
|
|
||||||
*pp++ = c;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4245,10 +4242,7 @@ static int write_vim_spell(spellinfo_T *spin, char_u *fname)
|
|||||||
// Form the <folchars> string first, we need to know its length.
|
// Form the <folchars> string first, we need to know its length.
|
||||||
size_t l = 0;
|
size_t l = 0;
|
||||||
for (size_t i = 128; i < 256; ++i) {
|
for (size_t i = 128; i < 256; ++i) {
|
||||||
if (has_mbyte)
|
|
||||||
l += (size_t)utf_char2bytes(spelltab.st_fold[i], folchars + l);
|
l += (size_t)utf_char2bytes(spelltab.st_fold[i], folchars + l);
|
||||||
else
|
|
||||||
folchars[l++] = spelltab.st_fold[i];
|
|
||||||
}
|
}
|
||||||
put_bytes(fd, 1 + 128 + 2 + l, 4); // <sectionlen>
|
put_bytes(fd, 1 + 128 + 2 + l, 4); // <sectionlen>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user