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)
void init_spell_chartab(void);
int spell_iswordp(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);
void ex_spellrepall(exarg_T *eap);
void onecap_copy(char_u *word, char_u *wcopy, int upper);
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);
{
// "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]);
}
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);
*/
int
spell_casefold(
+ win_T *wp,
char_u *str,
int len,
char_u *buf,
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;
}
word = inword;
else
{
- (void)spell_casefold(inword, (int)STRLEN(inword), fword, MAXWLEN);
+ (void)spell_casefold(curwin,
+ inword, (int)STRLEN(inword), fword, MAXWLEN);
word = fword;
}
if (ga_grow(gap, 1) == OK)
{
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);
- (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);
++gap->ga_len;
}
int res = OK;
char_u *p;
- (void)spell_casefold(word, len, foldword, MAXWLEN);
+ (void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
for (p = pfxlist; res == OK; ++p)
{
if (!need_affix || (p != NULL && *p != NUL))
if (su->su_badlen >= MAXWLEN)
su->su_badlen = MAXWLEN - 1; // just in case
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);
// TODO: make this work if the case-folded text is longer than the original
// text. Currently an illegal byte causes wrong pointer computations.
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 (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)
{
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
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2974,
/**/
2973,
/**/