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)
diff --git a/src/spell.c b/src/spell.c
index d430566..0b693c7 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -249,7 +249,7 @@
if (*mi.mi_fend != NUL)
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);
mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
@@ -736,7 +736,8 @@
{
// "fword" is only needed for checking syllables.
if (ptr == mip->mi_word)
- (void)spell_casefold(ptr, wlen, fword, MAXWLEN);
+ (void)spell_casefold(mip->mi_win,
+ ptr, wlen, fword, MAXWLEN);
else
vim_strncpy(fword, ptr, endlen[endidxcnt]);
}
@@ -1213,7 +1214,7 @@
if (*mip->mi_fend != NUL)
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,
MAXWLEN - mip->mi_fwordlen);
flen = (int)STRLEN(mip->mi_fword + mip->mi_fwordlen);
@@ -2737,6 +2738,7 @@
*/
int
spell_casefold(
+ win_T *wp,
char_u *str,
int len,
char_u *buf,
@@ -2765,7 +2767,21 @@
return FAIL;
}
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;
}
@@ -3097,7 +3113,8 @@
word = inword;
else
{
- (void)spell_casefold(inword, (int)STRLEN(inword), fword, MAXWLEN);
+ (void)spell_casefold(curwin,
+ inword, (int)STRLEN(inword), fword, MAXWLEN);
word = fword;
}