mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
vim-patch:8.2.2974: Greek spell checking uses wrong case folding
Problem: Greek spell checking uses wrong case folding.
Solution: Fold capital sigma depending on whether it is at the end of a
word or not. (closes vim/vim#299)
4f13527598
This commit is contained in:
parent
8ebbeee1d0
commit
2644fe5b7c
@ -441,7 +441,8 @@ size_t spell_check(
|
||||
MB_PTR_ADV(mi.mi_fend);
|
||||
}
|
||||
|
||||
(void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword, MAXWLEN + 1);
|
||||
(void)spell_casefold(wp, ptr, (int)(mi.mi_fend - ptr), mi.mi_fword,
|
||||
MAXWLEN + 1);
|
||||
mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
|
||||
|
||||
if (camel_case) {
|
||||
@ -869,10 +870,11 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
|
||||
if (slang->sl_compsylmax < MAXWLEN) {
|
||||
// "fword" is only needed for checking syllables.
|
||||
if (ptr == mip->mi_word)
|
||||
(void)spell_casefold(ptr, wlen, fword, MAXWLEN);
|
||||
else
|
||||
if (ptr == mip->mi_word) {
|
||||
(void)spell_casefold(mip->mi_win, ptr, wlen, fword, MAXWLEN);
|
||||
} else {
|
||||
STRLCPY(fword, ptr, endlen[endidxcnt] + 1);
|
||||
}
|
||||
}
|
||||
if (!can_compound(slang, fword, mip->mi_compflags))
|
||||
continue;
|
||||
@ -1315,9 +1317,9 @@ static int fold_more(matchinf_T *mip)
|
||||
MB_PTR_ADV(mip->mi_fend);
|
||||
}
|
||||
|
||||
(void)spell_casefold(p, (int)(mip->mi_fend - p),
|
||||
mip->mi_fword + mip->mi_fwordlen,
|
||||
MAXWLEN - mip->mi_fwordlen);
|
||||
(void)spell_casefold(mip->mi_win, p, (int)(mip->mi_fend - p),
|
||||
mip->mi_fword + mip->mi_fwordlen,
|
||||
MAXWLEN - mip->mi_fwordlen);
|
||||
flen = (int)STRLEN(mip->mi_fword + mip->mi_fwordlen);
|
||||
mip->mi_fwordlen += flen;
|
||||
return flen;
|
||||
@ -2655,7 +2657,9 @@ static bool spell_iswordp_w(const int *p, const win_T *wp)
|
||||
// Uses the character definitions from the .spl file.
|
||||
// When using a multi-byte 'encoding' the length may change!
|
||||
// Returns FAIL when something wrong.
|
||||
int spell_casefold(char_u *str, int len, char_u *buf, int buflen)
|
||||
int spell_casefold(const win_T *wp, char_u *str, int len, char_u *buf,
|
||||
int buflen)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
if (len >= buflen) {
|
||||
buf[0] = NUL;
|
||||
@ -2670,8 +2674,22 @@ int spell_casefold(char_u *str, int len, char_u *buf, int buflen)
|
||||
buf[outi] = NUL;
|
||||
return FAIL;
|
||||
}
|
||||
const int c = mb_cptr2char_adv((const char_u **)&p);
|
||||
outi += utf_char2bytes(SPELL_TOFOLD(c), buf + outi);
|
||||
int c = mb_cptr2char_adv((const char_u **)&p);
|
||||
|
||||
// Exception: greek capital sigma 0x03A3 folds to 0x03C3, except
|
||||
// when it is the last character in a word, then it folds to
|
||||
// 0x03C2.
|
||||
if (c == 0x03a3 || c == 0x03c2) {
|
||||
if (p == str + len || !spell_iswordp(p, wp)) {
|
||||
c = 0x03c2;
|
||||
} else {
|
||||
c = 0x03c3;
|
||||
}
|
||||
} else {
|
||||
c = SPELL_TOFOLD(c);
|
||||
}
|
||||
|
||||
outi += utf_char2bytes(c, buf + outi);
|
||||
}
|
||||
buf[outi] = NUL;
|
||||
|
||||
@ -3155,7 +3173,8 @@ spell_find_suggest (
|
||||
if (su->su_badlen >= MAXWLEN)
|
||||
su->su_badlen = MAXWLEN - 1; // just in case
|
||||
STRLCPY(su->su_badword, su->su_badptr, su->su_badlen + 1);
|
||||
(void)spell_casefold(su->su_badptr, su->su_badlen, su->su_fbadword, MAXWLEN);
|
||||
(void)spell_casefold(curwin, su->su_badptr, su->su_badlen, su->su_fbadword,
|
||||
MAXWLEN);
|
||||
|
||||
// TODO(vim): make this work if the case-folded text is longer than the
|
||||
// original text. Currently an illegal byte causes wrong pointer
|
||||
@ -3535,7 +3554,7 @@ static void suggest_try_change(suginfo_T *su)
|
||||
STRCPY(fword, su->su_fbadword);
|
||||
n = (int)STRLEN(fword);
|
||||
p = su->su_badptr + su->su_badlen;
|
||||
(void)spell_casefold(p, (int)STRLEN(p), fword + n, MAXWLEN - n);
|
||||
(void)spell_casefold(curwin, p, (int)STRLEN(p), fword + n, MAXWLEN - n);
|
||||
|
||||
for (int lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi) {
|
||||
lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);
|
||||
@ -5087,7 +5106,7 @@ stp_sal_score (
|
||||
pbad = badsound;
|
||||
else {
|
||||
// soundfold the bad word with more characters following
|
||||
(void)spell_casefold(su->su_badptr, stp->st_orglen, fword, MAXWLEN);
|
||||
(void)spell_casefold(curwin, su->su_badptr, stp->st_orglen, fword, MAXWLEN);
|
||||
|
||||
// When joining two words the sound often changes a lot. E.g., "t he"
|
||||
// sounds like "t h" while "the" sounds like "@". Avoid that by
|
||||
@ -5800,10 +5819,10 @@ void spell_soundfold(slang_T *slang, char_u *inword, bool folded, char_u *res)
|
||||
spell_soundfold_sofo(slang, inword, res);
|
||||
else {
|
||||
// SAL items used. Requires the word to be case-folded.
|
||||
if (folded)
|
||||
if (folded) {
|
||||
word = inword;
|
||||
else {
|
||||
(void)spell_casefold(inword, (int)STRLEN(inword), fword, MAXWLEN);
|
||||
} else {
|
||||
(void)spell_casefold(curwin, inword, (int)STRLEN(inword), fword, MAXWLEN);
|
||||
word = fword;
|
||||
}
|
||||
|
||||
|
@ -2942,9 +2942,9 @@ static void add_fromto(spellinfo_T *spin, garray_T *gap, char_u *from, char_u *t
|
||||
char_u word[MAXWLEN];
|
||||
|
||||
fromto_T *ftp = GA_APPEND_VIA_PTR(fromto_T, gap);
|
||||
(void)spell_casefold(from, (int)STRLEN(from), word, MAXWLEN);
|
||||
(void)spell_casefold(curwin, from, (int)STRLEN(from), word, MAXWLEN);
|
||||
ftp->ft_from = getroom_save(spin, word);
|
||||
(void)spell_casefold(to, (int)STRLEN(to), word, MAXWLEN);
|
||||
(void)spell_casefold(curwin, to, (int)STRLEN(to), word, MAXWLEN);
|
||||
ftp->ft_to = getroom_save(spin, word);
|
||||
}
|
||||
|
||||
@ -3764,7 +3764,7 @@ store_word (
|
||||
char_u *word,
|
||||
int flags, // extra flags, WF_BANNED
|
||||
int region, // supported region(s)
|
||||
char_u *pfxlist, // list of prefix IDs or NULL
|
||||
const char_u *pfxlist, // list of prefix IDs or NULL
|
||||
bool need_affix // only store word with affix ID
|
||||
)
|
||||
{
|
||||
@ -3772,25 +3772,28 @@ store_word (
|
||||
int ct = captype(word, word + len);
|
||||
char_u foldword[MAXWLEN];
|
||||
int res = OK;
|
||||
char_u *p;
|
||||
|
||||
(void)spell_casefold(word, len, foldword, MAXWLEN);
|
||||
for (p = pfxlist; res == OK; ++p) {
|
||||
if (!need_affix || (p != NULL && *p != NUL))
|
||||
(void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
|
||||
for (const char_u *p = pfxlist; res == OK; p++) {
|
||||
if (!need_affix || (p != NULL && *p != NUL)) {
|
||||
res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,
|
||||
region, p == NULL ? 0 : *p);
|
||||
if (p == NULL || *p == NUL)
|
||||
region, p == NULL ? 0 : *p);
|
||||
}
|
||||
if (p == NULL || *p == NUL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
++spin->si_foldwcount;
|
||||
|
||||
if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP))) {
|
||||
for (p = pfxlist; res == OK; ++p) {
|
||||
if (!need_affix || (p != NULL && *p != NUL))
|
||||
for (const char_u *p = pfxlist; res == OK; p++) {
|
||||
if (!need_affix || (p != NULL && *p != NUL)) {
|
||||
res = tree_add_word(spin, word, spin->si_keeproot, flags,
|
||||
region, p == NULL ? 0 : *p);
|
||||
if (p == NULL || *p == NUL)
|
||||
region, p == NULL ? 0 : *p);
|
||||
}
|
||||
if (p == NULL || *p == NUL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
++spin->si_keepwcount;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user