Mercurial > vim
comparison src/spell.c @ 334:a1270013cb34
updated for version 7.0087
author | vimboss |
---|---|
date | Fri, 17 Jun 2005 21:51:16 +0000 |
parents | f76b0d38b6bd |
children | 64221fecdfa1 |
comparison
equal
deleted
inserted
replaced
333:18f024844150 | 334:a1270013cb34 |
---|---|
1954 * Info used while reading the spell files. | 1954 * Info used while reading the spell files. |
1955 */ | 1955 */ |
1956 typedef struct spellinfo_S | 1956 typedef struct spellinfo_S |
1957 { | 1957 { |
1958 wordnode_T *si_foldroot; /* tree with case-folded words */ | 1958 wordnode_T *si_foldroot; /* tree with case-folded words */ |
1959 long si_foldwcount; /* nr of words in si_foldroot */ | |
1959 wordnode_T *si_keeproot; /* tree with keep-case words */ | 1960 wordnode_T *si_keeproot; /* tree with keep-case words */ |
1961 long si_keepwcount; /* nr of words in si_keeproot */ | |
1960 sblock_T *si_blocks; /* memory blocks used */ | 1962 sblock_T *si_blocks; /* memory blocks used */ |
1961 int si_ascii; /* handling only ASCII words */ | 1963 int si_ascii; /* handling only ASCII words */ |
1962 int si_add; /* addition file */ | 1964 int si_add; /* addition file */ |
1963 int si_region; /* region mask */ | 1965 int si_region; /* region mask */ |
1964 vimconv_T si_conv; /* for conversion to 'encoding' */ | 1966 vimconv_T si_conv; /* for conversion to 'encoding' */ |
2010 FILE *fd; | 2012 FILE *fd; |
2011 afffile_T *aff; | 2013 afffile_T *aff; |
2012 char_u rline[MAXLINELEN]; | 2014 char_u rline[MAXLINELEN]; |
2013 char_u *line; | 2015 char_u *line; |
2014 char_u *pc = NULL; | 2016 char_u *pc = NULL; |
2015 char_u *(items[6]); | 2017 #define MAXITEMCNT 7 |
2018 char_u *(items[MAXITEMCNT]); | |
2016 int itemcnt; | 2019 int itemcnt; |
2017 char_u *p; | 2020 char_u *p; |
2018 int lnum = 0; | 2021 int lnum = 0; |
2019 affheader_T *cur_aff = NULL; | 2022 affheader_T *cur_aff = NULL; |
2020 int aff_todo = 0; | 2023 int aff_todo = 0; |
2107 { | 2110 { |
2108 while (*p != NUL && *p <= ' ') /* skip white space and CR/NL */ | 2111 while (*p != NUL && *p <= ' ') /* skip white space and CR/NL */ |
2109 ++p; | 2112 ++p; |
2110 if (*p == NUL) | 2113 if (*p == NUL) |
2111 break; | 2114 break; |
2112 if (itemcnt == 6) /* too many items */ | 2115 if (itemcnt == MAXITEMCNT) /* too many items */ |
2113 break; | 2116 break; |
2114 items[itemcnt++] = p; | 2117 items[itemcnt++] = p; |
2115 while (*p > ' ') /* skip until white space or CR/NL */ | 2118 while (*p > ' ') /* skip until white space or CR/NL */ |
2116 ++p; | 2119 ++p; |
2117 if (*p == NUL) | 2120 if (*p == NUL) |
2160 smsg((char_u *)_(e_affname), fname, lnum, items[1]); | 2163 smsg((char_u *)_(e_affname), fname, lnum, items[1]); |
2161 } | 2164 } |
2162 else if ((STRCMP(items[0], "PFX") == 0 | 2165 else if ((STRCMP(items[0], "PFX") == 0 |
2163 || STRCMP(items[0], "SFX") == 0) | 2166 || STRCMP(items[0], "SFX") == 0) |
2164 && aff_todo == 0 | 2167 && aff_todo == 0 |
2165 && itemcnt == 4) | 2168 && itemcnt >= 4) |
2166 { | 2169 { |
2170 /* Myspell allows extra text after the item, but that might | |
2171 * mean mistakes go unnoticed. Require a comment-starter. */ | |
2172 if (itemcnt > 4 && *items[4] != '#') | |
2173 smsg((char_u *)_("Trailing text in %s line %d: %s"), | |
2174 fname, lnum, items[4]); | |
2175 | |
2167 /* New affix letter. */ | 2176 /* New affix letter. */ |
2168 cur_aff = (affheader_T *)getroom(&spin->si_blocks, | 2177 cur_aff = (affheader_T *)getroom(&spin->si_blocks, |
2169 sizeof(affheader_T)); | 2178 sizeof(affheader_T)); |
2170 if (cur_aff == NULL) | 2179 if (cur_aff == NULL) |
2171 break; | 2180 break; |
2195 } | 2204 } |
2196 else if ((STRCMP(items[0], "PFX") == 0 | 2205 else if ((STRCMP(items[0], "PFX") == 0 |
2197 || STRCMP(items[0], "SFX") == 0) | 2206 || STRCMP(items[0], "SFX") == 0) |
2198 && aff_todo > 0 | 2207 && aff_todo > 0 |
2199 && STRCMP(cur_aff->ah_key, items[1]) == 0 | 2208 && STRCMP(cur_aff->ah_key, items[1]) == 0 |
2200 && itemcnt == 5) | 2209 && itemcnt >= 5) |
2201 { | 2210 { |
2202 affentry_T *aff_entry; | 2211 affentry_T *aff_entry; |
2212 | |
2213 /* Myspell allows extra text after the item, but that might | |
2214 * mean mistakes go unnoticed. Require a comment-starter. */ | |
2215 if (itemcnt > 5 && *items[5] != '#') | |
2216 smsg((char_u *)_("Trailing text in %s line %d: %s"), | |
2217 fname, lnum, items[5]); | |
2203 | 2218 |
2204 /* New item for an affix letter. */ | 2219 /* New item for an affix letter. */ |
2205 --aff_todo; | 2220 --aff_todo; |
2206 aff_entry = (affentry_T *)getroom(&spin->si_blocks, | 2221 aff_entry = (affentry_T *)getroom(&spin->si_blocks, |
2207 sizeof(affentry_T)); | 2222 sizeof(affentry_T)); |
2475 } | 2490 } |
2476 | 2491 |
2477 /* The hashtable is only used to detect duplicated words. */ | 2492 /* The hashtable is only used to detect duplicated words. */ |
2478 hash_init(&ht); | 2493 hash_init(&ht); |
2479 | 2494 |
2495 spin->si_foldwcount = 0; | |
2496 spin->si_keepwcount = 0; | |
2497 | |
2480 if (spin->si_verbose || p_verbose > 2) | 2498 if (spin->si_verbose || p_verbose > 2) |
2481 { | 2499 { |
2482 if (!spin->si_verbose) | 2500 if (!spin->si_verbose) |
2483 verbose_enter(); | 2501 verbose_enter(); |
2484 smsg((char_u *)_("Reading dictionary file %s..."), fname); | 2502 smsg((char_u *)_("Reading dictionary file %s..."), fname); |
2513 | 2531 |
2514 /* This takes time, print a message now and then. */ | 2532 /* This takes time, print a message now and then. */ |
2515 if (spin->si_verbose && (lnum & 0x3ff) == 0) | 2533 if (spin->si_verbose && (lnum & 0x3ff) == 0) |
2516 { | 2534 { |
2517 vim_snprintf((char *)message, sizeof(message), | 2535 vim_snprintf((char *)message, sizeof(message), |
2518 _("line %6d - %s"), lnum, line); | 2536 _("line %6d, word %6d - %s"), |
2537 lnum, spin->si_foldwcount + spin->si_keepwcount, line); | |
2519 msg_start(); | 2538 msg_start(); |
2520 msg_outtrans_attr(message, 0); | 2539 msg_outtrans_attr(message, 0); |
2521 msg_clr_eos(); | 2540 msg_clr_eos(); |
2522 msg_didout = FALSE; | 2541 msg_didout = FALSE; |
2523 msg_col = 0; | 2542 msg_col = 0; |
3043 int res; | 3062 int res; |
3044 | 3063 |
3045 (void)spell_casefold(word, len, foldword, MAXWLEN); | 3064 (void)spell_casefold(word, len, foldword, MAXWLEN); |
3046 res = tree_add_word(foldword, spin->si_foldroot, ct | flags, | 3065 res = tree_add_word(foldword, spin->si_foldroot, ct | flags, |
3047 region, &spin->si_blocks); | 3066 region, &spin->si_blocks); |
3067 ++spin->si_foldwcount; | |
3048 | 3068 |
3049 if (res == OK && (ct == WF_KEEPCAP || flags & WF_KEEPCAP)) | 3069 if (res == OK && (ct == WF_KEEPCAP || flags & WF_KEEPCAP)) |
3070 { | |
3050 res = tree_add_word(word, spin->si_keeproot, flags, | 3071 res = tree_add_word(word, spin->si_keeproot, flags, |
3051 region, &spin->si_blocks); | 3072 region, &spin->si_blocks); |
3073 ++spin->si_keepwcount; | |
3074 } | |
3052 return res; | 3075 return res; |
3053 } | 3076 } |
3054 | 3077 |
3055 /* | 3078 /* |
3056 * Add word "word" to a word tree at "root". | 3079 * Add word "word" to a word tree at "root". |