To: vim_dev@googlegroups.com Subject: Patch 8.2.2974 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.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) Files: src/spell.c, src/proto/spell.pro, src/spellfile.c, src/spellsuggest.c *** ../vim-8.2.2973/src/spell.c 2020-12-31 17:40:57.536087870 +0100 --- src/spell.c 2021-06-11 19:00:44.735283906 +0200 *************** *** 249,255 **** if (*mi.mi_fend != NUL) MB_PTR_ADV(mi.mi_fend); ! (void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword, MAXWLEN + 1); mi.mi_fwordlen = (int)STRLEN(mi.mi_fword); --- 249,255 ---- if (*mi.mi_fend != NUL) MB_PTR_ADV(mi.mi_fend); ! (void)spell_casefold(wp, ptr, (int)(mi.mi_fend - ptr), mi.mi_fword, MAXWLEN + 1); mi.mi_fwordlen = (int)STRLEN(mi.mi_fword); *************** *** 736,742 **** { // "fword" is only needed for checking syllables. if (ptr == mip->mi_word) ! (void)spell_casefold(ptr, wlen, fword, MAXWLEN); else vim_strncpy(fword, ptr, endlen[endidxcnt]); } --- 736,743 ---- { // "fword" is only needed for checking syllables. if (ptr == mip->mi_word) ! (void)spell_casefold(mip->mi_win, ! ptr, wlen, fword, MAXWLEN); else vim_strncpy(fword, ptr, endlen[endidxcnt]); } *************** *** 1213,1219 **** if (*mip->mi_fend != NUL) MB_PTR_ADV(mip->mi_fend); ! (void)spell_casefold(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); --- 1214,1220 ---- if (*mip->mi_fend != NUL) MB_PTR_ADV(mip->mi_fend); ! (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,2742 **** --- 2738,2744 ---- */ int spell_casefold( + win_T *wp, char_u *str, int len, char_u *buf, *************** *** 2765,2771 **** return FAIL; } c = mb_cptr2char_adv(&p); ! outi += mb_char2bytes(SPELL_TOFOLD(c), buf + outi); } buf[outi] = NUL; } --- 2767,2787 ---- return FAIL; } c = mb_cptr2char_adv(&p); ! ! // 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,3103 **** word = inword; else { ! (void)spell_casefold(inword, (int)STRLEN(inword), fword, MAXWLEN); word = fword; } --- 3113,3120 ---- word = inword; else { ! (void)spell_casefold(curwin, ! inword, (int)STRLEN(inword), fword, MAXWLEN); word = fword; } *** ../vim-8.2.2973/src/proto/spell.pro 2020-06-08 18:54:44.957796367 +0200 --- src/proto/spell.pro 2021-06-11 18:57:41.343750421 +0200 *************** *** 27,33 **** 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 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); --- 27,33 ---- 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(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); *** ../vim-8.2.2973/src/spellfile.c 2021-02-03 20:14:18.903555669 +0100 --- src/spellfile.c 2021-06-11 19:02:27.819023408 +0200 *************** *** 3429,3437 **** if (ga_grow(gap, 1) == OK) { ftp = ((fromto_T *)gap->ga_data) + gap->ga_len; ! (void)spell_casefold(from, (int)STRLEN(from), word, MAXWLEN); ftp->ft_from = getroom_save(spin, word); ! (void)spell_casefold(to, (int)STRLEN(to), word, MAXWLEN); ftp->ft_to = getroom_save(spin, word); ++gap->ga_len; } --- 3429,3437 ---- if (ga_grow(gap, 1) == OK) { ftp = ((fromto_T *)gap->ga_data) + gap->ga_len; ! (void)spell_casefold(curwin, from, (int)STRLEN(from), word, MAXWLEN); ftp->ft_from = getroom_save(spin, word); ! (void)spell_casefold(curwin, to, (int)STRLEN(to), word, MAXWLEN); ftp->ft_to = getroom_save(spin, word); ++gap->ga_len; } *************** *** 4391,4397 **** int res = OK; char_u *p; ! (void)spell_casefold(word, len, foldword, MAXWLEN); for (p = pfxlist; res == OK; ++p) { if (!need_affix || (p != NULL && *p != NUL)) --- 4391,4397 ---- int res = OK; char_u *p; ! (void)spell_casefold(curwin, word, len, foldword, MAXWLEN); for (p = pfxlist; res == OK; ++p) { if (!need_affix || (p != NULL && *p != NUL)) *** ../vim-8.2.2973/src/spellsuggest.c 2021-01-20 21:42:30.237556832 +0100 --- src/spellsuggest.c 2021-06-11 19:04:10.466765027 +0200 *************** *** 791,797 **** 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, 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. --- 791,797 ---- 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(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,1182 **** 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); for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi) { --- 1176,1182 ---- STRCPY(fword, su->su_fbadword); n = (int)STRLEN(fword); p = su->su_badptr + su->su_badlen; ! (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,3011 **** else { // soundfold the bad word with more characters following ! (void)spell_casefold(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 --- 3005,3012 ---- else { // soundfold the bad word with more characters following ! (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 *** ../vim-8.2.2973/src/version.c 2021-06-10 21:52:11.813718366 +0200 --- src/version.c 2021-06-11 19:07:18.982292343 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2974, /**/ -- DENNIS: Oh, very nice. King, eh! I expect you've got a palace and fine clothes and courtiers and plenty of food. And how d'you get that? By exploiting the workers! By hanging on to outdated imperialist dogma which perpetuates the social and economic differences in our society! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///