comparison src/spell.c @ 24872:59cfa23bd9eb v8.2.2974

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)
author Bram Moolenaar <Bram@vim.org>
date Fri, 11 Jun 2021 19:15:04 +0200
parents bb0c53f4ef8b
children 078edc1821bf
comparison
equal deleted inserted replaced
24871:7551b2508d35 24872:59cfa23bd9eb
247 // case-fold the word with one non-word character, so that we can check 247 // case-fold the word with one non-word character, so that we can check
248 // for the word end. 248 // for the word end.
249 if (*mi.mi_fend != NUL) 249 if (*mi.mi_fend != NUL)
250 MB_PTR_ADV(mi.mi_fend); 250 MB_PTR_ADV(mi.mi_fend);
251 251
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,
253 MAXWLEN + 1); 253 MAXWLEN + 1);
254 mi.mi_fwordlen = (int)STRLEN(mi.mi_fword); 254 mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
255 255
256 if (camel_case) 256 if (camel_case)
257 // Introduce a fake word end space into the folded word. 257 // Introduce a fake word end space into the folded word.
734 734
735 if (slang->sl_compsylmax < MAXWLEN) 735 if (slang->sl_compsylmax < MAXWLEN)
736 { 736 {
737 // "fword" is only needed for checking syllables. 737 // "fword" is only needed for checking syllables.
738 if (ptr == mip->mi_word) 738 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);
740 else 741 else
741 vim_strncpy(fword, ptr, endlen[endidxcnt]); 742 vim_strncpy(fword, ptr, endlen[endidxcnt]);
742 } 743 }
743 if (!can_compound(slang, fword, mip->mi_compflags)) 744 if (!can_compound(slang, fword, mip->mi_compflags))
744 continue; 745 continue;
1211 1212
1212 // Include the non-word character so that we can check for the word end. 1213 // Include the non-word character so that we can check for the word end.
1213 if (*mip->mi_fend != NUL) 1214 if (*mip->mi_fend != NUL)
1214 MB_PTR_ADV(mip->mi_fend); 1215 MB_PTR_ADV(mip->mi_fend);
1215 1216
1216 (void)spell_casefold(p, (int)(mip->mi_fend - p), 1217 (void)spell_casefold(mip->mi_win, p, (int)(mip->mi_fend - p),
1217 mip->mi_fword + mip->mi_fwordlen, 1218 mip->mi_fword + mip->mi_fwordlen,
1218 MAXWLEN - mip->mi_fwordlen); 1219 MAXWLEN - mip->mi_fwordlen);
1219 flen = (int)STRLEN(mip->mi_fword + mip->mi_fwordlen); 1220 flen = (int)STRLEN(mip->mi_fword + mip->mi_fwordlen);
1220 mip->mi_fwordlen += flen; 1221 mip->mi_fwordlen += flen;
1221 return flen; 1222 return flen;
2735 * When using a multi-byte 'encoding' the length may change! 2736 * When using a multi-byte 'encoding' the length may change!
2736 * Returns FAIL when something wrong. 2737 * Returns FAIL when something wrong.
2737 */ 2738 */
2738 int 2739 int
2739 spell_casefold( 2740 spell_casefold(
2741 win_T *wp,
2740 char_u *str, 2742 char_u *str,
2741 int len, 2743 int len,
2742 char_u *buf, 2744 char_u *buf,
2743 int buflen) 2745 int buflen)
2744 { 2746 {
2763 { 2765 {
2764 buf[outi] = NUL; 2766 buf[outi] = NUL;
2765 return FAIL; 2767 return FAIL;
2766 } 2768 }
2767 c = mb_cptr2char_adv(&p); 2769 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);
2769 } 2785 }
2770 buf[outi] = NUL; 2786 buf[outi] = NUL;
2771 } 2787 }
2772 else 2788 else
2773 { 2789 {
3095 // SAL items used. Requires the word to be case-folded. 3111 // SAL items used. Requires the word to be case-folded.
3096 if (folded) 3112 if (folded)
3097 word = inword; 3113 word = inword;
3098 else 3114 else
3099 { 3115 {
3100 (void)spell_casefold(inword, (int)STRLEN(inword), fword, MAXWLEN); 3116 (void)spell_casefold(curwin,
3117 inword, (int)STRLEN(inword), fword, MAXWLEN);
3101 word = fword; 3118 word = fword;
3102 } 3119 }
3103 3120
3104 if (has_mbyte) 3121 if (has_mbyte)
3105 spell_soundfold_wsal(slang, word, res); 3122 spell_soundfold_wsal(slang, word, res);