annotate src/spellfile.c @ 13232:d11bbd3440b0 v8.0.1490

patch 8.0.1490: number of spell regions is spread out through the code commit https://github.com/vim/vim/commit/2993ac5fce5450428322ce43aaa5e643e6994443 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 10 14:12:43 2018 +0100 patch 8.0.1490: number of spell regions is spread out through the code Problem: Number of spell regions is spread out through the code. Solution: Define MAXREGIONS.
author Christian Brabandt <cb@256bit.org>
date Sat, 10 Feb 2018 14:15:05 +0100
parents 514c1741ab8c
children ac42c4b11dbc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9583
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 * spellfile.c: code for reading and writing spell files.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 * See spell.c for information about spell checking.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 * Vim spell file format: <HEADER>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 * <SECTIONS>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 * <LWORDTREE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 * <KWORDTREE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 * <PREFIXTREE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 * <HEADER>: <fileID> <versionnr>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 * <fileID> 8 bytes "VIMspell"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 * <versionnr> 1 byte VIMSPELLVERSION
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 * Sections make it possible to add information to the .spl file without
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 * making it incompatible with previous versions. There are two kinds of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 * sections:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 * 1. Not essential for correct spell checking. E.g. for making suggestions.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 * These are skipped when not supported.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 * 2. Optional information, but essential for spell checking when present.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 * E.g. conditions for affixes. When this section is present but not
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 * supported an error message is given.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 * <SECTIONS>: <section> ... <sectionend>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 * <section>: <sectionID> <sectionflags> <sectionlen> (section contents)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 * <sectionID> 1 byte number from 0 to 254 identifying the section
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 * <sectionflags> 1 byte SNF_REQUIRED: this section is required for correct
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 * spell checking
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 * <sectionlen> 4 bytes length of section contents, MSB first
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 * <sectionend> 1 byte SN_END
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 * sectionID == SN_INFO: <infotext>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 * <infotext> N bytes free format text with spell file info (version,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 * website, etc)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 * sectionID == SN_REGION: <regionname> ...
13232
d11bbd3440b0 patch 8.0.1490: number of spell regions is spread out through the code
Christian Brabandt <cb@256bit.org>
parents: 12694
diff changeset
57 * <regionname> 2 bytes Up to MAXREGIONS region names: ca, au, etc. Lower
d11bbd3440b0 patch 8.0.1490: number of spell regions is spread out through the code
Christian Brabandt <cb@256bit.org>
parents: 12694
diff changeset
58 * case. First <regionname> is region 1.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 * sectionID == SN_CHARFLAGS: <charflagslen> <charflags>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 * <folcharslen> <folchars>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 * <charflagslen> 1 byte Number of bytes in <charflags> (should be 128).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 * <charflags> N bytes List of flags (first one is for character 128):
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 * 0x01 word character CF_WORD
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 * 0x02 upper-case character CF_UPPER
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 * <folcharslen> 2 bytes Number of bytes in <folchars>.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 * <folchars> N bytes Folded characters, first one is for character 128.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 * sectionID == SN_MIDWORD: <midword>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 * <midword> N bytes Characters that are word characters only when used
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 * in the middle of a word.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 * sectionID == SN_PREFCOND: <prefcondcnt> <prefcond> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 * <prefcondcnt> 2 bytes Number of <prefcond> items following.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 * <prefcond> : <condlen> <condstr>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 * <condlen> 1 byte Length of <condstr>.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 * <condstr> N bytes Condition for the prefix.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 * sectionID == SN_REP: <repcount> <rep> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 * <repcount> 2 bytes number of <rep> items, MSB first.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 * <rep> : <repfromlen> <repfrom> <reptolen> <repto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 * <repfromlen> 1 byte length of <repfrom>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 * <repfrom> N bytes "from" part of replacement
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 * <reptolen> 1 byte length of <repto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 * <repto> N bytes "to" part of replacement
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 * sectionID == SN_REPSAL: <repcount> <rep> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 * just like SN_REP but for soundfolded words
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 * sectionID == SN_SAL: <salflags> <salcount> <sal> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 * <salflags> 1 byte flags for soundsalike conversion:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 * SAL_F0LLOWUP
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 * SAL_COLLAPSE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 * SAL_REM_ACCENTS
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 * <salcount> 2 bytes number of <sal> items following
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 * <sal> : <salfromlen> <salfrom> <saltolen> <salto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 * <salfromlen> 1 byte length of <salfrom>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 * <salfrom> N bytes "from" part of soundsalike
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 * <saltolen> 1 byte length of <salto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 * <salto> N bytes "to" part of soundsalike
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 * sectionID == SN_SOFO: <sofofromlen> <sofofrom> <sofotolen> <sofoto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 * <sofofromlen> 2 bytes length of <sofofrom>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 * <sofofrom> N bytes "from" part of soundfold
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 * <sofotolen> 2 bytes length of <sofoto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 * <sofoto> N bytes "to" part of soundfold
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 * sectionID == SN_SUGFILE: <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 * <timestamp> 8 bytes time in seconds that must match with .sug file
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 * sectionID == SN_NOSPLITSUGS: nothing
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 * sectionID == SN_NOCOMPOUNDSUGS: nothing
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 * sectionID == SN_WORDS: <word> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 * <word> N bytes NUL terminated common word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 * sectionID == SN_MAP: <mapstr>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 * <mapstr> N bytes String with sequences of similar characters,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 * separated by slashes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 * sectionID == SN_COMPOUND: <compmax> <compminlen> <compsylmax> <compoptions>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 * <comppatcount> <comppattern> ... <compflags>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 * <compmax> 1 byte Maximum nr of words in compound word.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 * <compminlen> 1 byte Minimal word length for compounding.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 * <compsylmax> 1 byte Maximum nr of syllables in compound word.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 * <compoptions> 2 bytes COMP_ flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 * <comppatcount> 2 bytes number of <comppattern> following
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 * <compflags> N bytes Flags from COMPOUNDRULE items, separated by
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 * slashes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 * <comppattern>: <comppatlen> <comppattext>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 * <comppatlen> 1 byte length of <comppattext>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 * <comppattext> N bytes end or begin chars from CHECKCOMPOUNDPATTERN
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 * sectionID == SN_NOBREAK: (empty, its presence is what matters)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 * sectionID == SN_SYLLABLE: <syllable>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 * <syllable> N bytes String from SYLLABLE item.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 * <LWORDTREE>: <wordtree>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 * <KWORDTREE>: <wordtree>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 * <PREFIXTREE>: <wordtree>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 * <wordtree>: <nodecount> <nodedata> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 * <nodecount> 4 bytes Number of nodes following. MSB first.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 * <nodedata>: <siblingcount> <sibling> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 * <siblingcount> 1 byte Number of siblings in this node. The siblings
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 * follow in sorted order.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 * <sibling>: <byte> [ <nodeidx> <xbyte>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 * | <flags> [<flags2>] [<region>] [<affixID>]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 * | [<pflags>] <affixID> <prefcondnr> ]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 * <byte> 1 byte Byte value of the sibling. Special cases:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 * BY_NOFLAGS: End of word without flags and for all
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 * regions.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 * For PREFIXTREE <affixID> and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 * <prefcondnr> follow.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 * BY_FLAGS: End of word, <flags> follow.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 * For PREFIXTREE <pflags>, <affixID>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 * and <prefcondnr> follow.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 * BY_FLAGS2: End of word, <flags> and <flags2>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 * follow. Not used in PREFIXTREE.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 * BY_INDEX: Child of sibling is shared, <nodeidx>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 * and <xbyte> follow.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 * <nodeidx> 3 bytes Index of child for this sibling, MSB first.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 * <xbyte> 1 byte byte value of the sibling.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 * <flags> 1 byte bitmask of:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 * WF_ALLCAP word must have only capitals
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 * WF_ONECAP first char of word must be capital
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 * WF_KEEPCAP keep-case word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 * WF_FIXCAP keep-case word, all caps not allowed
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 * WF_RARE rare word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 * WF_BANNED bad word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 * WF_REGION <region> follows
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 * WF_AFX <affixID> follows
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 * <flags2> 1 byte Bitmask of:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 * WF_HAS_AFF >> 8 word includes affix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 * WF_NEEDCOMP >> 8 word only valid in compound
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 * WF_NOSUGGEST >> 8 word not used for suggestions
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 * WF_COMPROOT >> 8 word already a compound
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 * WF_NOCOMPBEF >> 8 no compounding before this word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 * WF_NOCOMPAFT >> 8 no compounding after this word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 * <pflags> 1 byte bitmask of:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 * WFP_RARE rare prefix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198 * WFP_NC non-combining prefix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199 * WFP_UP letter after prefix made upper case
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 * <region> 1 byte Bitmask for regions in which word is valid. When
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 * omitted it's valid in all regions.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 * Lowest bit is for region 1.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 * <affixID> 1 byte ID of affix that can be used with this word. In
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 * PREFIXTREE used for the required prefix ID.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 * <prefcondnr> 2 bytes Prefix condition number, index in <prefcond> list
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 * from HEADER.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 * All text characters are in 'encoding', but stored as single bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 * Vim .sug file format: <SUGHEADER>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 * <SUGWORDTREE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 * <SUGTABLE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 * <SUGHEADER>: <fileID> <versionnr> <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 * <fileID> 6 bytes "VIMsug"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 * <versionnr> 1 byte VIMSUGVERSION
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 * <timestamp> 8 bytes timestamp that must match with .spl file
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 * <SUGWORDTREE>: <wordtree> (see above, no flags or region used)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 * <SUGTABLE>: <sugwcount> <sugline> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 * <sugwcount> 4 bytes number of <sugline> following
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 * <sugline>: <sugnr> ... NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 * <sugnr>: X bytes word number that results in this soundfolded word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 * stored as an offset to the previous number in as
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 * few bytes as possible, see offset2bytes())
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240 #include "vim.h"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242 #if defined(FEAT_SPELL) || defined(PROTO)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244 #ifndef UNIX /* it's in os_unix.h for Unix */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245 # include <time.h> /* for time_t */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 #ifndef UNIX /* it's in os_unix.h for Unix */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 # include <time.h> /* for time_t */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 /* Special byte values for <byte>. Some are only used in the tree for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253 * postponed prefixes, some only in the other trees. This is a bit messy... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254 #define BY_NOFLAGS 0 /* end of word without flags or region; for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 * postponed prefix: no <pflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256 #define BY_INDEX 1 /* child is shared, index follows */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257 #define BY_FLAGS 2 /* end of word, <flags> byte follows; for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
258 * postponed prefix: <pflags> follows */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
259 #define BY_FLAGS2 3 /* end of word, <flags> and <flags2> bytes
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260 * follow; never used in prefix tree */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 #define BY_SPECIAL BY_FLAGS2 /* highest special byte value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 /* Flags used in .spl file for soundsalike flags. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 #define SAL_F0LLOWUP 1
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 #define SAL_COLLAPSE 2
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 #define SAL_REM_ACCENTS 4
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 #define VIMSPELLMAGIC "VIMspell" /* string at start of Vim spell file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
269 #define VIMSPELLMAGICL 8
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
270 #define VIMSPELLVERSION 50
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272 /* Section IDs. Only renumber them when VIMSPELLVERSION changes! */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 #define SN_REGION 0 /* <regionname> section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
274 #define SN_CHARFLAGS 1 /* charflags section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
275 #define SN_MIDWORD 2 /* <midword> section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 #define SN_PREFCOND 3 /* <prefcond> section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 #define SN_REP 4 /* REP items section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278 #define SN_SAL 5 /* SAL items section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
279 #define SN_SOFO 6 /* soundfolding section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280 #define SN_MAP 7 /* MAP items section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281 #define SN_COMPOUND 8 /* compound words section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282 #define SN_SYLLABLE 9 /* syllable section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 #define SN_NOBREAK 10 /* NOBREAK section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
284 #define SN_SUGFILE 11 /* timestamp for .sug file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
285 #define SN_REPSAL 12 /* REPSAL items section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
286 #define SN_WORDS 13 /* common words */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
287 #define SN_NOSPLITSUGS 14 /* don't split word for suggestions */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
288 #define SN_INFO 15 /* info section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
289 #define SN_NOCOMPOUNDSUGS 16 /* don't compound for suggestions */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
290 #define SN_END 255 /* end of sections */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
291
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292 #define SNF_REQUIRED 1 /* <sectionflags>: required section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 #define CF_WORD 0x01
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295 #define CF_UPPER 0x02
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 static int set_spell_finish(spelltab_T *new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298 static int write_spell_prefcond(FILE *fd, garray_T *gap);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 static char_u *read_cnt_string(FILE *fd, int cnt_bytes, int *lenp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300 static int read_region_section(FILE *fd, slang_T *slang, int len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 static int read_charflags_section(FILE *fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 static int read_prefcond_section(FILE *fd, slang_T *lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 static int read_rep_section(FILE *fd, garray_T *gap, short *first);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304 static int read_sal_section(FILE *fd, slang_T *slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305 static int read_words_section(FILE *fd, slang_T *lp, int len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306 static int read_sofo_section(FILE *fd, slang_T *slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307 static int read_compound(FILE *fd, slang_T *slang, int len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
308 static int set_sofo(slang_T *lp, char_u *from, char_u *to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
309 static void set_sal_first(slang_T *lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 static int *mb_str2wide(char_u *s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
312 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 static int spell_read_tree(FILE *fd, char_u **bytsp, idx_T **idxsp, int prefixtree, int prefixcnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 static idx_T read_tree_node(FILE *fd, char_u *byts, idx_T *idxs, int maxidx, idx_T startidx, int prefixtree, int maxprefcondnr);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315 static void spell_reload_one(char_u *fname, int added_word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316 static void set_spell_charflags(char_u *flags, int cnt, char_u *upp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317 static int set_spell_chartab(char_u *fol, char_u *low, char_u *upp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318 static void set_map_str(slang_T *lp, char_u *map);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
320
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321 static char *e_spell_trunc = N_("E758: Truncated spell file");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322 static char *e_afftrailing = N_("Trailing text in %s line %d: %s");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323 static char *e_affname = N_("Affix name too long in %s line %d: %s");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 static char *e_affform = N_("E761: Format error in affix file FOL, LOW or UPP");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325 static char *e_affrange = N_("E762: Character in FOL, LOW or UPP is out of range");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326 static char *msg_compressing = N_("Compressing word tree...");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 * Load one spell file and store the info into a slang_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
331 * This is invoked in three ways:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332 * - From spell_load_cb() to load a spell file for the first time. "lang" is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333 * the language name, "old_lp" is NULL. Will allocate an slang_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334 * - To reload a spell file that was changed. "lang" is NULL and "old_lp"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335 * points to the existing slang_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 * - Just after writing a .spl file; it's read back to produce the .sug file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337 * "old_lp" is NULL and "lang" is NULL. Will allocate an slang_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
338 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
339 * Returns the slang_T the spell file was loaded into. NULL for error.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 slang_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 spell_load_file(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343 char_u *fname,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
344 char_u *lang,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 slang_T *old_lp,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 int silent) /* no error if file doesn't exist */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
347 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 char_u buf[VIMSPELLMAGICL];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 char_u *save_sourcing_name = sourcing_name;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 linenr_T save_sourcing_lnum = sourcing_lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 slang_T *lp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 int c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 int res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 if (!silent)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365 else if (p_verbose > 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
366 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 verbose_enter();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 smsg((char_u *)e_notopen, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 verbose_leave();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373 if (p_verbose > 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
374 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375 verbose_enter();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
376 smsg((char_u *)_("Reading spell file \"%s\""), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377 verbose_leave();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380 if (old_lp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 lp = slang_alloc(lang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383 if (lp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 /* Remember the file name, used to reload the file when it's updated. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387 lp->sl_fname = vim_strsave(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388 if (lp->sl_fname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
391 /* Check for .add.spl (_add.spl for VMS). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
392 lp->sl_add = strstr((char *)gettail(fname), SPL_FNAME_ADD) != NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395 lp = old_lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 /* Set sourcing_name, so that error messages mention the file name. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 sourcing_name = fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 sourcing_lnum = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 * <HEADER>: <fileID>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
404 for (i = 0; i < VIMSPELLMAGICL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 buf[i] = getc(fd); /* <fileID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 if (STRNCMP(buf, VIMSPELLMAGIC, VIMSPELLMAGICL) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 EMSG(_("E757: This does not look like a spell file"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
409 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
410 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
411 c = getc(fd); /* <versionnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412 if (c < VIMSPELLVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 EMSG(_("E771: Old spell file, needs to be updated"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417 else if (c > VIMSPELLVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
418 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 EMSG(_("E772: Spell file is for newer version of Vim"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
422
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 * <SECTIONS>: <section> ... <sectionend>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 * <section>: <sectionID> <sectionflags> <sectionlen> (section contents)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 for (;;)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
429 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430 n = getc(fd); /* <sectionID> or <sectionend> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431 if (n == SN_END)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
433 c = getc(fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
434 len = get4c(fd); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
435 if (len < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436 goto truncerr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
437
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
438 res = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439 switch (n)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
440 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441 case SN_INFO:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 lp->sl_info = read_string(fd, len); /* <infotext> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443 if (lp->sl_info == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447 case SN_REGION:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
448 res = read_region_section(fd, lp, len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
449 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
450
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
451 case SN_CHARFLAGS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
452 res = read_charflags_section(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
455 case SN_MIDWORD:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
456 lp->sl_midword = read_string(fd, len); /* <midword> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
457 if (lp->sl_midword == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
461 case SN_PREFCOND:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
462 res = read_prefcond_section(fd, lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
463 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
464
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
465 case SN_REP:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
466 res = read_rep_section(fd, &lp->sl_rep, lp->sl_rep_first);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
467 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
468
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469 case SN_REPSAL:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470 res = read_rep_section(fd, &lp->sl_repsal, lp->sl_repsal_first);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
472
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
473 case SN_SAL:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
474 res = read_sal_section(fd, lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
475 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477 case SN_SOFO:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 res = read_sofo_section(fd, lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
481 case SN_MAP:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
482 p = read_string(fd, len); /* <mapstr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
483 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
485 set_map_str(lp, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486 vim_free(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
488
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
489 case SN_WORDS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
490 res = read_words_section(fd, lp, len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
491 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
493 case SN_SUGFILE:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494 lp->sl_sugtime = get8ctime(fd); /* <timestamp> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
495 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
496
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
497 case SN_NOSPLITSUGS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
498 lp->sl_nosplitsugs = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
499 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
500
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
501 case SN_NOCOMPOUNDSUGS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
502 lp->sl_nocompoundsugs = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
503 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
504
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
505 case SN_COMPOUND:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
506 res = read_compound(fd, lp, len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
507 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
508
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
509 case SN_NOBREAK:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
510 lp->sl_nobreak = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
511 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
512
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
513 case SN_SYLLABLE:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
514 lp->sl_syllable = read_string(fd, len); /* <syllable> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
515 if (lp->sl_syllable == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
516 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
517 if (init_syl_tab(lp) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
518 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
519 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
520
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
521 default:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
522 /* Unsupported section. When it's required give an error
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
523 * message. When it's not required skip the contents. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
524 if (c & SNF_REQUIRED)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
525 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
526 EMSG(_("E770: Unsupported section in spell file"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
527 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529 while (--len >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530 if (getc(fd) < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531 goto truncerr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
533 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534 someerror:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
535 if (res == SP_FORMERROR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
536 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
537 EMSG(_(e_format));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
538 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
539 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
540 if (res == SP_TRUNCERROR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
541 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
542 truncerr:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
543 EMSG(_(e_spell_trunc));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546 if (res == SP_OTHERERROR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
547 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
548 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
549
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
550 /* <LWORDTREE> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
551 res = spell_read_tree(fd, &lp->sl_fbyts, &lp->sl_fidxs, FALSE, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552 if (res != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
554
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555 /* <KWORDTREE> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
556 res = spell_read_tree(fd, &lp->sl_kbyts, &lp->sl_kidxs, FALSE, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
557 if (res != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
558 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
559
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
560 /* <PREFIXTREE> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
561 res = spell_read_tree(fd, &lp->sl_pbyts, &lp->sl_pidxs, TRUE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
562 lp->sl_prefixcnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
563 if (res != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
564 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
565
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
566 /* For a new file link it in the list of spell files. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
567 if (old_lp == NULL && lang != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
568 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
569 lp->sl_next = first_lang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
570 first_lang = lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
571 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
572
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573 goto endOK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
574
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 endFAIL:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
576 if (lang != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577 /* truncating the name signals the error to spell_load_lang() */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 *lang = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579 if (lp != NULL && old_lp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
580 slang_free(lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
581 lp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583 endOK:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
585 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
586 sourcing_name = save_sourcing_name;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
587 sourcing_lnum = save_sourcing_lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
588
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
589 return lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
590 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
591
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
592 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593 * Fill in the wordcount fields for a trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
594 * Returns the total number of words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
596 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
597 tree_count_words(char_u *byts, idx_T *idxs)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
598 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
599 int depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
600 idx_T arridx[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
601 int curi[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
602 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603 idx_T n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
604 int wordcount[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
605
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 arridx[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607 curi[0] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608 wordcount[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609 depth = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 while (depth >= 0 && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612 if (curi[depth] > byts[arridx[depth]])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
613 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
614 /* Done all bytes at this node, go up one level. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
615 idxs[arridx[depth]] = wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
616 if (depth > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
617 wordcount[depth - 1] += wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
618
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
619 --depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
620 fast_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
621 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
622 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
623 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
624 /* Do one more byte at this node. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
625 n = arridx[depth] + curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
626 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
627
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
628 c = byts[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629 if (c == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
631 /* End of word, count it. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
632 ++wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
633
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
634 /* Skip over any other NUL bytes (same word with different
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
635 * flags). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
636 while (byts[n + 1] == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
637 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
638 ++n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
639 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
640 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
641 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
642 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
643 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
644 /* Normal char, go one level deeper to count the words. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
645 ++depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
646 arridx[depth] = idxs[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
647 curi[depth] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
648 wordcount[depth] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
649 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
650 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
651 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
652 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
653
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
654 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
655 * Load the .sug files for languages that have one and weren't loaded yet.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
656 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
657 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
658 suggest_load_files(void)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
659 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
660 langp_T *lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
661 int lpi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
662 slang_T *slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
663 char_u *dotp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
664 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
665 char_u buf[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
666 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
667 time_t timestamp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
668 int wcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
669 int wordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
670 garray_T ga;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
671 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
672
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
673 /* Do this for all languages that support sound folding. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
674 for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
675 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
676 lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
677 slang = lp->lp_slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
678 if (slang->sl_sugtime != 0 && !slang->sl_sugloaded)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
679 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
680 /* Change ".spl" to ".sug" and open the file. When the file isn't
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
681 * found silently skip it. Do set "sl_sugloaded" so that we
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
682 * don't try again and again. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
683 slang->sl_sugloaded = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
684
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
685 dotp = vim_strrchr(slang->sl_fname, '.');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
686 if (dotp == NULL || fnamecmp(dotp, ".spl") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
687 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
688 STRCPY(dotp, ".sug");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
689 fd = mch_fopen((char *)slang->sl_fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
690 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
691 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
692
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
693 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
694 * <SUGHEADER>: <fileID> <versionnr> <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
695 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
696 for (i = 0; i < VIMSUGMAGICL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
697 buf[i] = getc(fd); /* <fileID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
698 if (STRNCMP(buf, VIMSUGMAGIC, VIMSUGMAGICL) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
699 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
700 EMSG2(_("E778: This does not look like a .sug file: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
701 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
702 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
703 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
704 c = getc(fd); /* <versionnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
705 if (c < VIMSUGVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
706 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
707 EMSG2(_("E779: Old .sug file, needs to be updated: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
708 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
709 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
710 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
711 else if (c > VIMSUGVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
712 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
713 EMSG2(_("E780: .sug file is for newer version of Vim: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
715 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
716 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
717
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
718 /* Check the timestamp, it must be exactly the same as the one in
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
719 * the .spl file. Otherwise the word numbers won't match. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
720 timestamp = get8ctime(fd); /* <timestamp> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
721 if (timestamp != slang->sl_sugtime)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
722 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
723 EMSG2(_("E781: .sug file doesn't match .spl file: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
724 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
725 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
726 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
727
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
728 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
729 * <SUGWORDTREE>: <wordtree>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
730 * Read the trie with the soundfolded words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
731 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
732 if (spell_read_tree(fd, &slang->sl_sbyts, &slang->sl_sidxs,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
733 FALSE, 0) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
734 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
735 someerror:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
736 EMSG2(_("E782: error while reading .sug file: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
737 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
738 slang_clear_sug(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
739 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
740 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
741
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
742 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
743 * <SUGTABLE>: <sugwcount> <sugline> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
744 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
745 * Read the table with word numbers. We use a file buffer for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
746 * this, because it's so much like a file with lines. Makes it
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
747 * possible to swap the info and save on memory use.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
748 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
749 slang->sl_sugbuf = open_spellbuf();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
750 if (slang->sl_sugbuf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
751 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
752 /* <sugwcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
753 wcount = get4c(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
754 if (wcount < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
755 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
757 /* Read all the wordnr lists into the buffer, one NUL terminated
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
758 * list per line. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
759 ga_init2(&ga, 1, 100);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
760 for (wordnr = 0; wordnr < wcount; ++wordnr)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
761 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
762 ga.ga_len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
763 for (;;)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
764 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
765 c = getc(fd); /* <sugline> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
766 if (c < 0 || ga_grow(&ga, 1) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
767 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
768 ((char_u *)ga.ga_data)[ga.ga_len++] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
769 if (c == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
770 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
771 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
772 if (ml_append_buf(slang->sl_sugbuf, (linenr_T)wordnr,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
773 ga.ga_data, ga.ga_len, TRUE) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
774 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
775 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
776 ga_clear(&ga);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
777
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
778 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
779 * Need to put word counts in the word tries, so that we can find
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
780 * a word by its number.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
781 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
782 tree_count_words(slang->sl_fbyts, slang->sl_fidxs);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
783 tree_count_words(slang->sl_sbyts, slang->sl_sidxs);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
784
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
785 nextone:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
786 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
787 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
788 STRCPY(dotp, ".spl");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
789 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
790 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
791 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
792
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
793
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
794 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
795 * Read a length field from "fd" in "cnt_bytes" bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
796 * Allocate memory, read the string into it and add a NUL at the end.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
797 * Returns NULL when the count is zero.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
798 * Sets "*cntp" to SP_*ERROR when there is an error, length of the result
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
799 * otherwise.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
800 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
801 static char_u *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
802 read_cnt_string(FILE *fd, int cnt_bytes, int *cntp)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
803 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
804 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
805 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
806 char_u *str;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
807
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
808 /* read the length bytes, MSB first */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
809 for (i = 0; i < cnt_bytes; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
810 cnt = (cnt << 8) + getc(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
811 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
812 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
813 *cntp = SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
814 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
815 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
816 *cntp = cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
817 if (cnt == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
818 return NULL; /* nothing to read, return NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
819
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
820 str = read_string(fd, cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
821 if (str == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
822 *cntp = SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
823 return str;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
824 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
825
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
826 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
827 * Read SN_REGION: <regionname> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
828 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
829 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
830 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
831 read_region_section(FILE *fd, slang_T *lp, int len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
832 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
833 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
834
13232
d11bbd3440b0 patch 8.0.1490: number of spell regions is spread out through the code
Christian Brabandt <cb@256bit.org>
parents: 12694
diff changeset
835 if (len > MAXREGIONS * 2)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
836 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
837 for (i = 0; i < len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
838 lp->sl_regions[i] = getc(fd); /* <regionname> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
839 lp->sl_regions[len] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
840 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
841 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
842
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
843 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
844 * Read SN_CHARFLAGS section: <charflagslen> <charflags>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
845 * <folcharslen> <folchars>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
846 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
847 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
848 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
849 read_charflags_section(FILE *fd)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
850 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
851 char_u *flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
852 char_u *fol;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
853 int flagslen, follen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
854
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
855 /* <charflagslen> <charflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
856 flags = read_cnt_string(fd, 1, &flagslen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
857 if (flagslen < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
858 return flagslen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
859
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
860 /* <folcharslen> <folchars> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
861 fol = read_cnt_string(fd, 2, &follen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
862 if (follen < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
863 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
864 vim_free(flags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
865 return follen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
866 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
867
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
868 /* Set the word-char flags and fill SPELL_ISUPPER() table. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
869 if (flags != NULL && fol != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
870 set_spell_charflags(flags, flagslen, fol);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
871
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
872 vim_free(flags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
873 vim_free(fol);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
874
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
875 /* When <charflagslen> is zero then <fcharlen> must also be zero. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
876 if ((flags == NULL) != (fol == NULL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
877 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
878 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
879 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
880
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
881 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
882 * Read SN_PREFCOND section.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
883 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
884 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
885 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
886 read_prefcond_section(FILE *fd, slang_T *lp)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
887 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
888 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
889 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
890 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
891 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
892 char_u buf[MAXWLEN + 1];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
893
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
894 /* <prefcondcnt> <prefcond> ... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
895 cnt = get2c(fd); /* <prefcondcnt> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
896 if (cnt <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
897 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
898
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
899 lp->sl_prefprog = (regprog_T **)alloc_clear(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
900 (unsigned)sizeof(regprog_T *) * cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
901 if (lp->sl_prefprog == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
902 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
903 lp->sl_prefixcnt = cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
904
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
905 for (i = 0; i < cnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
906 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
907 /* <prefcond> : <condlen> <condstr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
908 n = getc(fd); /* <condlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
909 if (n < 0 || n >= MAXWLEN)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
910 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
911
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
912 /* When <condlen> is zero we have an empty condition. Otherwise
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
913 * compile the regexp program used to check for the condition. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
914 if (n > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
915 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
916 buf[0] = '^'; /* always match at one position only */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
917 p = buf + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
918 while (n-- > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
919 *p++ = getc(fd); /* <condstr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
920 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
921 lp->sl_prefprog[i] = vim_regcomp(buf, RE_MAGIC + RE_STRING);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
922 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
923 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
924 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
925 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
926
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
927 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
928 * Read REP or REPSAL items section from "fd": <repcount> <rep> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
929 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
930 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
931 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
932 read_rep_section(FILE *fd, garray_T *gap, short *first)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
933 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
934 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
935 fromto_T *ftp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
936 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
937
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
938 cnt = get2c(fd); /* <repcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
939 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
940 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
941
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
942 if (ga_grow(gap, cnt) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
943 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
944
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
945 /* <rep> : <repfromlen> <repfrom> <reptolen> <repto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
946 for (; gap->ga_len < cnt; ++gap->ga_len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
947 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
948 ftp = &((fromto_T *)gap->ga_data)[gap->ga_len];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
949 ftp->ft_from = read_cnt_string(fd, 1, &i);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
950 if (i < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
951 return i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
952 if (i == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
953 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
954 ftp->ft_to = read_cnt_string(fd, 1, &i);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
955 if (i <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
956 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
957 vim_free(ftp->ft_from);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
958 if (i < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
959 return i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
960 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
961 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
962 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
963
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
964 /* Fill the first-index table. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
965 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
966 first[i] = -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
967 for (i = 0; i < gap->ga_len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
968 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
969 ftp = &((fromto_T *)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
970 if (first[*ftp->ft_from] == -1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
971 first[*ftp->ft_from] = i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
972 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
973 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
974 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
975
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
976 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
977 * Read SN_SAL section: <salflags> <salcount> <sal> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
978 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
979 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
980 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
981 read_sal_section(FILE *fd, slang_T *slang)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
982 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
983 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
984 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
985 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
986 salitem_T *smp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
987 int ccnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
988 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
989 int c = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
990
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
991 slang->sl_sofo = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
992
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
993 i = getc(fd); /* <salflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
994 if (i & SAL_F0LLOWUP)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
995 slang->sl_followup = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
996 if (i & SAL_COLLAPSE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
997 slang->sl_collapse = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
998 if (i & SAL_REM_ACCENTS)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
999 slang->sl_rem_accents = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1000
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1001 cnt = get2c(fd); /* <salcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1002 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1003 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1004
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1005 gap = &slang->sl_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1006 ga_init2(gap, sizeof(salitem_T), 10);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1007 if (ga_grow(gap, cnt + 1) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1008 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1009
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1010 /* <sal> : <salfromlen> <salfrom> <saltolen> <salto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1011 for (; gap->ga_len < cnt; ++gap->ga_len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1012 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1013 smp = &((salitem_T *)gap->ga_data)[gap->ga_len];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1014 ccnt = getc(fd); /* <salfromlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1015 if (ccnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1016 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1017 if ((p = alloc(ccnt + 2)) == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1018 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1019 smp->sm_lead = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1020
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1021 /* Read up to the first special char into sm_lead. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1022 for (i = 0; i < ccnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1023 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1024 c = getc(fd); /* <salfrom> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1025 if (vim_strchr((char_u *)"0123456789(-<^$", c) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1026 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1027 *p++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1028 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1029 smp->sm_leadlen = (int)(p - smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1030 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1031
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1032 /* Put (abc) chars in sm_oneof, if any. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1033 if (c == '(')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1034 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1035 smp->sm_oneof = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1036 for (++i; i < ccnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1037 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1038 c = getc(fd); /* <salfrom> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1039 if (c == ')')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1040 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1041 *p++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1042 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1043 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1044 if (++i < ccnt)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1045 c = getc(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1046 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1047 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1048 smp->sm_oneof = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1049
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1050 /* Any following chars go in sm_rules. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1051 smp->sm_rules = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1052 if (i < ccnt)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1053 /* store the char we got while checking for end of sm_lead */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1054 *p++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1055 for (++i; i < ccnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1056 *p++ = getc(fd); /* <salfrom> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1057 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1058
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1059 /* <saltolen> <salto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1060 smp->sm_to = read_cnt_string(fd, 1, &ccnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1061 if (ccnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1062 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1063 vim_free(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1064 return ccnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1065 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1066
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1067 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1068 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1069 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1070 /* convert the multi-byte strings to wide char strings */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1071 smp->sm_lead_w = mb_str2wide(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1072 smp->sm_leadlen = mb_charlen(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1073 if (smp->sm_oneof == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1074 smp->sm_oneof_w = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1075 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1076 smp->sm_oneof_w = mb_str2wide(smp->sm_oneof);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1077 if (smp->sm_to == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1078 smp->sm_to_w = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1079 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1080 smp->sm_to_w = mb_str2wide(smp->sm_to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1081 if (smp->sm_lead_w == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1082 || (smp->sm_oneof_w == NULL && smp->sm_oneof != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1083 || (smp->sm_to_w == NULL && smp->sm_to != NULL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1084 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1085 vim_free(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1086 vim_free(smp->sm_to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1087 vim_free(smp->sm_lead_w);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1088 vim_free(smp->sm_oneof_w);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1089 vim_free(smp->sm_to_w);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1090 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1091 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1092 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1093 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1094 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1095
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1096 if (gap->ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1097 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1098 /* Add one extra entry to mark the end with an empty sm_lead. Avoids
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1099 * that we need to check the index every time. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1100 smp = &((salitem_T *)gap->ga_data)[gap->ga_len];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1101 if ((p = alloc(1)) == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1102 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1103 p[0] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1104 smp->sm_lead = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1105 smp->sm_leadlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1106 smp->sm_oneof = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1107 smp->sm_rules = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1108 smp->sm_to = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1109 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1110 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1111 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1112 smp->sm_lead_w = mb_str2wide(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1113 smp->sm_leadlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1114 smp->sm_oneof_w = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1115 smp->sm_to_w = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1116 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1117 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1118 ++gap->ga_len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1119 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1120
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1121 /* Fill the first-index table. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1122 set_sal_first(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1123
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1124 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1125 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1126
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1127 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1128 * Read SN_WORDS: <word> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1129 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1130 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1131 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1132 read_words_section(FILE *fd, slang_T *lp, int len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1133 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1134 int done = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1135 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1136 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1137 char_u word[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1138
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1139 while (done < len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1140 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1141 /* Read one word at a time. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1142 for (i = 0; ; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1143 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1144 c = getc(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1145 if (c == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1146 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1147 word[i] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1148 if (word[i] == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1149 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1150 if (i == MAXWLEN - 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1151 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1152 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1153
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1154 /* Init the count to 10. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1155 count_common_word(lp, word, -1, 10);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1156 done += i + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1157 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1158 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1159 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1160
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1161 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1162 * SN_SOFO: <sofofromlen> <sofofrom> <sofotolen> <sofoto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1163 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1164 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1165 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1166 read_sofo_section(FILE *fd, slang_T *slang)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1167 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1168 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1169 char_u *from, *to;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1170 int res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1171
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1172 slang->sl_sofo = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1173
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1174 /* <sofofromlen> <sofofrom> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1175 from = read_cnt_string(fd, 2, &cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1176 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1177 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1178
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1179 /* <sofotolen> <sofoto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1180 to = read_cnt_string(fd, 2, &cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1181 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1182 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1183 vim_free(from);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1184 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1185 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1186
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1187 /* Store the info in slang->sl_sal and/or slang->sl_sal_first. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1188 if (from != NULL && to != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1189 res = set_sofo(slang, from, to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1190 else if (from != NULL || to != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1191 res = SP_FORMERROR; /* only one of two strings is an error */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1192 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1193 res = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1194
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1195 vim_free(from);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1196 vim_free(to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1197 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1198 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1199
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1200 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1201 * Read the compound section from the .spl file:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1202 * <compmax> <compminlen> <compsylmax> <compoptions> <compflags>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1203 * Returns SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1204 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1205 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1206 read_compound(FILE *fd, slang_T *slang, int len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1207 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1208 int todo = len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1209 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1210 int atstart;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1211 char_u *pat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1212 char_u *pp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1213 char_u *cp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1214 char_u *ap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1215 char_u *crp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1216 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1217 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1218
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1219 if (todo < 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1220 return SP_FORMERROR; /* need at least two bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1221
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1222 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1223 c = getc(fd); /* <compmax> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1224 if (c < 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1225 c = MAXWLEN;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1226 slang->sl_compmax = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1227
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1228 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1229 c = getc(fd); /* <compminlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1230 if (c < 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1231 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1232 slang->sl_compminlen = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1233
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1234 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1235 c = getc(fd); /* <compsylmax> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1236 if (c < 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1237 c = MAXWLEN;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1238 slang->sl_compsylmax = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1239
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1240 c = getc(fd); /* <compoptions> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1241 if (c != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1242 ungetc(c, fd); /* be backwards compatible with Vim 7.0b */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1243 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1244 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1245 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1246 c = getc(fd); /* only use the lower byte for now */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1247 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1248 slang->sl_compoptions = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1249
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1250 gap = &slang->sl_comppat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1251 c = get2c(fd); /* <comppatcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1252 todo -= 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1253 ga_init2(gap, sizeof(char_u *), c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1254 if (ga_grow(gap, c) == OK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1255 while (--c >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1256 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1257 ((char_u **)(gap->ga_data))[gap->ga_len++] =
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1258 read_cnt_string(fd, 1, &cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1259 /* <comppatlen> <comppattext> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1260 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1261 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1262 todo -= cnt + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1263 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1264 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1265 if (todo < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1266 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1267
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1268 /* Turn the COMPOUNDRULE items into a regexp pattern:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1269 * "a[bc]/a*b+" -> "^\(a[bc]\|a*b\+\)$".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1270 * Inserting backslashes may double the length, "^\(\)$<Nul>" is 7 bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1271 * Conversion to utf-8 may double the size. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1272 c = todo * 2 + 7;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1273 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1274 if (enc_utf8)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1275 c += todo * 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1276 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1277 pat = alloc((unsigned)c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1278 if (pat == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1279 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1280
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1281 /* We also need a list of all flags that can appear at the start and one
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1282 * for all flags. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1283 cp = alloc(todo + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1284 if (cp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1285 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1286 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1287 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1288 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1289 slang->sl_compstartflags = cp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1290 *cp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1291
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1292 ap = alloc(todo + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1293 if (ap == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1294 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1295 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1296 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1297 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1298 slang->sl_compallflags = ap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1299 *ap = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1300
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1301 /* And a list of all patterns in their original form, for checking whether
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1302 * compounding may work in match_compoundrule(). This is freed when we
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1303 * encounter a wildcard, the check doesn't work then. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1304 crp = alloc(todo + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1305 slang->sl_comprules = crp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1306
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1307 pp = pat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1308 *pp++ = '^';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1309 *pp++ = '\\';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1310 *pp++ = '(';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1311
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1312 atstart = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1313 while (todo-- > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1314 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1315 c = getc(fd); /* <compflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1316 if (c == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1317 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1318 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1319 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1320 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1321
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1322 /* Add all flags to "sl_compallflags". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1323 if (vim_strchr((char_u *)"?*+[]/", c) == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1324 && !byte_in_str(slang->sl_compallflags, c))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1325 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1326 *ap++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1327 *ap = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1328 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1329
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1330 if (atstart != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1331 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1332 /* At start of item: copy flags to "sl_compstartflags". For a
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1333 * [abc] item set "atstart" to 2 and copy up to the ']'. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1334 if (c == '[')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1335 atstart = 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1336 else if (c == ']')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1337 atstart = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1338 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1339 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1340 if (!byte_in_str(slang->sl_compstartflags, c))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1341 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1342 *cp++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1343 *cp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1344 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1345 if (atstart == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1346 atstart = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1347 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1348 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1349
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1350 /* Copy flag to "sl_comprules", unless we run into a wildcard. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1351 if (crp != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1352 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1353 if (c == '?' || c == '+' || c == '*')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1354 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1355 vim_free(slang->sl_comprules);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1356 slang->sl_comprules = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1357 crp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1358 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1359 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1360 *crp++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1361 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1362
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1363 if (c == '/') /* slash separates two items */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1364 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1365 *pp++ = '\\';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1366 *pp++ = '|';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1367 atstart = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1368 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1369 else /* normal char, "[abc]" and '*' are copied as-is */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1370 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1371 if (c == '?' || c == '+' || c == '~')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1372 *pp++ = '\\'; /* "a?" becomes "a\?", "a+" becomes "a\+" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1373 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1374 if (enc_utf8)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1375 pp += mb_char2bytes(c, pp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1376 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1377 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1378 *pp++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1379 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1380 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1381
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1382 *pp++ = '\\';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1383 *pp++ = ')';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1384 *pp++ = '$';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1385 *pp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1386
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1387 if (crp != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1388 *crp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1389
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1390 slang->sl_compprog = vim_regcomp(pat, RE_MAGIC + RE_STRING + RE_STRICT);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1391 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1392 if (slang->sl_compprog == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1393 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1394
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1395 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1396 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1397
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1398 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1399 * Set the SOFOFROM and SOFOTO items in language "lp".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1400 * Returns SP_*ERROR flags when there is something wrong.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1401 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1402 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1403 set_sofo(slang_T *lp, char_u *from, char_u *to)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1404 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1405 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1406
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1407 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1408 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1409 char_u *s;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1410 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1411 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1412 int *inp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1413
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1414 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1415 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1416 /* Use "sl_sal" as an array with 256 pointers to a list of wide
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1417 * characters. The index is the low byte of the character.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1418 * The list contains from-to pairs with a terminating NUL.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1419 * sl_sal_first[] is used for latin1 "from" characters. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1420 gap = &lp->sl_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1421 ga_init2(gap, sizeof(int *), 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1422 if (ga_grow(gap, 256) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1423 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1424 vim_memset(gap->ga_data, 0, sizeof(int *) * 256);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1425 gap->ga_len = 256;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1426
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1427 /* First count the number of items for each list. Temporarily use
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1428 * sl_sal_first[] for this. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1429 for (p = from, s = to; *p != NUL && *s != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1430 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1431 c = mb_cptr2char_adv(&p);
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10974
diff changeset
1432 MB_CPTR_ADV(s);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1433 if (c >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1434 ++lp->sl_sal_first[c & 0xff];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1435 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1436 if (*p != NUL || *s != NUL) /* lengths differ */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1437 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1438
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1439 /* Allocate the lists. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1440 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1441 if (lp->sl_sal_first[i] > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1442 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1443 p = alloc(sizeof(int) * (lp->sl_sal_first[i] * 2 + 1));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1444 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1445 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1446 ((int **)gap->ga_data)[i] = (int *)p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1447 *(int *)p = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1448 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1449
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1450 /* Put the characters up to 255 in sl_sal_first[] the rest in a sl_sal
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1451 * list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1452 vim_memset(lp->sl_sal_first, 0, sizeof(salfirst_T) * 256);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1453 for (p = from, s = to; *p != NUL && *s != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1454 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1455 c = mb_cptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1456 i = mb_cptr2char_adv(&s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1457 if (c >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1458 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1459 /* Append the from-to chars at the end of the list with
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1460 * the low byte. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1461 inp = ((int **)gap->ga_data)[c & 0xff];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1462 while (*inp != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1463 ++inp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1464 *inp++ = c; /* from char */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1465 *inp++ = i; /* to char */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1466 *inp++ = NUL; /* NUL at the end */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1467 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1468 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1469 /* mapping byte to char is done in sl_sal_first[] */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1470 lp->sl_sal_first[c] = i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1471 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1472 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1473 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1474 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1475 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1476 /* mapping bytes to bytes is done in sl_sal_first[] */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1477 if (STRLEN(from) != STRLEN(to))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1478 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1479
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1480 for (i = 0; to[i] != NUL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1481 lp->sl_sal_first[from[i]] = to[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1482 lp->sl_sal.ga_len = 1; /* indicates we have soundfolding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1483 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1484
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1485 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1486 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1487
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1488 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1489 * Fill the first-index table for "lp".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1490 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1491 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1492 set_sal_first(slang_T *lp)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1493 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1494 salfirst_T *sfirst;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1495 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1496 salitem_T *smp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1497 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1498 garray_T *gap = &lp->sl_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1499
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1500 sfirst = lp->sl_sal_first;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1501 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1502 sfirst[i] = -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1503 smp = (salitem_T *)gap->ga_data;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1504 for (i = 0; i < gap->ga_len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1505 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1506 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1507 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1508 /* Use the lowest byte of the first character. For latin1 it's
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1509 * the character, for other encodings it should differ for most
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1510 * characters. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1511 c = *smp[i].sm_lead_w & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1512 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1513 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1514 c = *smp[i].sm_lead;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1515 if (sfirst[c] == -1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1516 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1517 sfirst[c] = i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1518 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1519 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1520 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1521 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1522
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1523 /* Make sure all entries with this byte are following each
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1524 * other. Move the ones that are in the wrong position. Do
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1525 * keep the same ordering! */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1526 while (i + 1 < gap->ga_len
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1527 && (*smp[i + 1].sm_lead_w & 0xff) == c)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1528 /* Skip over entry with same index byte. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1529 ++i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1530
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1531 for (n = 1; i + n < gap->ga_len; ++n)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1532 if ((*smp[i + n].sm_lead_w & 0xff) == c)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1533 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1534 salitem_T tsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1535
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1536 /* Move entry with same index byte after the entries
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1537 * we already found. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1538 ++i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1539 --n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1540 tsal = smp[i + n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1541 mch_memmove(smp + i + 1, smp + i,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1542 sizeof(salitem_T) * n);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1543 smp[i] = tsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1544 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1545 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1546 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1547 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1548 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1549 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1550
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1551 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1552 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1553 * Turn a multi-byte string into a wide character string.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1554 * Return it in allocated memory (NULL for out-of-memory)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1555 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1556 static int *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1557 mb_str2wide(char_u *s)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1558 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1559 int *res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1560 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1561 int i = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1562
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1563 res = (int *)alloc(sizeof(int) * (mb_charlen(s) + 1));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1564 if (res != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1565 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1566 for (p = s; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1567 res[i++] = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1568 res[i] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1569 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1570 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1571 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1572 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1573
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1574 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1575 * Read a tree from the .spl or .sug file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1576 * Allocates the memory and stores pointers in "bytsp" and "idxsp".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1577 * This is skipped when the tree has zero length.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1578 * Returns zero when OK, SP_ value for an error.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1579 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1580 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1581 spell_read_tree(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1582 FILE *fd,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1583 char_u **bytsp,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1584 idx_T **idxsp,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1585 int prefixtree, /* TRUE for the prefix tree */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1586 int prefixcnt) /* when "prefixtree" is TRUE: prefix count */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1587 {
10974
7d735b86f764 patch 8.0.0376: size computations in spell file reading are off
Christian Brabandt <cb@256bit.org>
parents: 10865
diff changeset
1588 long len;
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1589 int idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1590 char_u *bp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1591 idx_T *ip;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1592
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1593 /* The tree size was computed when writing the file, so that we can
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1594 * allocate it as one long block. <nodecount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1595 len = get4c(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1596 if (len < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1597 return SP_TRUNCERROR;
10974
7d735b86f764 patch 8.0.0376: size computations in spell file reading are off
Christian Brabandt <cb@256bit.org>
parents: 10865
diff changeset
1598 if (len >= LONG_MAX / (long)sizeof(int))
10865
1a18c0f93ffa patch 8.0.0322: possible overflow with corrupted spell file
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1599 /* Invalid length, multiply with sizeof(int) would overflow. */
1a18c0f93ffa patch 8.0.0322: possible overflow with corrupted spell file
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1600 return SP_FORMERROR;
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1601 if (len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1602 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1603 /* Allocate the byte array. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1604 bp = lalloc((long_u)len, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1605 if (bp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1606 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1607 *bytsp = bp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1608
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1609 /* Allocate the index array. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1610 ip = (idx_T *)lalloc_clear((long_u)(len * sizeof(int)), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1611 if (ip == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1612 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1613 *idxsp = ip;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1614
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1615 /* Recursively read the tree and store it in the array. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1616 idx = read_tree_node(fd, bp, ip, len, 0, prefixtree, prefixcnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1617 if (idx < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1618 return idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1619 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1620 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1621 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1622
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1623 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1624 * Read one row of siblings from the spell file and store it in the byte array
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1625 * "byts" and index array "idxs". Recursively read the children.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1626 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1627 * NOTE: The code here must match put_node()!
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1628 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1629 * Returns the index (>= 0) following the siblings.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1630 * Returns SP_TRUNCERROR if the file is shorter than expected.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1631 * Returns SP_FORMERROR if there is a format error.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1632 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1633 static idx_T
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1634 read_tree_node(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1635 FILE *fd,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1636 char_u *byts,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1637 idx_T *idxs,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1638 int maxidx, /* size of arrays */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1639 idx_T startidx, /* current index in "byts" and "idxs" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1640 int prefixtree, /* TRUE for reading PREFIXTREE */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1641 int maxprefcondnr) /* maximum for <prefcondnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1642 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1643 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1644 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1645 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1646 idx_T idx = startidx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1647 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1648 int c2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1649 #define SHARED_MASK 0x8000000
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1650
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1651 len = getc(fd); /* <siblingcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1652 if (len <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1653 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1654
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1655 if (startidx + len >= maxidx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1656 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1657 byts[idx++] = len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1658
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1659 /* Read the byte values, flag/region bytes and shared indexes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1660 for (i = 1; i <= len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1661 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1662 c = getc(fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1663 if (c < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1664 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1665 if (c <= BY_SPECIAL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1666 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1667 if (c == BY_NOFLAGS && !prefixtree)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1668 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1669 /* No flags, all regions. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1670 idxs[idx] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1671 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1672 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1673 else if (c != BY_INDEX)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1674 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1675 if (prefixtree)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1676 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1677 /* Read the optional pflags byte, the prefix ID and the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1678 * condition nr. In idxs[] store the prefix ID in the low
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1679 * byte, the condition index shifted up 8 bits, the flags
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1680 * shifted up 24 bits. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1681 if (c == BY_FLAGS)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1682 c = getc(fd) << 24; /* <pflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1683 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1684 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1685
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1686 c |= getc(fd); /* <affixID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1687
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1688 n = get2c(fd); /* <prefcondnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1689 if (n >= maxprefcondnr)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1690 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1691 c |= (n << 8);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1692 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1693 else /* c must be BY_FLAGS or BY_FLAGS2 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1694 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1695 /* Read flags and optional region and prefix ID. In
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1696 * idxs[] the flags go in the low two bytes, region above
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1697 * that and prefix ID above the region. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1698 c2 = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1699 c = getc(fd); /* <flags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1700 if (c2 == BY_FLAGS2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1701 c = (getc(fd) << 8) + c; /* <flags2> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1702 if (c & WF_REGION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1703 c = (getc(fd) << 16) + c; /* <region> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1704 if (c & WF_AFX)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1705 c = (getc(fd) << 24) + c; /* <affixID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1706 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1707
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1708 idxs[idx] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1709 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1710 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1711 else /* c == BY_INDEX */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1712 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1713 /* <nodeidx> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1714 n = get3c(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1715 if (n < 0 || n >= maxidx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1716 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1717 idxs[idx] = n + SHARED_MASK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1718 c = getc(fd); /* <xbyte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1719 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1720 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1721 byts[idx++] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1722 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1723
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1724 /* Recursively read the children for non-shared siblings.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1725 * Skip the end-of-word ones (zero byte value) and the shared ones (and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1726 * remove SHARED_MASK) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1727 for (i = 1; i <= len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1728 if (byts[startidx + i] != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1729 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1730 if (idxs[startidx + i] & SHARED_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1731 idxs[startidx + i] &= ~SHARED_MASK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1732 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1733 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1734 idxs[startidx + i] = idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1735 idx = read_tree_node(fd, byts, idxs, maxidx, idx,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1736 prefixtree, maxprefcondnr);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1737 if (idx < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1738 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1739 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1740 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1741
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1742 return idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1743 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1744
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1745 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1746 * Reload the spell file "fname" if it's loaded.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1747 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1748 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1749 spell_reload_one(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1750 char_u *fname,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1751 int added_word) /* invoked through "zg" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1752 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1753 slang_T *slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1754 int didit = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1755
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1756 for (slang = first_lang; slang != NULL; slang = slang->sl_next)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1757 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1758 if (fullpathcmp(fname, slang->sl_fname, FALSE) == FPC_SAME)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1759 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1760 slang_clear(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1761 if (spell_load_file(fname, NULL, slang, FALSE) == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1762 /* reloading failed, clear the language */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1763 slang_clear(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1764 redraw_all_later(SOME_VALID);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1765 didit = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1766 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1767 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1768
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1769 /* When "zg" was used and the file wasn't loaded yet, should redo
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1770 * 'spelllang' to load it now. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1771 if (added_word && !didit)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1772 did_set_spelllang(curwin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1773 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1774
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1775
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1776 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1777 * Functions for ":mkspell".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1778 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1779
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1780 #define MAXLINELEN 500 /* Maximum length in bytes of a line in a .aff
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1781 and .dic file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1782 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1783 * Main structure to store the contents of a ".aff" file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1784 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1785 typedef struct afffile_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1786 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1787 char_u *af_enc; /* "SET", normalized, alloc'ed string or NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1788 int af_flagtype; /* AFT_CHAR, AFT_LONG, AFT_NUM or AFT_CAPLONG */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1789 unsigned af_rare; /* RARE ID for rare word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1790 unsigned af_keepcase; /* KEEPCASE ID for keep-case word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1791 unsigned af_bad; /* BAD ID for banned word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1792 unsigned af_needaffix; /* NEEDAFFIX ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1793 unsigned af_circumfix; /* CIRCUMFIX ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1794 unsigned af_needcomp; /* NEEDCOMPOUND ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1795 unsigned af_comproot; /* COMPOUNDROOT ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1796 unsigned af_compforbid; /* COMPOUNDFORBIDFLAG ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1797 unsigned af_comppermit; /* COMPOUNDPERMITFLAG ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1798 unsigned af_nosuggest; /* NOSUGGEST ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1799 int af_pfxpostpone; /* postpone prefixes without chop string and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1800 without flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1801 int af_ignoreextra; /* IGNOREEXTRA present */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1802 hashtab_T af_pref; /* hashtable for prefixes, affheader_T */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1803 hashtab_T af_suff; /* hashtable for suffixes, affheader_T */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1804 hashtab_T af_comp; /* hashtable for compound flags, compitem_T */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1805 } afffile_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1806
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1807 #define AFT_CHAR 0 /* flags are one character */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1808 #define AFT_LONG 1 /* flags are two characters */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1809 #define AFT_CAPLONG 2 /* flags are one or two characters */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1810 #define AFT_NUM 3 /* flags are numbers, comma separated */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1811
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1812 typedef struct affentry_S affentry_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1813 /* Affix entry from ".aff" file. Used for prefixes and suffixes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1814 struct affentry_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1815 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1816 affentry_T *ae_next; /* next affix with same name/number */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1817 char_u *ae_chop; /* text to chop off basic word (can be NULL) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1818 char_u *ae_add; /* text to add to basic word (can be NULL) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1819 char_u *ae_flags; /* flags on the affix (can be NULL) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1820 char_u *ae_cond; /* condition (NULL for ".") */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1821 regprog_T *ae_prog; /* regexp program for ae_cond or NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1822 char ae_compforbid; /* COMPOUNDFORBIDFLAG found */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1823 char ae_comppermit; /* COMPOUNDPERMITFLAG found */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1824 };
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1825
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1826 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1827 # define AH_KEY_LEN 17 /* 2 x 8 bytes + NUL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1828 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1829 # define AH_KEY_LEN 7 /* 6 digits + NUL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1830 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1831
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1832 /* Affix header from ".aff" file. Used for af_pref and af_suff. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1833 typedef struct affheader_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1834 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1835 char_u ah_key[AH_KEY_LEN]; /* key for hashtab == name of affix */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1836 unsigned ah_flag; /* affix name as number, uses "af_flagtype" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1837 int ah_newID; /* prefix ID after renumbering; 0 if not used */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1838 int ah_combine; /* suffix may combine with prefix */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1839 int ah_follows; /* another affix block should be following */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1840 affentry_T *ah_first; /* first affix entry */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1841 } affheader_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1842
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1843 #define HI2AH(hi) ((affheader_T *)(hi)->hi_key)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1844
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1845 /* Flag used in compound items. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1846 typedef struct compitem_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1847 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1848 char_u ci_key[AH_KEY_LEN]; /* key for hashtab == name of compound */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1849 unsigned ci_flag; /* affix name as number, uses "af_flagtype" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1850 int ci_newID; /* affix ID after renumbering. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1851 } compitem_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1852
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1853 #define HI2CI(hi) ((compitem_T *)(hi)->hi_key)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1854
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1855 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1856 * Structure that is used to store the items in the word tree. This avoids
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1857 * the need to keep track of each allocated thing, everything is freed all at
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1858 * once after ":mkspell" is done.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1859 * Note: "sb_next" must be just before "sb_data" to make sure the alignment of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1860 * "sb_data" is correct for systems where pointers must be aligned on
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1861 * pointer-size boundaries and sizeof(pointer) > sizeof(int) (e.g., Sparc).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1862 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1863 #define SBLOCKSIZE 16000 /* size of sb_data */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1864 typedef struct sblock_S sblock_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1865 struct sblock_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1866 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1867 int sb_used; /* nr of bytes already in use */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1868 sblock_T *sb_next; /* next block in list */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1869 char_u sb_data[1]; /* data, actually longer */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1870 };
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1871
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1872 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1873 * A node in the tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1874 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1875 typedef struct wordnode_S wordnode_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1876 struct wordnode_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1877 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1878 union /* shared to save space */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1879 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1880 char_u hashkey[6]; /* the hash key, only used while compressing */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1881 int index; /* index in written nodes (valid after first
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1882 round) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1883 } wn_u1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1884 union /* shared to save space */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1885 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1886 wordnode_T *next; /* next node with same hash key */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1887 wordnode_T *wnode; /* parent node that will write this node */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1888 } wn_u2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1889 wordnode_T *wn_child; /* child (next byte in word) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1890 wordnode_T *wn_sibling; /* next sibling (alternate byte in word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1891 always sorted) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1892 int wn_refs; /* Nr. of references to this node. Only
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1893 relevant for first node in a list of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1894 siblings, in following siblings it is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1895 always one. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1896 char_u wn_byte; /* Byte for this node. NUL for word end */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1897
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1898 /* Info for when "wn_byte" is NUL.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1899 * In PREFIXTREE "wn_region" is used for the prefcondnr.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1900 * In the soundfolded word tree "wn_flags" has the MSW of the wordnr and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1901 * "wn_region" the LSW of the wordnr. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1902 char_u wn_affixID; /* supported/required prefix ID or 0 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1903 short_u wn_flags; /* WF_ flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1904 short wn_region; /* region mask */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1905
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1906 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1907 int wn_nr; /* sequence nr for printing */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1908 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1909 };
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1910
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1911 #define WN_MASK 0xffff /* mask relevant bits of "wn_flags" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1912
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1913 #define HI2WN(hi) (wordnode_T *)((hi)->hi_key)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1914
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1915 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1916 * Info used while reading the spell files.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1917 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1918 typedef struct spellinfo_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1919 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1920 wordnode_T *si_foldroot; /* tree with case-folded words */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1921 long si_foldwcount; /* nr of words in si_foldroot */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1922
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1923 wordnode_T *si_keeproot; /* tree with keep-case words */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1924 long si_keepwcount; /* nr of words in si_keeproot */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1925
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1926 wordnode_T *si_prefroot; /* tree with postponed prefixes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1927
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1928 long si_sugtree; /* creating the soundfolding trie */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1929
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1930 sblock_T *si_blocks; /* memory blocks used */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1931 long si_blocks_cnt; /* memory blocks allocated */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1932 int si_did_emsg; /* TRUE when ran out of memory */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1933
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1934 long si_compress_cnt; /* words to add before lowering
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1935 compression limit */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1936 wordnode_T *si_first_free; /* List of nodes that have been freed during
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1937 compression, linked by "wn_child" field. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1938 long si_free_count; /* number of nodes in si_first_free */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1939 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1940 int si_wordnode_nr; /* sequence nr for nodes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1941 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1942 buf_T *si_spellbuf; /* buffer used to store soundfold word table */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1943
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1944 int si_ascii; /* handling only ASCII words */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1945 int si_add; /* addition file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1946 int si_clear_chartab; /* when TRUE clear char tables */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1947 int si_region; /* region mask */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1948 vimconv_T si_conv; /* for conversion to 'encoding' */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1949 int si_memtot; /* runtime memory used */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1950 int si_verbose; /* verbose messages */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1951 int si_msg_count; /* number of words added since last message */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1952 char_u *si_info; /* info text chars or NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1953 int si_region_count; /* number of regions supported (1 when there
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1954 are no regions) */
13232
d11bbd3440b0 patch 8.0.1490: number of spell regions is spread out through the code
Christian Brabandt <cb@256bit.org>
parents: 12694
diff changeset
1955 char_u si_region_name[MAXREGIONS * 2 + 1];
d11bbd3440b0 patch 8.0.1490: number of spell regions is spread out through the code
Christian Brabandt <cb@256bit.org>
parents: 12694
diff changeset
1956 /* region names; used only if
d11bbd3440b0 patch 8.0.1490: number of spell regions is spread out through the code
Christian Brabandt <cb@256bit.org>
parents: 12694
diff changeset
1957 * si_region_count > 1) */
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1958
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1959 garray_T si_rep; /* list of fromto_T entries from REP lines */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1960 garray_T si_repsal; /* list of fromto_T entries from REPSAL lines */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1961 garray_T si_sal; /* list of fromto_T entries from SAL lines */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1962 char_u *si_sofofr; /* SOFOFROM text */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1963 char_u *si_sofoto; /* SOFOTO text */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1964 int si_nosugfile; /* NOSUGFILE item found */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1965 int si_nosplitsugs; /* NOSPLITSUGS item found */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1966 int si_nocompoundsugs; /* NOCOMPOUNDSUGS item found */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1967 int si_followup; /* soundsalike: ? */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1968 int si_collapse; /* soundsalike: ? */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1969 hashtab_T si_commonwords; /* hashtable for common words */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1970 time_t si_sugtime; /* timestamp for .sug file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1971 int si_rem_accents; /* soundsalike: remove accents */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1972 garray_T si_map; /* MAP info concatenated */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1973 char_u *si_midword; /* MIDWORD chars or NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1974 int si_compmax; /* max nr of words for compounding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1975 int si_compminlen; /* minimal length for compounding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1976 int si_compsylmax; /* max nr of syllables for compounding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1977 int si_compoptions; /* COMP_ flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1978 garray_T si_comppat; /* CHECKCOMPOUNDPATTERN items, each stored as
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1979 a string */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1980 char_u *si_compflags; /* flags used for compounding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1981 char_u si_nobreak; /* NOBREAK */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1982 char_u *si_syllable; /* syllable string */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1983 garray_T si_prefcond; /* table with conditions for postponed
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1984 * prefixes, each stored as a string */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1985 int si_newprefID; /* current value for ah_newID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1986 int si_newcompID; /* current value for compound ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1987 } spellinfo_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1988
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1989 static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1990 static int is_aff_rule(char_u **items, int itemcnt, char *rulename, int mincount);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1991 static void aff_process_flags(afffile_T *affile, affentry_T *entry);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1992 static int spell_info_item(char_u *s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1993 static unsigned affitem2flag(int flagtype, char_u *item, char_u *fname, int lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1994 static unsigned get_affitem(int flagtype, char_u **pp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1995 static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1996 static void check_renumber(spellinfo_T *spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1997 static int flag_in_afflist(int flagtype, char_u *afflist, unsigned flag);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1998 static void aff_check_number(int spinval, int affval, char *name);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1999 static void aff_check_string(char_u *spinval, char_u *affval, char *name);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2000 static int str_equal(char_u *s1, char_u *s2);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2001 static void add_fromto(spellinfo_T *spin, garray_T *gap, char_u *from, char_u *to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2002 static int sal_to_bool(char_u *s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2003 static void spell_free_aff(afffile_T *aff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2004 static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2005 static int get_affix_flags(afffile_T *affile, char_u *afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2006 static int get_pfxlist(afffile_T *affile, char_u *afflist, char_u *store_afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2007 static void get_compflags(afffile_T *affile, char_u *afflist, char_u *store_afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2008 static int store_aff_word(spellinfo_T *spin, char_u *word, char_u *afflist, afffile_T *affile, hashtab_T *ht, hashtab_T *xht, int condit, int flags, char_u *pfxlist, int pfxlen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2009 static int spell_read_wordfile(spellinfo_T *spin, char_u *fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2010 static void *getroom(spellinfo_T *spin, size_t len, int align);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2011 static char_u *getroom_save(spellinfo_T *spin, char_u *s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2012 static void free_blocks(sblock_T *bl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2013 static wordnode_T *wordtree_alloc(spellinfo_T *spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2014 static int store_word(spellinfo_T *spin, char_u *word, int flags, int region, char_u *pfxlist, int need_affix);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2015 static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *tree, int flags, int region, int affixID);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2016 static wordnode_T *get_wordnode(spellinfo_T *spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2017 static int deref_wordnode(spellinfo_T *spin, wordnode_T *node);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2018 static void free_wordnode(spellinfo_T *spin, wordnode_T *n);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2019 static void wordtree_compress(spellinfo_T *spin, wordnode_T *root);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2020 static int node_compress(spellinfo_T *spin, wordnode_T *node, hashtab_T *ht, int *tot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2021 static int node_equal(wordnode_T *n1, wordnode_T *n2);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2022 static int write_vim_spell(spellinfo_T *spin, char_u *fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2023 static void clear_node(wordnode_T *node);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2024 static int put_node(FILE *fd, wordnode_T *node, int idx, int regionmask, int prefixtree);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2025 static void spell_make_sugfile(spellinfo_T *spin, char_u *wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2026 static int sug_filltree(spellinfo_T *spin, slang_T *slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2027 static int sug_maketable(spellinfo_T *spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2028 static int sug_filltable(spellinfo_T *spin, wordnode_T *node, int startwordnr, garray_T *gap);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2029 static int offset2bytes(int nr, char_u *buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2030 static void sug_write(spellinfo_T *spin, char_u *fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2031 static void spell_message(spellinfo_T *spin, char_u *str);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2032 static void init_spellfile(void);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2033
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2034 /* In the postponed prefixes tree wn_flags is used to store the WFP_ flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2035 * but it must be negative to indicate the prefix tree to tree_add_word().
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2036 * Use a negative number with the lower 8 bits zero. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2037 #define PFX_FLAGS -256
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2038
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2039 /* flags for "condit" argument of store_aff_word() */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2040 #define CONDIT_COMB 1 /* affix must combine */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2041 #define CONDIT_CFIX 2 /* affix must have CIRCUMFIX flag */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2042 #define CONDIT_SUF 4 /* add a suffix for matching flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2043 #define CONDIT_AFF 8 /* word already has an affix */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2044
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2045 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2046 * Tunable parameters for when the tree is compressed. See 'mkspellmem'.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2047 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2048 static long compress_start = 30000; /* memory / SBLOCKSIZE */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2049 static long compress_inc = 100; /* memory / SBLOCKSIZE */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2050 static long compress_added = 500000; /* word count */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2051
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2052 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2053 * Check the 'mkspellmem' option. Return FAIL if it's wrong.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2054 * Sets "sps_flags".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2055 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2056 int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2057 spell_check_msm(void)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2058 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2059 char_u *p = p_msm;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2060 long start = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2061 long incr = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2062 long added = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2063
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2064 if (!VIM_ISDIGIT(*p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2065 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2066 /* block count = (value * 1024) / SBLOCKSIZE (but avoid overflow)*/
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2067 start = (getdigits(&p) * 10) / (SBLOCKSIZE / 102);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2068 if (*p != ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2069 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2070 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2071 if (!VIM_ISDIGIT(*p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2072 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2073 incr = (getdigits(&p) * 102) / (SBLOCKSIZE / 10);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2074 if (*p != ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2075 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2076 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2077 if (!VIM_ISDIGIT(*p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2078 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2079 added = getdigits(&p) * 1024;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2080 if (*p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2081 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2082
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2083 if (start == 0 || incr == 0 || added == 0 || incr > start)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2084 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2085
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2086 compress_start = start;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2087 compress_inc = incr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2088 compress_added = added;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2089 return OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2090 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2091
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2092 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2093 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2094 * For debugging the tree code: print the current tree in a (more or less)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2095 * readable format, so that we can see what happens when adding a word and/or
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2096 * compressing the tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2097 * Based on code from Olaf Seibert.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2098 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2099 #define PRINTLINESIZE 1000
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2100 #define PRINTWIDTH 6
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2101
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2102 #define PRINTSOME(l, depth, fmt, a1, a2) vim_snprintf(l + depth * PRINTWIDTH, \
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2103 PRINTLINESIZE - PRINTWIDTH * depth, fmt, a1, a2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2104
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2105 static char line1[PRINTLINESIZE];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2106 static char line2[PRINTLINESIZE];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2107 static char line3[PRINTLINESIZE];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2108
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2109 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2110 spell_clear_flags(wordnode_T *node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2111 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2112 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2113
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2114 for (np = node; np != NULL; np = np->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2115 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2116 np->wn_u1.index = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2117 spell_clear_flags(np->wn_child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2118 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2119 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2120
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2121 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2122 spell_print_node(wordnode_T *node, int depth)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2123 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2124 if (node->wn_u1.index)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2125 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2126 /* Done this node before, print the reference. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2127 PRINTSOME(line1, depth, "(%d)", node->wn_nr, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2128 PRINTSOME(line2, depth, " ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2129 PRINTSOME(line3, depth, " ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2130 msg((char_u *)line1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2131 msg((char_u *)line2);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2132 msg((char_u *)line3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2133 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2134 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2135 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2136 node->wn_u1.index = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2137
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2138 if (node->wn_byte != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2139 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2140 if (node->wn_child != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2141 PRINTSOME(line1, depth, " %c -> ", node->wn_byte, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2142 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2143 /* Cannot happen? */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2144 PRINTSOME(line1, depth, " %c ???", node->wn_byte, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2145 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2146 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2147 PRINTSOME(line1, depth, " $ ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2148
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2149 PRINTSOME(line2, depth, "%d/%d ", node->wn_nr, node->wn_refs);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2150
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2151 if (node->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2152 PRINTSOME(line3, depth, " | ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2153 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2154 PRINTSOME(line3, depth, " ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2155
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2156 if (node->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2157 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2158 msg((char_u *)line1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2159 msg((char_u *)line2);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2160 msg((char_u *)line3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2161 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2162
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2163 /* do the children */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2164 if (node->wn_byte != NUL && node->wn_child != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2165 spell_print_node(node->wn_child, depth + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2166
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2167 /* do the siblings */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2168 if (node->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2169 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2170 /* get rid of all parent details except | */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2171 STRCPY(line1, line3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2172 STRCPY(line2, line3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2173 spell_print_node(node->wn_sibling, depth);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2174 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2175 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2176 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2177
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2178 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2179 spell_print_tree(wordnode_T *root)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2180 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2181 if (root != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2182 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2183 /* Clear the "wn_u1.index" fields, used to remember what has been
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2184 * done. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2185 spell_clear_flags(root);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2186
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2187 /* Recursively print the tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2188 spell_print_node(root, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2189 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2190 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2191 #endif /* SPELL_PRINTTREE */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2192
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2193 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2194 * Read the affix file "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2195 * Returns an afffile_T, NULL for complete failure.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2196 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2197 static afffile_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2198 spell_read_aff(spellinfo_T *spin, char_u *fname)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2199 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2200 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2201 afffile_T *aff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2202 char_u rline[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2203 char_u *line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2204 char_u *pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2205 #define MAXITEMCNT 30
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2206 char_u *(items[MAXITEMCNT]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2207 int itemcnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2208 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2209 int lnum = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2210 affheader_T *cur_aff = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2211 int did_postpone_prefix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2212 int aff_todo = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2213 hashtab_T *tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2214 char_u *low = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2215 char_u *fol = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2216 char_u *upp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2217 int do_rep;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2218 int do_repsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2219 int do_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2220 int do_mapline;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2221 int found_map = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2222 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2223 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2224 int compminlen = 0; /* COMPOUNDMIN value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2225 int compsylmax = 0; /* COMPOUNDSYLMAX value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2226 int compoptions = 0; /* COMP_ flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2227 int compmax = 0; /* COMPOUNDWORDMAX value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2228 char_u *compflags = NULL; /* COMPOUNDFLAG and COMPOUNDRULE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2229 concatenated */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2230 char_u *midword = NULL; /* MIDWORD value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2231 char_u *syllable = NULL; /* SYLLABLE value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2232 char_u *sofofrom = NULL; /* SOFOFROM value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2233 char_u *sofoto = NULL; /* SOFOTO value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2234
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2235 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2236 * Open the file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2237 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2238 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2239 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2240 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2241 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2242 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2243 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2244
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2245 vim_snprintf((char *)IObuff, IOSIZE, _("Reading affix file %s ..."), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2246 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2247
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2248 /* Only do REP lines when not done in another .aff file already. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2249 do_rep = spin->si_rep.ga_len == 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2250
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2251 /* Only do REPSAL lines when not done in another .aff file already. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2252 do_repsal = spin->si_repsal.ga_len == 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2253
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2254 /* Only do SAL lines when not done in another .aff file already. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2255 do_sal = spin->si_sal.ga_len == 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2256
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2257 /* Only do MAP lines when not done in another .aff file already. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2258 do_mapline = spin->si_map.ga_len == 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2259
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2260 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2261 * Allocate and init the afffile_T structure.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2262 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2263 aff = (afffile_T *)getroom(spin, sizeof(afffile_T), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2264 if (aff == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2265 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2266 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2267 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2268 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2269 hash_init(&aff->af_pref);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2270 hash_init(&aff->af_suff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2271 hash_init(&aff->af_comp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2272
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2273 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2274 * Read all the lines in the file one by one.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2275 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2276 while (!vim_fgets(rline, MAXLINELEN, fd) && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2277 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2278 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2279 ++lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2280
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2281 /* Skip comment lines. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2282 if (*rline == '#')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2283 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2284
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2285 /* Convert from "SET" to 'encoding' when needed. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2286 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2287 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2288 if (spin->si_conv.vc_type != CONV_NONE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2289 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2290 pc = string_convert(&spin->si_conv, rline, NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2291 if (pc == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2292 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2293 smsg((char_u *)_("Conversion failure for word in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2294 fname, lnum, rline);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2295 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2296 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2297 line = pc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2298 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2299 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2300 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2301 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2302 pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2303 line = rline;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2304 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2305
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2306 /* Split the line up in white separated items. Put a NUL after each
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2307 * item. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2308 itemcnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2309 for (p = line; ; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2310 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2311 while (*p != NUL && *p <= ' ') /* skip white space and CR/NL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2312 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2313 if (*p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2314 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2315 if (itemcnt == MAXITEMCNT) /* too many items */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2316 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2317 items[itemcnt++] = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2318 /* A few items have arbitrary text argument, don't split them. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2319 if (itemcnt == 2 && spell_info_item(items[0]))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2320 while (*p >= ' ' || *p == TAB) /* skip until CR/NL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2321 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2322 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2323 while (*p > ' ') /* skip until white space or CR/NL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2324 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2325 if (*p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2326 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2327 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2328 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2329
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2330 /* Handle non-empty lines. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2331 if (itemcnt > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2332 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2333 if (is_aff_rule(items, itemcnt, "SET", 2) && aff->af_enc == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2334 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2335 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2336 /* Setup for conversion from "ENC" to 'encoding'. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2337 aff->af_enc = enc_canonize(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2338 if (aff->af_enc != NULL && !spin->si_ascii
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2339 && convert_setup(&spin->si_conv, aff->af_enc,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2340 p_enc) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2341 smsg((char_u *)_("Conversion in %s not supported: from %s to %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2342 fname, aff->af_enc, p_enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2343 spin->si_conv.vc_fail = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2344 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2345 smsg((char_u *)_("Conversion in %s not supported"), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2346 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2347 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2348 else if (is_aff_rule(items, itemcnt, "FLAG", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2349 && aff->af_flagtype == AFT_CHAR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2350 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2351 if (STRCMP(items[1], "long") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2352 aff->af_flagtype = AFT_LONG;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2353 else if (STRCMP(items[1], "num") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2354 aff->af_flagtype = AFT_NUM;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2355 else if (STRCMP(items[1], "caplong") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2356 aff->af_flagtype = AFT_CAPLONG;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2357 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2358 smsg((char_u *)_("Invalid value for FLAG in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2359 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2360 if (aff->af_rare != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2361 || aff->af_keepcase != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2362 || aff->af_bad != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2363 || aff->af_needaffix != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2364 || aff->af_circumfix != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2365 || aff->af_needcomp != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2366 || aff->af_comproot != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2367 || aff->af_nosuggest != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2368 || compflags != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2369 || aff->af_suff.ht_used > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2370 || aff->af_pref.ht_used > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2371 smsg((char_u *)_("FLAG after using flags in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2372 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2373 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2374 else if (spell_info_item(items[0]))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2375 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2376 p = (char_u *)getroom(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2377 (spin->si_info == NULL ? 0 : STRLEN(spin->si_info))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2378 + STRLEN(items[0])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2379 + STRLEN(items[1]) + 3, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2380 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2381 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2382 if (spin->si_info != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2383 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2384 STRCPY(p, spin->si_info);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2385 STRCAT(p, "\n");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2386 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2387 STRCAT(p, items[0]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2388 STRCAT(p, " ");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2389 STRCAT(p, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2390 spin->si_info = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2391 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2392 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2393 else if (is_aff_rule(items, itemcnt, "MIDWORD", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2394 && midword == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2395 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2396 midword = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2397 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2398 else if (is_aff_rule(items, itemcnt, "TRY", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2399 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2400 /* ignored, we look in the tree for what chars may appear */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2401 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2402 /* TODO: remove "RAR" later */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2403 else if ((is_aff_rule(items, itemcnt, "RAR", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2404 || is_aff_rule(items, itemcnt, "RARE", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2405 && aff->af_rare == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2406 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2407 aff->af_rare = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2408 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2409 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2410 /* TODO: remove "KEP" later */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2411 else if ((is_aff_rule(items, itemcnt, "KEP", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2412 || is_aff_rule(items, itemcnt, "KEEPCASE", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2413 && aff->af_keepcase == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2414 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2415 aff->af_keepcase = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2416 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2417 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2418 else if ((is_aff_rule(items, itemcnt, "BAD", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2419 || is_aff_rule(items, itemcnt, "FORBIDDENWORD", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2420 && aff->af_bad == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2421 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2422 aff->af_bad = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2423 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2424 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2425 else if (is_aff_rule(items, itemcnt, "NEEDAFFIX", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2426 && aff->af_needaffix == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2427 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2428 aff->af_needaffix = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2429 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2430 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2431 else if (is_aff_rule(items, itemcnt, "CIRCUMFIX", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2432 && aff->af_circumfix == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2433 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2434 aff->af_circumfix = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2435 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2436 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2437 else if (is_aff_rule(items, itemcnt, "NOSUGGEST", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2438 && aff->af_nosuggest == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2439 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2440 aff->af_nosuggest = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2441 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2442 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2443 else if ((is_aff_rule(items, itemcnt, "NEEDCOMPOUND", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2444 || is_aff_rule(items, itemcnt, "ONLYINCOMPOUND", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2445 && aff->af_needcomp == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2446 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2447 aff->af_needcomp = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2448 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2449 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2450 else if (is_aff_rule(items, itemcnt, "COMPOUNDROOT", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2451 && aff->af_comproot == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2452 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2453 aff->af_comproot = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2454 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2455 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2456 else if (is_aff_rule(items, itemcnt, "COMPOUNDFORBIDFLAG", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2457 && aff->af_compforbid == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2458 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2459 aff->af_compforbid = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2460 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2461 if (aff->af_pref.ht_used > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2462 smsg((char_u *)_("Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line %d"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2463 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2464 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2465 else if (is_aff_rule(items, itemcnt, "COMPOUNDPERMITFLAG", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2466 && aff->af_comppermit == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2467 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2468 aff->af_comppermit = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2469 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2470 if (aff->af_pref.ht_used > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2471 smsg((char_u *)_("Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line %d"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2472 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2473 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2474 else if (is_aff_rule(items, itemcnt, "COMPOUNDFLAG", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2475 && compflags == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2476 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2477 /* Turn flag "c" into COMPOUNDRULE compatible string "c+",
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2478 * "Na" into "Na+", "1234" into "1234+". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2479 p = getroom(spin, STRLEN(items[1]) + 2, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2480 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2481 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2482 STRCPY(p, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2483 STRCAT(p, "+");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2484 compflags = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2485 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2486 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2487 else if (is_aff_rule(items, itemcnt, "COMPOUNDRULES", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2488 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2489 /* We don't use the count, but do check that it's a number and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2490 * not COMPOUNDRULE mistyped. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2491 if (atoi((char *)items[1]) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2492 smsg((char_u *)_("Wrong COMPOUNDRULES value in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2493 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2494 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2495 else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2496 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2497 /* Don't use the first rule if it is a number. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2498 if (compflags != NULL || *skipdigits(items[1]) != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2499 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2500 /* Concatenate this string to previously defined ones,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2501 * using a slash to separate them. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2502 l = (int)STRLEN(items[1]) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2503 if (compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2504 l += (int)STRLEN(compflags) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2505 p = getroom(spin, l, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2506 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2507 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2508 if (compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2509 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2510 STRCPY(p, compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2511 STRCAT(p, "/");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2512 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2513 STRCAT(p, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2514 compflags = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2515 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2516 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2517 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2518 else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2519 && compmax == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2520 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2521 compmax = atoi((char *)items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2522 if (compmax == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2523 smsg((char_u *)_("Wrong COMPOUNDWORDMAX value in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2524 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2525 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2526 else if (is_aff_rule(items, itemcnt, "COMPOUNDMIN", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2527 && compminlen == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2528 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2529 compminlen = atoi((char *)items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2530 if (compminlen == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2531 smsg((char_u *)_("Wrong COMPOUNDMIN value in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2532 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2533 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2534 else if (is_aff_rule(items, itemcnt, "COMPOUNDSYLMAX", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2535 && compsylmax == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2536 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2537 compsylmax = atoi((char *)items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2538 if (compsylmax == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2539 smsg((char_u *)_("Wrong COMPOUNDSYLMAX value in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2540 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2541 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2542 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDDUP", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2543 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2544 compoptions |= COMP_CHECKDUP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2545 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2546 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDREP", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2547 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2548 compoptions |= COMP_CHECKREP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2549 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2550 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDCASE", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2551 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2552 compoptions |= COMP_CHECKCASE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2553 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2554 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDTRIPLE", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2555 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2556 compoptions |= COMP_CHECKTRIPLE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2557 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2558 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2559 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2560 if (atoi((char *)items[1]) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2561 smsg((char_u *)_("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2562 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2563 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2564 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 3))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2565 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2566 garray_T *gap = &spin->si_comppat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2567 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2568
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2569 /* Only add the couple if it isn't already there. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2570 for (i = 0; i < gap->ga_len - 1; i += 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2571 if (STRCMP(((char_u **)(gap->ga_data))[i], items[1]) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2572 && STRCMP(((char_u **)(gap->ga_data))[i + 1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2573 items[2]) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2574 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2575 if (i >= gap->ga_len && ga_grow(gap, 2) == OK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2576 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2577 ((char_u **)(gap->ga_data))[gap->ga_len++]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2578 = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2579 ((char_u **)(gap->ga_data))[gap->ga_len++]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2580 = getroom_save(spin, items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2581 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2582 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2583 else if (is_aff_rule(items, itemcnt, "SYLLABLE", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2584 && syllable == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2585 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2586 syllable = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2587 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2588 else if (is_aff_rule(items, itemcnt, "NOBREAK", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2589 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2590 spin->si_nobreak = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2591 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2592 else if (is_aff_rule(items, itemcnt, "NOSPLITSUGS", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2593 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2594 spin->si_nosplitsugs = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2595 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2596 else if (is_aff_rule(items, itemcnt, "NOCOMPOUNDSUGS", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2597 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2598 spin->si_nocompoundsugs = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2599 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2600 else if (is_aff_rule(items, itemcnt, "NOSUGFILE", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2601 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2602 spin->si_nosugfile = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2603 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2604 else if (is_aff_rule(items, itemcnt, "PFXPOSTPONE", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2605 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2606 aff->af_pfxpostpone = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2607 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2608 else if (is_aff_rule(items, itemcnt, "IGNOREEXTRA", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2609 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2610 aff->af_ignoreextra = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2611 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2612 else if ((STRCMP(items[0], "PFX") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2613 || STRCMP(items[0], "SFX") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2614 && aff_todo == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2615 && itemcnt >= 4)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2616 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2617 int lasti = 4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2618 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2619
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2620 if (*items[0] == 'P')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2621 tp = &aff->af_pref;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2622 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2623 tp = &aff->af_suff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2624
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2625 /* Myspell allows the same affix name to be used multiple
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2626 * times. The affix files that do this have an undocumented
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2627 * "S" flag on all but the last block, thus we check for that
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2628 * and store it in ah_follows. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2629 vim_strncpy(key, items[1], AH_KEY_LEN - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2630 hi = hash_find(tp, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2631 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2632 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2633 cur_aff = HI2AH(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2634 if (cur_aff->ah_combine != (*items[2] == 'Y'))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2635 smsg((char_u *)_("Different combining flag in continued affix block in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2636 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2637 if (!cur_aff->ah_follows)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2638 smsg((char_u *)_("Duplicate affix in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2639 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2640 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2641 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2642 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2643 /* New affix letter. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2644 cur_aff = (affheader_T *)getroom(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2645 sizeof(affheader_T), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2646 if (cur_aff == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2647 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2648 cur_aff->ah_flag = affitem2flag(aff->af_flagtype, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2649 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2650 if (cur_aff->ah_flag == 0 || STRLEN(items[1]) >= AH_KEY_LEN)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2651 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2652 if (cur_aff->ah_flag == aff->af_bad
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2653 || cur_aff->ah_flag == aff->af_rare
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2654 || cur_aff->ah_flag == aff->af_keepcase
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2655 || cur_aff->ah_flag == aff->af_needaffix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2656 || cur_aff->ah_flag == aff->af_circumfix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2657 || cur_aff->ah_flag == aff->af_nosuggest
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2658 || cur_aff->ah_flag == aff->af_needcomp
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2659 || cur_aff->ah_flag == aff->af_comproot)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2660 smsg((char_u *)_("Affix also used for BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2661 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2662 STRCPY(cur_aff->ah_key, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2663 hash_add(tp, cur_aff->ah_key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2664
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2665 cur_aff->ah_combine = (*items[2] == 'Y');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2666 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2667
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2668 /* Check for the "S" flag, which apparently means that another
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2669 * block with the same affix name is following. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2670 if (itemcnt > lasti && STRCMP(items[lasti], "S") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2671 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2672 ++lasti;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2673 cur_aff->ah_follows = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2674 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2675 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2676 cur_aff->ah_follows = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2677
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2678 /* Myspell allows extra text after the item, but that might
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2679 * mean mistakes go unnoticed. Require a comment-starter. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2680 if (itemcnt > lasti && *items[lasti] != '#')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2681 smsg((char_u *)_(e_afftrailing), fname, lnum, items[lasti]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2682
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2683 if (STRCMP(items[2], "Y") != 0 && STRCMP(items[2], "N") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2684 smsg((char_u *)_("Expected Y or N in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2685 fname, lnum, items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2686
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2687 if (*items[0] == 'P' && aff->af_pfxpostpone)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2688 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2689 if (cur_aff->ah_newID == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2690 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2691 /* Use a new number in the .spl file later, to be able
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2692 * to handle multiple .aff files. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2693 check_renumber(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2694 cur_aff->ah_newID = ++spin->si_newprefID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2695
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2696 /* We only really use ah_newID if the prefix is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2697 * postponed. We know that only after handling all
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2698 * the items. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2699 did_postpone_prefix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2700 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2701 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2702 /* Did use the ID in a previous block. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2703 did_postpone_prefix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2704 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2705
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2706 aff_todo = atoi((char *)items[3]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2707 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2708 else if ((STRCMP(items[0], "PFX") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2709 || STRCMP(items[0], "SFX") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2710 && aff_todo > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2711 && STRCMP(cur_aff->ah_key, items[1]) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2712 && itemcnt >= 5)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2713 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2714 affentry_T *aff_entry;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2715 int upper = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2716 int lasti = 5;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2717
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2718 /* Myspell allows extra text after the item, but that might
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2719 * mean mistakes go unnoticed. Require a comment-starter,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2720 * unless IGNOREEXTRA is used. Hunspell uses a "-" item. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2721 if (itemcnt > lasti
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2722 && !aff->af_ignoreextra
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2723 && *items[lasti] != '#'
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2724 && (STRCMP(items[lasti], "-") != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2725 || itemcnt != lasti + 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2726 smsg((char_u *)_(e_afftrailing), fname, lnum, items[lasti]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2727
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2728 /* New item for an affix letter. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2729 --aff_todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2730 aff_entry = (affentry_T *)getroom(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2731 sizeof(affentry_T), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2732 if (aff_entry == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2733 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2734
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2735 if (STRCMP(items[2], "0") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2736 aff_entry->ae_chop = getroom_save(spin, items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2737 if (STRCMP(items[3], "0") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2738 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2739 aff_entry->ae_add = getroom_save(spin, items[3]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2740
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2741 /* Recognize flags on the affix: abcd/XYZ */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2742 aff_entry->ae_flags = vim_strchr(aff_entry->ae_add, '/');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2743 if (aff_entry->ae_flags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2744 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2745 *aff_entry->ae_flags++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2746 aff_process_flags(aff, aff_entry);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2747 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2748 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2749
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2750 /* Don't use an affix entry with non-ASCII characters when
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2751 * "spin->si_ascii" is TRUE. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2752 if (!spin->si_ascii || !(has_non_ascii(aff_entry->ae_chop)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2753 || has_non_ascii(aff_entry->ae_add)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2754 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2755 aff_entry->ae_next = cur_aff->ah_first;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2756 cur_aff->ah_first = aff_entry;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2757
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2758 if (STRCMP(items[4], ".") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2759 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2760 char_u buf[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2761
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2762 aff_entry->ae_cond = getroom_save(spin, items[4]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2763 if (*items[0] == 'P')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2764 sprintf((char *)buf, "^%s", items[4]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2765 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2766 sprintf((char *)buf, "%s$", items[4]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2767 aff_entry->ae_prog = vim_regcomp(buf,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2768 RE_MAGIC + RE_STRING + RE_STRICT);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2769 if (aff_entry->ae_prog == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2770 smsg((char_u *)_("Broken condition in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2771 fname, lnum, items[4]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2772 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2773
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2774 /* For postponed prefixes we need an entry in si_prefcond
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2775 * for the condition. Use an existing one if possible.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2776 * Can't be done for an affix with flags, ignoring
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2777 * COMPOUNDFORBIDFLAG and COMPOUNDPERMITFLAG. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2778 if (*items[0] == 'P' && aff->af_pfxpostpone
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2779 && aff_entry->ae_flags == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2780 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2781 /* When the chop string is one lower-case letter and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2782 * the add string ends in the upper-case letter we set
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2783 * the "upper" flag, clear "ae_chop" and remove the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2784 * letters from "ae_add". The condition must either
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2785 * be empty or start with the same letter. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2786 if (aff_entry->ae_chop != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2787 && aff_entry->ae_add != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2788 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2789 && aff_entry->ae_chop[(*mb_ptr2len)(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2790 aff_entry->ae_chop)] == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2791 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2792 && aff_entry->ae_chop[1] == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2793 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2794 )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2795 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2796 int c, c_up;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2797
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2798 c = PTR2CHAR(aff_entry->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2799 c_up = SPELL_TOUPPER(c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2800 if (c_up != c
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2801 && (aff_entry->ae_cond == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2802 || PTR2CHAR(aff_entry->ae_cond) == c))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2803 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2804 p = aff_entry->ae_add
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2805 + STRLEN(aff_entry->ae_add);
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10974
diff changeset
2806 MB_PTR_BACK(aff_entry->ae_add, p);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2807 if (PTR2CHAR(p) == c_up)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2808 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2809 upper = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2810 aff_entry->ae_chop = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2811 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2812
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2813 /* The condition is matched with the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2814 * actual word, thus must check for the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2815 * upper-case letter. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2816 if (aff_entry->ae_cond != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2817 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2818 char_u buf[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2819 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2820 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2821 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2822 onecap_copy(items[4], buf, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2823 aff_entry->ae_cond = getroom_save(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2824 spin, buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2825 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2826 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2827 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2828 *aff_entry->ae_cond = c_up;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2829 if (aff_entry->ae_cond != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2830 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2831 sprintf((char *)buf, "^%s",
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2832 aff_entry->ae_cond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2833 vim_regfree(aff_entry->ae_prog);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2834 aff_entry->ae_prog = vim_regcomp(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2835 buf, RE_MAGIC + RE_STRING);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2836 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2837 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2838 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2839 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2840 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2841
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2842 if (aff_entry->ae_chop == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2843 && aff_entry->ae_flags == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2844 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2845 int idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2846 char_u **pp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2847 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2848
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2849 /* Find a previously used condition. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2850 for (idx = spin->si_prefcond.ga_len - 1; idx >= 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2851 --idx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2852 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2853 p = ((char_u **)spin->si_prefcond.ga_data)[idx];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2854 if (str_equal(p, aff_entry->ae_cond))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2855 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2856 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2857 if (idx < 0 && ga_grow(&spin->si_prefcond, 1) == OK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2858 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2859 /* Not found, add a new condition. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2860 idx = spin->si_prefcond.ga_len++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2861 pp = ((char_u **)spin->si_prefcond.ga_data)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2862 + idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2863 if (aff_entry->ae_cond == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2864 *pp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2865 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2866 *pp = getroom_save(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2867 aff_entry->ae_cond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2868 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2869
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2870 /* Add the prefix to the prefix tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2871 if (aff_entry->ae_add == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2872 p = (char_u *)"";
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2873 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2874 p = aff_entry->ae_add;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2875
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2876 /* PFX_FLAGS is a negative number, so that
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2877 * tree_add_word() knows this is the prefix tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2878 n = PFX_FLAGS;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2879 if (!cur_aff->ah_combine)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2880 n |= WFP_NC;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2881 if (upper)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2882 n |= WFP_UP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2883 if (aff_entry->ae_comppermit)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2884 n |= WFP_COMPPERMIT;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2885 if (aff_entry->ae_compforbid)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2886 n |= WFP_COMPFORBID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2887 tree_add_word(spin, p, spin->si_prefroot, n,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2888 idx, cur_aff->ah_newID);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2889 did_postpone_prefix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2890 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2891
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2892 /* Didn't actually use ah_newID, backup si_newprefID. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2893 if (aff_todo == 0 && !did_postpone_prefix)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2894 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2895 --spin->si_newprefID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2896 cur_aff->ah_newID = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2897 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2898 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2899 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2900 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2901 else if (is_aff_rule(items, itemcnt, "FOL", 2) && fol == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2902 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2903 fol = vim_strsave(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2904 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2905 else if (is_aff_rule(items, itemcnt, "LOW", 2) && low == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2906 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2907 low = vim_strsave(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2908 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2909 else if (is_aff_rule(items, itemcnt, "UPP", 2) && upp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2910 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2911 upp = vim_strsave(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2912 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2913 else if (is_aff_rule(items, itemcnt, "REP", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2914 || is_aff_rule(items, itemcnt, "REPSAL", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2915 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2916 /* Ignore REP/REPSAL count */;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2917 if (!isdigit(*items[1]))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2918 smsg((char_u *)_("Expected REP(SAL) count in %s line %d"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2919 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2920 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2921 else if ((STRCMP(items[0], "REP") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2922 || STRCMP(items[0], "REPSAL") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2923 && itemcnt >= 3)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2924 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2925 /* REP/REPSAL item */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2926 /* Myspell ignores extra arguments, we require it starts with
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2927 * # to detect mistakes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2928 if (itemcnt > 3 && items[3][0] != '#')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2929 smsg((char_u *)_(e_afftrailing), fname, lnum, items[3]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2930 if (items[0][3] == 'S' ? do_repsal : do_rep)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2931 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2932 /* Replace underscore with space (can't include a space
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2933 * directly). */
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10974
diff changeset
2934 for (p = items[1]; *p != NUL; MB_PTR_ADV(p))
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2935 if (*p == '_')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2936 *p = ' ';
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10974
diff changeset
2937 for (p = items[2]; *p != NUL; MB_PTR_ADV(p))
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2938 if (*p == '_')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2939 *p = ' ';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2940 add_fromto(spin, items[0][3] == 'S'
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2941 ? &spin->si_repsal
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2942 : &spin->si_rep, items[1], items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2943 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2944 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2945 else if (is_aff_rule(items, itemcnt, "MAP", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2946 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2947 /* MAP item or count */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2948 if (!found_map)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2949 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2950 /* First line contains the count. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2951 found_map = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2952 if (!isdigit(*items[1]))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2953 smsg((char_u *)_("Expected MAP count in %s line %d"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2954 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2955 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2956 else if (do_mapline)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2957 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2958 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2959
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2960 /* Check that every character appears only once. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2961 for (p = items[1]; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2962 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2963 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2964 c = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2965 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2966 c = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2967 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2968 if ((spin->si_map.ga_len > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2969 && vim_strchr(spin->si_map.ga_data, c)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2970 != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2971 || vim_strchr(p, c) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2972 smsg((char_u *)_("Duplicate character in MAP in %s line %d"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2973 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2974 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2975
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2976 /* We simply concatenate all the MAP strings, separated by
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2977 * slashes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2978 ga_concat(&spin->si_map, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2979 ga_append(&spin->si_map, '/');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2980 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2981 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2982 /* Accept "SAL from to" and "SAL from to #comment". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2983 else if (is_aff_rule(items, itemcnt, "SAL", 3))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2984 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2985 if (do_sal)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2986 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2987 /* SAL item (sounds-a-like)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2988 * Either one of the known keys or a from-to pair. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2989 if (STRCMP(items[1], "followup") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2990 spin->si_followup = sal_to_bool(items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2991 else if (STRCMP(items[1], "collapse_result") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2992 spin->si_collapse = sal_to_bool(items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2993 else if (STRCMP(items[1], "remove_accents") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2994 spin->si_rem_accents = sal_to_bool(items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2995 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2996 /* when "to" is "_" it means empty */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2997 add_fromto(spin, &spin->si_sal, items[1],
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2998 STRCMP(items[2], "_") == 0 ? (char_u *)""
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2999 : items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3000 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3001 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3002 else if (is_aff_rule(items, itemcnt, "SOFOFROM", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3003 && sofofrom == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3004 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3005 sofofrom = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3006 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3007 else if (is_aff_rule(items, itemcnt, "SOFOTO", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3008 && sofoto == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3009 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3010 sofoto = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3011 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3012 else if (STRCMP(items[0], "COMMON") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3013 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3014 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3015
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3016 for (i = 1; i < itemcnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3017 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3018 if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3019 items[i])))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3020 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3021 p = vim_strsave(items[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3022 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3023 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3024 hash_add(&spin->si_commonwords, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3025 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3026 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3027 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3028 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3029 smsg((char_u *)_("Unrecognized or duplicate item in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3030 fname, lnum, items[0]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3031 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3032 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3033
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3034 if (fol != NULL || low != NULL || upp != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3035 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3036 if (spin->si_clear_chartab)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3037 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3038 /* Clear the char type tables, don't want to use any of the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3039 * currently used spell properties. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3040 init_spell_chartab();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3041 spin->si_clear_chartab = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3042 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3043
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3044 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3045 * Don't write a word table for an ASCII file, so that we don't check
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3046 * for conflicts with a word table that matches 'encoding'.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3047 * Don't write one for utf-8 either, we use utf_*() and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3048 * mb_get_class(), the list of chars in the file will be incomplete.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3049 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3050 if (!spin->si_ascii
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3051 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3052 && !enc_utf8
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3053 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3054 )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3055 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3056 if (fol == NULL || low == NULL || upp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3057 smsg((char_u *)_("Missing FOL/LOW/UPP line in %s"), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3058 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3059 (void)set_spell_chartab(fol, low, upp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3060 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3061
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3062 vim_free(fol);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3063 vim_free(low);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3064 vim_free(upp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3065 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3066
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3067 /* Use compound specifications of the .aff file for the spell info. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3068 if (compmax != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3069 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3070 aff_check_number(spin->si_compmax, compmax, "COMPOUNDWORDMAX");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3071 spin->si_compmax = compmax;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3072 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3073
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3074 if (compminlen != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3075 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3076 aff_check_number(spin->si_compminlen, compminlen, "COMPOUNDMIN");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3077 spin->si_compminlen = compminlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3078 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3079
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3080 if (compsylmax != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3081 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3082 if (syllable == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3083 smsg((char_u *)_("COMPOUNDSYLMAX used without SYLLABLE"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3084 aff_check_number(spin->si_compsylmax, compsylmax, "COMPOUNDSYLMAX");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3085 spin->si_compsylmax = compsylmax;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3086 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3087
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3088 if (compoptions != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3089 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3090 aff_check_number(spin->si_compoptions, compoptions, "COMPOUND options");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3091 spin->si_compoptions |= compoptions;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3092 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3093
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3094 if (compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3095 process_compflags(spin, aff, compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3096
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3097 /* Check that we didn't use too many renumbered flags. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3098 if (spin->si_newcompID < spin->si_newprefID)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3099 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3100 if (spin->si_newcompID == 127 || spin->si_newcompID == 255)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3101 MSG(_("Too many postponed prefixes"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3102 else if (spin->si_newprefID == 0 || spin->si_newprefID == 127)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3103 MSG(_("Too many compound flags"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3104 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3105 MSG(_("Too many postponed prefixes and/or compound flags"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3106 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3107
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3108 if (syllable != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3109 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3110 aff_check_string(spin->si_syllable, syllable, "SYLLABLE");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3111 spin->si_syllable = syllable;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3112 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3113
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3114 if (sofofrom != NULL || sofoto != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3115 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3116 if (sofofrom == NULL || sofoto == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3117 smsg((char_u *)_("Missing SOFO%s line in %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3118 sofofrom == NULL ? "FROM" : "TO", fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3119 else if (spin->si_sal.ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3120 smsg((char_u *)_("Both SAL and SOFO lines in %s"), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3121 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3122 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3123 aff_check_string(spin->si_sofofr, sofofrom, "SOFOFROM");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3124 aff_check_string(spin->si_sofoto, sofoto, "SOFOTO");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3125 spin->si_sofofr = sofofrom;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3126 spin->si_sofoto = sofoto;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3127 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3128 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3129
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3130 if (midword != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3131 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3132 aff_check_string(spin->si_midword, midword, "MIDWORD");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3133 spin->si_midword = midword;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3134 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3135
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3136 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3137 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3138 return aff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3139 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3140
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3141 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3142 * Return TRUE when items[0] equals "rulename", there are "mincount" items or
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3143 * a comment is following after item "mincount".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3144 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3145 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3146 is_aff_rule(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3147 char_u **items,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3148 int itemcnt,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3149 char *rulename,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3150 int mincount)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3151 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3152 return (STRCMP(items[0], rulename) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3153 && (itemcnt == mincount
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3154 || (itemcnt > mincount && items[mincount][0] == '#')));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3155 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3156
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3157 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3158 * For affix "entry" move COMPOUNDFORBIDFLAG and COMPOUNDPERMITFLAG from
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3159 * ae_flags to ae_comppermit and ae_compforbid.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3160 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3161 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3162 aff_process_flags(afffile_T *affile, affentry_T *entry)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3163 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3164 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3165 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3166 unsigned flag;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3167
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3168 if (entry->ae_flags != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3169 && (affile->af_compforbid != 0 || affile->af_comppermit != 0))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3170 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3171 for (p = entry->ae_flags; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3172 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3173 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3174 flag = get_affitem(affile->af_flagtype, &p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3175 if (flag == affile->af_comppermit || flag == affile->af_compforbid)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3176 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3177 STRMOVE(prevp, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3178 p = prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3179 if (flag == affile->af_comppermit)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3180 entry->ae_comppermit = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3181 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3182 entry->ae_compforbid = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3183 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3184 if (affile->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3185 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3186 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3187 if (*entry->ae_flags == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3188 entry->ae_flags = NULL; /* nothing left */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3189 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3190 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3191
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3192 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3193 * Return TRUE if "s" is the name of an info item in the affix file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3194 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3195 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3196 spell_info_item(char_u *s)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3197 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3198 return STRCMP(s, "NAME") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3199 || STRCMP(s, "HOME") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3200 || STRCMP(s, "VERSION") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3201 || STRCMP(s, "AUTHOR") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3202 || STRCMP(s, "EMAIL") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3203 || STRCMP(s, "COPYRIGHT") == 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3204 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3205
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3206 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3207 * Turn an affix flag name into a number, according to the FLAG type.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3208 * returns zero for failure.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3209 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3210 static unsigned
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3211 affitem2flag(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3212 int flagtype,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3213 char_u *item,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3214 char_u *fname,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3215 int lnum)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3216 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3217 unsigned res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3218 char_u *p = item;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3219
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3220 res = get_affitem(flagtype, &p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3221 if (res == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3222 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3223 if (flagtype == AFT_NUM)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3224 smsg((char_u *)_("Flag is not a number in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3225 fname, lnum, item);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3226 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3227 smsg((char_u *)_("Illegal flag in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3228 fname, lnum, item);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3229 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3230 if (*p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3231 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3232 smsg((char_u *)_(e_affname), fname, lnum, item);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3233 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3234 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3235
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3236 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3237 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3238
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3239 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3240 * Get one affix name from "*pp" and advance the pointer.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3241 * Returns zero for an error, still advances the pointer then.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3242 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3243 static unsigned
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3244 get_affitem(int flagtype, char_u **pp)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3245 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3246 int res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3247
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3248 if (flagtype == AFT_NUM)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3249 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3250 if (!VIM_ISDIGIT(**pp))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3251 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3252 ++*pp; /* always advance, avoid getting stuck */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3253 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3254 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3255 res = getdigits(pp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3256 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3257 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3258 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3259 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3260 res = mb_ptr2char_adv(pp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3261 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3262 res = *(*pp)++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3263 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3264 if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3265 && res >= 'A' && res <= 'Z'))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3266 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3267 if (**pp == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3268 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3269 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3270 res = mb_ptr2char_adv(pp) + (res << 16);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3271 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3272 res = *(*pp)++ + (res << 16);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3273 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3274 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3275 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3276 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3277 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3278
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3279 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3280 * Process the "compflags" string used in an affix file and append it to
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3281 * spin->si_compflags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3282 * The processing involves changing the affix names to ID numbers, so that
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3283 * they fit in one byte.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3284 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3285 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3286 process_compflags(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3287 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3288 afffile_T *aff,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3289 char_u *compflags)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3290 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3291 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3292 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3293 unsigned flag;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3294 compitem_T *ci;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3295 int id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3296 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3297 char_u *tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3298 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3299 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3300
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3301 /* Make room for the old and the new compflags, concatenated with a / in
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3302 * between. Processing it makes it shorter, but we don't know by how
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3303 * much, thus allocate the maximum. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3304 len = (int)STRLEN(compflags) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3305 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3306 len += (int)STRLEN(spin->si_compflags) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3307 p = getroom(spin, len, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3308 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3309 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3310 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3311 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3312 STRCPY(p, spin->si_compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3313 STRCAT(p, "/");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3314 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3315 spin->si_compflags = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3316 tp = p + STRLEN(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3317
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3318 for (p = compflags; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3319 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3320 if (vim_strchr((char_u *)"/?*+[]", *p) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3321 /* Copy non-flag characters directly. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3322 *tp++ = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3323 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3324 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3325 /* First get the flag number, also checks validity. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3326 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3327 flag = get_affitem(aff->af_flagtype, &p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3328 if (flag != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3329 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3330 /* Find the flag in the hashtable. If it was used before, use
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3331 * the existing ID. Otherwise add a new entry. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3332 vim_strncpy(key, prevp, p - prevp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3333 hi = hash_find(&aff->af_comp, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3334 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3335 id = HI2CI(hi)->ci_newID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3336 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3337 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3338 ci = (compitem_T *)getroom(spin, sizeof(compitem_T), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3339 if (ci == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3340 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3341 STRCPY(ci->ci_key, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3342 ci->ci_flag = flag;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3343 /* Avoid using a flag ID that has a special meaning in a
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3344 * regexp (also inside []). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3345 do
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3346 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3347 check_renumber(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3348 id = spin->si_newcompID--;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3349 } while (vim_strchr((char_u *)"/?*+[]\\-^", id) != NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3350 ci->ci_newID = id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3351 hash_add(&aff->af_comp, ci->ci_key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3352 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3353 *tp++ = id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3354 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3355 if (aff->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3356 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3357 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3358 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3359
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3360 *tp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3361 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3362
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3363 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3364 * Check that the new IDs for postponed affixes and compounding don't overrun
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3365 * each other. We have almost 255 available, but start at 0-127 to avoid
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3366 * using two bytes for utf-8. When the 0-127 range is used up go to 128-255.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3367 * When that is used up an error message is given.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3368 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3369 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3370 check_renumber(spellinfo_T *spin)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3371 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3372 if (spin->si_newprefID == spin->si_newcompID && spin->si_newcompID < 128)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3373 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3374 spin->si_newprefID = 127;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3375 spin->si_newcompID = 255;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3376 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3377 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3378
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3379 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3380 * Return TRUE if flag "flag" appears in affix list "afflist".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3381 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3382 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3383 flag_in_afflist(int flagtype, char_u *afflist, unsigned flag)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3384 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3385 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3386 unsigned n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3387
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3388 switch (flagtype)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3389 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3390 case AFT_CHAR:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3391 return vim_strchr(afflist, flag) != NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3392
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3393 case AFT_CAPLONG:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3394 case AFT_LONG:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3395 for (p = afflist; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3396 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3397 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3398 n = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3399 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3400 n = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3401 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3402 if ((flagtype == AFT_LONG || (n >= 'A' && n <= 'Z'))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3403 && *p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3404 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3405 n = mb_ptr2char_adv(&p) + (n << 16);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3406 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3407 n = *p++ + (n << 16);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3408 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3409 if (n == flag)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3410 return TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3411 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3412 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3413
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3414 case AFT_NUM:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3415 for (p = afflist; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3416 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3417 n = getdigits(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3418 if (n == flag)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3419 return TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3420 if (*p != NUL) /* skip over comma */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3421 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3422 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3423 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3424 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3425 return FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3426 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3427
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3428 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3429 * Give a warning when "spinval" and "affval" numbers are set and not the same.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3430 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3431 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3432 aff_check_number(int spinval, int affval, char *name)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3433 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3434 if (spinval != 0 && spinval != affval)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3435 smsg((char_u *)_("%s value differs from what is used in another .aff file"), name);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3436 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3437
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3438 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3439 * Give a warning when "spinval" and "affval" strings are set and not the same.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3440 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3441 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3442 aff_check_string(char_u *spinval, char_u *affval, char *name)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3443 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3444 if (spinval != NULL && STRCMP(spinval, affval) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3445 smsg((char_u *)_("%s value differs from what is used in another .aff file"), name);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3446 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3447
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3448 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3449 * Return TRUE if strings "s1" and "s2" are equal. Also consider both being
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3450 * NULL as equal.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3451 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3452 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3453 str_equal(char_u *s1, char_u *s2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3454 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3455 if (s1 == NULL || s2 == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3456 return s1 == s2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3457 return STRCMP(s1, s2) == 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3458 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3459
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3460 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3461 * Add a from-to item to "gap". Used for REP and SAL items.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3462 * They are stored case-folded.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3463 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3464 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3465 add_fromto(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3466 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3467 garray_T *gap,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3468 char_u *from,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3469 char_u *to)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3470 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3471 fromto_T *ftp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3472 char_u word[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3473
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3474 if (ga_grow(gap, 1) == OK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3475 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3476 ftp = ((fromto_T *)gap->ga_data) + gap->ga_len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3477 (void)spell_casefold(from, (int)STRLEN(from), word, MAXWLEN);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3478 ftp->ft_from = getroom_save(spin, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3479 (void)spell_casefold(to, (int)STRLEN(to), word, MAXWLEN);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3480 ftp->ft_to = getroom_save(spin, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3481 ++gap->ga_len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3482 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3483 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3484
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3485 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3486 * Convert a boolean argument in a SAL line to TRUE or FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3487 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3488 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3489 sal_to_bool(char_u *s)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3490 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3491 return STRCMP(s, "1") == 0 || STRCMP(s, "true") == 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3492 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3493
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3494 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3495 * Free the structure filled by spell_read_aff().
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3496 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3497 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3498 spell_free_aff(afffile_T *aff)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3499 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3500 hashtab_T *ht;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3501 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3502 int todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3503 affheader_T *ah;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3504 affentry_T *ae;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3505
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3506 vim_free(aff->af_enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3507
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3508 /* All this trouble to free the "ae_prog" items... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3509 for (ht = &aff->af_pref; ; ht = &aff->af_suff)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3510 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3511 todo = (int)ht->ht_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3512 for (hi = ht->ht_array; todo > 0; ++hi)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3513 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3514 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3515 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3516 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3517 ah = HI2AH(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3518 for (ae = ah->ah_first; ae != NULL; ae = ae->ae_next)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3519 vim_regfree(ae->ae_prog);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3520 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3521 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3522 if (ht == &aff->af_suff)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3523 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3524 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3525
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3526 hash_clear(&aff->af_pref);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3527 hash_clear(&aff->af_suff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3528 hash_clear(&aff->af_comp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3529 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3530
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3531 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3532 * Read dictionary file "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3533 * Returns OK or FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3534 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3535 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3536 spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3537 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3538 hashtab_T ht;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3539 char_u line[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3540 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3541 char_u *afflist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3542 char_u store_afflist[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3543 int pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3544 int need_affix;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3545 char_u *dw;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3546 char_u *pc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3547 char_u *w;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3548 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3549 hash_T hash;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3550 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3551 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3552 int lnum = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3553 int non_ascii = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3554 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3555 char_u message[MAXLINELEN + MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3556 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3557 int duplicate = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3558
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3559 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3560 * Open the file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3561 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3562 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3563 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3564 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3565 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3566 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3567 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3568
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3569 /* The hashtable is only used to detect duplicated words. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3570 hash_init(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3571
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3572 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3573 _("Reading dictionary file %s ..."), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3574 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3575
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3576 /* start with a message for the first line */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3577 spin->si_msg_count = 999999;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3578
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3579 /* Read and ignore the first line: word count. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3580 (void)vim_fgets(line, MAXLINELEN, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3581 if (!vim_isdigit(*skipwhite(line)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3582 EMSG2(_("E760: No word count in %s"), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3584 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3585 * Read all the lines in the file one by one.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3586 * The words are converted to 'encoding' here, before being added to
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3587 * the hashtable.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3588 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3589 while (!vim_fgets(line, MAXLINELEN, fd) && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3590 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3591 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3592 ++lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3593 if (line[0] == '#' || line[0] == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3594 continue; /* comment line */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3595
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3596 /* Remove CR, LF and white space from the end. White space halfway
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3597 * the word is kept to allow e.g., "et al.". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3598 l = (int)STRLEN(line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3599 while (l > 0 && line[l - 1] <= ' ')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3600 --l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3601 if (l == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3602 continue; /* empty line */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3603 line[l] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3604
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3605 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3606 /* Convert from "SET" to 'encoding' when needed. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3607 if (spin->si_conv.vc_type != CONV_NONE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3608 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3609 pc = string_convert(&spin->si_conv, line, NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3610 if (pc == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3611 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3612 smsg((char_u *)_("Conversion failure for word in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3613 fname, lnum, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3614 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3615 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3616 w = pc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3617 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3618 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3619 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3620 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3621 pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3622 w = line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3623 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3624
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3625 /* Truncate the word at the "/", set "afflist" to what follows.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3626 * Replace "\/" by "/" and "\\" by "\". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3627 afflist = NULL;
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10974
diff changeset
3628 for (p = w; *p != NUL; MB_PTR_ADV(p))
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3629 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3630 if (*p == '\\' && (p[1] == '\\' || p[1] == '/'))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3631 STRMOVE(p, p + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3632 else if (*p == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3633 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3634 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3635 afflist = p + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3636 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3637 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3638 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3639
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3640 /* Skip non-ASCII words when "spin->si_ascii" is TRUE. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3641 if (spin->si_ascii && has_non_ascii(w))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3642 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3643 ++non_ascii;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3644 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3645 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3646 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3647
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3648 /* This takes time, print a message every 10000 words. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3649 if (spin->si_verbose && spin->si_msg_count > 10000)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3650 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3651 spin->si_msg_count = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3652 vim_snprintf((char *)message, sizeof(message),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3653 _("line %6d, word %6d - %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3654 lnum, spin->si_foldwcount + spin->si_keepwcount, w);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3655 msg_start();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3656 msg_puts_long_attr(message, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3657 msg_clr_eos();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3658 msg_didout = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3659 msg_col = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3660 out_flush();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3661 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3662
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3663 /* Store the word in the hashtable to be able to find duplicates. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3664 dw = (char_u *)getroom_save(spin, w);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3665 if (dw == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3666 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3667 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3668 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3669 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3670 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3671
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3672 hash = hash_hash(dw);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3673 hi = hash_lookup(&ht, dw, hash);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3674 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3675 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3676 if (p_verbose > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3677 smsg((char_u *)_("Duplicate word in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3678 fname, lnum, dw);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3679 else if (duplicate == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3680 smsg((char_u *)_("First duplicate word in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3681 fname, lnum, dw);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3682 ++duplicate;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3683 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3684 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3685 hash_add_item(&ht, hi, dw, hash);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3686
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3687 flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3688 store_afflist[0] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3689 pfxlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3690 need_affix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3691 if (afflist != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3692 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3693 /* Extract flags from the affix list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3694 flags |= get_affix_flags(affile, afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3695
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3696 if (affile->af_needaffix != 0 && flag_in_afflist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3697 affile->af_flagtype, afflist, affile->af_needaffix))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3698 need_affix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3699
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3700 if (affile->af_pfxpostpone)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3701 /* Need to store the list of prefix IDs with the word. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3702 pfxlen = get_pfxlist(affile, afflist, store_afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3703
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3704 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3705 /* Need to store the list of compound flags with the word.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3706 * Concatenate them to the list of prefix IDs. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3707 get_compflags(affile, afflist, store_afflist + pfxlen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3708 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3709
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3710 /* Add the word to the word tree(s). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3711 if (store_word(spin, dw, flags, spin->si_region,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3712 store_afflist, need_affix) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3713 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3714
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3715 if (afflist != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3716 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3717 /* Find all matching suffixes and add the resulting words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3718 * Additionally do matching prefixes that combine. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3719 if (store_aff_word(spin, dw, afflist, affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3720 &affile->af_suff, &affile->af_pref,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3721 CONDIT_SUF, flags, store_afflist, pfxlen) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3722 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3723
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3724 /* Find all matching prefixes and add the resulting words. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3725 if (store_aff_word(spin, dw, afflist, affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3726 &affile->af_pref, NULL,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3727 CONDIT_SUF, flags, store_afflist, pfxlen) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3728 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3729 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3730
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3731 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3732 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3733
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3734 if (duplicate > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3735 smsg((char_u *)_("%d duplicate word(s) in %s"), duplicate, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3736 if (spin->si_ascii && non_ascii > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3737 smsg((char_u *)_("Ignored %d word(s) with non-ASCII characters in %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3738 non_ascii, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3739 hash_clear(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3740
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3741 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3742 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3743 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3744
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3745 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3746 * Check for affix flags in "afflist" that are turned into word flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3747 * Return WF_ flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3748 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3749 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3750 get_affix_flags(afffile_T *affile, char_u *afflist)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3751 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3752 int flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3753
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3754 if (affile->af_keepcase != 0 && flag_in_afflist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3755 affile->af_flagtype, afflist, affile->af_keepcase))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3756 flags |= WF_KEEPCAP | WF_FIXCAP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3757 if (affile->af_rare != 0 && flag_in_afflist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3758 affile->af_flagtype, afflist, affile->af_rare))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3759 flags |= WF_RARE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3760 if (affile->af_bad != 0 && flag_in_afflist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3761 affile->af_flagtype, afflist, affile->af_bad))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3762 flags |= WF_BANNED;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3763 if (affile->af_needcomp != 0 && flag_in_afflist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3764 affile->af_flagtype, afflist, affile->af_needcomp))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3765 flags |= WF_NEEDCOMP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3766 if (affile->af_comproot != 0 && flag_in_afflist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3767 affile->af_flagtype, afflist, affile->af_comproot))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3768 flags |= WF_COMPROOT;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3769 if (affile->af_nosuggest != 0 && flag_in_afflist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3770 affile->af_flagtype, afflist, affile->af_nosuggest))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3771 flags |= WF_NOSUGGEST;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3772 return flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3773 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3774
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3775 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3776 * Get the list of prefix IDs from the affix list "afflist".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3777 * Used for PFXPOSTPONE.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3778 * Put the resulting flags in "store_afflist[MAXWLEN]" with a terminating NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3779 * and return the number of affixes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3780 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3781 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3782 get_pfxlist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3783 afffile_T *affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3784 char_u *afflist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3785 char_u *store_afflist)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3786 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3787 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3788 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3789 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3790 int id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3791 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3792 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3793
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3794 for (p = afflist; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3795 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3796 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3797 if (get_affitem(affile->af_flagtype, &p) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3798 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3799 /* A flag is a postponed prefix flag if it appears in "af_pref"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3800 * and it's ID is not zero. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3801 vim_strncpy(key, prevp, p - prevp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3802 hi = hash_find(&affile->af_pref, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3803 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3804 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3805 id = HI2AH(hi)->ah_newID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3806 if (id != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3807 store_afflist[cnt++] = id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3808 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3809 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3810 if (affile->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3811 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3812 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3813
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3814 store_afflist[cnt] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3815 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3816 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3817
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3818 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3819 * Get the list of compound IDs from the affix list "afflist" that are used
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3820 * for compound words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3821 * Puts the flags in "store_afflist[]".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3822 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3823 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3824 get_compflags(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3825 afffile_T *affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3826 char_u *afflist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3827 char_u *store_afflist)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3828 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3829 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3830 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3831 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3832 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3833 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3834
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3835 for (p = afflist; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3836 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3837 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3838 if (get_affitem(affile->af_flagtype, &p) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3839 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3840 /* A flag is a compound flag if it appears in "af_comp". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3841 vim_strncpy(key, prevp, p - prevp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3842 hi = hash_find(&affile->af_comp, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3843 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3844 store_afflist[cnt++] = HI2CI(hi)->ci_newID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3845 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3846 if (affile->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3847 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3848 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3849
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3850 store_afflist[cnt] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3851 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3852
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3853 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3854 * Apply affixes to a word and store the resulting words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3855 * "ht" is the hashtable with affentry_T that need to be applied, either
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3856 * prefixes or suffixes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3857 * "xht", when not NULL, is the prefix hashtable, to be used additionally on
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3858 * the resulting words for combining affixes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3859 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3860 * Returns FAIL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3861 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3862 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3863 store_aff_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3864 spellinfo_T *spin, /* spell info */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3865 char_u *word, /* basic word start */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3866 char_u *afflist, /* list of names of supported affixes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3867 afffile_T *affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3868 hashtab_T *ht,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3869 hashtab_T *xht,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3870 int condit, /* CONDIT_SUF et al. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3871 int flags, /* flags for the word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3872 char_u *pfxlist, /* list of prefix IDs */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3873 int pfxlen) /* nr of flags in "pfxlist" for prefixes, rest
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3874 * is compound flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3875 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3876 int todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3877 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3878 affheader_T *ah;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3879 affentry_T *ae;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3880 char_u newword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3881 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3882 int i, j;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3883 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3884 int use_flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3885 char_u *use_pfxlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3886 int use_pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3887 int need_affix;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3888 char_u store_afflist[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3889 char_u pfx_pfxlist[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3890 size_t wordlen = STRLEN(word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3891 int use_condit;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3892
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3893 todo = (int)ht->ht_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3894 for (hi = ht->ht_array; todo > 0 && retval == OK; ++hi)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3895 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3896 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3897 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3898 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3899 ah = HI2AH(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3900
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3901 /* Check that the affix combines, if required, and that the word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3902 * supports this affix. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3903 if (((condit & CONDIT_COMB) == 0 || ah->ah_combine)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3904 && flag_in_afflist(affile->af_flagtype, afflist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3905 ah->ah_flag))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3906 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3907 /* Loop over all affix entries with this name. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3908 for (ae = ah->ah_first; ae != NULL; ae = ae->ae_next)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3909 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3910 /* Check the condition. It's not logical to match case
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3911 * here, but it is required for compatibility with
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3912 * Myspell.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3913 * Another requirement from Myspell is that the chop
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3914 * string is shorter than the word itself.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3915 * For prefixes, when "PFXPOSTPONE" was used, only do
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3916 * prefixes with a chop string and/or flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3917 * When a previously added affix had CIRCUMFIX this one
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3918 * must have it too, if it had not then this one must not
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3919 * have one either. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3920 if ((xht != NULL || !affile->af_pfxpostpone
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3921 || ae->ae_chop != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3922 || ae->ae_flags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3923 && (ae->ae_chop == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3924 || STRLEN(ae->ae_chop) < wordlen)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3925 && (ae->ae_prog == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3926 || vim_regexec_prog(&ae->ae_prog, FALSE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3927 word, (colnr_T)0))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3928 && (((condit & CONDIT_CFIX) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3929 == ((condit & CONDIT_AFF) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3930 || ae->ae_flags == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3931 || !flag_in_afflist(affile->af_flagtype,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3932 ae->ae_flags, affile->af_circumfix))))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3933 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3934 /* Match. Remove the chop and add the affix. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3935 if (xht == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3936 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3937 /* prefix: chop/add at the start of the word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3938 if (ae->ae_add == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3939 *newword = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3940 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3941 vim_strncpy(newword, ae->ae_add, MAXWLEN - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3942 p = word;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3943 if (ae->ae_chop != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3944 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3945 /* Skip chop string. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3946 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3947 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3948 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3949 i = mb_charlen(ae->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3950 for ( ; i > 0; --i)
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10974
diff changeset
3951 MB_PTR_ADV(p);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3952 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3953 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3954 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3955 p += STRLEN(ae->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3956 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3957 STRCAT(newword, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3958 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3959 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3960 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3961 /* suffix: chop/add at the end of the word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3962 vim_strncpy(newword, word, MAXWLEN - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3963 if (ae->ae_chop != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3964 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3965 /* Remove chop string. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3966 p = newword + STRLEN(newword);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3967 i = (int)MB_CHARLEN(ae->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3968 for ( ; i > 0; --i)
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10974
diff changeset
3969 MB_PTR_BACK(newword, p);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3970 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3971 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3972 if (ae->ae_add != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3973 STRCAT(newword, ae->ae_add);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3974 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3975
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3976 use_flags = flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3977 use_pfxlist = pfxlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3978 use_pfxlen = pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3979 need_affix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3980 use_condit = condit | CONDIT_COMB | CONDIT_AFF;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3981 if (ae->ae_flags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3982 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3983 /* Extract flags from the affix list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3984 use_flags |= get_affix_flags(affile, ae->ae_flags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3985
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3986 if (affile->af_needaffix != 0 && flag_in_afflist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3987 affile->af_flagtype, ae->ae_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3988 affile->af_needaffix))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3989 need_affix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3990
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3991 /* When there is a CIRCUMFIX flag the other affix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3992 * must also have it and we don't add the word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3993 * with one affix. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3994 if (affile->af_circumfix != 0 && flag_in_afflist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3995 affile->af_flagtype, ae->ae_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3996 affile->af_circumfix))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3997 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3998 use_condit |= CONDIT_CFIX;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3999 if ((condit & CONDIT_CFIX) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4000 need_affix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4001 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4002
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4003 if (affile->af_pfxpostpone
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4004 || spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4005 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4006 if (affile->af_pfxpostpone)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4007 /* Get prefix IDS from the affix list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4008 use_pfxlen = get_pfxlist(affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4009 ae->ae_flags, store_afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4010 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4011 use_pfxlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4012 use_pfxlist = store_afflist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4013
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4014 /* Combine the prefix IDs. Avoid adding the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4015 * same ID twice. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4016 for (i = 0; i < pfxlen; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4017 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4018 for (j = 0; j < use_pfxlen; ++j)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4019 if (pfxlist[i] == use_pfxlist[j])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4020 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4021 if (j == use_pfxlen)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4022 use_pfxlist[use_pfxlen++] = pfxlist[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4023 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4024
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4025 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4026 /* Get compound IDS from the affix list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4027 get_compflags(affile, ae->ae_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4028 use_pfxlist + use_pfxlen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4029
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4030 /* Combine the list of compound flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4031 * Concatenate them to the prefix IDs list.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4032 * Avoid adding the same ID twice. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4033 for (i = pfxlen; pfxlist[i] != NUL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4034 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4035 for (j = use_pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4036 use_pfxlist[j] != NUL; ++j)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4037 if (pfxlist[i] == use_pfxlist[j])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4038 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4039 if (use_pfxlist[j] == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4040 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4041 use_pfxlist[j++] = pfxlist[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4042 use_pfxlist[j] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4043 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4044 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4045 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4046 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4047
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4048 /* Obey a "COMPOUNDFORBIDFLAG" of the affix: don't
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4049 * use the compound flags. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4050 if (use_pfxlist != NULL && ae->ae_compforbid)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4051 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4052 vim_strncpy(pfx_pfxlist, use_pfxlist, use_pfxlen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4053 use_pfxlist = pfx_pfxlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4054 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4055
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4056 /* When there are postponed prefixes... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4057 if (spin->si_prefroot != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4058 && spin->si_prefroot->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4059 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4060 /* ... add a flag to indicate an affix was used. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4061 use_flags |= WF_HAS_AFF;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4062
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4063 /* ... don't use a prefix list if combining
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4064 * affixes is not allowed. But do use the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4065 * compound flags after them. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4066 if (!ah->ah_combine && use_pfxlist != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4067 use_pfxlist += use_pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4068 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4069
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4070 /* When compounding is supported and there is no
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4071 * "COMPOUNDPERMITFLAG" then forbid compounding on the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4072 * side where the affix is applied. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4073 if (spin->si_compflags != NULL && !ae->ae_comppermit)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4074 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4075 if (xht != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4076 use_flags |= WF_NOCOMPAFT;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4077 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4078 use_flags |= WF_NOCOMPBEF;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4079 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4080
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4081 /* Store the modified word. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4082 if (store_word(spin, newword, use_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4083 spin->si_region, use_pfxlist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4084 need_affix) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4085 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4086
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4087 /* When added a prefix or a first suffix and the affix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4088 * has flags may add a(nother) suffix. RECURSIVE! */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4089 if ((condit & CONDIT_SUF) && ae->ae_flags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4090 if (store_aff_word(spin, newword, ae->ae_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4091 affile, &affile->af_suff, xht,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4092 use_condit & (xht == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4093 ? ~0 : ~CONDIT_SUF),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4094 use_flags, use_pfxlist, pfxlen) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4095 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4096
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4097 /* When added a suffix and combining is allowed also
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4098 * try adding a prefix additionally. Both for the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4099 * word flags and for the affix flags. RECURSIVE! */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4100 if (xht != NULL && ah->ah_combine)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4101 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4102 if (store_aff_word(spin, newword,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4103 afflist, affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4104 xht, NULL, use_condit,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4105 use_flags, use_pfxlist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4106 pfxlen) == FAIL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4107 || (ae->ae_flags != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4108 && store_aff_word(spin, newword,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4109 ae->ae_flags, affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4110 xht, NULL, use_condit,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4111 use_flags, use_pfxlist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4112 pfxlen) == FAIL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4113 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4114 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4115 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4116 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4117 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4118 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4119 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4120
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4121 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4122 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4123
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4124 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4125 * Read a file with a list of words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4126 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4127 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4128 spell_read_wordfile(spellinfo_T *spin, char_u *fname)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4129 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4130 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4131 long lnum = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4132 char_u rline[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4133 char_u *line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4134 char_u *pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4135 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4136 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4137 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4138 int did_word = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4139 int non_ascii = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4140 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4141 int regionmask;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4142
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4143 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4144 * Open the file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4145 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4146 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4147 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4148 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4149 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4150 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4151 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4152
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4153 vim_snprintf((char *)IObuff, IOSIZE, _("Reading word file %s ..."), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4154 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4155
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4156 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4157 * Read all the lines in the file one by one.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4158 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4159 while (!vim_fgets(rline, MAXLINELEN, fd) && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4160 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4161 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4162 ++lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4163
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4164 /* Skip comment lines. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4165 if (*rline == '#')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4166 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4167
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4168 /* Remove CR, LF and white space from the end. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4169 l = (int)STRLEN(rline);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4170 while (l > 0 && rline[l - 1] <= ' ')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4171 --l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4172 if (l == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4173 continue; /* empty or blank line */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4174 rline[l] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4175
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4176 /* Convert from "/encoding={encoding}" to 'encoding' when needed. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4177 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4178 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4179 if (spin->si_conv.vc_type != CONV_NONE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4180 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4181 pc = string_convert(&spin->si_conv, rline, NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4182 if (pc == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4183 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4184 smsg((char_u *)_("Conversion failure for word in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4185 fname, lnum, rline);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4186 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4187 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4188 line = pc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4189 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4190 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4191 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4192 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4193 pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4194 line = rline;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4195 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4196
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4197 if (*line == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4198 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4199 ++line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4200 if (STRNCMP(line, "encoding=", 9) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4201 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4202 if (spin->si_conv.vc_type != CONV_NONE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4203 smsg((char_u *)_("Duplicate /encoding= line ignored in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4204 fname, lnum, line - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4205 else if (did_word)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4206 smsg((char_u *)_("/encoding= line after word ignored in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4207 fname, lnum, line - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4208 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4209 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4210 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4211 char_u *enc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4212
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4213 /* Setup for conversion to 'encoding'. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4214 line += 9;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4215 enc = enc_canonize(line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4216 if (enc != NULL && !spin->si_ascii
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4217 && convert_setup(&spin->si_conv, enc,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4218 p_enc) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4219 smsg((char_u *)_("Conversion in %s not supported: from %s to %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4220 fname, line, p_enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4221 vim_free(enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4222 spin->si_conv.vc_fail = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4223 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4224 smsg((char_u *)_("Conversion in %s not supported"), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4225 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4226 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4227 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4228 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4229
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4230 if (STRNCMP(line, "regions=", 8) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4231 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4232 if (spin->si_region_count > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4233 smsg((char_u *)_("Duplicate /regions= line ignored in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4234 fname, lnum, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4235 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4236 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4237 line += 8;
13232
d11bbd3440b0 patch 8.0.1490: number of spell regions is spread out through the code
Christian Brabandt <cb@256bit.org>
parents: 12694
diff changeset
4238 if (STRLEN(line) > MAXREGIONS * 2)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4239 smsg((char_u *)_("Too many regions in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4240 fname, lnum, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4241 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4242 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4243 spin->si_region_count = (int)STRLEN(line) / 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4244 STRCPY(spin->si_region_name, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4245
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4246 /* Adjust the mask for a word valid in all regions. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4247 spin->si_region = (1 << spin->si_region_count) - 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4248 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4249 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4250 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4251 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4252
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4253 smsg((char_u *)_("/ line ignored in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4254 fname, lnum, line - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4255 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4256 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4257
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4258 flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4259 regionmask = spin->si_region;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4260
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4261 /* Check for flags and region after a slash. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4262 p = vim_strchr(line, '/');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4263 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4264 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4265 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4266 while (*p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4267 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4268 if (*p == '=') /* keep-case word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4269 flags |= WF_KEEPCAP | WF_FIXCAP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4270 else if (*p == '!') /* Bad, bad, wicked word. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4271 flags |= WF_BANNED;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4272 else if (*p == '?') /* Rare word. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4273 flags |= WF_RARE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4274 else if (VIM_ISDIGIT(*p)) /* region number(s) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4275 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4276 if ((flags & WF_REGION) == 0) /* first one */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4277 regionmask = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4278 flags |= WF_REGION;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4279
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4280 l = *p - '0';
12694
514c1741ab8c patch 8.0.1225: no check for spell region being zero
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
4281 if (l == 0 || l > spin->si_region_count)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4282 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4283 smsg((char_u *)_("Invalid region nr in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4284 fname, lnum, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4285 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4286 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4287 regionmask |= 1 << (l - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4288 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4289 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4290 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4291 smsg((char_u *)_("Unrecognized flags in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4292 fname, lnum, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4293 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4294 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4295 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4296 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4297 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4298
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4299 /* Skip non-ASCII words when "spin->si_ascii" is TRUE. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4300 if (spin->si_ascii && has_non_ascii(line))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4301 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4302 ++non_ascii;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4303 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4304 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4305
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4306 /* Normal word: store it. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4307 if (store_word(spin, line, flags, regionmask, NULL, FALSE) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4308 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4309 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4310 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4311 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4312 did_word = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4313 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4314
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4315 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4316 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4317
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4318 if (spin->si_ascii && non_ascii > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4319 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4320 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4321 _("Ignored %d words with non-ASCII characters"), non_ascii);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4322 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4323 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4324
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4325 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4326 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4327
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4328 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4329 * Get part of an sblock_T, "len" bytes long.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4330 * This avoids calling free() for every little struct we use (and keeping
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4331 * track of them).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4332 * The memory is cleared to all zeros.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4333 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4334 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4335 static void *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4336 getroom(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4337 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4338 size_t len, /* length needed */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4339 int align) /* align for pointer */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4340 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4341 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4342 sblock_T *bl = spin->si_blocks;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4343
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4344 if (align && bl != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4345 /* Round size up for alignment. On some systems structures need to be
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4346 * aligned to the size of a pointer (e.g., SPARC). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4347 bl->sb_used = (bl->sb_used + sizeof(char *) - 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4348 & ~(sizeof(char *) - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4349
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4350 if (bl == NULL || bl->sb_used + len > SBLOCKSIZE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4351 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4352 if (len >= SBLOCKSIZE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4353 bl = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4354 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4355 /* Allocate a block of memory. It is not freed until much later. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4356 bl = (sblock_T *)alloc_clear(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4357 (unsigned)(sizeof(sblock_T) + SBLOCKSIZE));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4358 if (bl == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4359 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4360 if (!spin->si_did_emsg)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4361 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4362 EMSG(_("E845: Insufficient memory, word list will be incomplete"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4363 spin->si_did_emsg = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4364 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4365 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4366 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4367 bl->sb_next = spin->si_blocks;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4368 spin->si_blocks = bl;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4369 bl->sb_used = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4370 ++spin->si_blocks_cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4371 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4372
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4373 p = bl->sb_data + bl->sb_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4374 bl->sb_used += (int)len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4375
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4376 return p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4377 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4378
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4379 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4380 * Make a copy of a string into memory allocated with getroom().
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4381 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4382 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4383 static char_u *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4384 getroom_save(spellinfo_T *spin, char_u *s)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4385 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4386 char_u *sc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4387
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4388 sc = (char_u *)getroom(spin, STRLEN(s) + 1, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4389 if (sc != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4390 STRCPY(sc, s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4391 return sc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4392 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4393
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4394
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4395 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4396 * Free the list of allocated sblock_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4397 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4398 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4399 free_blocks(sblock_T *bl)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4400 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4401 sblock_T *next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4402
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4403 while (bl != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4404 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4405 next = bl->sb_next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4406 vim_free(bl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4407 bl = next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4408 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4409 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4410
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4411 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4412 * Allocate the root of a word tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4413 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4414 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4415 static wordnode_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4416 wordtree_alloc(spellinfo_T *spin)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4417 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4418 return (wordnode_T *)getroom(spin, sizeof(wordnode_T), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4419 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4420
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4421 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4422 * Store a word in the tree(s).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4423 * Always store it in the case-folded tree. For a keep-case word this is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4424 * useful when the word can also be used with all caps (no WF_FIXCAP flag) and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4425 * used to find suggestions.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4426 * For a keep-case word also store it in the keep-case tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4427 * When "pfxlist" is not NULL store the word for each postponed prefix ID and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4428 * compound flag.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4429 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4430 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4431 store_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4432 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4433 char_u *word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4434 int flags, /* extra flags, WF_BANNED */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4435 int region, /* supported region(s) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4436 char_u *pfxlist, /* list of prefix IDs or NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4437 int need_affix) /* only store word with affix ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4438 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4439 int len = (int)STRLEN(word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4440 int ct = captype(word, word + len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4441 char_u foldword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4442 int res = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4443 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4444
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4445 (void)spell_casefold(word, len, foldword, MAXWLEN);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4446 for (p = pfxlist; res == OK; ++p)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4447 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4448 if (!need_affix || (p != NULL && *p != NUL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4449 res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4450 region, p == NULL ? 0 : *p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4451 if (p == NULL || *p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4452 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4453 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4454 ++spin->si_foldwcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4455
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4456 if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4457 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4458 for (p = pfxlist; res == OK; ++p)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4459 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4460 if (!need_affix || (p != NULL && *p != NUL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4461 res = tree_add_word(spin, word, spin->si_keeproot, flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4462 region, p == NULL ? 0 : *p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4463 if (p == NULL || *p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4464 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4465 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4466 ++spin->si_keepwcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4467 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4468 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4469 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4470
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4471 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4472 * Add word "word" to a word tree at "root".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4473 * When "flags" < 0 we are adding to the prefix tree where "flags" is used for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4474 * "rare" and "region" is the condition nr.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4475 * Returns FAIL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4476 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4477 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4478 tree_add_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4479 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4480 char_u *word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4481 wordnode_T *root,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4482 int flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4483 int region,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4484 int affixID)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4485 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4486 wordnode_T *node = root;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4487 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4488 wordnode_T *copyp, **copyprev;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4489 wordnode_T **prev = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4490 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4491
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4492 /* Add each byte of the word to the tree, including the NUL at the end. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4493 for (i = 0; ; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4494 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4495 /* When there is more than one reference to this node we need to make
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4496 * a copy, so that we can modify it. Copy the whole list of siblings
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4497 * (we don't optimize for a partly shared list of siblings). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4498 if (node != NULL && node->wn_refs > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4499 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4500 --node->wn_refs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4501 copyprev = prev;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4502 for (copyp = node; copyp != NULL; copyp = copyp->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4503 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4504 /* Allocate a new node and copy the info. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4505 np = get_wordnode(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4506 if (np == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4507 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4508 np->wn_child = copyp->wn_child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4509 if (np->wn_child != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4510 ++np->wn_child->wn_refs; /* child gets extra ref */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4511 np->wn_byte = copyp->wn_byte;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4512 if (np->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4513 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4514 np->wn_flags = copyp->wn_flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4515 np->wn_region = copyp->wn_region;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4516 np->wn_affixID = copyp->wn_affixID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4517 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4518
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4519 /* Link the new node in the list, there will be one ref. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4520 np->wn_refs = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4521 if (copyprev != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4522 *copyprev = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4523 copyprev = &np->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4524
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4525 /* Let "node" point to the head of the copied list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4526 if (copyp == node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4527 node = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4528 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4529 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4530
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4531 /* Look for the sibling that has the same character. They are sorted
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4532 * on byte value, thus stop searching when a sibling is found with a
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4533 * higher byte value. For zero bytes (end of word) the sorting is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4534 * done on flags and then on affixID. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4535 while (node != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4536 && (node->wn_byte < word[i]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4537 || (node->wn_byte == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4538 && (flags < 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4539 ? node->wn_affixID < (unsigned)affixID
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4540 : (node->wn_flags < (unsigned)(flags & WN_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4541 || (node->wn_flags == (flags & WN_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4542 && (spin->si_sugtree
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4543 ? (node->wn_region & 0xffff) < region
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4544 : node->wn_affixID
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4545 < (unsigned)affixID)))))))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4546 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4547 prev = &node->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4548 node = *prev;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4549 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4550 if (node == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4551 || node->wn_byte != word[i]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4552 || (word[i] == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4553 && (flags < 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4554 || spin->si_sugtree
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4555 || node->wn_flags != (flags & WN_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4556 || node->wn_affixID != affixID)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4557 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4558 /* Allocate a new node. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4559 np = get_wordnode(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4560 if (np == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4561 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4562 np->wn_byte = word[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4563
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4564 /* If "node" is NULL this is a new child or the end of the sibling
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4565 * list: ref count is one. Otherwise use ref count of sibling and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4566 * make ref count of sibling one (matters when inserting in front
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4567 * of the list of siblings). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4568 if (node == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4569 np->wn_refs = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4570 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4571 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4572 np->wn_refs = node->wn_refs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4573 node->wn_refs = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4574 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4575 if (prev != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4576 *prev = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4577 np->wn_sibling = node;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4578 node = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4579 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4580
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4581 if (word[i] == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4582 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4583 node->wn_flags = flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4584 node->wn_region |= region;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4585 node->wn_affixID = affixID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4586 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4587 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4588 prev = &node->wn_child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4589 node = *prev;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4590 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4591 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4592 smsg((char_u *)"Added \"%s\"", word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4593 spell_print_tree(root->wn_sibling);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4594 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4595
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4596 /* count nr of words added since last message */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4597 ++spin->si_msg_count;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4598
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4599 if (spin->si_compress_cnt > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4600 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4601 if (--spin->si_compress_cnt == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4602 /* Did enough words to lower the block count limit. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4603 spin->si_blocks_cnt += compress_inc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4604 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4605
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4606 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4607 * When we have allocated lots of memory we need to compress the word tree
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4608 * to free up some room. But compression is slow, and we might actually
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4609 * need that room, thus only compress in the following situations:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4610 * 1. When not compressed before (si_compress_cnt == 0): when using
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4611 * "compress_start" blocks.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4612 * 2. When compressed before and used "compress_inc" blocks before
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4613 * adding "compress_added" words (si_compress_cnt > 1).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4614 * 3. When compressed before, added "compress_added" words
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4615 * (si_compress_cnt == 1) and the number of free nodes drops below the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4616 * maximum word length.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4617 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4618 #ifndef SPELL_COMPRESS_ALLWAYS
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4619 if (spin->si_compress_cnt == 1
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4620 ? spin->si_free_count < MAXWLEN
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4621 : spin->si_blocks_cnt >= compress_start)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4622 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4623 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4624 /* Decrement the block counter. The effect is that we compress again
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4625 * when the freed up room has been used and another "compress_inc"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4626 * blocks have been allocated. Unless "compress_added" words have
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4627 * been added, then the limit is put back again. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4628 spin->si_blocks_cnt -= compress_inc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4629 spin->si_compress_cnt = compress_added;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4630
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4631 if (spin->si_verbose)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4632 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4633 msg_start();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4634 msg_puts((char_u *)_(msg_compressing));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4635 msg_clr_eos();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4636 msg_didout = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4637 msg_col = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4638 out_flush();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4639 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4640
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4641 /* Compress both trees. Either they both have many nodes, which makes
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4642 * compression useful, or one of them is small, which means
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4643 * compression goes fast. But when filling the soundfold word tree
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4644 * there is no keep-case tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4645 wordtree_compress(spin, spin->si_foldroot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4646 if (affixID >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4647 wordtree_compress(spin, spin->si_keeproot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4648 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4649
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4650 return OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4651 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4652
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4653 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4654 * Get a wordnode_T, either from the list of previously freed nodes or
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4655 * allocate a new one.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4656 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4657 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4658 static wordnode_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4659 get_wordnode(spellinfo_T *spin)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4660 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4661 wordnode_T *n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4662
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4663 if (spin->si_first_free == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4664 n = (wordnode_T *)getroom(spin, sizeof(wordnode_T), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4665 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4666 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4667 n = spin->si_first_free;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4668 spin->si_first_free = n->wn_child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4669 vim_memset(n, 0, sizeof(wordnode_T));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4670 --spin->si_free_count;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4671 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4672 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4673 if (n != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4674 n->wn_nr = ++spin->si_wordnode_nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4675 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4676 return n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4677 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4678
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4679 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4680 * Decrement the reference count on a node (which is the head of a list of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4681 * siblings). If the reference count becomes zero free the node and its
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4682 * siblings.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4683 * Returns the number of nodes actually freed.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4684 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4685 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4686 deref_wordnode(spellinfo_T *spin, wordnode_T *node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4687 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4688 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4689 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4690
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4691 if (--node->wn_refs == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4692 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4693 for (np = node; np != NULL; np = np->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4694 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4695 if (np->wn_child != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4696 cnt += deref_wordnode(spin, np->wn_child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4697 free_wordnode(spin, np);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4698 ++cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4699 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4700 ++cnt; /* length field */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4701 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4702 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4703 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4704
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4705 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4706 * Free a wordnode_T for re-use later.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4707 * Only the "wn_child" field becomes invalid.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4708 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4709 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4710 free_wordnode(spellinfo_T *spin, wordnode_T *n)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4711 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4712 n->wn_child = spin->si_first_free;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4713 spin->si_first_free = n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4714 ++spin->si_free_count;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4715 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4716
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4717 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4718 * Compress a tree: find tails that are identical and can be shared.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4719 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4720 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4721 wordtree_compress(spellinfo_T *spin, wordnode_T *root)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4722 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4723 hashtab_T ht;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4724 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4725 int tot = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4726 int perc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4727
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4728 /* Skip the root itself, it's not actually used. The first sibling is the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4729 * start of the tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4730 if (root->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4731 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4732 hash_init(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4733 n = node_compress(spin, root->wn_sibling, &ht, &tot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4734
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4735 #ifndef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4736 if (spin->si_verbose || p_verbose > 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4737 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4738 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4739 if (tot > 1000000)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4740 perc = (tot - n) / (tot / 100);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4741 else if (tot == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4742 perc = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4743 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4744 perc = (tot - n) * 100 / tot;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4745 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4746 _("Compressed %d of %d nodes; %d (%d%%) remaining"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4747 n, tot, tot - n, perc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4748 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4749 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4750 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4751 spell_print_tree(root->wn_sibling);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4752 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4753 hash_clear(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4754 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4755 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4756
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4757 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4758 * Compress a node, its siblings and its children, depth first.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4759 * Returns the number of compressed nodes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4760 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4761 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4762 node_compress(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4763 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4764 wordnode_T *node,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4765 hashtab_T *ht,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4766 int *tot) /* total count of nodes before compressing,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4767 incremented while going through the tree */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4768 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4769 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4770 wordnode_T *tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4771 wordnode_T *child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4772 hash_T hash;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4773 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4774 int len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4775 unsigned nr, n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4776 int compressed = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4777
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4778 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4779 * Go through the list of siblings. Compress each child and then try
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4780 * finding an identical child to replace it.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4781 * Note that with "child" we mean not just the node that is pointed to,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4782 * but the whole list of siblings of which the child node is the first.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4783 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4784 for (np = node; np != NULL && !got_int; np = np->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4785 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4786 ++len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4787 if ((child = np->wn_child) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4788 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4789 /* Compress the child first. This fills hashkey. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4790 compressed += node_compress(spin, child, ht, tot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4791
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4792 /* Try to find an identical child. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4793 hash = hash_hash(child->wn_u1.hashkey);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4794 hi = hash_lookup(ht, child->wn_u1.hashkey, hash);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4795 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4796 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4797 /* There are children we encountered before with a hash value
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4798 * identical to the current child. Now check if there is one
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4799 * that is really identical. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4800 for (tp = HI2WN(hi); tp != NULL; tp = tp->wn_u2.next)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4801 if (node_equal(child, tp))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4802 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4803 /* Found one! Now use that child in place of the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4804 * current one. This means the current child and all
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4805 * its siblings is unlinked from the tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4806 ++tp->wn_refs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4807 compressed += deref_wordnode(spin, child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4808 np->wn_child = tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4809 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4810 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4811 if (tp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4812 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4813 /* No other child with this hash value equals the child of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4814 * the node, add it to the linked list after the first
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4815 * item. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4816 tp = HI2WN(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4817 child->wn_u2.next = tp->wn_u2.next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4818 tp->wn_u2.next = child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4819 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4820 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4821 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4822 /* No other child has this hash value, add it to the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4823 * hashtable. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4824 hash_add_item(ht, hi, child->wn_u1.hashkey, hash);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4825 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4826 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4827 *tot += len + 1; /* add one for the node that stores the length */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4828
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4829 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4830 * Make a hash key for the node and its siblings, so that we can quickly
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4831 * find a lookalike node. This must be done after compressing the sibling
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4832 * list, otherwise the hash key would become invalid by the compression.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4833 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4834 node->wn_u1.hashkey[0] = len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4835 nr = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4836 for (np = node; np != NULL; np = np->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4837 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4838 if (np->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4839 /* end node: use wn_flags, wn_region and wn_affixID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4840 n = np->wn_flags + (np->wn_region << 8) + (np->wn_affixID << 16);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4841 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4842 /* byte node: use the byte value and the child pointer */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4843 n = (unsigned)(np->wn_byte + ((long_u)np->wn_child << 8));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4844 nr = nr * 101 + n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4845 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4846
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4847 /* Avoid NUL bytes, it terminates the hash key. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4848 n = nr & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4849 node->wn_u1.hashkey[1] = n == 0 ? 1 : n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4850 n = (nr >> 8) & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4851 node->wn_u1.hashkey[2] = n == 0 ? 1 : n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4852 n = (nr >> 16) & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4853 node->wn_u1.hashkey[3] = n == 0 ? 1 : n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4854 n = (nr >> 24) & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4855 node->wn_u1.hashkey[4] = n == 0 ? 1 : n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4856 node->wn_u1.hashkey[5] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4857
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4858 /* Check for CTRL-C pressed now and then. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4859 fast_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4860
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4861 return compressed;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4862 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4863
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4864 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4865 * Return TRUE when two nodes have identical siblings and children.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4866 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4867 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4868 node_equal(wordnode_T *n1, wordnode_T *n2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4869 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4870 wordnode_T *p1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4871 wordnode_T *p2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4872
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4873 for (p1 = n1, p2 = n2; p1 != NULL && p2 != NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4874 p1 = p1->wn_sibling, p2 = p2->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4875 if (p1->wn_byte != p2->wn_byte
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4876 || (p1->wn_byte == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4877 ? (p1->wn_flags != p2->wn_flags
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4878 || p1->wn_region != p2->wn_region
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4879 || p1->wn_affixID != p2->wn_affixID)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4880 : (p1->wn_child != p2->wn_child)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4881 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4882
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4883 return p1 == NULL && p2 == NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4884 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4885
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4886 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4887 #ifdef __BORLANDC__
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4888 _RTLENTRYF
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4889 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4890 rep_compare(const void *s1, const void *s2);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4891
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4892 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4893 * Function given to qsort() to sort the REP items on "from" string.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4894 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4895 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4896 #ifdef __BORLANDC__
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4897 _RTLENTRYF
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4898 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4899 rep_compare(const void *s1, const void *s2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4900 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4901 fromto_T *p1 = (fromto_T *)s1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4902 fromto_T *p2 = (fromto_T *)s2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4903
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4904 return STRCMP(p1->ft_from, p2->ft_from);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4905 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4906
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4907 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4908 * Write the Vim .spl file "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4909 * Return FAIL or OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4910 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4911 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4912 write_vim_spell(spellinfo_T *spin, char_u *fname)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4913 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4914 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4915 int regionmask;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4916 int round;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4917 wordnode_T *tree;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4918 int nodecount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4919 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4920 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4921 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4922 fromto_T *ftp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4923 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4924 int rr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4925 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4926 size_t fwv = 1; /* collect return value of fwrite() to avoid
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4927 warnings from picky compiler */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4928
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4929 fd = mch_fopen((char *)fname, "w");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4930 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4931 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4932 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4933 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4934 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4935
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4936 /* <HEADER>: <fileID> <versionnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4937 /* <fileID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4938 fwv &= fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4939 if (fwv != (size_t)1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4940 /* Catch first write error, don't try writing more. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4941 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4942
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4943 putc(VIMSPELLVERSION, fd); /* <versionnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4944
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4945 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4946 * <SECTIONS>: <section> ... <sectionend>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4947 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4948
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4949 /* SN_INFO: <infotext> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4950 if (spin->si_info != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4951 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4952 putc(SN_INFO, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4953 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4954
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4955 i = (int)STRLEN(spin->si_info);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4956 put_bytes(fd, (long_u)i, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4957 fwv &= fwrite(spin->si_info, (size_t)i, (size_t)1, fd); /* <infotext> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4958 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4959
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4960 /* SN_REGION: <regionname> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4961 * Write the region names only if there is more than one. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4962 if (spin->si_region_count > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4963 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4964 putc(SN_REGION, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4965 putc(SNF_REQUIRED, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4966 l = spin->si_region_count * 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4967 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4968 fwv &= fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4969 /* <regionname> ... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4970 regionmask = (1 << spin->si_region_count) - 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4971 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4972 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4973 regionmask = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4974
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4975 /* SN_CHARFLAGS: <charflagslen> <charflags> <folcharslen> <folchars>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4976 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4977 * The table with character flags and the table for case folding.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4978 * This makes sure the same characters are recognized as word characters
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4979 * when generating an when using a spell file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4980 * Skip this for ASCII, the table may conflict with the one used for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4981 * 'encoding'.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4982 * Also skip this for an .add.spl file, the main spell file must contain
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4983 * the table (avoids that it conflicts). File is shorter too.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4984 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4985 if (!spin->si_ascii && !spin->si_add)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4986 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4987 char_u folchars[128 * 8];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4988 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4989
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4990 putc(SN_CHARFLAGS, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4991 putc(SNF_REQUIRED, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4992
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4993 /* Form the <folchars> string first, we need to know its length. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4994 l = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4995 for (i = 128; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4996 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4997 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4998 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4999 l += mb_char2bytes(spelltab.st_fold[i], folchars + l);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5000 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5001 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5002 folchars[l++] = spelltab.st_fold[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5003 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5004 put_bytes(fd, (long_u)(1 + 128 + 2 + l), 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5005
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5006 fputc(128, fd); /* <charflagslen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5007 for (i = 128; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5008 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5009 flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5010 if (spelltab.st_isw[i])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5011 flags |= CF_WORD;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5012 if (spelltab.st_isu[i])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5013 flags |= CF_UPPER;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5014 fputc(flags, fd); /* <charflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5015 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5016
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5017 put_bytes(fd, (long_u)l, 2); /* <folcharslen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5018 fwv &= fwrite(folchars, (size_t)l, (size_t)1, fd); /* <folchars> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5019 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5020
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5021 /* SN_MIDWORD: <midword> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5022 if (spin->si_midword != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5023 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5024 putc(SN_MIDWORD, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5025 putc(SNF_REQUIRED, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5026
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5027 i = (int)STRLEN(spin->si_midword);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5028 put_bytes(fd, (long_u)i, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5029 fwv &= fwrite(spin->si_midword, (size_t)i, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5030 /* <midword> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5031 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5032
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5033 /* SN_PREFCOND: <prefcondcnt> <prefcond> ... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5034 if (spin->si_prefcond.ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5035 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5036 putc(SN_PREFCOND, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5037 putc(SNF_REQUIRED, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5038
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5039 l = write_spell_prefcond(NULL, &spin->si_prefcond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5040 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5041
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5042 write_spell_prefcond(fd, &spin->si_prefcond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5043 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5044
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5045 /* SN_REP: <repcount> <rep> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5046 * SN_SAL: <salflags> <salcount> <sal> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5047 * SN_REPSAL: <repcount> <rep> ... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5048
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5049 /* round 1: SN_REP section
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5050 * round 2: SN_SAL section (unless SN_SOFO is used)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5051 * round 3: SN_REPSAL section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5052 for (round = 1; round <= 3; ++round)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5053 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5054 if (round == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5055 gap = &spin->si_rep;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5056 else if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5057 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5058 /* Don't write SN_SAL when using a SN_SOFO section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5059 if (spin->si_sofofr != NULL && spin->si_sofoto != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5060 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5061 gap = &spin->si_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5062 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5063 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5064 gap = &spin->si_repsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5065
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5066 /* Don't write the section if there are no items. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5067 if (gap->ga_len == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5068 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5069
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5070 /* Sort the REP/REPSAL items. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5071 if (round != 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5072 qsort(gap->ga_data, (size_t)gap->ga_len,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5073 sizeof(fromto_T), rep_compare);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5074
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5075 i = round == 1 ? SN_REP : (round == 2 ? SN_SAL : SN_REPSAL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5076 putc(i, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5077
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5078 /* This is for making suggestions, section is not required. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5079 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5080
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5081 /* Compute the length of what follows. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5082 l = 2; /* count <repcount> or <salcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5083 for (i = 0; i < gap->ga_len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5084 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5085 ftp = &((fromto_T *)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5086 l += 1 + (int)STRLEN(ftp->ft_from); /* count <*fromlen> and <*from> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5087 l += 1 + (int)STRLEN(ftp->ft_to); /* count <*tolen> and <*to> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5088 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5089 if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5090 ++l; /* count <salflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5091 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5092
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5093 if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5094 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5095 i = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5096 if (spin->si_followup)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5097 i |= SAL_F0LLOWUP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5098 if (spin->si_collapse)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5099 i |= SAL_COLLAPSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5100 if (spin->si_rem_accents)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5101 i |= SAL_REM_ACCENTS;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5102 putc(i, fd); /* <salflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5103 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5104
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5105 put_bytes(fd, (long_u)gap->ga_len, 2); /* <repcount> or <salcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5106 for (i = 0; i < gap->ga_len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5107 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5108 /* <rep> : <repfromlen> <repfrom> <reptolen> <repto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5109 /* <sal> : <salfromlen> <salfrom> <saltolen> <salto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5110 ftp = &((fromto_T *)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5111 for (rr = 1; rr <= 2; ++rr)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5112 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5113 p = rr == 1 ? ftp->ft_from : ftp->ft_to;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5114 l = (int)STRLEN(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5115 putc(l, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5116 if (l > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5117 fwv &= fwrite(p, l, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5118 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5119 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5120
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5121 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5122
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5123 /* SN_SOFO: <sofofromlen> <sofofrom> <sofotolen> <sofoto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5124 * This is for making suggestions, section is not required. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5125 if (spin->si_sofofr != NULL && spin->si_sofoto != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5126 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5127 putc(SN_SOFO, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5128 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5129
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5130 l = (int)STRLEN(spin->si_sofofr);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5131 put_bytes(fd, (long_u)(l + STRLEN(spin->si_sofoto) + 4), 4);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5132 /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5133
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5134 put_bytes(fd, (long_u)l, 2); /* <sofofromlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5135 fwv &= fwrite(spin->si_sofofr, l, (size_t)1, fd); /* <sofofrom> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5136
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5137 l = (int)STRLEN(spin->si_sofoto);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5138 put_bytes(fd, (long_u)l, 2); /* <sofotolen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5139 fwv &= fwrite(spin->si_sofoto, l, (size_t)1, fd); /* <sofoto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5140 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5141
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5142 /* SN_WORDS: <word> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5143 * This is for making suggestions, section is not required. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5144 if (spin->si_commonwords.ht_used > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5145 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5146 putc(SN_WORDS, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5147 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5148
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5149 /* round 1: count the bytes
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5150 * round 2: write the bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5151 for (round = 1; round <= 2; ++round)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5152 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5153 int todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5154 int len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5155 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5156
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5157 todo = (int)spin->si_commonwords.ht_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5158 for (hi = spin->si_commonwords.ht_array; todo > 0; ++hi)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5159 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5160 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5161 l = (int)STRLEN(hi->hi_key) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5162 len += l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5163 if (round == 2) /* <word> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5164 fwv &= fwrite(hi->hi_key, (size_t)l, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5165 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5166 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5167 if (round == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5168 put_bytes(fd, (long_u)len, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5169 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5170 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5171
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5172 /* SN_MAP: <mapstr>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5173 * This is for making suggestions, section is not required. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5174 if (spin->si_map.ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5175 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5176 putc(SN_MAP, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5177 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5178 l = spin->si_map.ga_len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5179 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5180 fwv &= fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5181 /* <mapstr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5182 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5183
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5184 /* SN_SUGFILE: <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5185 * This is used to notify that a .sug file may be available and at the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5186 * same time allows for checking that a .sug file that is found matches
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5187 * with this .spl file. That's because the word numbers must be exactly
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5188 * right. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5189 if (!spin->si_nosugfile
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5190 && (spin->si_sal.ga_len > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5191 || (spin->si_sofofr != NULL && spin->si_sofoto != NULL)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5192 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5193 putc(SN_SUGFILE, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5194 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5195 put_bytes(fd, (long_u)8, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5196
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5197 /* Set si_sugtime and write it to the file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5198 spin->si_sugtime = time(NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5199 put_time(fd, spin->si_sugtime); /* <timestamp> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5200 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5201
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5202 /* SN_NOSPLITSUGS: nothing
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5203 * This is used to notify that no suggestions with word splits are to be
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5204 * made. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5205 if (spin->si_nosplitsugs)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5206 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5207 putc(SN_NOSPLITSUGS, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5208 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5209 put_bytes(fd, (long_u)0, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5210 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5211
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5212 /* SN_NOCOMPUNDSUGS: nothing
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5213 * This is used to notify that no suggestions with compounds are to be
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5214 * made. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5215 if (spin->si_nocompoundsugs)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5216 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5217 putc(SN_NOCOMPOUNDSUGS, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5218 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5219 put_bytes(fd, (long_u)0, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5220 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5221
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5222 /* SN_COMPOUND: compound info.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5223 * We don't mark it required, when not supported all compound words will
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5224 * be bad words. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5225 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5226 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5227 putc(SN_COMPOUND, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5228 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5229
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5230 l = (int)STRLEN(spin->si_compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5231 for (i = 0; i < spin->si_comppat.ga_len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5232 l += (int)STRLEN(((char_u **)(spin->si_comppat.ga_data))[i]) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5233 put_bytes(fd, (long_u)(l + 7), 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5234
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5235 putc(spin->si_compmax, fd); /* <compmax> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5236 putc(spin->si_compminlen, fd); /* <compminlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5237 putc(spin->si_compsylmax, fd); /* <compsylmax> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5238 putc(0, fd); /* for Vim 7.0b compatibility */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5239 putc(spin->si_compoptions, fd); /* <compoptions> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5240 put_bytes(fd, (long_u)spin->si_comppat.ga_len, 2);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5241 /* <comppatcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5242 for (i = 0; i < spin->si_comppat.ga_len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5243 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5244 p = ((char_u **)(spin->si_comppat.ga_data))[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5245 putc((int)STRLEN(p), fd); /* <comppatlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5246 fwv &= fwrite(p, (size_t)STRLEN(p), (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5247 /* <comppattext> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5248 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5249 /* <compflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5250 fwv &= fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5251 (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5252 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5253
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5254 /* SN_NOBREAK: NOBREAK flag */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5255 if (spin->si_nobreak)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5256 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5257 putc(SN_NOBREAK, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5258 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5259
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5260 /* It's empty, the presence of the section flags the feature. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5261 put_bytes(fd, (long_u)0, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5262 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5263
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5264 /* SN_SYLLABLE: syllable info.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5265 * We don't mark it required, when not supported syllables will not be
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5266 * counted. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5267 if (spin->si_syllable != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5268 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5269 putc(SN_SYLLABLE, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5270 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5271
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5272 l = (int)STRLEN(spin->si_syllable);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5273 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5274 fwv &= fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5275 /* <syllable> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5276 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5277
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5278 /* end of <SECTIONS> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5279 putc(SN_END, fd); /* <sectionend> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5280
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5281
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5282 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5283 * <LWORDTREE> <KWORDTREE> <PREFIXTREE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5284 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5285 spin->si_memtot = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5286 for (round = 1; round <= 3; ++round)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5287 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5288 if (round == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5289 tree = spin->si_foldroot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5290 else if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5291 tree = spin->si_keeproot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5292 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5293 tree = spin->si_prefroot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5294
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5295 /* Clear the index and wnode fields in the tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5296 clear_node(tree);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5297
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5298 /* Count the number of nodes. Needed to be able to allocate the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5299 * memory when reading the nodes. Also fills in index for shared
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5300 * nodes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5301 nodecount = put_node(NULL, tree, 0, regionmask, round == 3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5302
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5303 /* number of nodes in 4 bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5304 put_bytes(fd, (long_u)nodecount, 4); /* <nodecount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5305 spin->si_memtot += nodecount + nodecount * sizeof(int);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5306
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5307 /* Write the nodes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5308 (void)put_node(fd, tree, 0, regionmask, round == 3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5309 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5310
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5311 /* Write another byte to check for errors (file system full). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5312 if (putc(0, fd) == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5313 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5314 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5315 if (fclose(fd) == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5316 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5317
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5318 if (fwv != (size_t)1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5319 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5320 if (retval == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5321 EMSG(_(e_write));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5322
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5323 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5324 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5325
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5326 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5327 * Clear the index and wnode fields of "node", it siblings and its
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5328 * children. This is needed because they are a union with other items to save
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5329 * space.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5330 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5331 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5332 clear_node(wordnode_T *node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5333 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5334 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5335
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5336 if (node != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5337 for (np = node; np != NULL; np = np->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5338 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5339 np->wn_u1.index = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5340 np->wn_u2.wnode = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5341
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5342 if (np->wn_byte != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5343 clear_node(np->wn_child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5344 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5345 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5346
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5347
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5348 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5349 * Dump a word tree at node "node".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5350 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5351 * This first writes the list of possible bytes (siblings). Then for each
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5352 * byte recursively write the children.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5353 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5354 * NOTE: The code here must match the code in read_tree_node(), since
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5355 * assumptions are made about the indexes (so that we don't have to write them
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5356 * in the file).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5357 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5358 * Returns the number of nodes used.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5359 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5360 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5361 put_node(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5362 FILE *fd, /* NULL when only counting */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5363 wordnode_T *node,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5364 int idx,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5365 int regionmask,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5366 int prefixtree) /* TRUE for PREFIXTREE */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5367 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5368 int newindex = idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5369 int siblingcount = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5370 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5371 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5372
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5373 /* If "node" is zero the tree is empty. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5374 if (node == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5375 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5376
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5377 /* Store the index where this node is written. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5378 node->wn_u1.index = idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5379
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5380 /* Count the number of siblings. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5381 for (np = node; np != NULL; np = np->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5382 ++siblingcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5383
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5384 /* Write the sibling count. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5385 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5386 putc(siblingcount, fd); /* <siblingcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5387
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5388 /* Write each sibling byte and optionally extra info. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5389 for (np = node; np != NULL; np = np->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5390 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5391 if (np->wn_byte == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5392 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5393 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5394 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5395 /* For a NUL byte (end of word) write the flags etc. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5396 if (prefixtree)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5397 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5398 /* In PREFIXTREE write the required affixID and the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5399 * associated condition nr (stored in wn_region). The
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5400 * byte value is misused to store the "rare" and "not
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5401 * combining" flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5402 if (np->wn_flags == (short_u)PFX_FLAGS)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5403 putc(BY_NOFLAGS, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5404 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5405 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5406 putc(BY_FLAGS, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5407 putc(np->wn_flags, fd); /* <pflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5408 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5409 putc(np->wn_affixID, fd); /* <affixID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5410 put_bytes(fd, (long_u)np->wn_region, 2); /* <prefcondnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5411 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5412 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5413 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5414 /* For word trees we write the flag/region items. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5415 flags = np->wn_flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5416 if (regionmask != 0 && np->wn_region != regionmask)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5417 flags |= WF_REGION;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5418 if (np->wn_affixID != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5419 flags |= WF_AFX;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5420 if (flags == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5421 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5422 /* word without flags or region */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5423 putc(BY_NOFLAGS, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5424 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5425 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5426 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5427 if (np->wn_flags >= 0x100)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5428 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5429 putc(BY_FLAGS2, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5430 putc(flags, fd); /* <flags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5431 putc((unsigned)flags >> 8, fd); /* <flags2> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5432 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5433 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5434 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5435 putc(BY_FLAGS, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5436 putc(flags, fd); /* <flags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5437 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5438 if (flags & WF_REGION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5439 putc(np->wn_region, fd); /* <region> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5440 if (flags & WF_AFX)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5441 putc(np->wn_affixID, fd); /* <affixID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5442 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5443 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5444 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5445 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5446 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5447 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5448 if (np->wn_child->wn_u1.index != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5449 && np->wn_child->wn_u2.wnode != node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5450 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5451 /* The child is written elsewhere, write the reference. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5452 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5453 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5454 putc(BY_INDEX, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5455 /* <nodeidx> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5456 put_bytes(fd, (long_u)np->wn_child->wn_u1.index, 3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5457 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5458 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5459 else if (np->wn_child->wn_u2.wnode == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5460 /* We will write the child below and give it an index. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5461 np->wn_child->wn_u2.wnode = node;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5462
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5463 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5464 if (putc(np->wn_byte, fd) == EOF) /* <byte> or <xbyte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5465 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5466 EMSG(_(e_write));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5467 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5468 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5469 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5470 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5471
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5472 /* Space used in the array when reading: one for each sibling and one for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5473 * the count. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5474 newindex += siblingcount + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5475
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5476 /* Recursively dump the children of each sibling. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5477 for (np = node; np != NULL; np = np->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5478 if (np->wn_byte != 0 && np->wn_child->wn_u2.wnode == node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5479 newindex = put_node(fd, np->wn_child, newindex, regionmask,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5480 prefixtree);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5481
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5482 return newindex;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5483 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5484
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5485
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5486 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5487 * ":mkspell [-ascii] outfile infile ..."
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5488 * ":mkspell [-ascii] addfile"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5489 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5490 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5491 ex_mkspell(exarg_T *eap)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5492 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5493 int fcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5494 char_u **fnames;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5495 char_u *arg = eap->arg;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5496 int ascii = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5497
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5498 if (STRNCMP(arg, "-ascii", 6) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5499 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5500 ascii = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5501 arg = skipwhite(arg + 6);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5502 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5503
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5504 /* Expand all the remaining arguments (e.g., $VIMRUNTIME). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5505 if (get_arglist_exp(arg, &fcount, &fnames, FALSE) == OK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5506 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5507 mkspell(fcount, fnames, ascii, eap->forceit, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5508 FreeWild(fcount, fnames);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5509 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5510 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5511
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5512 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5513 * Create the .sug file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5514 * Uses the soundfold info in "spin".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5515 * Writes the file with the name "wfname", with ".spl" changed to ".sug".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5516 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5517 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5518 spell_make_sugfile(spellinfo_T *spin, char_u *wfname)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5519 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5520 char_u *fname = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5521 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5522 slang_T *slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5523 int free_slang = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5524
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5525 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5526 * Read back the .spl file that was written. This fills the required
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5527 * info for soundfolding. This also uses less memory than the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5528 * pointer-linked version of the trie. And it avoids having two versions
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5529 * of the code for the soundfolding stuff.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5530 * It might have been done already by spell_reload_one().
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5531 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5532 for (slang = first_lang; slang != NULL; slang = slang->sl_next)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5533 if (fullpathcmp(wfname, slang->sl_fname, FALSE) == FPC_SAME)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5534 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5535 if (slang == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5536 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5537 spell_message(spin, (char_u *)_("Reading back spell file..."));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5538 slang = spell_load_file(wfname, NULL, NULL, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5539 if (slang == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5540 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5541 free_slang = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5542 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5543
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5544 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5545 * Clear the info in "spin" that is used.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5546 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5547 spin->si_blocks = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5548 spin->si_blocks_cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5549 spin->si_compress_cnt = 0; /* will stay at 0 all the time*/
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5550 spin->si_free_count = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5551 spin->si_first_free = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5552 spin->si_foldwcount = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5553
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5554 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5555 * Go through the trie of good words, soundfold each word and add it to
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5556 * the soundfold trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5557 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5558 spell_message(spin, (char_u *)_("Performing soundfolding..."));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5559 if (sug_filltree(spin, slang) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5560 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5561
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5562 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5563 * Create the table which links each soundfold word with a list of the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5564 * good words it may come from. Creates buffer "spin->si_spellbuf".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5565 * This also removes the wordnr from the NUL byte entries to make
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5566 * compression possible.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5567 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5568 if (sug_maketable(spin) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5569 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5570
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5571 smsg((char_u *)_("Number of words after soundfolding: %ld"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5572 (long)spin->si_spellbuf->b_ml.ml_line_count);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5573
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5574 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5575 * Compress the soundfold trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5576 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5577 spell_message(spin, (char_u *)_(msg_compressing));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5578 wordtree_compress(spin, spin->si_foldroot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5579
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5580 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5581 * Write the .sug file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5582 * Make the file name by changing ".spl" to ".sug".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5583 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5584 fname = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5585 if (fname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5586 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5587 vim_strncpy(fname, wfname, MAXPATHL - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5588 len = (int)STRLEN(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5589 fname[len - 2] = 'u';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5590 fname[len - 1] = 'g';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5591 sug_write(spin, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5592
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5593 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5594 vim_free(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5595 if (free_slang)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5596 slang_free(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5597 free_blocks(spin->si_blocks);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5598 close_spellbuf(spin->si_spellbuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5599 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5600
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5601 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5602 * Build the soundfold trie for language "slang".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5603 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5604 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5605 sug_filltree(spellinfo_T *spin, slang_T *slang)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5606 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5607 char_u *byts;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5608 idx_T *idxs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5609 int depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5610 idx_T arridx[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5611 int curi[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5612 char_u tword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5613 char_u tsalword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5614 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5615 idx_T n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5616 unsigned words_done = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5617 int wordcount[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5618
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5619 /* We use si_foldroot for the soundfolded trie. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5620 spin->si_foldroot = wordtree_alloc(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5621 if (spin->si_foldroot == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5622 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5623
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5624 /* let tree_add_word() know we're adding to the soundfolded tree */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5625 spin->si_sugtree = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5626
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5627 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5628 * Go through the whole case-folded tree, soundfold each word and put it
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5629 * in the trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5630 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5631 byts = slang->sl_fbyts;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5632 idxs = slang->sl_fidxs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5633
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5634 arridx[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5635 curi[0] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5636 wordcount[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5637
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5638 depth = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5639 while (depth >= 0 && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5640 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5641 if (curi[depth] > byts[arridx[depth]])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5642 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5643 /* Done all bytes at this node, go up one level. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5644 idxs[arridx[depth]] = wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5645 if (depth > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5646 wordcount[depth - 1] += wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5647
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5648 --depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5649 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5650 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5651 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5652 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5653
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5654 /* Do one more byte at this node. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5655 n = arridx[depth] + curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5656 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5657
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5658 c = byts[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5659 if (c == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5660 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5661 /* Sound-fold the word. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5662 tword[depth] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5663 spell_soundfold(slang, tword, TRUE, tsalword);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5664
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5665 /* We use the "flags" field for the MSB of the wordnr,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5666 * "region" for the LSB of the wordnr. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5667 if (tree_add_word(spin, tsalword, spin->si_foldroot,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5668 words_done >> 16, words_done & 0xffff,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5669 0) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5670 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5671
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5672 ++words_done;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5673 ++wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5674
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5675 /* Reset the block count each time to avoid compression
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5676 * kicking in. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5677 spin->si_blocks_cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5678
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5679 /* Skip over any other NUL bytes (same word with different
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5680 * flags). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5681 while (byts[n + 1] == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5682 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5683 ++n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5684 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5685 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5686 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5687 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5688 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5689 /* Normal char, go one level deeper. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5690 tword[depth++] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5691 arridx[depth] = idxs[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5692 curi[depth] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5693 wordcount[depth] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5694 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5695 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5696 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5697
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5698 smsg((char_u *)_("Total number of words: %d"), words_done);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5699
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5700 return OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5701 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5702
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5703 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5704 * Make the table that links each word in the soundfold trie to the words it
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5705 * can be produced from.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5706 * This is not unlike lines in a file, thus use a memfile to be able to access
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5707 * the table efficiently.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5708 * Returns FAIL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5709 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5710 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5711 sug_maketable(spellinfo_T *spin)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5712 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5713 garray_T ga;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5714 int res = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5715
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5716 /* Allocate a buffer, open a memline for it and create the swap file
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5717 * (uses a temp file, not a .swp file). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5718 spin->si_spellbuf = open_spellbuf();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5719 if (spin->si_spellbuf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5720 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5721
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5722 /* Use a buffer to store the line info, avoids allocating many small
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5723 * pieces of memory. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5724 ga_init2(&ga, 1, 100);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5725
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5726 /* recursively go through the tree */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5727 if (sug_filltable(spin, spin->si_foldroot->wn_sibling, 0, &ga) == -1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5728 res = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5729
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5730 ga_clear(&ga);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5731 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5732 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5733
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5734 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5735 * Fill the table for one node and its children.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5736 * Returns the wordnr at the start of the node.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5737 * Returns -1 when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5738 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5739 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5740 sug_filltable(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5741 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5742 wordnode_T *node,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5743 int startwordnr,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5744 garray_T *gap) /* place to store line of numbers */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5745 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5746 wordnode_T *p, *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5747 int wordnr = startwordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5748 int nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5749 int prev_nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5750
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5751 for (p = node; p != NULL; p = p->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5752 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5753 if (p->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5754 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5755 gap->ga_len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5756 prev_nr = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5757 for (np = p; np != NULL && np->wn_byte == NUL; np = np->wn_sibling)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5758 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5759 if (ga_grow(gap, 10) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5760 return -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5761
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5762 nr = (np->wn_flags << 16) + (np->wn_region & 0xffff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5763 /* Compute the offset from the previous nr and store the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5764 * offset in a way that it takes a minimum number of bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5765 * It's a bit like utf-8, but without the need to mark
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5766 * following bytes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5767 nr -= prev_nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5768 prev_nr += nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5769 gap->ga_len += offset2bytes(nr,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5770 (char_u *)gap->ga_data + gap->ga_len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5771 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5772
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5773 /* add the NUL byte */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5774 ((char_u *)gap->ga_data)[gap->ga_len++] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5775
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5776 if (ml_append_buf(spin->si_spellbuf, (linenr_T)wordnr,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5777 gap->ga_data, gap->ga_len, TRUE) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5778 return -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5779 ++wordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5780
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5781 /* Remove extra NUL entries, we no longer need them. We don't
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5782 * bother freeing the nodes, the won't be reused anyway. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5783 while (p->wn_sibling != NULL && p->wn_sibling->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5784 p->wn_sibling = p->wn_sibling->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5785
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5786 /* Clear the flags on the remaining NUL node, so that compression
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5787 * works a lot better. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5788 p->wn_flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5789 p->wn_region = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5790 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5791 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5792 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5793 wordnr = sug_filltable(spin, p->wn_child, wordnr, gap);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5794 if (wordnr == -1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5795 return -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5796 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5797 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5798 return wordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5799 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5800
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5801 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5802 * Convert an offset into a minimal number of bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5803 * Similar to utf_char2byters, but use 8 bits in followup bytes and avoid NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5804 * bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5805 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5806 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5807 offset2bytes(int nr, char_u *buf)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5808 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5809 int rem;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5810 int b1, b2, b3, b4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5811
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5812 /* Split the number in parts of base 255. We need to avoid NUL bytes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5813 b1 = nr % 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5814 rem = nr / 255;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5815 b2 = rem % 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5816 rem = rem / 255;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5817 b3 = rem % 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5818 b4 = rem / 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5819
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5820 if (b4 > 1 || b3 > 0x1f) /* 4 bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5821 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5822 buf[0] = 0xe0 + b4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5823 buf[1] = b3;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5824 buf[2] = b2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5825 buf[3] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5826 return 4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5827 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5828 if (b3 > 1 || b2 > 0x3f ) /* 3 bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5829 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5830 buf[0] = 0xc0 + b3;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5831 buf[1] = b2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5832 buf[2] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5833 return 3;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5834 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5835 if (b2 > 1 || b1 > 0x7f ) /* 2 bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5836 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5837 buf[0] = 0x80 + b2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5838 buf[1] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5839 return 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5840 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5841 /* 1 byte */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5842 buf[0] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5843 return 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5844 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5845
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5846 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5847 * Write the .sug file in "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5848 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5849 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5850 sug_write(spellinfo_T *spin, char_u *fname)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5851 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5852 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5853 wordnode_T *tree;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5854 int nodecount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5855 int wcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5856 char_u *line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5857 linenr_T lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5858 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5859
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5860 /* Create the file. Note that an existing file is silently overwritten! */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5861 fd = mch_fopen((char *)fname, "w");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5862 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5863 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5864 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5865 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5866 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5867
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5868 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5869 _("Writing suggestion file %s ..."), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5870 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5871
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5872 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5873 * <SUGHEADER>: <fileID> <versionnr> <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5874 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5875 if (fwrite(VIMSUGMAGIC, VIMSUGMAGICL, (size_t)1, fd) != 1) /* <fileID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5876 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5877 EMSG(_(e_write));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5878 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5879 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5880 putc(VIMSUGVERSION, fd); /* <versionnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5881
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5882 /* Write si_sugtime to the file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5883 put_time(fd, spin->si_sugtime); /* <timestamp> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5884
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5885 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5886 * <SUGWORDTREE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5887 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5888 spin->si_memtot = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5889 tree = spin->si_foldroot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5890
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5891 /* Clear the index and wnode fields in the tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5892 clear_node(tree);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5893
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5894 /* Count the number of nodes. Needed to be able to allocate the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5895 * memory when reading the nodes. Also fills in index for shared
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5896 * nodes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5897 nodecount = put_node(NULL, tree, 0, 0, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5898
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5899 /* number of nodes in 4 bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5900 put_bytes(fd, (long_u)nodecount, 4); /* <nodecount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5901 spin->si_memtot += nodecount + nodecount * sizeof(int);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5902
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5903 /* Write the nodes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5904 (void)put_node(fd, tree, 0, 0, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5905
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5906 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5907 * <SUGTABLE>: <sugwcount> <sugline> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5908 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5909 wcount = spin->si_spellbuf->b_ml.ml_line_count;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5910 put_bytes(fd, (long_u)wcount, 4); /* <sugwcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5911
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5912 for (lnum = 1; lnum <= (linenr_T)wcount; ++lnum)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5913 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5914 /* <sugline>: <sugnr> ... NUL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5915 line = ml_get_buf(spin->si_spellbuf, lnum, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5916 len = (int)STRLEN(line) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5917 if (fwrite(line, (size_t)len, (size_t)1, fd) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5918 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5919 EMSG(_(e_write));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5920 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5921 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5922 spin->si_memtot += len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5923 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5924
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5925 /* Write another byte to check for errors. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5926 if (putc(0, fd) == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5927 EMSG(_(e_write));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5928
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5929 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5930 _("Estimated runtime memory use: %d bytes"), spin->si_memtot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5931 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5932
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5933 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5934 /* close the file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5935 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5936 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5937
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5938
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5939 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5940 * Create a Vim spell file from one or more word lists.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5941 * "fnames[0]" is the output file name.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5942 * "fnames[fcount - 1]" is the last input file name.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5943 * Exception: when "fnames[0]" ends in ".add" it's used as the input file name
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5944 * and ".spl" is appended to make the output file name.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5945 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5946 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5947 mkspell(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5948 int fcount,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5949 char_u **fnames,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5950 int ascii, /* -ascii argument given */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5951 int over_write, /* overwrite existing output file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5952 int added_word) /* invoked through "zg" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5953 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5954 char_u *fname = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5955 char_u *wfname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5956 char_u **innames;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5957 int incount;
13232
d11bbd3440b0 patch 8.0.1490: number of spell regions is spread out through the code
Christian Brabandt <cb@256bit.org>
parents: 12694
diff changeset
5958 afffile_T *(afile[MAXREGIONS]);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5959 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5960 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5961 stat_T st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5962 int error = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5963 spellinfo_T spin;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5964
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5965 vim_memset(&spin, 0, sizeof(spin));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5966 spin.si_verbose = !added_word;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5967 spin.si_ascii = ascii;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5968 spin.si_followup = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5969 spin.si_rem_accents = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5970 ga_init2(&spin.si_rep, (int)sizeof(fromto_T), 20);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5971 ga_init2(&spin.si_repsal, (int)sizeof(fromto_T), 20);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5972 ga_init2(&spin.si_sal, (int)sizeof(fromto_T), 20);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5973 ga_init2(&spin.si_map, (int)sizeof(char_u), 100);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5974 ga_init2(&spin.si_comppat, (int)sizeof(char_u *), 20);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5975 ga_init2(&spin.si_prefcond, (int)sizeof(char_u *), 50);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5976 hash_init(&spin.si_commonwords);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5977 spin.si_newcompID = 127; /* start compound ID at first maximum */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5978
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5979 /* default: fnames[0] is output file, following are input files */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5980 innames = &fnames[1];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5981 incount = fcount - 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5982
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5983 wfname = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5984 if (wfname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5985 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5986
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5987 if (fcount >= 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5988 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5989 len = (int)STRLEN(fnames[0]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5990 if (fcount == 1 && len > 4 && STRCMP(fnames[0] + len - 4, ".add") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5991 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5992 /* For ":mkspell path/en.latin1.add" output file is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5993 * "path/en.latin1.add.spl". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5994 innames = &fnames[0];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5995 incount = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5996 vim_snprintf((char *)wfname, MAXPATHL, "%s.spl", fnames[0]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5997 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5998 else if (fcount == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5999 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6000 /* For ":mkspell path/vim" output file is "path/vim.latin1.spl". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6001 innames = &fnames[0];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6002 incount = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6003 vim_snprintf((char *)wfname, MAXPATHL, SPL_FNAME_TMPL,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6004 fnames[0], spin.si_ascii ? (char_u *)"ascii" : spell_enc());
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6005 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6006 else if (len > 4 && STRCMP(fnames[0] + len - 4, ".spl") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6007 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6008 /* Name ends in ".spl", use as the file name. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6009 vim_strncpy(wfname, fnames[0], MAXPATHL - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6010 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6011 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6012 /* Name should be language, make the file name from it. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6013 vim_snprintf((char *)wfname, MAXPATHL, SPL_FNAME_TMPL,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6014 fnames[0], spin.si_ascii ? (char_u *)"ascii" : spell_enc());
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6015
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6016 /* Check for .ascii.spl. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6017 if (strstr((char *)gettail(wfname), SPL_FNAME_ASCII) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6018 spin.si_ascii = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6019
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6020 /* Check for .add.spl. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6021 if (strstr((char *)gettail(wfname), SPL_FNAME_ADD) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6022 spin.si_add = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6023 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6024
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6025 if (incount <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6026 EMSG(_(e_invarg)); /* need at least output and input names */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6027 else if (vim_strchr(gettail(wfname), '_') != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6028 EMSG(_("E751: Output file name must not have region name"));
13232
d11bbd3440b0 patch 8.0.1490: number of spell regions is spread out through the code
Christian Brabandt <cb@256bit.org>
parents: 12694
diff changeset
6029 else if (incount > MAXREGIONS)
d11bbd3440b0 patch 8.0.1490: number of spell regions is spread out through the code
Christian Brabandt <cb@256bit.org>
parents: 12694
diff changeset
6030 EMSGN(_("E754: Only up to %ld regions supported"), MAXREGIONS);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6031 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6032 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6033 /* Check for overwriting before doing things that may take a lot of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6034 * time. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6035 if (!over_write && mch_stat((char *)wfname, &st) >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6036 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6037 EMSG(_(e_exists));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6038 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6039 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6040 if (mch_isdir(wfname))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6041 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6042 EMSG2(_(e_isadir2), wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6043 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6044 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6045
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6046 fname = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6047 if (fname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6048 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6049
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6050 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6051 * Init the aff and dic pointers.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6052 * Get the region names if there are more than 2 arguments.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6053 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6054 for (i = 0; i < incount; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6055 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6056 afile[i] = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6057
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6058 if (incount > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6059 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6060 len = (int)STRLEN(innames[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6061 if (STRLEN(gettail(innames[i])) < 5
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6062 || innames[i][len - 3] != '_')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6063 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6064 EMSG2(_("E755: Invalid region in %s"), innames[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6065 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6066 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6067 spin.si_region_name[i * 2] = TOLOWER_ASC(innames[i][len - 2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6068 spin.si_region_name[i * 2 + 1] =
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6069 TOLOWER_ASC(innames[i][len - 1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6070 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6071 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6072 spin.si_region_count = incount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6073
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6074 spin.si_foldroot = wordtree_alloc(&spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6075 spin.si_keeproot = wordtree_alloc(&spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6076 spin.si_prefroot = wordtree_alloc(&spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6077 if (spin.si_foldroot == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6078 || spin.si_keeproot == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6079 || spin.si_prefroot == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6080 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6081 free_blocks(spin.si_blocks);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6082 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6083 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6084
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6085 /* When not producing a .add.spl file clear the character table when
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6086 * we encounter one in the .aff file. This means we dump the current
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6087 * one in the .spl file if the .aff file doesn't define one. That's
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6088 * better than guessing the contents, the table will match a
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6089 * previously loaded spell file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6090 if (!spin.si_add)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6091 spin.si_clear_chartab = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6092
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6093 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6094 * Read all the .aff and .dic files.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6095 * Text is converted to 'encoding'.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6096 * Words are stored in the case-folded and keep-case trees.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6097 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6098 for (i = 0; i < incount && !error; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6099 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6100 spin.si_conv.vc_type = CONV_NONE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6101 spin.si_region = 1 << i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6102
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6103 vim_snprintf((char *)fname, MAXPATHL, "%s.aff", innames[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6104 if (mch_stat((char *)fname, &st) >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6105 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6106 /* Read the .aff file. Will init "spin->si_conv" based on the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6107 * "SET" line. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6108 afile[i] = spell_read_aff(&spin, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6109 if (afile[i] == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6110 error = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6111 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6112 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6113 /* Read the .dic file and store the words in the trees. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6114 vim_snprintf((char *)fname, MAXPATHL, "%s.dic",
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6115 innames[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6116 if (spell_read_dic(&spin, fname, afile[i]) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6117 error = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6118 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6119 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6120 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6121 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6122 /* No .aff file, try reading the file as a word list. Store
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6123 * the words in the trees. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6124 if (spell_read_wordfile(&spin, innames[i]) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6125 error = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6126 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6127
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6128 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6129 /* Free any conversion stuff. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6130 convert_setup(&spin.si_conv, NULL, NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6131 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6132 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6133
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6134 if (spin.si_compflags != NULL && spin.si_nobreak)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6135 MSG(_("Warning: both compounding and NOBREAK specified"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6136
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6137 if (!error && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6138 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6139 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6140 * Combine tails in the tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6141 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6142 spell_message(&spin, (char_u *)_(msg_compressing));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6143 wordtree_compress(&spin, spin.si_foldroot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6144 wordtree_compress(&spin, spin.si_keeproot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6145 wordtree_compress(&spin, spin.si_prefroot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6146 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6147
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6148 if (!error && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6149 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6150 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6151 * Write the info in the spell file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6152 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6153 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6154 _("Writing spell file %s ..."), wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6155 spell_message(&spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6156
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6157 error = write_vim_spell(&spin, wfname) == FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6158
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6159 spell_message(&spin, (char_u *)_("Done!"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6160 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6161 _("Estimated runtime memory use: %d bytes"), spin.si_memtot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6162 spell_message(&spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6163
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6164 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6165 * If the file is loaded need to reload it.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6166 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6167 if (!error)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6168 spell_reload_one(wfname, added_word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6169 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6170
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6171 /* Free the allocated memory. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6172 ga_clear(&spin.si_rep);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6173 ga_clear(&spin.si_repsal);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6174 ga_clear(&spin.si_sal);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6175 ga_clear(&spin.si_map);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6176 ga_clear(&spin.si_comppat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6177 ga_clear(&spin.si_prefcond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6178 hash_clear_all(&spin.si_commonwords, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6179
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6180 /* Free the .aff file structures. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6181 for (i = 0; i < incount; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6182 if (afile[i] != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6183 spell_free_aff(afile[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6184
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6185 /* Free all the bits and pieces at once. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6186 free_blocks(spin.si_blocks);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6187
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6188 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6189 * If there is soundfolding info and no NOSUGFILE item create the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6190 * .sug file with the soundfolded word trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6191 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6192 if (spin.si_sugtime != 0 && !error && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6193 spell_make_sugfile(&spin, wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6194
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6195 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6196
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6197 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6198 vim_free(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6199 vim_free(wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6200 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6201
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6202 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6203 * Display a message for spell file processing when 'verbose' is set or using
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6204 * ":mkspell". "str" can be IObuff.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6205 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6206 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6207 spell_message(spellinfo_T *spin, char_u *str)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6208 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6209 if (spin->si_verbose || p_verbose > 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6210 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6211 if (!spin->si_verbose)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6212 verbose_enter();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6213 MSG(str);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6214 out_flush();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6215 if (!spin->si_verbose)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6216 verbose_leave();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6217 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6218 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6219
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6220 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6221 * ":[count]spellgood {word}"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6222 * ":[count]spellwrong {word}"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6223 * ":[count]spellundo {word}"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6224 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6225 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6226 ex_spell(exarg_T *eap)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6227 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6228 spell_add_word(eap->arg, (int)STRLEN(eap->arg), eap->cmdidx == CMD_spellwrong,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6229 eap->forceit ? 0 : (int)eap->line2,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6230 eap->cmdidx == CMD_spellundo);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6231 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6232
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6233 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6234 * Add "word[len]" to 'spellfile' as a good or bad word.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6235 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6236 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6237 spell_add_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6238 char_u *word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6239 int len,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6240 int bad,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6241 int idx, /* "zG" and "zW": zero, otherwise index in
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6242 'spellfile' */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6243 int undo) /* TRUE for "zug", "zuG", "zuw" and "zuW" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6244 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6245 FILE *fd = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6246 buf_T *buf = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6247 int new_spf = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6248 char_u *fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6249 char_u *fnamebuf = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6250 char_u line[MAXWLEN * 2];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6251 long fpos, fpos_next = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6252 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6253 char_u *spf;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6254
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6255 if (idx == 0) /* use internal wordlist */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6256 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6257 if (int_wordlist == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6258 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6259 int_wordlist = vim_tempname('s', FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6260 if (int_wordlist == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6261 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6262 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6263 fname = int_wordlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6264 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6265 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6266 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6267 /* If 'spellfile' isn't set figure out a good default value. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6268 if (*curwin->w_s->b_p_spf == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6269 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6270 init_spellfile();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6271 new_spf = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6272 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6273
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6274 if (*curwin->w_s->b_p_spf == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6275 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6276 EMSG2(_(e_notset), "spellfile");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6277 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6278 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6279 fnamebuf = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6280 if (fnamebuf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6281 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6282
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6283 for (spf = curwin->w_s->b_p_spf, i = 1; *spf != NUL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6284 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6285 copy_option_part(&spf, fnamebuf, MAXPATHL, ",");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6286 if (i == idx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6287 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6288 if (*spf == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6289 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6290 EMSGN(_("E765: 'spellfile' does not have %ld entries"), idx);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6291 vim_free(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6292 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6293 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6294 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6295
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6296 /* Check that the user isn't editing the .add file somewhere. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6297 buf = buflist_findname_exp(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6298 if (buf != NULL && buf->b_ml.ml_mfp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6299 buf = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6300 if (buf != NULL && bufIsChanged(buf))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6301 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6302 EMSG(_(e_bufloaded));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6303 vim_free(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6304 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6305 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6306
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6307 fname = fnamebuf;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6308 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6309
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6310 if (bad || undo)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6311 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6312 /* When the word appears as good word we need to remove that one,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6313 * since its flags sort before the one with WF_BANNED. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6314 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6315 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6316 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6317 while (!vim_fgets(line, MAXWLEN * 2, fd))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6318 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6319 fpos = fpos_next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6320 fpos_next = ftell(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6321 if (STRNCMP(word, line, len) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6322 && (line[len] == '/' || line[len] < ' '))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6323 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6324 /* Found duplicate word. Remove it by writing a '#' at
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6325 * the start of the line. Mixing reading and writing
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6326 * doesn't work for all systems, close the file first. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6327 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6328 fd = mch_fopen((char *)fname, "r+");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6329 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6330 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6331 if (fseek(fd, fpos, SEEK_SET) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6332 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6333 fputc('#', fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6334 if (undo)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6335 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6336 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6337 smsg((char_u *)_("Word '%.*s' removed from %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6338 len, word, NameBuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6339 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6340 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6341 fseek(fd, fpos_next, SEEK_SET);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6342 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6343 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6344 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6345 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6346 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6347 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6348
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6349 if (!undo)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6350 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6351 fd = mch_fopen((char *)fname, "a");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6352 if (fd == NULL && new_spf)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6353 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6354 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6355
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6356 /* We just initialized the 'spellfile' option and can't open the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6357 * file. We may need to create the "spell" directory first. We
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6358 * already checked the runtime directory is writable in
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6359 * init_spellfile(). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6360 if (!dir_of_file_exists(fname) && (p = gettail_sep(fname)) != fname)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6361 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6362 int c = *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6363
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6364 /* The directory doesn't exist. Try creating it and opening
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6365 * the file again. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6366 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6367 vim_mkdir(fname, 0755);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6368 *p = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6369 fd = mch_fopen((char *)fname, "a");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6370 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6371 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6372
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6373 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6374 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6375 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6376 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6377 if (bad)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6378 fprintf(fd, "%.*s/!\n", len, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6379 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6380 fprintf(fd, "%.*s\n", len, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6381 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6382
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6383 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6384 smsg((char_u *)_("Word '%.*s' added to %s"), len, word, NameBuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6385 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6386 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6387
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6388 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6389 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6390 /* Update the .add.spl file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6391 mkspell(1, &fname, FALSE, TRUE, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6392
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6393 /* If the .add file is edited somewhere, reload it. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6394 if (buf != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6395 buf_reload(buf, buf->b_orig_mode);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6396
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6397 redraw_all_later(SOME_VALID);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6398 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6399 vim_free(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6400 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6401
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6402 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6403 * Initialize 'spellfile' for the current buffer.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6404 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6405 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6406 init_spellfile(void)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6407 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6408 char_u *buf;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6409 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6410 char_u *fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6411 char_u *rtp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6412 char_u *lend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6413 int aspath = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6414 char_u *lstart = curbuf->b_s.b_p_spl;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6415
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6416 if (*curwin->w_s->b_p_spl != NUL && curwin->w_s->b_langp.ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6417 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6418 buf = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6419 if (buf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6420 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6421
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6422 /* Find the end of the language name. Exclude the region. If there
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6423 * is a path separator remember the start of the tail. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6424 for (lend = curwin->w_s->b_p_spl; *lend != NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6425 && vim_strchr((char_u *)",._", *lend) == NULL; ++lend)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6426 if (vim_ispathsep(*lend))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6427 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6428 aspath = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6429 lstart = lend + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6430 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6431
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6432 /* Loop over all entries in 'runtimepath'. Use the first one where we
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6433 * are allowed to write. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6434 rtp = p_rtp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6435 while (*rtp != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6436 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6437 if (aspath)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6438 /* Use directory of an entry with path, e.g., for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6439 * "/dir/lg.utf-8.spl" use "/dir". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6440 vim_strncpy(buf, curbuf->b_s.b_p_spl,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6441 lstart - curbuf->b_s.b_p_spl - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6442 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6443 /* Copy the path from 'runtimepath' to buf[]. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6444 copy_option_part(&rtp, buf, MAXPATHL, ",");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6445 if (filewritable(buf) == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6446 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6447 /* Use the first language name from 'spelllang' and the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6448 * encoding used in the first loaded .spl file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6449 if (aspath)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6450 vim_strncpy(buf, curbuf->b_s.b_p_spl,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6451 lend - curbuf->b_s.b_p_spl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6452 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6453 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6454 /* Create the "spell" directory if it doesn't exist yet. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6455 l = (int)STRLEN(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6456 vim_snprintf((char *)buf + l, MAXPATHL - l, "/spell");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6457 if (filewritable(buf) != 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6458 vim_mkdir(buf, 0755);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6459
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6460 l = (int)STRLEN(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6461 vim_snprintf((char *)buf + l, MAXPATHL - l,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6462 "/%.*s", (int)(lend - lstart), lstart);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6463 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6464 l = (int)STRLEN(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6465 fname = LANGP_ENTRY(curwin->w_s->b_langp, 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6466 ->lp_slang->sl_fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6467 vim_snprintf((char *)buf + l, MAXPATHL - l, ".%s.add",
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6468 fname != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6469 && strstr((char *)gettail(fname), ".ascii.") != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6470 ? (char_u *)"ascii" : spell_enc());
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6471 set_option_value((char_u *)"spellfile", 0L, buf, OPT_LOCAL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6472 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6473 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6474 aspath = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6475 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6476
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6477 vim_free(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6478 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6479 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6480
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6481
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6482
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6483 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6484 * Set the spell character tables from strings in the affix file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6485 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6486 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6487 set_spell_chartab(char_u *fol, char_u *low, char_u *upp)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6488 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6489 /* We build the new tables here first, so that we can compare with the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6490 * previous one. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6491 spelltab_T new_st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6492 char_u *pf = fol, *pl = low, *pu = upp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6493 int f, l, u;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6494
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6495 clear_spell_chartab(&new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6496
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6497 while (*pf != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6498 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6499 if (*pl == NUL || *pu == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6500 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6501 EMSG(_(e_affform));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6502 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6503 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6504 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6505 f = mb_ptr2char_adv(&pf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6506 l = mb_ptr2char_adv(&pl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6507 u = mb_ptr2char_adv(&pu);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6508 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6509 f = *pf++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6510 l = *pl++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6511 u = *pu++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6512 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6513 /* Every character that appears is a word character. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6514 if (f < 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6515 new_st.st_isw[f] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6516 if (l < 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6517 new_st.st_isw[l] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6518 if (u < 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6519 new_st.st_isw[u] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6520
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6521 /* if "LOW" and "FOL" are not the same the "LOW" char needs
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6522 * case-folding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6523 if (l < 256 && l != f)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6524 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6525 if (f >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6526 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6527 EMSG(_(e_affrange));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6528 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6529 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6530 new_st.st_fold[l] = f;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6531 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6532
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6533 /* if "UPP" and "FOL" are not the same the "UPP" char needs
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6534 * case-folding, it's upper case and the "UPP" is the upper case of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6535 * "FOL" . */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6536 if (u < 256 && u != f)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6537 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6538 if (f >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6539 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6540 EMSG(_(e_affrange));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6541 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6542 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6543 new_st.st_fold[u] = f;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6544 new_st.st_isu[u] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6545 new_st.st_upper[f] = u;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6546 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6547 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6548
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6549 if (*pl != NUL || *pu != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6550 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6551 EMSG(_(e_affform));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6552 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6553 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6554
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6555 return set_spell_finish(&new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6556 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6557
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6558 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6559 * Set the spell character tables from strings in the .spl file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6560 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6561 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6562 set_spell_charflags(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6563 char_u *flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6564 int cnt, /* length of "flags" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6565 char_u *fol)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6566 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6567 /* We build the new tables here first, so that we can compare with the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6568 * previous one. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6569 spelltab_T new_st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6570 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6571 char_u *p = fol;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6572 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6573
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6574 clear_spell_chartab(&new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6575
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6576 for (i = 0; i < 128; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6577 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6578 if (i < cnt)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6579 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6580 new_st.st_isw[i + 128] = (flags[i] & CF_WORD) != 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6581 new_st.st_isu[i + 128] = (flags[i] & CF_UPPER) != 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6582 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6584 if (*p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6585 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6586 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6587 c = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6588 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6589 c = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6590 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6591 new_st.st_fold[i + 128] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6592 if (i + 128 != c && new_st.st_isu[i + 128] && c < 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6593 new_st.st_upper[c] = i + 128;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6594 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6595 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6596
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6597 (void)set_spell_finish(&new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6598 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6599
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6600 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6601 set_spell_finish(spelltab_T *new_st)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6602 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6603 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6604
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6605 if (did_set_spelltab)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6606 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6607 /* check that it's the same table */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6608 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6609 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6610 if (spelltab.st_isw[i] != new_st->st_isw[i]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6611 || spelltab.st_isu[i] != new_st->st_isu[i]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6612 || spelltab.st_fold[i] != new_st->st_fold[i]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6613 || spelltab.st_upper[i] != new_st->st_upper[i])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6614 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6615 EMSG(_("E763: Word characters differ between spell files"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6616 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6617 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6618 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6619 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6620 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6621 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6622 /* copy the new spelltab into the one being used */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6623 spelltab = *new_st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6624 did_set_spelltab = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6625 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6626
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6627 return OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6628 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6629
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6630 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6631 * Write the table with prefix conditions to the .spl file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6632 * When "fd" is NULL only count the length of what is written.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6633 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6634 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6635 write_spell_prefcond(FILE *fd, garray_T *gap)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6636 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6637 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6638 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6639 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6640 int totlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6641 size_t x = 1; /* collect return value of fwrite() */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6642
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6643 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6644 put_bytes(fd, (long_u)gap->ga_len, 2); /* <prefcondcnt> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6645
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6646 totlen = 2 + gap->ga_len; /* length of <prefcondcnt> and <condlen> bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6647
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6648 for (i = 0; i < gap->ga_len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6649 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6650 /* <prefcond> : <condlen> <condstr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6651 p = ((char_u **)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6652 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6653 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6654 len = (int)STRLEN(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6655 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6656 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6657 fputc(len, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6658 x &= fwrite(p, (size_t)len, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6659 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6660 totlen += len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6661 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6662 else if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6663 fputc(0, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6664 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6665
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6666 return totlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6667 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6668
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6669
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6670 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6671 * Use map string "map" for languages "lp".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6672 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6673 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6674 set_map_str(slang_T *lp, char_u *map)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6675 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6676 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6677 int headc = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6678 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6679 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6680
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6681 if (*map == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6682 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6683 lp->sl_has_map = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6684 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6685 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6686 lp->sl_has_map = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6687
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6688 /* Init the array and hash tables empty. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6689 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6690 lp->sl_map_array[i] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6691 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6692 hash_init(&lp->sl_map_hash);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6693 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6694
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6695 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6696 * The similar characters are stored separated with slashes:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6697 * "aaa/bbb/ccc/". Fill sl_map_array[c] with the character before c and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6698 * before the same slash. For characters above 255 sl_map_hash is used.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6699 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6700 for (p = map; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6701 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6702 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6703 c = mb_cptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6704 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6705 c = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6706 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6707 if (c == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6708 headc = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6709 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6710 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6711 if (headc == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6712 headc = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6713
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6714 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6715 /* Characters above 255 don't fit in sl_map_array[], put them in
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6716 * the hash table. Each entry is the char, a NUL the headchar and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6717 * a NUL. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6718 if (c >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6719 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6720 int cl = mb_char2len(c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6721 int headcl = mb_char2len(headc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6722 char_u *b;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6723 hash_T hash;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6724 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6725
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6726 b = alloc((unsigned)(cl + headcl + 2));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6727 if (b == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6728 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6729 mb_char2bytes(c, b);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6730 b[cl] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6731 mb_char2bytes(headc, b + cl + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6732 b[cl + 1 + headcl] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6733 hash = hash_hash(b);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6734 hi = hash_lookup(&lp->sl_map_hash, b, hash);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6735 if (HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6736 hash_add_item(&lp->sl_map_hash, hi, b, hash);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6737 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6738 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6739 /* This should have been checked when generating the .spl
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6740 * file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6741 EMSG(_("E783: duplicate char in MAP entry"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6742 vim_free(b);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6743 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6744 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6745 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6746 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6747 lp->sl_map_array[c] = headc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6748 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6749 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6750 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6751
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6752
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6753 #endif /* FEAT_SPELL */