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 #299)
This commit is contained in:
@ -27,7 +27,7 @@ void clear_spell_chartab(spelltab_T *sp);
|
|||||||
void init_spell_chartab(void);
|
void init_spell_chartab(void);
|
||||||
int spell_iswordp(char_u *p, win_T *wp);
|
int spell_iswordp(char_u *p, win_T *wp);
|
||||||
int spell_iswordp_nmw(char_u *p, win_T *wp);
|
int spell_iswordp_nmw(char_u *p, win_T *wp);
|
||||||
int spell_casefold(char_u *str, int len, char_u *buf, int buflen);
|
int spell_casefold(win_T *wp, char_u *str, int len, char_u *buf, int buflen);
|
||||||
int check_need_cap(linenr_T lnum, colnr_T col);
|
int check_need_cap(linenr_T lnum, colnr_T col);
|
||||||
void ex_spellrepall(exarg_T *eap);
|
void ex_spellrepall(exarg_T *eap);
|
||||||
void onecap_copy(char_u *word, char_u *wcopy, int upper);
|
void onecap_copy(char_u *word, char_u *wcopy, int upper);
|
||||||
|
|||||||
27
src/spell.c
27
src/spell.c
@ -249,7 +249,7 @@ spell_check(
|
|||||||
if (*mi.mi_fend != NUL)
|
if (*mi.mi_fend != NUL)
|
||||||
MB_PTR_ADV(mi.mi_fend);
|
MB_PTR_ADV(mi.mi_fend);
|
||||||
|
|
||||||
(void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword,
|
(void)spell_casefold(wp, ptr, (int)(mi.mi_fend - ptr), mi.mi_fword,
|
||||||
MAXWLEN + 1);
|
MAXWLEN + 1);
|
||||||
mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
|
mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
|
||||||
|
|
||||||
@ -736,7 +736,8 @@ find_word(matchinf_T *mip, int mode)
|
|||||||
{
|
{
|
||||||
// "fword" is only needed for checking syllables.
|
// "fword" is only needed for checking syllables.
|
||||||
if (ptr == mip->mi_word)
|
if (ptr == mip->mi_word)
|
||||||
(void)spell_casefold(ptr, wlen, fword, MAXWLEN);
|
(void)spell_casefold(mip->mi_win,
|
||||||
|
ptr, wlen, fword, MAXWLEN);
|
||||||
else
|
else
|
||||||
vim_strncpy(fword, ptr, endlen[endidxcnt]);
|
vim_strncpy(fword, ptr, endlen[endidxcnt]);
|
||||||
}
|
}
|
||||||
@ -1213,7 +1214,7 @@ fold_more(matchinf_T *mip)
|
|||||||
if (*mip->mi_fend != NUL)
|
if (*mip->mi_fend != NUL)
|
||||||
MB_PTR_ADV(mip->mi_fend);
|
MB_PTR_ADV(mip->mi_fend);
|
||||||
|
|
||||||
(void)spell_casefold(p, (int)(mip->mi_fend - p),
|
(void)spell_casefold(mip->mi_win, p, (int)(mip->mi_fend - p),
|
||||||
mip->mi_fword + mip->mi_fwordlen,
|
mip->mi_fword + mip->mi_fwordlen,
|
||||||
MAXWLEN - mip->mi_fwordlen);
|
MAXWLEN - mip->mi_fwordlen);
|
||||||
flen = (int)STRLEN(mip->mi_fword + mip->mi_fwordlen);
|
flen = (int)STRLEN(mip->mi_fword + mip->mi_fwordlen);
|
||||||
@ -2737,6 +2738,7 @@ spell_iswordp_w(int *p, win_T *wp)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
spell_casefold(
|
spell_casefold(
|
||||||
|
win_T *wp,
|
||||||
char_u *str,
|
char_u *str,
|
||||||
int len,
|
int len,
|
||||||
char_u *buf,
|
char_u *buf,
|
||||||
@ -2765,7 +2767,21 @@ spell_casefold(
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
c = mb_cptr2char_adv(&p);
|
c = mb_cptr2char_adv(&p);
|
||||||
outi += mb_char2bytes(SPELL_TOFOLD(c), buf + outi);
|
|
||||||
|
// 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 += mb_char2bytes(c, buf + outi);
|
||||||
}
|
}
|
||||||
buf[outi] = NUL;
|
buf[outi] = NUL;
|
||||||
}
|
}
|
||||||
@ -3097,7 +3113,8 @@ spell_soundfold(
|
|||||||
word = inword;
|
word = inword;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(void)spell_casefold(inword, (int)STRLEN(inword), fword, MAXWLEN);
|
(void)spell_casefold(curwin,
|
||||||
|
inword, (int)STRLEN(inword), fword, MAXWLEN);
|
||||||
word = fword;
|
word = fword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3429,9 +3429,9 @@ add_fromto(
|
|||||||
if (ga_grow(gap, 1) == OK)
|
if (ga_grow(gap, 1) == OK)
|
||||||
{
|
{
|
||||||
ftp = ((fromto_T *)gap->ga_data) + gap->ga_len;
|
ftp = ((fromto_T *)gap->ga_data) + gap->ga_len;
|
||||||
(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);
|
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);
|
ftp->ft_to = getroom_save(spin, word);
|
||||||
++gap->ga_len;
|
++gap->ga_len;
|
||||||
}
|
}
|
||||||
@ -4391,7 +4391,7 @@ store_word(
|
|||||||
int res = OK;
|
int res = OK;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
(void)spell_casefold(word, len, foldword, MAXWLEN);
|
(void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
|
||||||
for (p = pfxlist; res == OK; ++p)
|
for (p = pfxlist; res == OK; ++p)
|
||||||
{
|
{
|
||||||
if (!need_affix || (p != NULL && *p != NUL))
|
if (!need_affix || (p != NULL && *p != NUL))
|
||||||
|
|||||||
@ -791,7 +791,7 @@ spell_find_suggest(
|
|||||||
if (su->su_badlen >= MAXWLEN)
|
if (su->su_badlen >= MAXWLEN)
|
||||||
su->su_badlen = MAXWLEN - 1; // just in case
|
su->su_badlen = MAXWLEN - 1; // just in case
|
||||||
vim_strncpy(su->su_badword, su->su_badptr, su->su_badlen);
|
vim_strncpy(su->su_badword, su->su_badptr, su->su_badlen);
|
||||||
(void)spell_casefold(su->su_badptr, su->su_badlen,
|
(void)spell_casefold(curwin, su->su_badptr, su->su_badlen,
|
||||||
su->su_fbadword, MAXWLEN);
|
su->su_fbadword, MAXWLEN);
|
||||||
// TODO: make this work if the case-folded text is longer than the original
|
// TODO: make this work if the case-folded text is longer than the original
|
||||||
// text. Currently an illegal byte causes wrong pointer computations.
|
// text. Currently an illegal byte causes wrong pointer computations.
|
||||||
@ -1176,7 +1176,7 @@ suggest_try_change(suginfo_T *su)
|
|||||||
STRCPY(fword, su->su_fbadword);
|
STRCPY(fword, su->su_fbadword);
|
||||||
n = (int)STRLEN(fword);
|
n = (int)STRLEN(fword);
|
||||||
p = su->su_badptr + su->su_badlen;
|
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 (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)
|
for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)
|
||||||
{
|
{
|
||||||
@ -3005,7 +3005,8 @@ stp_sal_score(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// soundfold the bad word with more characters following
|
// 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"
|
// 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
|
// sounds like "t h" while "the" sounds like "@". Avoid that by
|
||||||
|
|||||||
@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2974,
|
||||||
/**/
|
/**/
|
||||||
2973,
|
2973,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user