• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision59cfa23bd9eb2d4115d3a0e27944e1fdcf522c66 (tree)
Zeit2021-06-12 02:15:04
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.2974: Greek spell checking uses wrong case folding

Commit: https://github.com/vim/vim/commit/4f135275984722c1b1e9ace72eeeb7ce7e4ec983
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jun 11 19:07:40 2021 +0200

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)

Ändern Zusammenfassung

Diff

diff -r 7551b2508d35 -r 59cfa23bd9eb src/proto/spell.pro
--- a/src/proto/spell.pro Thu Jun 10 22:00:04 2021 +0200
+++ b/src/proto/spell.pro Fri Jun 11 19:15:04 2021 +0200
@@ -27,7 +27,7 @@
2727 void init_spell_chartab(void);
2828 int spell_iswordp(char_u *p, win_T *wp);
2929 int spell_iswordp_nmw(char_u *p, win_T *wp);
30-int spell_casefold(char_u *str, int len, char_u *buf, int buflen);
30+int spell_casefold(win_T *wp, char_u *str, int len, char_u *buf, int buflen);
3131 int check_need_cap(linenr_T lnum, colnr_T col);
3232 void ex_spellrepall(exarg_T *eap);
3333 void onecap_copy(char_u *word, char_u *wcopy, int upper);
diff -r 7551b2508d35 -r 59cfa23bd9eb src/spell.c
--- a/src/spell.c Thu Jun 10 22:00:04 2021 +0200
+++ b/src/spell.c Fri Jun 11 19:15:04 2021 +0200
@@ -249,7 +249,7 @@
249249 if (*mi.mi_fend != NUL)
250250 MB_PTR_ADV(mi.mi_fend);
251251
252- (void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword,
252+ (void)spell_casefold(wp, ptr, (int)(mi.mi_fend - ptr), mi.mi_fword,
253253 MAXWLEN + 1);
254254 mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
255255
@@ -736,7 +736,8 @@
736736 {
737737 // "fword" is only needed for checking syllables.
738738 if (ptr == mip->mi_word)
739- (void)spell_casefold(ptr, wlen, fword, MAXWLEN);
739+ (void)spell_casefold(mip->mi_win,
740+ ptr, wlen, fword, MAXWLEN);
740741 else
741742 vim_strncpy(fword, ptr, endlen[endidxcnt]);
742743 }
@@ -1213,7 +1214,7 @@
12131214 if (*mip->mi_fend != NUL)
12141215 MB_PTR_ADV(mip->mi_fend);
12151216
1216- (void)spell_casefold(p, (int)(mip->mi_fend - p),
1217+ (void)spell_casefold(mip->mi_win, p, (int)(mip->mi_fend - p),
12171218 mip->mi_fword + mip->mi_fwordlen,
12181219 MAXWLEN - mip->mi_fwordlen);
12191220 flen = (int)STRLEN(mip->mi_fword + mip->mi_fwordlen);
@@ -2737,6 +2738,7 @@
27372738 */
27382739 int
27392740 spell_casefold(
2741+ win_T *wp,
27402742 char_u *str,
27412743 int len,
27422744 char_u *buf,
@@ -2765,7 +2767,21 @@
27652767 return FAIL;
27662768 }
27672769 c = mb_cptr2char_adv(&p);
2768- outi += mb_char2bytes(SPELL_TOFOLD(c), buf + outi);
2770+
2771+ // Exception: greek capital sigma 0x03A3 folds to 0x03C3, except
2772+ // when it is the last character in a word, then it folds to
2773+ // 0x03C2.
2774+ if (c == 0x03a3 || c == 0x03c2)
2775+ {
2776+ if (p == str + len || !spell_iswordp(p, wp))
2777+ c = 0x03c2;
2778+ else
2779+ c = 0x03c3;
2780+ }
2781+ else
2782+ c = SPELL_TOFOLD(c);
2783+
2784+ outi += mb_char2bytes(c, buf + outi);
27692785 }
27702786 buf[outi] = NUL;
27712787 }
@@ -3097,7 +3113,8 @@
30973113 word = inword;
30983114 else
30993115 {
3100- (void)spell_casefold(inword, (int)STRLEN(inword), fword, MAXWLEN);
3116+ (void)spell_casefold(curwin,
3117+ inword, (int)STRLEN(inword), fword, MAXWLEN);
31013118 word = fword;
31023119 }
31033120
diff -r 7551b2508d35 -r 59cfa23bd9eb src/spellfile.c
--- a/src/spellfile.c Thu Jun 10 22:00:04 2021 +0200
+++ b/src/spellfile.c Fri Jun 11 19:15:04 2021 +0200
@@ -3429,9 +3429,9 @@
34293429 if (ga_grow(gap, 1) == OK)
34303430 {
34313431 ftp = ((fromto_T *)gap->ga_data) + gap->ga_len;
3432- (void)spell_casefold(from, (int)STRLEN(from), word, MAXWLEN);
3432+ (void)spell_casefold(curwin, from, (int)STRLEN(from), word, MAXWLEN);
34333433 ftp->ft_from = getroom_save(spin, word);
3434- (void)spell_casefold(to, (int)STRLEN(to), word, MAXWLEN);
3434+ (void)spell_casefold(curwin, to, (int)STRLEN(to), word, MAXWLEN);
34353435 ftp->ft_to = getroom_save(spin, word);
34363436 ++gap->ga_len;
34373437 }
@@ -4391,7 +4391,7 @@
43914391 int res = OK;
43924392 char_u *p;
43934393
4394- (void)spell_casefold(word, len, foldword, MAXWLEN);
4394+ (void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
43954395 for (p = pfxlist; res == OK; ++p)
43964396 {
43974397 if (!need_affix || (p != NULL && *p != NUL))
diff -r 7551b2508d35 -r 59cfa23bd9eb src/spellsuggest.c
--- a/src/spellsuggest.c Thu Jun 10 22:00:04 2021 +0200
+++ b/src/spellsuggest.c Fri Jun 11 19:15:04 2021 +0200
@@ -791,7 +791,7 @@
791791 if (su->su_badlen >= MAXWLEN)
792792 su->su_badlen = MAXWLEN - 1; // just in case
793793 vim_strncpy(su->su_badword, su->su_badptr, su->su_badlen);
794- (void)spell_casefold(su->su_badptr, su->su_badlen,
794+ (void)spell_casefold(curwin, su->su_badptr, su->su_badlen,
795795 su->su_fbadword, MAXWLEN);
796796 // TODO: make this work if the case-folded text is longer than the original
797797 // text. Currently an illegal byte causes wrong pointer computations.
@@ -1176,7 +1176,7 @@
11761176 STRCPY(fword, su->su_fbadword);
11771177 n = (int)STRLEN(fword);
11781178 p = su->su_badptr + su->su_badlen;
1179- (void)spell_casefold(p, (int)STRLEN(p), fword + n, MAXWLEN - n);
1179+ (void)spell_casefold(curwin, p, (int)STRLEN(p), fword + n, MAXWLEN - n);
11801180
11811181 for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)
11821182 {
@@ -3005,7 +3005,8 @@
30053005 else
30063006 {
30073007 // soundfold the bad word with more characters following
3008- (void)spell_casefold(su->su_badptr, stp->st_orglen, fword, MAXWLEN);
3008+ (void)spell_casefold(curwin,
3009+ su->su_badptr, stp->st_orglen, fword, MAXWLEN);
30093010
30103011 // When joining two words the sound often changes a lot. E.g., "t he"
30113012 // sounds like "t h" while "the" sounds like "@". Avoid that by
diff -r 7551b2508d35 -r 59cfa23bd9eb src/version.c
--- a/src/version.c Thu Jun 10 22:00:04 2021 +0200
+++ b/src/version.c Fri Jun 11 19:15:04 2021 +0200
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 2974,
755+/**/
754756 2973,
755757 /**/
756758 2972,
Show on old repository browser