]> granicus.if.org Git - vim/commitdiff
patch 8.2.2974: Greek spell checking uses wrong case folding v8.2.2974
authorBram Moolenaar <Bram@vim.org>
Fri, 11 Jun 2021 17:07:40 +0000 (19:07 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 11 Jun 2021 17:07:40 +0000 (19:07 +0200)
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)

src/proto/spell.pro
src/spell.c
src/spellfile.c
src/spellsuggest.c
src/version.c

index 6b1f84bc385e8d9b55fc51013be877a2bf61e6c9..3f97008a3e6f59f274d11b8461593b2c3206151a 100644 (file)
@@ -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);
index d43056660e67d00f1349af90efc9c1acff99b335..0b693c7d7b96e28fda78f38040976e219f81e914 100644 (file)
@@ -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;
        }
 
index 20181695a2e38910898a171d30fab55f4eb40441..264264c621796118946902c7562a2b9ee4299f3f 100644 (file)
@@ -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))
index 3de9ff2112a820cc28e5ba8a2d1b8415876b2aa4..2951eea2eaa2641585d66ca46c7b63fca1f42031 100644 (file)
@@ -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
index 25f2d156dc87c91d526995f123b527eaac89dde2..99a635b46948f58af5647f72cc028da51d5569f4 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2974,
 /**/
     2973,
 /**/