comparison src/spell.c @ 819:23f82b5d2814 v7.0c10

updated for version 7.0c10
author vimboss
date Wed, 05 Apr 2006 20:41:53 +0000
parents 6897668c467f
children 57c7403f6599
comparison
equal deleted inserted replaced
818:1f929f3ca806 819:23f82b5d2814
254 * <flags2> 1 byte Bitmask of: 254 * <flags2> 1 byte Bitmask of:
255 * WF_HAS_AFF >> 8 word includes affix 255 * WF_HAS_AFF >> 8 word includes affix
256 * WF_NEEDCOMP >> 8 word only valid in compound 256 * WF_NEEDCOMP >> 8 word only valid in compound
257 * WF_NOSUGGEST >> 8 word not used for suggestions 257 * WF_NOSUGGEST >> 8 word not used for suggestions
258 * WF_COMPROOT >> 8 word already a compound 258 * WF_COMPROOT >> 8 word already a compound
259 * WF_NOCOMPBEF >> 8 no compounding before this word
260 * WF_NOCOMPAFT >> 8 no compounding after this word
259 * 261 *
260 * <pflags> 1 byte bitmask of: 262 * <pflags> 1 byte bitmask of:
261 * WFP_RARE rare prefix 263 * WFP_RARE rare prefix
262 * WFP_NC non-combining prefix 264 * WFP_NC non-combining prefix
263 * WFP_UP letter after prefix made upper case 265 * WFP_UP letter after prefix made upper case
343 /* for <flags2>, shifted up one byte to be used in wn_flags */ 345 /* for <flags2>, shifted up one byte to be used in wn_flags */
344 #define WF_HAS_AFF 0x0100 /* word includes affix */ 346 #define WF_HAS_AFF 0x0100 /* word includes affix */
345 #define WF_NEEDCOMP 0x0200 /* word only valid in compound */ 347 #define WF_NEEDCOMP 0x0200 /* word only valid in compound */
346 #define WF_NOSUGGEST 0x0400 /* word not to be suggested */ 348 #define WF_NOSUGGEST 0x0400 /* word not to be suggested */
347 #define WF_COMPROOT 0x0800 /* already compounded word, COMPOUNDROOT */ 349 #define WF_COMPROOT 0x0800 /* already compounded word, COMPOUNDROOT */
350 #define WF_NOCOMPBEF 0x1000 /* no compounding before this word */
351 #define WF_NOCOMPAFT 0x2000 /* no compounding after this word */
348 352
349 /* only used for su_badflags */ 353 /* only used for su_badflags */
350 #define WF_MIXCAP 0x20 /* mix of upper and lower case: macaRONI */ 354 #define WF_MIXCAP 0x20 /* mix of upper and lower case: macaRONI */
351 355
352 #define WF_CAPMASK (WF_ONECAP | WF_ALLCAP | WF_KEEPCAP | WF_FIXCAP) 356 #define WF_CAPMASK (WF_ONECAP | WF_ALLCAP | WF_KEEPCAP | WF_FIXCAP)
1498 if (!word_ends && mip->mi_complen + mip->mi_compextra + 2 1502 if (!word_ends && mip->mi_complen + mip->mi_compextra + 2
1499 > slang->sl_compmax 1503 > slang->sl_compmax
1500 && slang->sl_compsylmax == MAXWLEN) 1504 && slang->sl_compsylmax == MAXWLEN)
1501 continue; 1505 continue;
1502 1506
1507 /* Don't allow compounding on a side where an affix was added,
1508 * unless COMPOUNDPERMITFLAG was used. */
1509 if (mip->mi_complen > 0 && (flags & WF_NOCOMPBEF))
1510 continue;
1511 if (!word_ends && (flags & WF_NOCOMPAFT))
1512 continue;
1513
1503 /* Quickly check if compounding is possible with this flag. */ 1514 /* Quickly check if compounding is possible with this flag. */
1504 if (!byte_in_str(mip->mi_complen == 0 1515 if (!byte_in_str(mip->mi_complen == 0
1505 ? slang->sl_compstartflags 1516 ? slang->sl_compstartflags
1506 : slang->sl_compallflags, 1517 : slang->sl_compallflags,
1507 ((unsigned)flags >> 24))) 1518 ((unsigned)flags >> 24)))
1632 { 1643 {
1633 /* Find following word in keep-case tree. */ 1644 /* Find following word in keep-case tree. */
1634 mip->mi_compoff = wlen; 1645 mip->mi_compoff = wlen;
1635 find_word(mip, FIND_KEEPCOMPOUND); 1646 find_word(mip, FIND_KEEPCOMPOUND);
1636 1647
1648 #if 0 /* Disabled, a prefix must not appear halfway a compound word,
1649 unless the COMPOUNDPERMITFLAG is used and then it can't be a
1650 postponed prefix. */
1637 if (!slang->sl_nobreak || mip->mi_result == SP_BAD) 1651 if (!slang->sl_nobreak || mip->mi_result == SP_BAD)
1638 { 1652 {
1639 /* Check for following word with prefix. */ 1653 /* Check for following word with prefix. */
1640 mip->mi_compoff = c; 1654 mip->mi_compoff = c;
1641 find_prefix(mip, FIND_COMPOUND); 1655 find_prefix(mip, FIND_COMPOUND);
1642 } 1656 }
1657 #endif
1643 } 1658 }
1644 1659
1645 if (!slang->sl_nobreak) 1660 if (!slang->sl_nobreak)
1646 break; 1661 break;
1647 } 1662 }
6700 affile->af_rare)) 6715 affile->af_rare))
6701 use_flags = flags | WF_RARE; 6716 use_flags = flags | WF_RARE;
6702 else 6717 else
6703 use_flags = flags; 6718 use_flags = flags;
6704 6719
6705 /* Obey a "COMPOUNDFORBID" flag of the affix: don't 6720 /* Obey a "COMPOUNDFORBIDFLAG" of the affix: don't
6706 * use the compound flags. */ 6721 * use the compound flags. */
6707 use_pfxlist = pfxlist; 6722 use_pfxlist = pfxlist;
6708 if (pfxlist != NULL 6723 if (pfxlist != NULL
6709 && affile->af_compforbid != 0 6724 && affile->af_compforbid != 0
6710 && ae->ae_flags != NULL 6725 && ae->ae_flags != NULL
6728 * compound flags after them. */ 6743 * compound flags after them. */
6729 if ((!ah->ah_combine || comb) && pfxlist != NULL) 6744 if ((!ah->ah_combine || comb) && pfxlist != NULL)
6730 use_pfxlist += pfxlen; 6745 use_pfxlist += pfxlen;
6731 } 6746 }
6732 6747
6748 /* When compounding is supported and there is no
6749 * "COMPOUNDPERMITFLAG" then forbid compounding on the
6750 * side where the affix is applied. */
6751 if (spin->si_compflags != NULL
6752 && (affile->af_comppermit == 0
6753 || ae->ae_flags == NULL
6754 || !flag_in_afflist(
6755 affile->af_flagtype, ae->ae_flags,
6756 affile->af_comppermit)))
6757 {
6758 if (xht != NULL)
6759 use_flags |= WF_NOCOMPAFT;
6760 else
6761 use_flags |= WF_NOCOMPBEF;
6762 }
6763
6733 /* Store the modified word. */ 6764 /* Store the modified word. */
6734 if (store_word(spin, newword, use_flags, 6765 if (store_word(spin, newword, use_flags,
6735 spin->si_region, use_pfxlist, FALSE) == FAIL) 6766 spin->si_region, use_pfxlist, FALSE) == FAIL)
6736 retval = FAIL; 6767 retval = FAIL;
6737 6768
6738 /* When added a suffix and combining is allowed also 6769 /* When added a suffix and combining is allowed also
6739 * try adding prefixes additionally. */ 6770 * try adding prefixes additionally. RECURSIVE! */
6740 if (xht != NULL && ah->ah_combine) 6771 if (xht != NULL && ah->ah_combine)
6741 if (store_aff_word(spin, newword, afflist, affile, 6772 if (store_aff_word(spin, newword, afflist, affile,
6742 xht, NULL, TRUE, 6773 xht, NULL, TRUE,
6743 use_flags, use_pfxlist, pfxlen) == FAIL) 6774 use_flags, use_pfxlist, pfxlen) == FAIL)
6744 retval = FAIL; 6775 retval = FAIL;
9208 * encoding used in the first loaded .spl file. */ 9239 * encoding used in the first loaded .spl file. */
9209 if (aspath) 9240 if (aspath)
9210 vim_strncpy(buf, curbuf->b_p_spl, lend - curbuf->b_p_spl); 9241 vim_strncpy(buf, curbuf->b_p_spl, lend - curbuf->b_p_spl);
9211 else 9242 else
9212 { 9243 {
9244 /* Create the "spell" directory if it doesn't exist yet. */
9245 l = STRLEN(buf);
9246 vim_snprintf((char *)buf + l, MAXPATHL - l, "/spell");
9247 if (!filewritable(buf) != 2)
9248 vim_mkdir(buf, 0755);
9249
9213 l = STRLEN(buf); 9250 l = STRLEN(buf);
9214 vim_snprintf((char *)buf + l, MAXPATHL - l, 9251 vim_snprintf((char *)buf + l, MAXPATHL - l,
9215 "/spell/%.*s", (int)(lend - lstart), lstart); 9252 "/%.*s", (int)(lend - lstart), lstart);
9216 } 9253 }
9217 l = STRLEN(buf); 9254 l = STRLEN(buf);
9218 fname = LANGP_ENTRY(curbuf->b_langp, 0)->lp_slang->sl_fname; 9255 fname = LANGP_ENTRY(curbuf->b_langp, 0)->lp_slang->sl_fname;
9219 vim_snprintf((char *)buf + l, MAXPATHL - l, ".%s.add", 9256 vim_snprintf((char *)buf + l, MAXPATHL - l, ".%s.add",
9220 fname != NULL 9257 fname != NULL
9945 mch_memmove(p, line, c); 9982 mch_memmove(p, line, c);
9946 STRCPY(p + c, stp->st_word); 9983 STRCPY(p + c, stp->st_word);
9947 STRCAT(p, sug.su_badptr + stp->st_orglen); 9984 STRCAT(p, sug.su_badptr + stp->st_orglen);
9948 ml_replace(curwin->w_cursor.lnum, p, FALSE); 9985 ml_replace(curwin->w_cursor.lnum, p, FALSE);
9949 curwin->w_cursor.col = c; 9986 curwin->w_cursor.col = c;
9950 changed_bytes(curwin->w_cursor.lnum, c);
9951 9987
9952 /* For redo we use a change-word command. */ 9988 /* For redo we use a change-word command. */
9953 ResetRedobuff(); 9989 ResetRedobuff();
9954 AppendToRedobuff((char_u *)"ciw"); 9990 AppendToRedobuff((char_u *)"ciw");
9955 AppendToRedobuffLit(p + c, 9991 AppendToRedobuffLit(p + c,
9956 stp->st_wordlen + sug.su_badlen - stp->st_orglen); 9992 stp->st_wordlen + sug.su_badlen - stp->st_orglen);
9957 AppendCharToRedobuff(ESC); 9993 AppendCharToRedobuff(ESC);
9994
9995 /* After this "p" may be invalid. */
9996 changed_bytes(curwin->w_cursor.lnum, c);
9958 } 9997 }
9959 } 9998 }
9960 else 9999 else
9961 curwin->w_cursor = prev_cursor; 10000 curwin->w_cursor = prev_cursor;
9962 10001