mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +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:
188
src/nvim/spell.c
188
src/nvim/spell.c
@@ -2619,16 +2619,11 @@ static bool spell_iswordp(char_u *p, win_T *wp)
|
||||
// Unlike spell_iswordp() this doesn't check for "midword" characters.
|
||||
bool spell_iswordp_nmw(const char_u *p, win_T *wp)
|
||||
{
|
||||
int c;
|
||||
|
||||
if (has_mbyte) {
|
||||
c = utf_ptr2char(p);
|
||||
if (c > 255) {
|
||||
return spell_mb_isword_class(mb_get_class(p), wp);
|
||||
}
|
||||
return spelltab.st_isw[c];
|
||||
int c = utf_ptr2char(p);
|
||||
if (c > 255) {
|
||||
return spell_mb_isword_class(mb_get_class(p), wp);
|
||||
}
|
||||
return spelltab.st_isw[*p];
|
||||
return spelltab.st_isw[c];
|
||||
}
|
||||
|
||||
// Returns true if word class indicates a word character.
|
||||
@@ -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) {
|
||||
p = tword + sp->ts_twordlen - sp->ts_tcharlen;
|
||||
c = utf_ptr2char(p);
|
||||
if (enc_utf8 && utf_iscomposing(c)) {
|
||||
if (utf_iscomposing(c)) {
|
||||
// Inserting a composing char doesn't
|
||||
// count that much.
|
||||
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
|
||||
// a bit illogical for soundfold tree but it does give better
|
||||
// results.
|
||||
if (has_mbyte) {
|
||||
c = utf_ptr2char(fword + sp->ts_fidx);
|
||||
stack[depth].ts_fidx += MB_PTR2LEN(fword + sp->ts_fidx);
|
||||
if (enc_utf8 && utf_iscomposing(c)) {
|
||||
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
|
||||
} else if (c == utf_ptr2char(fword + stack[depth].ts_fidx)) {
|
||||
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;
|
||||
c = utf_ptr2char(fword + sp->ts_fidx);
|
||||
stack[depth].ts_fidx += MB_PTR2LEN(fword + sp->ts_fidx);
|
||||
if (utf_iscomposing(c)) {
|
||||
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
|
||||
} else if (c == utf_ptr2char(fword + stack[depth].ts_fidx)) {
|
||||
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// FALLTHROUGH
|
||||
@@ -4515,24 +4505,14 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
break;
|
||||
}
|
||||
|
||||
if (has_mbyte) {
|
||||
n = MB_CPTR2LEN(p);
|
||||
c = utf_ptr2char(p);
|
||||
if (p[n] == NUL) {
|
||||
c2 = NUL;
|
||||
} else if (!soundfold && !spell_iswordp(p + n, curwin)) {
|
||||
c2 = c; // don't swap non-word char
|
||||
} else {
|
||||
c2 = utf_ptr2char(p + n);
|
||||
}
|
||||
n = MB_CPTR2LEN(p);
|
||||
c = utf_ptr2char(p);
|
||||
if (p[n] == NUL) {
|
||||
c2 = NUL;
|
||||
} else if (!soundfold && !spell_iswordp(p + n, curwin)) {
|
||||
c2 = c; // don't swap non-word char
|
||||
} 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];
|
||||
}
|
||||
c2 = utf_ptr2char(p + n);
|
||||
}
|
||||
|
||||
// When the second character is NUL we can't swap.
|
||||
@@ -4578,39 +4558,25 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
case STATE_UNSWAP:
|
||||
// Undo the STATE_SWAP swap: "21" -> "12".
|
||||
p = fword + sp->ts_fidx;
|
||||
if (has_mbyte) {
|
||||
n = MB_PTR2LEN(p);
|
||||
c = utf_ptr2char(p + n);
|
||||
memmove(p + MB_PTR2LEN(p + n), p, n);
|
||||
mb_char2bytes(c, p);
|
||||
} else {
|
||||
c = *p;
|
||||
*p = p[1];
|
||||
p[1] = c;
|
||||
}
|
||||
n = MB_PTR2LEN(p);
|
||||
c = utf_ptr2char(p + n);
|
||||
memmove(p + MB_PTR2LEN(p + n), p, n);
|
||||
mb_char2bytes(c, p);
|
||||
|
||||
// FALLTHROUGH
|
||||
|
||||
case STATE_SWAP3:
|
||||
// Swap two bytes, skipping one: "123" -> "321". We change
|
||||
// "fword" here, it's changed back afterwards at STATE_UNSWAP3.
|
||||
p = fword + sp->ts_fidx;
|
||||
if (has_mbyte) {
|
||||
n = MB_CPTR2LEN(p);
|
||||
c = utf_ptr2char(p);
|
||||
fl = MB_CPTR2LEN(p + n);
|
||||
c2 = utf_ptr2char(p + n);
|
||||
if (!soundfold && !spell_iswordp(p + n + fl, curwin)) {
|
||||
c3 = c; // don't swap non-word char
|
||||
} else {
|
||||
c3 = utf_ptr2char(p + n + fl);
|
||||
}
|
||||
n = MB_CPTR2LEN(p);
|
||||
c = utf_ptr2char(p);
|
||||
fl = MB_CPTR2LEN(p + n);
|
||||
c2 = utf_ptr2char(p + n);
|
||||
if (!soundfold && !spell_iswordp(p + n + fl, curwin)) {
|
||||
c3 = c; // don't swap non-word char
|
||||
} 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];
|
||||
c3 = utf_ptr2char(p + n + fl);
|
||||
}
|
||||
|
||||
// When characters are identical: "121" then SWAP3 result is
|
||||
@@ -4654,22 +4620,15 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
case STATE_UNSWAP3:
|
||||
// Undo STATE_SWAP3: "321" -> "123"
|
||||
p = fword + sp->ts_fidx;
|
||||
if (has_mbyte) {
|
||||
n = MB_PTR2LEN(p);
|
||||
c2 = utf_ptr2char(p + n);
|
||||
fl = MB_PTR2LEN(p + n);
|
||||
c = utf_ptr2char(p + n + fl);
|
||||
tl = MB_PTR2LEN(p + n + fl);
|
||||
memmove(p + fl + tl, p, n);
|
||||
mb_char2bytes(c, p);
|
||||
mb_char2bytes(c2, p + tl);
|
||||
p = p + tl;
|
||||
} else {
|
||||
c = *p;
|
||||
*p = p[2];
|
||||
p[2] = c;
|
||||
++p;
|
||||
}
|
||||
n = MB_PTR2LEN(p);
|
||||
c2 = utf_ptr2char(p + n);
|
||||
fl = MB_PTR2LEN(p + n);
|
||||
c = utf_ptr2char(p + n + fl);
|
||||
tl = MB_PTR2LEN(p + n + fl);
|
||||
memmove(p + fl + tl, p, n);
|
||||
mb_char2bytes(c, p);
|
||||
mb_char2bytes(c2, p + tl);
|
||||
p = p + tl;
|
||||
|
||||
if (!soundfold && !spell_iswordp(p, curwin)) {
|
||||
// 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:
|
||||
// Undo ROT3L: "231" -> "123"
|
||||
p = fword + sp->ts_fidx;
|
||||
if (has_mbyte) {
|
||||
n = MB_PTR2LEN(p);
|
||||
n += MB_PTR2LEN(p + n);
|
||||
c = utf_ptr2char(p + n);
|
||||
tl = MB_PTR2LEN(p + n);
|
||||
memmove(p + tl, p, n);
|
||||
mb_char2bytes(c, p);
|
||||
} else {
|
||||
c = p[2];
|
||||
p[2] = p[1];
|
||||
p[1] = *p;
|
||||
*p = c;
|
||||
}
|
||||
n = MB_PTR2LEN(p);
|
||||
n += MB_PTR2LEN(p + n);
|
||||
c = utf_ptr2char(p + n);
|
||||
tl = MB_PTR2LEN(p + n);
|
||||
memmove(p + tl, p, n);
|
||||
mb_char2bytes(c, p);
|
||||
|
||||
// Rotate three bytes right: "123" -> "312". We change "fword"
|
||||
// here, it's changed back afterwards at STATE_UNROT3R.
|
||||
@@ -4745,21 +4697,13 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
sp->ts_state = STATE_UNROT3R;
|
||||
++depth;
|
||||
p = fword + sp->ts_fidx;
|
||||
if (has_mbyte) {
|
||||
n = MB_CPTR2LEN(p);
|
||||
n += MB_CPTR2LEN(p + n);
|
||||
c = utf_ptr2char(p + n);
|
||||
tl = MB_CPTR2LEN(p + n);
|
||||
memmove(p + tl, p, n);
|
||||
mb_char2bytes(c, p);
|
||||
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;
|
||||
}
|
||||
n = MB_CPTR2LEN(p);
|
||||
n += MB_CPTR2LEN(p + n);
|
||||
c = utf_ptr2char(p + n);
|
||||
tl = MB_CPTR2LEN(p + n);
|
||||
memmove(p + tl, p, n);
|
||||
mb_char2bytes(c, p);
|
||||
stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;
|
||||
} else {
|
||||
PROF_STORE(sp->ts_state)
|
||||
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:
|
||||
// Undo ROT3R: "312" -> "123"
|
||||
p = fword + sp->ts_fidx;
|
||||
if (has_mbyte) {
|
||||
c = utf_ptr2char(p);
|
||||
tl = MB_PTR2LEN(p);
|
||||
n = MB_PTR2LEN(p + tl);
|
||||
n += MB_PTR2LEN(p + tl + n);
|
||||
memmove(p, p + tl, n);
|
||||
mb_char2bytes(c, p + n);
|
||||
} else {
|
||||
c = *p;
|
||||
*p = p[1];
|
||||
p[1] = p[2];
|
||||
p[2] = c;
|
||||
}
|
||||
c = utf_ptr2char(p);
|
||||
tl = MB_PTR2LEN(p);
|
||||
n = MB_PTR2LEN(p + tl);
|
||||
n += MB_PTR2LEN(p + tl + n);
|
||||
memmove(p, p + tl, n);
|
||||
mb_char2bytes(c, p + n);
|
||||
|
||||
// FALLTHROUGH
|
||||
|
||||
case STATE_REP_INI:
|
||||
@@ -5666,11 +5604,7 @@ add_suggestion (
|
||||
break;
|
||||
MB_PTR_BACK(goodword, pgood);
|
||||
MB_PTR_BACK(su->su_badptr, pbad);
|
||||
if (has_mbyte) {
|
||||
if (utf_ptr2char(pgood) != utf_ptr2char(pbad)) {
|
||||
break;
|
||||
}
|
||||
} else if (*pgood != *pbad) {
|
||||
if (utf_ptr2char(pgood) != utf_ptr2char(pbad)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user