mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 23:38:17 +00:00
Remove some occrrences of enc_utf8 and has_mbyte
Removing uses and related dead code in the locallity of changes of the two parent commits.
This commit is contained in:
@@ -476,11 +476,8 @@ bool leftcol_changed(void)
|
|||||||
|
|
||||||
int gchar_cursor(void)
|
int gchar_cursor(void)
|
||||||
{
|
{
|
||||||
if (has_mbyte) {
|
|
||||||
return utf_ptr2char(get_cursor_pos_ptr());
|
return utf_ptr2char(get_cursor_pos_ptr());
|
||||||
}
|
}
|
||||||
return (int)(*get_cursor_pos_ptr());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write a character at the current cursor position.
|
* Write a character at the current cursor position.
|
||||||
|
@@ -2311,24 +2311,14 @@ static void ins_compl_longest_match(compl_T *match)
|
|||||||
p = compl_leader;
|
p = compl_leader;
|
||||||
s = match->cp_str;
|
s = match->cp_str;
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
if (has_mbyte) {
|
|
||||||
c1 = utf_ptr2char(p);
|
c1 = utf_ptr2char(p);
|
||||||
c2 = utf_ptr2char(s);
|
c2 = utf_ptr2char(s);
|
||||||
} else {
|
|
||||||
c1 = *p;
|
if (match->cp_icase ? (mb_tolower(c1) != mb_tolower(c2)) : (c1 != c2)) {
|
||||||
c2 = *s;
|
|
||||||
}
|
|
||||||
if (match->cp_icase ? (mb_tolower(c1) != mb_tolower(c2))
|
|
||||||
: (c1 != c2)) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (has_mbyte) {
|
|
||||||
MB_PTR_ADV(p);
|
MB_PTR_ADV(p);
|
||||||
MB_PTR_ADV(s);
|
MB_PTR_ADV(s);
|
||||||
} else {
|
|
||||||
++p;
|
|
||||||
++s;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p != NUL) {
|
if (*p != NUL) {
|
||||||
|
@@ -701,13 +701,12 @@ open_line (
|
|||||||
replace_push(NUL); /* end of extra blanks */
|
replace_push(NUL); /* end of extra blanks */
|
||||||
if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES)) {
|
if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES)) {
|
||||||
while ((*p_extra == ' ' || *p_extra == '\t')
|
while ((*p_extra == ' ' || *p_extra == '\t')
|
||||||
&& (!enc_utf8
|
&& !utf_iscomposing(utf_ptr2char(p_extra + 1))) {
|
||||||
|| !utf_iscomposing(utf_ptr2char(p_extra + 1)))
|
if (REPLACE_NORMAL(State)) {
|
||||||
) {
|
|
||||||
if (REPLACE_NORMAL(State))
|
|
||||||
replace_push(*p_extra);
|
replace_push(*p_extra);
|
||||||
++p_extra;
|
}
|
||||||
++less_cols_off;
|
p_extra++;
|
||||||
|
less_cols_off++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*p_extra != NUL) {
|
if (*p_extra != NUL) {
|
||||||
@@ -1749,12 +1748,7 @@ del_lines (
|
|||||||
|
|
||||||
int gchar_pos(pos_T *pos)
|
int gchar_pos(pos_T *pos)
|
||||||
{
|
{
|
||||||
char_u *ptr = ml_get_pos(pos);
|
return utf_ptr2char(ml_get_pos(pos));
|
||||||
|
|
||||||
if (has_mbyte) {
|
|
||||||
return utf_ptr2char(ptr);
|
|
||||||
}
|
|
||||||
return (int)(*ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2390,12 +2384,12 @@ int get_keystroke(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (has_mbyte) {
|
if (MB_BYTE2LEN(n) > len) {
|
||||||
if (MB_BYTE2LEN(n) > len)
|
// more bytes to get.
|
||||||
continue; /* more bytes to get */
|
continue;
|
||||||
|
}
|
||||||
buf[len >= buflen ? buflen - 1 : len] = NUL;
|
buf[len >= buflen ? buflen - 1 : len] = NUL;
|
||||||
n = utf_ptr2char(buf);
|
n = utf_ptr2char(buf);
|
||||||
}
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
if (n == intr_char)
|
if (n == intr_char)
|
||||||
n = ESC;
|
n = ESC;
|
||||||
|
@@ -772,14 +772,9 @@ static int get_equi_class(char_u **pp)
|
|||||||
char_u *p = *pp;
|
char_u *p = *pp;
|
||||||
|
|
||||||
if (p[1] == '=') {
|
if (p[1] == '=') {
|
||||||
if (has_mbyte)
|
|
||||||
l = (*mb_ptr2len)(p + 2);
|
l = (*mb_ptr2len)(p + 2);
|
||||||
if (p[l + 2] == '=' && p[l + 3] == ']') {
|
if (p[l + 2] == '=' && p[l + 3] == ']') {
|
||||||
if (has_mbyte) {
|
|
||||||
c = utf_ptr2char(p + 2);
|
c = utf_ptr2char(p + 2);
|
||||||
} else {
|
|
||||||
c = p[2];
|
|
||||||
}
|
|
||||||
*pp += l + 4;
|
*pp += l + 4;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -1108,14 +1103,9 @@ static int get_coll_element(char_u **pp)
|
|||||||
char_u *p = *pp;
|
char_u *p = *pp;
|
||||||
|
|
||||||
if (p[0] != NUL && p[1] == '.') {
|
if (p[0] != NUL && p[1] == '.') {
|
||||||
if (has_mbyte)
|
|
||||||
l = (*mb_ptr2len)(p + 2);
|
l = (*mb_ptr2len)(p + 2);
|
||||||
if (p[l + 2] == '.' && p[l + 3] == ']') {
|
if (p[l + 2] == '.' && p[l + 3] == ']') {
|
||||||
if (has_mbyte) {
|
|
||||||
c = utf_ptr2char(p + 2);
|
c = utf_ptr2char(p + 2);
|
||||||
} else {
|
|
||||||
c = p[2];
|
|
||||||
}
|
|
||||||
*pp += l + 4;
|
*pp += l + 4;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -1301,11 +1291,7 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (OP(scan) == EXACTLY) {
|
if (OP(scan) == EXACTLY) {
|
||||||
if (has_mbyte) {
|
|
||||||
r->regstart = utf_ptr2char(OPERAND(scan));
|
r->regstart = utf_ptr2char(OPERAND(scan));
|
||||||
} else {
|
|
||||||
r->regstart = *OPERAND(scan);
|
|
||||||
}
|
|
||||||
} else if (OP(scan) == BOW
|
} else if (OP(scan) == BOW
|
||||||
|| OP(scan) == EOW
|
|| OP(scan) == EOW
|
||||||
|| OP(scan) == NOTHING
|
|| OP(scan) == NOTHING
|
||||||
@@ -1313,11 +1299,7 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags)
|
|||||||
|| OP(scan) == MCLOSE + 0 || OP(scan) == NCLOSE) {
|
|| OP(scan) == MCLOSE + 0 || OP(scan) == NCLOSE) {
|
||||||
char_u *regnext_scan = regnext(scan);
|
char_u *regnext_scan = regnext(scan);
|
||||||
if (OP(regnext_scan) == EXACTLY) {
|
if (OP(regnext_scan) == EXACTLY) {
|
||||||
if (has_mbyte) {
|
|
||||||
r->regstart = utf_ptr2char(OPERAND(regnext_scan));
|
r->regstart = utf_ptr2char(OPERAND(regnext_scan));
|
||||||
} else {
|
|
||||||
r->regstart = *OPERAND(regnext_scan);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2416,20 +2398,16 @@ collection:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (has_mbyte) {
|
// produce a multibyte character, including any
|
||||||
int len;
|
// following composing characters.
|
||||||
|
|
||||||
/* produce a multibyte character, including any
|
|
||||||
* following composing characters */
|
|
||||||
startc = utf_ptr2char(regparse);
|
startc = utf_ptr2char(regparse);
|
||||||
len = (*mb_ptr2len)(regparse);
|
int len = utfc_ptr2len(regparse);
|
||||||
if (enc_utf8 && utf_char2len(startc) != len)
|
if (utf_char2len(startc) != len) {
|
||||||
startc = -1; /* composing chars */
|
// composing chars
|
||||||
while (--len >= 0)
|
startc = -1;
|
||||||
|
}
|
||||||
|
while (--len >= 0) {
|
||||||
regc(*regparse++);
|
regc(*regparse++);
|
||||||
} else {
|
|
||||||
startc = *regparse++;
|
|
||||||
regc(startc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2910,20 +2888,14 @@ static int peekchr(void)
|
|||||||
* Next character can never be (made) magic?
|
* Next character can never be (made) magic?
|
||||||
* Then backslashing it won't do anything.
|
* Then backslashing it won't do anything.
|
||||||
*/
|
*/
|
||||||
if (has_mbyte) {
|
|
||||||
curchr = utf_ptr2char(regparse + 1);
|
curchr = utf_ptr2char(regparse + 1);
|
||||||
} else {
|
|
||||||
curchr = c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (has_mbyte) {
|
|
||||||
curchr = utf_ptr2char(regparse);
|
curchr = utf_ptr2char(regparse);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return curchr;
|
return curchr;
|
||||||
}
|
}
|
||||||
@@ -3474,11 +3446,7 @@ static long bt_regexec_both(char_u *line,
|
|||||||
if (prog->regmust != NULL) {
|
if (prog->regmust != NULL) {
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
if (has_mbyte) {
|
|
||||||
c = utf_ptr2char(prog->regmust);
|
c = utf_ptr2char(prog->regmust);
|
||||||
} else {
|
|
||||||
c = *prog->regmust;
|
|
||||||
}
|
|
||||||
s = line + col;
|
s = line + col;
|
||||||
|
|
||||||
// This is used very often, esp. for ":global". Use two versions of
|
// This is used very often, esp. for ":global". Use two versions of
|
||||||
@@ -3509,17 +3477,11 @@ static long bt_regexec_both(char_u *line,
|
|||||||
|
|
||||||
/* Simplest case: Anchored match need be tried only once. */
|
/* Simplest case: Anchored match need be tried only once. */
|
||||||
if (prog->reganch) {
|
if (prog->reganch) {
|
||||||
int c;
|
int c = utf_ptr2char(regline + col);
|
||||||
|
|
||||||
if (has_mbyte) {
|
|
||||||
c = utf_ptr2char(regline + col);
|
|
||||||
} else {
|
|
||||||
c = regline[col];
|
|
||||||
}
|
|
||||||
if (prog->regstart == NUL
|
if (prog->regstart == NUL
|
||||||
|| prog->regstart == c
|
|| prog->regstart == c
|
||||||
|| (rex.reg_ic
|
|| (rex.reg_ic
|
||||||
&& (((enc_utf8 && utf_fold(prog->regstart) == utf_fold(c)))
|
&& (utf_fold(prog->regstart) == utf_fold(c)
|
||||||
|| (c < 255 && prog->regstart < 255
|
|| (c < 255 && prog->regstart < 255
|
||||||
&& mb_tolower(prog->regstart) == mb_tolower(c))))) {
|
&& mb_tolower(prog->regstart) == mb_tolower(c))))) {
|
||||||
retval = regtry(prog, col);
|
retval = regtry(prog, col);
|
||||||
@@ -3866,13 +3828,10 @@ regmatch (
|
|||||||
} else if (rex.reg_line_lbr && WITH_NL(op) && *reginput == '\n') {
|
} else if (rex.reg_line_lbr && WITH_NL(op) && *reginput == '\n') {
|
||||||
ADVANCE_REGINPUT();
|
ADVANCE_REGINPUT();
|
||||||
} else {
|
} else {
|
||||||
if (WITH_NL(op))
|
if (WITH_NL(op)) {
|
||||||
op -= ADD_NL;
|
op -= ADD_NL;
|
||||||
if (has_mbyte) {
|
|
||||||
c = utf_ptr2char(reginput);
|
|
||||||
} else {
|
|
||||||
c = *reginput;
|
|
||||||
}
|
}
|
||||||
|
c = utf_ptr2char(reginput);
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case BOL:
|
case BOL:
|
||||||
if (reginput != regline)
|
if (reginput != regline)
|
||||||
@@ -6791,20 +6750,20 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
}
|
}
|
||||||
c = *src++;
|
c = *src++;
|
||||||
}
|
}
|
||||||
} else if (has_mbyte) {
|
} else {
|
||||||
c = utf_ptr2char(src - 1);
|
c = utf_ptr2char(src - 1);
|
||||||
}
|
}
|
||||||
|
// Write to buffer, if copy is set.
|
||||||
/* Write to buffer, if copy is set. */
|
if (func_one != NULL) {
|
||||||
if (func_one != (fptr_T)NULL)
|
|
||||||
/* Turbo C complains without the typecast */
|
|
||||||
func_one = (fptr_T)(func_one(&cc, c));
|
func_one = (fptr_T)(func_one(&cc, c));
|
||||||
else if (func_all != (fptr_T)NULL)
|
} else {
|
||||||
/* Turbo C complains without the typecast */
|
if (func_all != NULL) {
|
||||||
func_all = (fptr_T)(func_all(&cc, c));
|
func_all = (fptr_T)(func_all(&cc, c));
|
||||||
else /* just copy */
|
} else {
|
||||||
|
// just copy
|
||||||
cc = c;
|
cc = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
int totlen = mb_ptr2len(src - 1);
|
int totlen = mb_ptr2len(src - 1);
|
||||||
|
|
||||||
@@ -6888,11 +6847,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
}
|
}
|
||||||
dst += 2;
|
dst += 2;
|
||||||
} else {
|
} else {
|
||||||
if (has_mbyte) {
|
|
||||||
c = utf_ptr2char(s);
|
c = utf_ptr2char(s);
|
||||||
} else {
|
|
||||||
c = *s;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (func_one != (fptr_T)NULL)
|
if (func_one != (fptr_T)NULL)
|
||||||
/* Turbo C complains without the typecast */
|
/* Turbo C complains without the typecast */
|
||||||
|
@@ -5033,13 +5033,8 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
|
|||||||
int curc;
|
int curc;
|
||||||
int clen;
|
int clen;
|
||||||
|
|
||||||
if (has_mbyte) {
|
|
||||||
curc = utf_ptr2char(reginput);
|
curc = utf_ptr2char(reginput);
|
||||||
clen = (*mb_ptr2len)(reginput);
|
clen = utfc_ptr2len(reginput);
|
||||||
} else {
|
|
||||||
curc = *reginput;
|
|
||||||
clen = 1;
|
|
||||||
}
|
|
||||||
if (curc == NUL) {
|
if (curc == NUL) {
|
||||||
clen = 0;
|
clen = 0;
|
||||||
go_to_nextline = false;
|
go_to_nextline = false;
|
||||||
|
@@ -1120,8 +1120,8 @@ int do_search(
|
|||||||
msgbuf = xmalloc(STRLEN(p) + 40);
|
msgbuf = xmalloc(STRLEN(p) + 40);
|
||||||
{
|
{
|
||||||
msgbuf[0] = dirc;
|
msgbuf[0] = dirc;
|
||||||
if (enc_utf8 && utf_iscomposing(utf_ptr2char(p))) {
|
if (utf_iscomposing(utf_ptr2char(p))) {
|
||||||
/* Use a space to draw the composing char on. */
|
// Use a space to draw the composing char on.
|
||||||
msgbuf[1] = ' ';
|
msgbuf[1] = ' ';
|
||||||
STRCPY(msgbuf + 2, p);
|
STRCPY(msgbuf + 2, p);
|
||||||
} else
|
} else
|
||||||
|
@@ -2619,17 +2619,12 @@ static bool spell_iswordp(char_u *p, win_T *wp)
|
|||||||
// Unlike spell_iswordp() this doesn't check for "midword" characters.
|
// Unlike spell_iswordp() this doesn't check for "midword" characters.
|
||||||
bool spell_iswordp_nmw(const char_u *p, win_T *wp)
|
bool spell_iswordp_nmw(const char_u *p, win_T *wp)
|
||||||
{
|
{
|
||||||
int c;
|
int c = utf_ptr2char(p);
|
||||||
|
|
||||||
if (has_mbyte) {
|
|
||||||
c = utf_ptr2char(p);
|
|
||||||
if (c > 255) {
|
if (c > 255) {
|
||||||
return spell_mb_isword_class(mb_get_class(p), wp);
|
return spell_mb_isword_class(mb_get_class(p), wp);
|
||||||
}
|
}
|
||||||
return spelltab.st_isw[c];
|
return spelltab.st_isw[c];
|
||||||
}
|
}
|
||||||
return spelltab.st_isw[*p];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if word class indicates a word character.
|
// Returns true if word class indicates a word character.
|
||||||
// Only for characters above 255.
|
// Only for characters above 255.
|
||||||
@@ -4316,7 +4311,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
&& sp->ts_twordlen > sp->ts_tcharlen) {
|
&& sp->ts_twordlen > sp->ts_tcharlen) {
|
||||||
p = tword + sp->ts_twordlen - sp->ts_tcharlen;
|
p = tword + sp->ts_twordlen - sp->ts_tcharlen;
|
||||||
c = utf_ptr2char(p);
|
c = utf_ptr2char(p);
|
||||||
if (enc_utf8 && utf_iscomposing(c)) {
|
if (utf_iscomposing(c)) {
|
||||||
// Inserting a composing char doesn't
|
// Inserting a composing char doesn't
|
||||||
// count that much.
|
// count that much.
|
||||||
sp->ts_score -= SCORE_INS - SCORE_INSCOMP;
|
sp->ts_score -= SCORE_INS - SCORE_INSCOMP;
|
||||||
@@ -4388,19 +4383,14 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
// score if the same character is following "nn" -> "n". It's
|
// score if the same character is following "nn" -> "n". It's
|
||||||
// a bit illogical for soundfold tree but it does give better
|
// a bit illogical for soundfold tree but it does give better
|
||||||
// results.
|
// results.
|
||||||
if (has_mbyte) {
|
|
||||||
c = utf_ptr2char(fword + sp->ts_fidx);
|
c = utf_ptr2char(fword + sp->ts_fidx);
|
||||||
stack[depth].ts_fidx += MB_PTR2LEN(fword + sp->ts_fidx);
|
stack[depth].ts_fidx += MB_PTR2LEN(fword + sp->ts_fidx);
|
||||||
if (enc_utf8 && utf_iscomposing(c)) {
|
if (utf_iscomposing(c)) {
|
||||||
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
|
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
|
||||||
} else if (c == utf_ptr2char(fword + stack[depth].ts_fidx)) {
|
} else if (c == utf_ptr2char(fword + stack[depth].ts_fidx)) {
|
||||||
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
|
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
++stack[depth].ts_fidx;
|
|
||||||
if (fword[sp->ts_fidx] == fword[sp->ts_fidx + 1])
|
|
||||||
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// FALLTHROUGH
|
// FALLTHROUGH
|
||||||
@@ -4515,7 +4505,6 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_mbyte) {
|
|
||||||
n = MB_CPTR2LEN(p);
|
n = MB_CPTR2LEN(p);
|
||||||
c = utf_ptr2char(p);
|
c = utf_ptr2char(p);
|
||||||
if (p[n] == NUL) {
|
if (p[n] == NUL) {
|
||||||
@@ -4525,15 +4514,6 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
} else {
|
} else {
|
||||||
c2 = utf_ptr2char(p + n);
|
c2 = utf_ptr2char(p + n);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (p[1] == NUL) {
|
|
||||||
c2 = NUL;
|
|
||||||
} else if (!soundfold && !spell_iswordp(p + 1, curwin)) {
|
|
||||||
c2 = c; // don't swap non-word char
|
|
||||||
} else {
|
|
||||||
c2 = p[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// When the second character is NUL we can't swap.
|
// When the second character is NUL we can't swap.
|
||||||
if (c2 == NUL) {
|
if (c2 == NUL) {
|
||||||
@@ -4578,23 +4558,17 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
case STATE_UNSWAP:
|
case STATE_UNSWAP:
|
||||||
// Undo the STATE_SWAP swap: "21" -> "12".
|
// Undo the STATE_SWAP swap: "21" -> "12".
|
||||||
p = fword + sp->ts_fidx;
|
p = fword + sp->ts_fidx;
|
||||||
if (has_mbyte) {
|
|
||||||
n = MB_PTR2LEN(p);
|
n = MB_PTR2LEN(p);
|
||||||
c = utf_ptr2char(p + n);
|
c = utf_ptr2char(p + n);
|
||||||
memmove(p + MB_PTR2LEN(p + n), p, n);
|
memmove(p + MB_PTR2LEN(p + n), p, n);
|
||||||
mb_char2bytes(c, p);
|
mb_char2bytes(c, p);
|
||||||
} else {
|
|
||||||
c = *p;
|
|
||||||
*p = p[1];
|
|
||||||
p[1] = c;
|
|
||||||
}
|
|
||||||
// FALLTHROUGH
|
// FALLTHROUGH
|
||||||
|
|
||||||
case STATE_SWAP3:
|
case STATE_SWAP3:
|
||||||
// Swap two bytes, skipping one: "123" -> "321". We change
|
// Swap two bytes, skipping one: "123" -> "321". We change
|
||||||
// "fword" here, it's changed back afterwards at STATE_UNSWAP3.
|
// "fword" here, it's changed back afterwards at STATE_UNSWAP3.
|
||||||
p = fword + sp->ts_fidx;
|
p = fword + sp->ts_fidx;
|
||||||
if (has_mbyte) {
|
|
||||||
n = MB_CPTR2LEN(p);
|
n = MB_CPTR2LEN(p);
|
||||||
c = utf_ptr2char(p);
|
c = utf_ptr2char(p);
|
||||||
fl = MB_CPTR2LEN(p + n);
|
fl = MB_CPTR2LEN(p + n);
|
||||||
@@ -4604,14 +4578,6 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
} else {
|
} else {
|
||||||
c3 = utf_ptr2char(p + n + fl);
|
c3 = utf_ptr2char(p + n + fl);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
c = *p;
|
|
||||||
c2 = p[1];
|
|
||||||
if (!soundfold && !spell_iswordp(p + 2, curwin))
|
|
||||||
c3 = c; // don't swap non-word char
|
|
||||||
else
|
|
||||||
c3 = p[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
// When characters are identical: "121" then SWAP3 result is
|
// When characters are identical: "121" then SWAP3 result is
|
||||||
// identical, ROT3L result is same as SWAP: "211", ROT3L result is
|
// identical, ROT3L result is same as SWAP: "211", ROT3L result is
|
||||||
@@ -4654,7 +4620,6 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
case STATE_UNSWAP3:
|
case STATE_UNSWAP3:
|
||||||
// Undo STATE_SWAP3: "321" -> "123"
|
// Undo STATE_SWAP3: "321" -> "123"
|
||||||
p = fword + sp->ts_fidx;
|
p = fword + sp->ts_fidx;
|
||||||
if (has_mbyte) {
|
|
||||||
n = MB_PTR2LEN(p);
|
n = MB_PTR2LEN(p);
|
||||||
c2 = utf_ptr2char(p + n);
|
c2 = utf_ptr2char(p + n);
|
||||||
fl = MB_PTR2LEN(p + n);
|
fl = MB_PTR2LEN(p + n);
|
||||||
@@ -4664,12 +4629,6 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
mb_char2bytes(c, p);
|
mb_char2bytes(c, p);
|
||||||
mb_char2bytes(c2, p + tl);
|
mb_char2bytes(c2, p + tl);
|
||||||
p = p + tl;
|
p = p + tl;
|
||||||
} else {
|
|
||||||
c = *p;
|
|
||||||
*p = p[2];
|
|
||||||
p[2] = c;
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!soundfold && !spell_iswordp(p, curwin)) {
|
if (!soundfold && !spell_iswordp(p, curwin)) {
|
||||||
// Middle char is not a word char, skip the rotate. First and
|
// Middle char is not a word char, skip the rotate. First and
|
||||||
@@ -4717,19 +4676,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
case STATE_UNROT3L:
|
case STATE_UNROT3L:
|
||||||
// Undo ROT3L: "231" -> "123"
|
// Undo ROT3L: "231" -> "123"
|
||||||
p = fword + sp->ts_fidx;
|
p = fword + sp->ts_fidx;
|
||||||
if (has_mbyte) {
|
|
||||||
n = MB_PTR2LEN(p);
|
n = MB_PTR2LEN(p);
|
||||||
n += MB_PTR2LEN(p + n);
|
n += MB_PTR2LEN(p + n);
|
||||||
c = utf_ptr2char(p + n);
|
c = utf_ptr2char(p + n);
|
||||||
tl = MB_PTR2LEN(p + n);
|
tl = MB_PTR2LEN(p + n);
|
||||||
memmove(p + tl, p, n);
|
memmove(p + tl, p, n);
|
||||||
mb_char2bytes(c, p);
|
mb_char2bytes(c, p);
|
||||||
} else {
|
|
||||||
c = p[2];
|
|
||||||
p[2] = p[1];
|
|
||||||
p[1] = *p;
|
|
||||||
*p = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rotate three bytes right: "123" -> "312". We change "fword"
|
// Rotate three bytes right: "123" -> "312". We change "fword"
|
||||||
// here, it's changed back afterwards at STATE_UNROT3R.
|
// here, it's changed back afterwards at STATE_UNROT3R.
|
||||||
@@ -4745,7 +4697,6 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
sp->ts_state = STATE_UNROT3R;
|
sp->ts_state = STATE_UNROT3R;
|
||||||
++depth;
|
++depth;
|
||||||
p = fword + sp->ts_fidx;
|
p = fword + sp->ts_fidx;
|
||||||
if (has_mbyte) {
|
|
||||||
n = MB_CPTR2LEN(p);
|
n = MB_CPTR2LEN(p);
|
||||||
n += MB_CPTR2LEN(p + n);
|
n += MB_CPTR2LEN(p + n);
|
||||||
c = utf_ptr2char(p + n);
|
c = utf_ptr2char(p + n);
|
||||||
@@ -4753,13 +4704,6 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
memmove(p + tl, p, n);
|
memmove(p + tl, p, n);
|
||||||
mb_char2bytes(c, p);
|
mb_char2bytes(c, p);
|
||||||
stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;
|
stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;
|
||||||
} else {
|
|
||||||
c = p[2];
|
|
||||||
p[2] = p[1];
|
|
||||||
p[1] = *p;
|
|
||||||
*p = 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;
|
||||||
@@ -4769,19 +4713,13 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
case STATE_UNROT3R:
|
case STATE_UNROT3R:
|
||||||
// Undo ROT3R: "312" -> "123"
|
// Undo ROT3R: "312" -> "123"
|
||||||
p = fword + sp->ts_fidx;
|
p = fword + sp->ts_fidx;
|
||||||
if (has_mbyte) {
|
|
||||||
c = utf_ptr2char(p);
|
c = utf_ptr2char(p);
|
||||||
tl = MB_PTR2LEN(p);
|
tl = MB_PTR2LEN(p);
|
||||||
n = MB_PTR2LEN(p + tl);
|
n = MB_PTR2LEN(p + tl);
|
||||||
n += MB_PTR2LEN(p + tl + n);
|
n += MB_PTR2LEN(p + tl + n);
|
||||||
memmove(p, p + tl, n);
|
memmove(p, p + tl, n);
|
||||||
mb_char2bytes(c, p + n);
|
mb_char2bytes(c, p + n);
|
||||||
} else {
|
|
||||||
c = *p;
|
|
||||||
*p = p[1];
|
|
||||||
p[1] = p[2];
|
|
||||||
p[2] = c;
|
|
||||||
}
|
|
||||||
// FALLTHROUGH
|
// FALLTHROUGH
|
||||||
|
|
||||||
case STATE_REP_INI:
|
case STATE_REP_INI:
|
||||||
@@ -5666,13 +5604,9 @@ add_suggestion (
|
|||||||
break;
|
break;
|
||||||
MB_PTR_BACK(goodword, pgood);
|
MB_PTR_BACK(goodword, pgood);
|
||||||
MB_PTR_BACK(su->su_badptr, pbad);
|
MB_PTR_BACK(su->su_badptr, pbad);
|
||||||
if (has_mbyte) {
|
|
||||||
if (utf_ptr2char(pgood) != utf_ptr2char(pbad)) {
|
if (utf_ptr2char(pgood) != utf_ptr2char(pbad)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (*pgood != *pbad) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (badlen == 0 && goodlen == 0)
|
if (badlen == 0 && goodlen == 0)
|
||||||
|
@@ -4101,13 +4101,9 @@ get_syn_options(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else if (flagtab[fidx].argtype == 11 && arg[5] == '=') {
|
} else if (flagtab[fidx].argtype == 11 && arg[5] == '=') {
|
||||||
/* cchar=? */
|
// cchar=?
|
||||||
if (has_mbyte) {
|
|
||||||
*conceal_char = utf_ptr2char(arg + 6);
|
*conceal_char = utf_ptr2char(arg + 6);
|
||||||
arg += mb_ptr2len(arg + 6) - 1;
|
arg += mb_ptr2len(arg + 6) - 1;
|
||||||
} else {
|
|
||||||
*conceal_char = arg[6];
|
|
||||||
}
|
|
||||||
if (!vim_isprintc_strict(*conceal_char)) {
|
if (!vim_isprintc_strict(*conceal_char)) {
|
||||||
EMSG(_("E844: invalid cchar value"));
|
EMSG(_("E844: invalid cchar value"));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Reference in New Issue
Block a user