summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-06-11 19:07:40 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-11 19:07:40 +0200
commit4f135275984722c1b1e9ace72eeeb7ce7e4ec983 (patch)
treefb221b9db23bfa8ad33a167f8969126fa953894a
parent3044324e8dccd470bd854cf7d9457232cc9c220e (diff)
patch 8.2.2974: Greek spell checking uses wrong case foldingv8.2.2974
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)
-rw-r--r--src/proto/spell.pro2
-rw-r--r--src/spell.c27
-rw-r--r--src/spellfile.c6
-rw-r--r--src/spellsuggest.c7
-rw-r--r--src/version.c2
5 files changed, 32 insertions, 12 deletions
diff --git a/src/proto/spell.pro b/src/proto/spell.pro
index 6b1f84bc38..3f97008a3e 100644
--- a/src/proto/spell.pro
+++ b/src/proto/spell.pro
@@ -27,7 +27,7 @@ void clear_spell_chartab(spelltab_T *sp);
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);
diff --git a/src/spell.c b/src/spell.c
index d43056660e..0b693c7d7b 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -249,7 +249,7 @@ spell_check(
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 @@ find_word(matchinf_T *mip, int mode)
{
// "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 @@ fold_more(matchinf_T *mip)
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 @@ spell_iswordp_w(int *p, win_T *wp)
*/
int
spell_casefold(
+ win_T *wp,
char_u *str,
int len,
char_u *buf,
@@ -2765,7 +2767,21 @@ spell_casefold(
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 @@ spell_soundfold(
word = inword;
else
{
- (void)spell_casefold(inword, (int)STRLEN(inword), fword, MAXWLEN);
+ (void)spell_casefold(curwin,
+ inword, (int)STRLEN(inword), fword, MAXWLEN);
word = fword;
}
diff --git a/src/spellfile.c b/src/spellfile.c
index 20181695a2..264264c621 100644
--- a/src/spellfile.c
+++ b/src/spellfile.c
@@ -3429,9 +3429,9 @@ add_fromto(
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;
}
@@ -4391,7 +4391,7 @@ store_word(
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))
diff --git a/src/spellsuggest.c b/src/spellsuggest.c
index 3de9ff2112..2951eea2ea 100644
--- a/src/spellsuggest.c
+++ b/src/spellsuggest.c
@@ -791,7 +791,7 @@ spell_find_suggest(
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.
@@ -1176,7 +1176,7 @@ 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 (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)
{
@@ -3005,7 +3005,8 @@ stp_sal_score(
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
diff --git a/src/version.c b/src/version.c
index 25f2d156dc..99a635b469 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2974,
+/**/
2973,
/**/
2972,