annotate src/spellfile.c @ 19760:9daed26b788b v8.2.0436

patch 8.2.0436: no warnings for incorrect printf arguments Commit: https://github.com/vim/vim/commit/db99f9f29a248b84742b6779c3343123f72065e7 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 23 22:12:22 2020 +0100 patch 8.2.0436: no warnings for incorrect printf arguments Problem: No warnings for incorrect printf arguments. Solution: Fix attribute in declaration. Fix uncovered mistakes. (Dominique Pelle, closes #5834)
author Bram Moolenaar <Bram@vim.org>
date Mon, 23 Mar 2020 22:15:05 +0100
parents af1eca322b9e
children 435726a03481
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
244 #ifndef UNIX // it's in os_unix.h for Unix
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
245 # include <time.h> // for time_t
9583
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
248 #ifndef UNIX // it's in os_unix.h for Unix
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
249 # include <time.h> // for time_t
9583
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
252 // Special byte values for <byte>. Some are only used in the tree for
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
253 // postponed prefixes, some only in the other trees. This is a bit messy...
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
254 #define BY_NOFLAGS 0 // end of word without flags or region; for
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
255 // postponed prefix: no <pflags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
256 #define BY_INDEX 1 // child is shared, index follows
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
257 #define BY_FLAGS 2 // end of word, <flags> byte follows; for
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
258 // postponed prefix: <pflags> follows
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
259 #define BY_FLAGS2 3 // end of word, <flags> and <flags2> bytes
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
260 // follow; never used in prefix tree
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
261 #define BY_SPECIAL BY_FLAGS2 // highest special byte value
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262
18548
4fbfecbb968c patch 8.1.2268: spell file flag zero is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 17682
diff changeset
263 #define ZERO_FLAG 65009 // used when flag is zero: "0"
4fbfecbb968c patch 8.1.2268: spell file flag zero is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 17682
diff changeset
264
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
265 // Flags used in .spl file for soundsalike flags.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 #define SAL_F0LLOWUP 1
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267 #define SAL_COLLAPSE 2
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 #define SAL_REM_ACCENTS 4
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
269
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
270 #define VIMSPELLMAGIC "VIMspell" // string at start of Vim spell file
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271 #define VIMSPELLMAGICL 8
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272 #define VIMSPELLVERSION 50
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
274 // Section IDs. Only renumber them when VIMSPELLVERSION changes!
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
275 #define SN_REGION 0 // <regionname> section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
276 #define SN_CHARFLAGS 1 // charflags section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
277 #define SN_MIDWORD 2 // <midword> section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
278 #define SN_PREFCOND 3 // <prefcond> section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
279 #define SN_REP 4 // REP items section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
280 #define SN_SAL 5 // SAL items section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
281 #define SN_SOFO 6 // soundfolding section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
282 #define SN_MAP 7 // MAP items section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
283 #define SN_COMPOUND 8 // compound words section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
284 #define SN_SYLLABLE 9 // syllable section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
285 #define SN_NOBREAK 10 // NOBREAK section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
286 #define SN_SUGFILE 11 // timestamp for .sug file
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
287 #define SN_REPSAL 12 // REPSAL items section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
288 #define SN_WORDS 13 // common words
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
289 #define SN_NOSPLITSUGS 14 // don't split word for suggestions
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
290 #define SN_INFO 15 // info section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
291 #define SN_NOCOMPOUNDSUGS 16 // don't compound for suggestions
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
292 #define SN_END 255 // end of sections
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
293
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
294 #define SNF_REQUIRED 1 // <sectionflags>: required section
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296 #define CF_WORD 0x01
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 #define CF_UPPER 0x02
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 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
300 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
301 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
302 static int read_charflags_section(FILE *fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 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
304 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
305 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
306 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
307 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
308 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
309 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
310 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
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 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
313 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
314 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
315 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
316 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
317
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319 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
320 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
321 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
322 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
323 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
324 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
325
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327 * 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
328 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 * This is invoked in three ways:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 * - 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
331 * 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
332 * - 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
333 * points to the existing slang_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334 * - 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
335 * "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
336 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337 * 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
338 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
339 slang_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340 spell_load_file(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 char_u *fname,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 char_u *lang,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343 slang_T *old_lp,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
344 int silent) // no error if file doesn't exist
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
347 char_u buf[VIMSPELLMAGICL];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 slang_T *lp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353 int c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 int res;
19073
45eb6f37692e patch 8.2.0097: crash with autocommand and spellfile
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
355 int did_estack_push = FALSE;
19075
af1eca322b9e patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents: 19073
diff changeset
356 ESTACK_CHECK_DECLARATION
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361 if (!silent)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
362 semsg(_(e_notopen), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 else if (p_verbose > 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365 verbose_enter();
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
366 smsg((const char *)e_notopen, fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 verbose_leave();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 goto endFAIL;
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 if (p_verbose > 2)
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 verbose_enter();
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
374 smsg(_("Reading spell file \"%s\""), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375 verbose_leave();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
376 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 if (old_lp == NULL)
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 lp = slang_alloc(lang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 if (lp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
384 // Remember the file name, used to reload the file when it's updated.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385 lp->sl_fname = vim_strsave(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 if (lp->sl_fname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
389 // Check for .add.spl (_add.spl for VMS).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390 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
391 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
392 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 lp = old_lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
395 // Set sourcing_name, so that error messages mention the file name.
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18814
diff changeset
396 estack_push(ETYPE_SPELL, fname, 0);
19075
af1eca322b9e patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents: 19073
diff changeset
397 ESTACK_CHECK_SETUP
19073
45eb6f37692e patch 8.2.0097: crash with autocommand and spellfile
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
398 did_estack_push = TRUE;
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399
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 * <HEADER>: <fileID>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403 for (i = 0; i < VIMSPELLMAGICL; ++i)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
404 buf[i] = getc(fd); // <fileID>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 if (STRNCMP(buf, VIMSPELLMAGIC, VIMSPELLMAGICL) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
407 emsg(_("E757: This does not look like a spell file"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
409 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
410 c = getc(fd); // <versionnr>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
411 if (c < VIMSPELLVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
413 emsg(_("E771: Old spell file, needs to be updated"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 else if (c > VIMSPELLVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
418 emsg(_("E772: Spell file is for newer version of Vim"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 }
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 * <SECTIONS>: <section> ... <sectionend>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 * <section>: <sectionID> <sectionflags> <sectionlen> (section contents)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 for (;;)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
429 n = getc(fd); // <sectionID> or <sectionend>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430 if (n == SN_END)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431 break;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
432 c = getc(fd); // <sectionflags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
433 len = get4c(fd); // <sectionlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
434 if (len < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
435 goto truncerr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
437 res = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
438 switch (n)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
440 case SN_INFO:
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
441 lp->sl_info = read_string(fd, len); // <infotext>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 if (lp->sl_info == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446 case SN_REGION:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447 res = read_region_section(fd, lp, len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
448 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
449
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
450 case SN_CHARFLAGS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
451 res = read_charflags_section(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
452 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454 case SN_MIDWORD:
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
455 lp->sl_midword = read_string(fd, len); // <midword>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
456 if (lp->sl_midword == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
457 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460 case SN_PREFCOND:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
461 res = read_prefcond_section(fd, lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
462 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
463
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
464 case SN_REP:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
465 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
466 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
467
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
468 case SN_REPSAL:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469 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
470 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
472 case SN_SAL:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
473 res = read_sal_section(fd, lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
474 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
475
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476 case SN_SOFO:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477 res = read_sofo_section(fd, lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480 case SN_MAP:
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
481 p = read_string(fd, len); // <mapstr>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
482 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
483 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484 set_map_str(lp, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
485 vim_free(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
488 case SN_WORDS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
489 res = read_words_section(fd, lp, len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
490 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
491
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492 case SN_SUGFILE:
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
493 lp->sl_sugtime = get8ctime(fd); // <timestamp>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
495
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
496 case SN_NOSPLITSUGS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
497 lp->sl_nosplitsugs = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
498 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
499
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
500 case SN_NOCOMPOUNDSUGS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
501 lp->sl_nocompoundsugs = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
502 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
503
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
504 case SN_COMPOUND:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
505 res = read_compound(fd, lp, len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
506 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
507
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
508 case SN_NOBREAK:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
509 lp->sl_nobreak = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
510 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
511
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
512 case SN_SYLLABLE:
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
513 lp->sl_syllable = read_string(fd, len); // <syllable>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
514 if (lp->sl_syllable == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
515 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
516 if (init_syl_tab(lp) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
517 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
518 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
519
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
520 default:
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
521 // Unsupported section. When it's required give an error
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
522 // message. When it's not required skip the contents.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
523 if (c & SNF_REQUIRED)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
524 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
525 emsg(_("E770: Unsupported section in spell file"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
526 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
527 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528 while (--len >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529 if (getc(fd) < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530 goto truncerr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
533 someerror:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534 if (res == SP_FORMERROR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
535 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
536 emsg(_(e_format));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
537 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
538 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
539 if (res == SP_TRUNCERROR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
540 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
541 truncerr:
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
542 emsg(_(e_spell_trunc));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
543 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545 if (res == SP_OTHERERROR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
547 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
548
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
549 // <LWORDTREE>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
550 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
551 if (res != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
554 // <KWORDTREE>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555 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
556 if (res != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
557 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
558
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
559 // <PREFIXTREE>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
560 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
561 lp->sl_prefixcnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
562 if (res != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
563 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
564
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
565 // For a new file link it in the list of spell files.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
566 if (old_lp == NULL && lang != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
567 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
568 lp->sl_next = first_lang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
569 first_lang = lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
570 }
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 goto endOK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
574 endFAIL:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 if (lang != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
576 // truncating the name signals the error to spell_load_lang()
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577 *lang = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 if (lp != NULL && old_lp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579 slang_free(lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
580 lp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
581
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582 endOK:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 fclose(fd);
19073
45eb6f37692e patch 8.2.0097: crash with autocommand and spellfile
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
585 if (did_estack_push)
19075
af1eca322b9e patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents: 19073
diff changeset
586 {
af1eca322b9e patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents: 19073
diff changeset
587 ESTACK_CHECK_NOW
19073
45eb6f37692e patch 8.2.0097: crash with autocommand and spellfile
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
588 estack_pop();
19075
af1eca322b9e patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents: 19073
diff changeset
589 }
9583
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 return lp;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
594 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595 * 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
596 * Returns the total number of words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
597 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
598 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
599 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
600 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
601 int depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
602 idx_T arridx[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603 int curi[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
604 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
605 idx_T n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 int wordcount[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608 arridx[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609 curi[0] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 wordcount[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611 depth = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612 while (depth >= 0 && !got_int)
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 if (curi[depth] > byts[arridx[depth]])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
615 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
616 // Done all bytes at this node, go up one level.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
617 idxs[arridx[depth]] = wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
618 if (depth > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
619 wordcount[depth - 1] += wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
620
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
621 --depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
622 fast_breakcheck();
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
625 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
626 // Do one more byte at this node.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
627 n = arridx[depth] + curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
628 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630 c = byts[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
631 if (c == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
632 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
633 // End of word, count it.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
634 ++wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
635
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
636 // Skip over any other NUL bytes (same word with different
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
637 // flags).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
638 while (byts[n + 1] == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
639 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
640 ++n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
641 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
642 }
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
645 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
646 // Normal char, go one level deeper to count the words.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
647 ++depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
648 arridx[depth] = idxs[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
649 curi[depth] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
650 wordcount[depth] = 0;
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
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 * 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
658 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
659 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
660 suggest_load_files(void)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
661 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
662 langp_T *lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
663 int lpi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
664 slang_T *slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
665 char_u *dotp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
666 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
667 char_u buf[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
668 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
669 time_t timestamp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
670 int wcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
671 int wordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
672 garray_T ga;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
673 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
674
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
675 // Do this for all languages that support sound folding.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
676 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
677 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
678 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
679 slang = lp->lp_slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
680 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
681 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
682 // Change ".spl" to ".sug" and open the file. When the file isn't
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
683 // found silently skip it. Do set "sl_sugloaded" so that we
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
684 // don't try again and again.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
685 slang->sl_sugloaded = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
686
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
687 dotp = vim_strrchr(slang->sl_fname, '.');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
688 if (dotp == NULL || fnamecmp(dotp, ".spl") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
689 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
690 STRCPY(dotp, ".sug");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
691 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
692 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
693 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
694
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 * <SUGHEADER>: <fileID> <versionnr> <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
697 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
698 for (i = 0; i < VIMSUGMAGICL; ++i)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
699 buf[i] = getc(fd); // <fileID>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
700 if (STRNCMP(buf, VIMSUGMAGIC, VIMSUGMAGICL) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
701 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
702 semsg(_("E778: This does not look like a .sug file: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
703 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
704 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
705 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
706 c = getc(fd); // <versionnr>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
707 if (c < VIMSUGVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
708 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
709 semsg(_("E779: Old .sug file, needs to be updated: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
710 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
711 goto nextone;
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 else if (c > VIMSUGVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
715 semsg(_("E780: .sug file is for newer version of Vim: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
716 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
717 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
718 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
719
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
720 // Check the timestamp, it must be exactly the same as the one in
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
721 // the .spl file. Otherwise the word numbers won't match.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
722 timestamp = get8ctime(fd); // <timestamp>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
723 if (timestamp != slang->sl_sugtime)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
724 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
725 semsg(_("E781: .sug file doesn't match .spl file: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
726 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
727 goto nextone;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
730 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
731 * <SUGWORDTREE>: <wordtree>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
732 * Read the trie with the soundfolded words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
733 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
734 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
735 FALSE, 0) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
736 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
737 someerror:
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
738 semsg(_("E782: error while reading .sug file: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
739 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
740 slang_clear_sug(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
741 goto nextone;
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
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 * <SUGTABLE>: <sugwcount> <sugline> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
746 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
747 * 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
748 * 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
749 * 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
750 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
751 slang->sl_sugbuf = open_spellbuf();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
752 if (slang->sl_sugbuf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
753 goto someerror;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
754 // <sugwcount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
755 wcount = get4c(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756 if (wcount < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
757 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
758
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
759 // Read all the wordnr lists into the buffer, one NUL terminated
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
760 // list per line.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
761 ga_init2(&ga, 1, 100);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
762 for (wordnr = 0; wordnr < wcount; ++wordnr)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
763 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
764 ga.ga_len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
765 for (;;)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
766 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
767 c = getc(fd); // <sugline>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
768 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
769 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
770 ((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
771 if (c == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
772 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
773 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
774 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
775 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
776 goto someerror;
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 ga_clear(&ga);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
779
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
780 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
781 * 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
782 * a word by its number.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
783 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
784 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
785 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
786
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
787 nextone:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
788 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
789 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
790 STRCPY(dotp, ".spl");
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
796 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
797 * 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
798 * 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
799 * Returns NULL when the count is zero.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
800 * 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
801 * otherwise.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
802 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
803 static char_u *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
804 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
805 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
806 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
807 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
808 char_u *str;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
809
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
810 // read the length bytes, MSB first
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
811 for (i = 0; i < cnt_bytes; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
812 cnt = (cnt << 8) + getc(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
813 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
814 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
815 *cntp = SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
816 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
817 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
818 *cntp = cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
819 if (cnt == 0)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
820 return NULL; // nothing to read, return NULL
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
821
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
822 str = read_string(fd, cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
823 if (str == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
824 *cntp = SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
825 return str;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
828 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
829 * Read SN_REGION: <regionname> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
830 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
831 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
832 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
833 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
834 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
835 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
836
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
837 if (len > MAXREGIONS * 2)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
838 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
839 for (i = 0; i < len; ++i)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
840 lp->sl_regions[i] = getc(fd); // <regionname>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
841 lp->sl_regions[len] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
842 return 0;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
845 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
846 * Read SN_CHARFLAGS section: <charflagslen> <charflags>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
847 * <folcharslen> <folchars>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
848 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
849 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
850 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
851 read_charflags_section(FILE *fd)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
852 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
853 char_u *flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
854 char_u *fol;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
855 int flagslen, follen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
856
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
857 // <charflagslen> <charflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
858 flags = read_cnt_string(fd, 1, &flagslen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
859 if (flagslen < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
860 return flagslen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
861
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
862 // <folcharslen> <folchars>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
863 fol = read_cnt_string(fd, 2, &follen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
864 if (follen < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
865 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
866 vim_free(flags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
867 return follen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
868 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
869
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
870 // Set the word-char flags and fill SPELL_ISUPPER() table.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
871 if (flags != NULL && fol != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
872 set_spell_charflags(flags, flagslen, fol);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
873
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
874 vim_free(flags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
875 vim_free(fol);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
876
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
877 // When <charflagslen> is zero then <fcharlen> must also be zero.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
878 if ((flags == NULL) != (fol == NULL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
879 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
880 return 0;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
883 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
884 * Read SN_PREFCOND section.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
885 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
886 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
887 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
888 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
889 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
890 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
891 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
892 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
893 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
894 char_u buf[MAXWLEN + 1];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
895
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
896 // <prefcondcnt> <prefcond> ...
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
897 cnt = get2c(fd); // <prefcondcnt>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
898 if (cnt <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
899 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
900
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
901 lp->sl_prefprog = ALLOC_CLEAR_MULT(regprog_T *, cnt);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
902 if (lp->sl_prefprog == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
903 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
904 lp->sl_prefixcnt = cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
905
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
906 for (i = 0; i < cnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
907 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
908 // <prefcond> : <condlen> <condstr>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
909 n = getc(fd); // <condlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
910 if (n < 0 || n >= MAXWLEN)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
911 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
912
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
913 // When <condlen> is zero we have an empty condition. Otherwise
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
914 // compile the regexp program used to check for the condition.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
915 if (n > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
916 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
917 buf[0] = '^'; // always match at one position only
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
918 p = buf + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
919 while (n-- > 0)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
920 *p++ = getc(fd); // <condstr>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
921 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
922 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
923 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
924 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
925 return 0;
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
929 * 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
930 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
931 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
932 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
933 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
934 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
935 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
936 fromto_T *ftp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
937 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
938
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
939 cnt = get2c(fd); // <repcount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
940 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
941 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
942
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
943 if (ga_grow(gap, cnt) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
944 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
945
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
946 // <rep> : <repfromlen> <repfrom> <reptolen> <repto>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
947 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
948 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
949 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
950 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
951 if (i < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
952 return i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
953 if (i == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
954 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
955 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
956 if (i <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
957 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
958 vim_free(ftp->ft_from);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
959 if (i < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
960 return i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
961 return SP_FORMERROR;
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
965 // Fill the first-index table.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
966 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
967 first[i] = -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
968 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
969 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
970 ftp = &((fromto_T *)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
971 if (first[*ftp->ft_from] == -1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
972 first[*ftp->ft_from] = i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
973 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
974 return 0;
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
978 * Read SN_SAL section: <salflags> <salcount> <sal> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
979 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
980 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
981 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
982 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
983 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
984 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
985 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
986 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
987 salitem_T *smp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
988 int ccnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
989 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
990 int c = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
991
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
992 slang->sl_sofo = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
993
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
994 i = getc(fd); // <salflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
995 if (i & SAL_F0LLOWUP)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
996 slang->sl_followup = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
997 if (i & SAL_COLLAPSE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
998 slang->sl_collapse = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
999 if (i & SAL_REM_ACCENTS)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1000 slang->sl_rem_accents = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1001
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1002 cnt = get2c(fd); // <salcount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1003 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1004 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1005
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1006 gap = &slang->sl_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1007 ga_init2(gap, sizeof(salitem_T), 10);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1008 if (ga_grow(gap, cnt + 1) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1009 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1010
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1011 // <sal> : <salfromlen> <salfrom> <saltolen> <salto>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1012 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
1013 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1014 smp = &((salitem_T *)gap->ga_data)[gap->ga_len];
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1015 ccnt = getc(fd); // <salfromlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1016 if (ccnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1017 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1018 if ((p = alloc(ccnt + 2)) == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1019 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1020 smp->sm_lead = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1021
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1022 // Read up to the first special char into sm_lead.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1023 for (i = 0; i < ccnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1024 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1025 c = getc(fd); // <salfrom>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1026 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
1027 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1028 *p++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1029 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1030 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
1031 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1032
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1033 // Put (abc) chars in sm_oneof, if any.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1034 if (c == '(')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1035 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1036 smp->sm_oneof = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1037 for (++i; i < ccnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1038 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1039 c = getc(fd); // <salfrom>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1040 if (c == ')')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1041 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1042 *p++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1043 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1044 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1045 if (++i < ccnt)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1046 c = getc(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1047 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1048 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1049 smp->sm_oneof = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1050
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1051 // Any following chars go in sm_rules.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1052 smp->sm_rules = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1053 if (i < ccnt)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1054 // store the char we got while checking for end of sm_lead
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1055 *p++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1056 for (++i; i < ccnt; ++i)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1057 *p++ = getc(fd); // <salfrom>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1058 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1059
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1060 // <saltolen> <salto>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1061 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
1062 if (ccnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1063 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1064 vim_free(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1065 return ccnt;
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
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 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1070 // convert the multi-byte strings to wide char strings
9583
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 }
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 if (gap->ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1096 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1097 // Add one extra entry to mark the end with an empty sm_lead. Avoids
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1098 // that we need to check the index every time.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1099 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
1100 if ((p = alloc(1)) == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1101 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1102 p[0] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1103 smp->sm_lead = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1104 smp->sm_leadlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1105 smp->sm_oneof = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1106 smp->sm_rules = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1107 smp->sm_to = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1108 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1109 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1110 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
1111 smp->sm_leadlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1112 smp->sm_oneof_w = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1113 smp->sm_to_w = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1114 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1115 ++gap->ga_len;
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1118 // Fill the first-index table.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1119 set_sal_first(slang);
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 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1122 }
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1125 * Read SN_WORDS: <word> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1126 * Return SP_*ERROR flags.
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1129 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
1130 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1131 int done = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1132 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1133 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1134 char_u word[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1135
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1136 while (done < len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1137 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1138 // Read one word at a time.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1139 for (i = 0; ; ++i)
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 c = getc(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1142 if (c == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1143 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1144 word[i] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1145 if (word[i] == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1146 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1147 if (i == MAXWLEN - 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1148 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1149 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1150
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1151 // Init the count to 10.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1152 count_common_word(lp, word, -1, 10);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1153 done += i + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1154 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1155 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1156 }
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1159 * SN_SOFO: <sofofromlen> <sofofrom> <sofotolen> <sofoto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1160 * Return SP_*ERROR flags.
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1163 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
1164 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1165 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1166 char_u *from, *to;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1167 int res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1168
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1169 slang->sl_sofo = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1170
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1171 // <sofofromlen> <sofofrom>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1172 from = read_cnt_string(fd, 2, &cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1173 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1174 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1175
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1176 // <sofotolen> <sofoto>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1177 to = read_cnt_string(fd, 2, &cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1178 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1179 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1180 vim_free(from);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1181 return cnt;
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1184 // Store the info in slang->sl_sal and/or slang->sl_sal_first.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1185 if (from != NULL && to != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1186 res = set_sofo(slang, from, to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1187 else if (from != NULL || to != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1188 res = SP_FORMERROR; // only one of two strings is an error
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1189 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1190 res = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1191
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1192 vim_free(from);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1193 vim_free(to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1194 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1195 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1196
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1197 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1198 * 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
1199 * <compmax> <compminlen> <compsylmax> <compoptions> <compflags>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1200 * Returns SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1201 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1202 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1203 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
1204 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1205 int todo = len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1206 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1207 int atstart;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1208 char_u *pat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1209 char_u *pp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1210 char_u *cp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1211 char_u *ap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1212 char_u *crp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1213 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1214 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1215
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1216 if (todo < 2)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1217 return SP_FORMERROR; // need at least two bytes
9583
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 --todo;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1220 c = getc(fd); // <compmax>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1221 if (c < 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1222 c = MAXWLEN;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1223 slang->sl_compmax = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1224
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1225 --todo;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1226 c = getc(fd); // <compminlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1227 if (c < 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1228 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1229 slang->sl_compminlen = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1230
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1231 --todo;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1232 c = getc(fd); // <compsylmax>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1233 if (c < 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1234 c = MAXWLEN;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1235 slang->sl_compsylmax = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1236
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1237 c = getc(fd); // <compoptions>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1238 if (c != 0)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1239 ungetc(c, fd); // be backwards compatible with Vim 7.0b
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1240 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1241 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1242 --todo;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1243 c = getc(fd); // only use the lower byte for now
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1244 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1245 slang->sl_compoptions = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1246
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1247 gap = &slang->sl_comppat;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1248 c = get2c(fd); // <comppatcount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1249 todo -= 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1250 ga_init2(gap, sizeof(char_u *), c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1251 if (ga_grow(gap, c) == OK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1252 while (--c >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1253 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1254 ((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
1255 read_cnt_string(fd, 1, &cnt);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1256 // <comppatlen> <comppattext>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1257 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1258 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1259 todo -= cnt + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1260 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1261 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1262 if (todo < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1263 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1264
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1265 // Turn the COMPOUNDRULE items into a regexp pattern:
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1266 // "a[bc]/a*b+" -> "^\(a[bc]\|a*b\+\)$".
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1267 // Inserting backslashes may double the length, "^\(\)$<Nul>" is 7 bytes.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1268 // Conversion to utf-8 may double the size.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1269 c = todo * 2 + 7;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1270 if (enc_utf8)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1271 c += todo * 2;
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16738
diff changeset
1272 pat = alloc(c);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1273 if (pat == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1274 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1275
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1276 // We also need a list of all flags that can appear at the start and one
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1277 // for all flags.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1278 cp = alloc(todo + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1279 if (cp == NULL)
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 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1282 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1283 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1284 slang->sl_compstartflags = cp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1285 *cp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1286
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1287 ap = alloc(todo + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1288 if (ap == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1289 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1290 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1291 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1292 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1293 slang->sl_compallflags = ap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1294 *ap = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1295
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1296 // And a list of all patterns in their original form, for checking whether
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1297 // compounding may work in match_compoundrule(). This is freed when we
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1298 // encounter a wildcard, the check doesn't work then.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1299 crp = alloc(todo + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1300 slang->sl_comprules = crp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1301
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1302 pp = pat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1303 *pp++ = '^';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1304 *pp++ = '\\';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1305 *pp++ = '(';
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 atstart = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1308 while (todo-- > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1309 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1310 c = getc(fd); // <compflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1311 if (c == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1312 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1313 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1314 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1315 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1316
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1317 // Add all flags to "sl_compallflags".
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1318 if (vim_strchr((char_u *)"?*+[]/", c) == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1319 && !byte_in_str(slang->sl_compallflags, c))
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 *ap++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1322 *ap = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1323 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1324
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1325 if (atstart != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1326 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1327 // At start of item: copy flags to "sl_compstartflags". For a
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1328 // [abc] item set "atstart" to 2 and copy up to the ']'.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1329 if (c == '[')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1330 atstart = 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1331 else if (c == ']')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1332 atstart = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1333 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1334 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1335 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
1336 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1337 *cp++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1338 *cp = NUL;
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 (atstart == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1341 atstart = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1342 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1343 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1344
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1345 // Copy flag to "sl_comprules", unless we run into a wildcard.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1346 if (crp != NULL)
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 if (c == '?' || c == '+' || c == '*')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1349 {
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13232
diff changeset
1350 VIM_CLEAR(slang->sl_comprules);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1351 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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1354 *crp++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1355 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1356
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1357 if (c == '/') // slash separates two items
9583
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 *pp++ = '\\';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1360 *pp++ = '|';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1361 atstart = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1362 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1363 else // normal char, "[abc]" and '*' are copied as-is
9583
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 if (c == '?' || c == '+' || c == '~')
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1366 *pp++ = '\\'; // "a?" becomes "a\?", "a+" becomes "a\+"
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1367 if (enc_utf8)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1368 pp += mb_char2bytes(c, pp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1369 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1370 *pp++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1371 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1372 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1373
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1374 *pp++ = '\\';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1375 *pp++ = ')';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1376 *pp++ = '$';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1377 *pp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1378
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1379 if (crp != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1380 *crp = NUL;
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 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
1383 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1384 if (slang->sl_compprog == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1385 return SP_FORMERROR;
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 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1388 }
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1391 * 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
1392 * 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
1393 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1394 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1395 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
1396 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1397 int i;
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 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1400 char_u *s;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1401 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1402 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1403 int *inp;
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 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1406 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1407 // Use "sl_sal" as an array with 256 pointers to a list of wide
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1408 // characters. The index is the low byte of the character.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1409 // The list contains from-to pairs with a terminating NUL.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1410 // sl_sal_first[] is used for latin1 "from" characters.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1411 gap = &lp->sl_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1412 ga_init2(gap, sizeof(int *), 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1413 if (ga_grow(gap, 256) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1414 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1415 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
1416 gap->ga_len = 256;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1417
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1418 // First count the number of items for each list. Temporarily use
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1419 // sl_sal_first[] for this.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1420 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
1421 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1422 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
1423 MB_CPTR_ADV(s);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1424 if (c >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1425 ++lp->sl_sal_first[c & 0xff];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1426 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1427 if (*p != NUL || *s != NUL) // lengths differ
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1428 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1429
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1430 // Allocate the lists.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1431 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1432 if (lp->sl_sal_first[i] > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1433 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1434 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
1435 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1436 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1437 ((int **)gap->ga_data)[i] = (int *)p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1438 *(int *)p = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1439 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1440
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1441 // Put the characters up to 255 in sl_sal_first[] the rest in a sl_sal
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1442 // list.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1443 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
1444 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
1445 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1446 c = mb_cptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1447 i = mb_cptr2char_adv(&s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1448 if (c >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1449 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1450 // Append the from-to chars at the end of the list with
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1451 // the low byte.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1452 inp = ((int **)gap->ga_data)[c & 0xff];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1453 while (*inp != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1454 ++inp;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1455 *inp++ = c; // from char
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1456 *inp++ = i; // to char
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1457 *inp++ = NUL; // NUL at the end
9583
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 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1460 // mapping byte to char is done in sl_sal_first[]
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1461 lp->sl_sal_first[c] = i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1462 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1463 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1464 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1465 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1466 // mapping bytes to bytes is done in sl_sal_first[]
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1467 if (STRLEN(from) != STRLEN(to))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1468 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1469
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1470 for (i = 0; to[i] != NUL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1471 lp->sl_sal_first[from[i]] = to[i];
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1472 lp->sl_sal.ga_len = 1; // indicates we have soundfolding
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1473 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1474
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1475 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1476 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1477
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1478 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1479 * Fill the first-index table for "lp".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1480 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1481 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1482 set_sal_first(slang_T *lp)
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 salfirst_T *sfirst;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1485 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1486 salitem_T *smp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1487 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1488 garray_T *gap = &lp->sl_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1489
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1490 sfirst = lp->sl_sal_first;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1491 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1492 sfirst[i] = -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1493 smp = (salitem_T *)gap->ga_data;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1494 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
1495 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1496 if (has_mbyte)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1497 // Use the lowest byte of the first character. For latin1 it's
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1498 // the character, for other encodings it should differ for most
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1499 // characters.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1500 c = *smp[i].sm_lead_w & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1501 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1502 c = *smp[i].sm_lead;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1503 if (sfirst[c] == -1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1504 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1505 sfirst[c] = i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1506 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1507 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1508 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1509
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1510 // Make sure all entries with this byte are following each
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1511 // other. Move the ones that are in the wrong position. Do
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1512 // keep the same ordering!
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1513 while (i + 1 < gap->ga_len
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1514 && (*smp[i + 1].sm_lead_w & 0xff) == c)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1515 // Skip over entry with same index byte.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1516 ++i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1517
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1518 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
1519 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
1520 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1521 salitem_T tsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1522
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1523 // Move entry with same index byte after the entries
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1524 // we already found.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1525 ++i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1526 --n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1527 tsal = smp[i + n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1528 mch_memmove(smp + i + 1, smp + i,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1529 sizeof(salitem_T) * n);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1530 smp[i] = tsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1531 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1532 }
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 }
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1537 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1538 * 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
1539 * 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
1540 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1541 static int *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1542 mb_str2wide(char_u *s)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1543 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1544 int *res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1545 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1546 int i = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1547
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
1548 res = ALLOC_MULT(int, mb_charlen(s) + 1);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1549 if (res != NULL)
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 for (p = s; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1552 res[i++] = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1553 res[i] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1554 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1555 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1556 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1557
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 * 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
1560 * 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
1561 * 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
1562 * 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
1563 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1564 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1565 spell_read_tree(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1566 FILE *fd,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1567 char_u **bytsp,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1568 idx_T **idxsp,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1569 int prefixtree, // TRUE for the prefix tree
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1570 int prefixcnt) // when "prefixtree" is TRUE: prefix count
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1571 {
10974
7d735b86f764 patch 8.0.0376: size computations in spell file reading are off
Christian Brabandt <cb@256bit.org>
parents: 10865
diff changeset
1572 long len;
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1573 int idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1574 char_u *bp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1575 idx_T *ip;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1576
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1577 // The tree size was computed when writing the file, so that we can
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1578 // allocate it as one long block. <nodecount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1579 len = get4c(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1580 if (len < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1581 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
1582 if (len >= LONG_MAX / (long)sizeof(int))
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1583 // Invalid length, multiply with sizeof(int) would overflow.
10865
1a18c0f93ffa patch 8.0.0322: possible overflow with corrupted spell file
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1584 return SP_FORMERROR;
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1585 if (len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1586 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1587 // Allocate the byte array.
16768
695d9ef00b03 patch 8.1.1386: unessesary type casts for lalloc()
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
1588 bp = alloc(len);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1589 if (bp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1590 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1591 *bytsp = bp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1592
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1593 // Allocate the index array.
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
1594 ip = lalloc_clear(len * sizeof(int), TRUE);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1595 if (ip == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1596 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1597 *idxsp = ip;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1598
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1599 // Recursively read the tree and store it in the array.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1600 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
1601 if (idx < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1602 return idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1603 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1604 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1605 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1606
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1607 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1608 * 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
1609 * "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
1610 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1611 * 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
1612 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1613 * Returns the index (>= 0) following the siblings.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1614 * 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
1615 * 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
1616 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1617 static idx_T
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1618 read_tree_node(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1619 FILE *fd,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1620 char_u *byts,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1621 idx_T *idxs,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1622 int maxidx, // size of arrays
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1623 idx_T startidx, // current index in "byts" and "idxs"
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1624 int prefixtree, // TRUE for reading PREFIXTREE
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1625 int maxprefcondnr) // maximum for <prefcondnr>
9583
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 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1628 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1629 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1630 idx_T idx = startidx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1631 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1632 int c2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1633 #define SHARED_MASK 0x8000000
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1634
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1635 len = getc(fd); // <siblingcount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1636 if (len <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1637 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1638
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1639 if (startidx + len >= maxidx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1640 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1641 byts[idx++] = len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1642
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1643 // Read the byte values, flag/region bytes and shared indexes.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1644 for (i = 1; i <= len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1645 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1646 c = getc(fd); // <byte>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1647 if (c < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1648 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1649 if (c <= BY_SPECIAL)
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 if (c == BY_NOFLAGS && !prefixtree)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1652 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1653 // No flags, all regions.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1654 idxs[idx] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1655 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1656 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1657 else if (c != BY_INDEX)
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 if (prefixtree)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1660 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1661 // Read the optional pflags byte, the prefix ID and the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1662 // condition nr. In idxs[] store the prefix ID in the low
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1663 // byte, the condition index shifted up 8 bits, the flags
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1664 // shifted up 24 bits.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1665 if (c == BY_FLAGS)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1666 c = getc(fd) << 24; // <pflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1667 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1668 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1669
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1670 c |= getc(fd); // <affixID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1671
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1672 n = get2c(fd); // <prefcondnr>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1673 if (n >= maxprefcondnr)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1674 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1675 c |= (n << 8);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1676 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1677 else // c must be BY_FLAGS or BY_FLAGS2
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1678 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1679 // Read flags and optional region and prefix ID. In
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1680 // idxs[] the flags go in the low two bytes, region above
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1681 // that and prefix ID above the region.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1682 c2 = c;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1683 c = getc(fd); // <flags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1684 if (c2 == BY_FLAGS2)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1685 c = (getc(fd) << 8) + c; // <flags2>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1686 if (c & WF_REGION)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1687 c = (getc(fd) << 16) + c; // <region>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1688 if (c & WF_AFX)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1689 c = (getc(fd) << 24) + c; // <affixID>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1690 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1691
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1692 idxs[idx] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1693 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1694 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1695 else // c == BY_INDEX
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1696 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1697 // <nodeidx>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1698 n = get3c(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1699 if (n < 0 || n >= maxidx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1700 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1701 idxs[idx] = n + SHARED_MASK;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1702 c = getc(fd); // <xbyte>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1703 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1704 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1705 byts[idx++] = c;
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1708 // Recursively read the children for non-shared siblings.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1709 // Skip the end-of-word ones (zero byte value) and the shared ones (and
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1710 // remove SHARED_MASK)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1711 for (i = 1; i <= len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1712 if (byts[startidx + i] != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1713 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1714 if (idxs[startidx + i] & SHARED_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1715 idxs[startidx + i] &= ~SHARED_MASK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1716 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1717 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1718 idxs[startidx + i] = idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1719 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
1720 prefixtree, maxprefcondnr);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1721 if (idx < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1722 break;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1725
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1726 return idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1727 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1728
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 * 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
1731 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1732 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1733 spell_reload_one(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1734 char_u *fname,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1735 int added_word) // invoked through "zg"
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1736 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1737 slang_T *slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1738 int didit = FALSE;
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 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
1741 {
16738
b52ea9c5f1db patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents: 16606
diff changeset
1742 if (fullpathcmp(fname, slang->sl_fname, FALSE, TRUE) == FPC_SAME)
9583
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 slang_clear(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1745 if (spell_load_file(fname, NULL, slang, FALSE) == NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1746 // reloading failed, clear the language
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1747 slang_clear(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1748 redraw_all_later(SOME_VALID);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1749 didit = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1750 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1751 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1752
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1753 // When "zg" was used and the file wasn't loaded yet, should redo
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1754 // 'spelllang' to load it now.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1755 if (added_word && !didit)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1756 did_set_spelllang(curwin);
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
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1761 * Functions for ":mkspell".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1762 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1763
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1764 #define MAXLINELEN 500 // Maximum length in bytes of a line in a .aff
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1765 // and .dic file.
9583
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 * 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
1768 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1769 typedef struct afffile_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1770 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1771 char_u *af_enc; // "SET", normalized, alloc'ed string or NULL
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1772 int af_flagtype; // AFT_CHAR, AFT_LONG, AFT_NUM or AFT_CAPLONG
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1773 unsigned af_rare; // RARE ID for rare word
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1774 unsigned af_keepcase; // KEEPCASE ID for keep-case word
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1775 unsigned af_bad; // BAD ID for banned word
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1776 unsigned af_needaffix; // NEEDAFFIX ID
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1777 unsigned af_circumfix; // CIRCUMFIX ID
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1778 unsigned af_needcomp; // NEEDCOMPOUND ID
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1779 unsigned af_comproot; // COMPOUNDROOT ID
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1780 unsigned af_compforbid; // COMPOUNDFORBIDFLAG ID
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1781 unsigned af_comppermit; // COMPOUNDPERMITFLAG ID
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1782 unsigned af_nosuggest; // NOSUGGEST ID
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1783 int af_pfxpostpone; // postpone prefixes without chop string and
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1784 // without flags
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1785 int af_ignoreextra; // IGNOREEXTRA present
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1786 hashtab_T af_pref; // hashtable for prefixes, affheader_T
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1787 hashtab_T af_suff; // hashtable for suffixes, affheader_T
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1788 hashtab_T af_comp; // hashtable for compound flags, compitem_T
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1789 } afffile_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1790
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1791 #define AFT_CHAR 0 // flags are one character
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1792 #define AFT_LONG 1 // flags are two characters
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1793 #define AFT_CAPLONG 2 // flags are one or two characters
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1794 #define AFT_NUM 3 // flags are numbers, comma separated
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1795
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1796 typedef struct affentry_S affentry_T;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1797 // Affix entry from ".aff" file. Used for prefixes and suffixes.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1798 struct affentry_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1799 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1800 affentry_T *ae_next; // next affix with same name/number
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1801 char_u *ae_chop; // text to chop off basic word (can be NULL)
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1802 char_u *ae_add; // text to add to basic word (can be NULL)
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1803 char_u *ae_flags; // flags on the affix (can be NULL)
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1804 char_u *ae_cond; // condition (NULL for ".")
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1805 regprog_T *ae_prog; // regexp program for ae_cond or NULL
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1806 char ae_compforbid; // COMPOUNDFORBIDFLAG found
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1807 char ae_comppermit; // COMPOUNDPERMITFLAG found
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1808 };
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1809
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1810 #define AH_KEY_LEN 17 // 2 x 8 bytes + NUL
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1811
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1812 // Affix header from ".aff" file. Used for af_pref and af_suff.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1813 typedef struct affheader_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1814 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1815 char_u ah_key[AH_KEY_LEN]; // key for hashtab == name of affix
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1816 unsigned ah_flag; // affix name as number, uses "af_flagtype"
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1817 int ah_newID; // prefix ID after renumbering; 0 if not used
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1818 int ah_combine; // suffix may combine with prefix
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1819 int ah_follows; // another affix block should be following
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1820 affentry_T *ah_first; // first affix entry
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1821 } affheader_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1822
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1823 #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
1824
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1825 // Flag used in compound items.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1826 typedef struct compitem_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1827 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1828 char_u ci_key[AH_KEY_LEN]; // key for hashtab == name of compound
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1829 unsigned ci_flag; // affix name as number, uses "af_flagtype"
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1830 int ci_newID; // affix ID after renumbering.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1831 } compitem_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1832
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1833 #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
1834
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1835 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1836 * 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
1837 * 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
1838 * once after ":mkspell" is done.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1839 * 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
1840 * "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
1841 * 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
1842 */
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1843 #define SBLOCKSIZE 16000 // size of sb_data
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1844 typedef struct sblock_S sblock_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1845 struct sblock_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1846 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1847 int sb_used; // nr of bytes already in use
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1848 sblock_T *sb_next; // next block in list
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1849 char_u sb_data[1]; // data, actually longer
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1850 };
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1851
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 * A node in the tree.
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 typedef struct wordnode_S wordnode_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1856 struct wordnode_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1857 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1858 union // shared to save space
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1859 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1860 char_u hashkey[6]; // the hash key, only used while compressing
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1861 int index; // index in written nodes (valid after first
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1862 // round)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1863 } wn_u1;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1864 union // shared to save space
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1865 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1866 wordnode_T *next; // next node with same hash key
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1867 wordnode_T *wnode; // parent node that will write this node
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1868 } wn_u2;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1869 wordnode_T *wn_child; // child (next byte in word)
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1870 wordnode_T *wn_sibling; // next sibling (alternate byte in word,
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1871 // always sorted)
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1872 int wn_refs; // Nr. of references to this node. Only
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1873 // relevant for first node in a list of
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1874 // siblings, in following siblings it is
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1875 // always one.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1876 char_u wn_byte; // Byte for this node. NUL for word end
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1877
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1878 // Info for when "wn_byte" is NUL.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1879 // In PREFIXTREE "wn_region" is used for the prefcondnr.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1880 // In the soundfolded word tree "wn_flags" has the MSW of the wordnr and
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1881 // "wn_region" the LSW of the wordnr.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1882 char_u wn_affixID; // supported/required prefix ID or 0
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1883 short_u wn_flags; // WF_ flags
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1884 short wn_region; // region mask
9583
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 #ifdef SPELL_PRINTTREE
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1887 int wn_nr; // sequence nr for printing
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1888 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1889 };
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1890
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1891 #define WN_MASK 0xffff // mask relevant bits of "wn_flags"
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1892
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1893 #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
1894
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1895 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1896 * Info used while reading the spell files.
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 typedef struct spellinfo_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1899 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1900 wordnode_T *si_foldroot; // tree with case-folded words
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1901 long si_foldwcount; // nr of words in si_foldroot
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1902
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1903 wordnode_T *si_keeproot; // tree with keep-case words
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1904 long si_keepwcount; // nr of words in si_keeproot
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1905
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1906 wordnode_T *si_prefroot; // tree with postponed prefixes
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1907
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1908 long si_sugtree; // creating the soundfolding trie
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1909
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1910 sblock_T *si_blocks; // memory blocks used
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1911 long si_blocks_cnt; // memory blocks allocated
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1912 int si_did_emsg; // TRUE when ran out of memory
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1913
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1914 long si_compress_cnt; // words to add before lowering
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1915 // compression limit
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1916 wordnode_T *si_first_free; // List of nodes that have been freed during
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1917 // compression, linked by "wn_child" field.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1918 long si_free_count; // number of nodes in si_first_free
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1919 #ifdef SPELL_PRINTTREE
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1920 int si_wordnode_nr; // sequence nr for nodes
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1921 #endif
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1922 buf_T *si_spellbuf; // buffer used to store soundfold word table
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1923
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1924 int si_ascii; // handling only ASCII words
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1925 int si_add; // addition file
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1926 int si_clear_chartab; // when TRUE clear char tables
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1927 int si_region; // region mask
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1928 vimconv_T si_conv; // for conversion to 'encoding'
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1929 int si_memtot; // runtime memory used
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1930 int si_verbose; // verbose messages
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1931 int si_msg_count; // number of words added since last message
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1932 char_u *si_info; // info text chars or NULL
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1933 int si_region_count; // number of regions supported (1 when there
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1934 // 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
1935 char_u si_region_name[MAXREGIONS * 2 + 1];
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1936 // region names; used only if
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1937 // si_region_count > 1)
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1938
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1939 garray_T si_rep; // list of fromto_T entries from REP lines
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1940 garray_T si_repsal; // list of fromto_T entries from REPSAL lines
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1941 garray_T si_sal; // list of fromto_T entries from SAL lines
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1942 char_u *si_sofofr; // SOFOFROM text
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1943 char_u *si_sofoto; // SOFOTO text
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1944 int si_nosugfile; // NOSUGFILE item found
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1945 int si_nosplitsugs; // NOSPLITSUGS item found
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1946 int si_nocompoundsugs; // NOCOMPOUNDSUGS item found
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1947 int si_followup; // soundsalike: ?
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1948 int si_collapse; // soundsalike: ?
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1949 hashtab_T si_commonwords; // hashtable for common words
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1950 time_t si_sugtime; // timestamp for .sug file
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1951 int si_rem_accents; // soundsalike: remove accents
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1952 garray_T si_map; // MAP info concatenated
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1953 char_u *si_midword; // MIDWORD chars or NULL
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1954 int si_compmax; // max nr of words for compounding
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1955 int si_compminlen; // minimal length for compounding
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1956 int si_compsylmax; // max nr of syllables for compounding
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1957 int si_compoptions; // COMP_ flags
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1958 garray_T si_comppat; // CHECKCOMPOUNDPATTERN items, each stored as
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1959 // a string
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1960 char_u *si_compflags; // flags used for compounding
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1961 char_u si_nobreak; // NOBREAK
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1962 char_u *si_syllable; // syllable string
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1963 garray_T si_prefcond; // table with conditions for postponed
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1964 // prefixes, each stored as a string
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1965 int si_newprefID; // current value for ah_newID
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
1966 int si_newcompID; // current value for compound ID
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1967 } spellinfo_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1968
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1969 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
1970 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
1971 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
1972 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
1973 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
1974 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
1975 static void check_renumber(spellinfo_T *spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1976 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
1977 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
1978 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
1979 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
1980 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
1981 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
1982 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
1983 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
1984 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
1985 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
1986 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
1987 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
1988 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
1989 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
1990 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
1991 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
1992 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
1993 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
1994 static void clear_node(wordnode_T *node);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1995 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
1996 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
1997 static int sug_maketable(spellinfo_T *spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1998 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
1999 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
2000 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
2001 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
2002 static void init_spellfile(void);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2003
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2004 // In the postponed prefixes tree wn_flags is used to store the WFP_ flags,
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2005 // but it must be negative to indicate the prefix tree to tree_add_word().
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2006 // Use a negative number with the lower 8 bits zero.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2007 #define PFX_FLAGS -256
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2008
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2009 // flags for "condit" argument of store_aff_word()
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2010 #define CONDIT_COMB 1 // affix must combine
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2011 #define CONDIT_CFIX 2 // affix must have CIRCUMFIX flag
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2012 #define CONDIT_SUF 4 // add a suffix for matching flags
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2013 #define CONDIT_AFF 8 // word already has an affix
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2014
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2015 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2016 * 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
2017 */
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2018 static long compress_start = 30000; // memory / SBLOCKSIZE
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2019 static long compress_inc = 100; // memory / SBLOCKSIZE
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2020 static long compress_added = 500000; // word count
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2021
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2022 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2023 * 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
2024 * Sets "sps_flags".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2025 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2026 int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2027 spell_check_msm(void)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2028 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2029 char_u *p = p_msm;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2030 long start = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2031 long incr = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2032 long added = 0;
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 if (!VIM_ISDIGIT(*p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2035 return FAIL;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2036 // block count = (value * 1024) / SBLOCKSIZE (but avoid overflow)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2037 start = (getdigits(&p) * 10) / (SBLOCKSIZE / 102);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2038 if (*p != ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2039 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2040 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2041 if (!VIM_ISDIGIT(*p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2042 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2043 incr = (getdigits(&p) * 102) / (SBLOCKSIZE / 10);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2044 if (*p != ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2045 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2046 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2047 if (!VIM_ISDIGIT(*p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2048 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2049 added = getdigits(&p) * 1024;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2050 if (*p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2051 return FAIL;
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 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
2054 return FAIL;
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 compress_start = start;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2057 compress_inc = incr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2058 compress_added = added;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2059 return OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2060 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2061
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2062 #ifdef SPELL_PRINTTREE
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 * 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
2065 * 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
2066 * compressing the tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2067 * Based on code from Olaf Seibert.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2068 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2069 #define PRINTLINESIZE 1000
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2070 #define PRINTWIDTH 6
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2071
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2072 #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
2073 PRINTLINESIZE - PRINTWIDTH * depth, fmt, a1, a2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2074
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2075 static char line1[PRINTLINESIZE];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2076 static char line2[PRINTLINESIZE];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2077 static char line3[PRINTLINESIZE];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2078
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2079 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2080 spell_clear_flags(wordnode_T *node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2081 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2082 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2083
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2084 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
2085 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2086 np->wn_u1.index = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2087 spell_clear_flags(np->wn_child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2088 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2089 }
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 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2092 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
2093 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2094 if (node->wn_u1.index)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2095 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2096 // Done this node before, print the reference.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2097 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
2098 PRINTSOME(line2, depth, " ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2099 PRINTSOME(line3, depth, " ", 0, 0);
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
2100 msg(line1);
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
2101 msg(line2);
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
2102 msg(line3);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2103 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2104 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2105 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2106 node->wn_u1.index = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2107
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2108 if (node->wn_byte != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2109 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2110 if (node->wn_child != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2111 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
2112 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2113 // Cannot happen?
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2114 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
2115 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2116 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2117 PRINTSOME(line1, depth, " $ ", 0, 0);
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 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
2120
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2121 if (node->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2122 PRINTSOME(line3, depth, " | ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2123 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2124 PRINTSOME(line3, depth, " ", 0, 0);
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 if (node->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2127 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
2128 msg(line1);
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
2129 msg(line2);
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
2130 msg(line3);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2131 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2132
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2133 // do the children
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2134 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
2135 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
2136
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2137 // do the siblings
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2138 if (node->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2139 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2140 // get rid of all parent details except |
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2141 STRCPY(line1, line3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2142 STRCPY(line2, line3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2143 spell_print_node(node->wn_sibling, depth);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2144 }
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2147
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2148 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2149 spell_print_tree(wordnode_T *root)
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 (root != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2152 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2153 // Clear the "wn_u1.index" fields, used to remember what has been
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2154 // done.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2155 spell_clear_flags(root);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2156
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2157 // Recursively print the tree.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2158 spell_print_node(root, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2159 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2160 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2161 #endif // SPELL_PRINTTREE
9583
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2164 * Read the affix file "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2165 * 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
2166 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2167 static afffile_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2168 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
2169 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2170 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2171 afffile_T *aff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2172 char_u rline[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2173 char_u *line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2174 char_u *pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2175 #define MAXITEMCNT 30
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2176 char_u *(items[MAXITEMCNT]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2177 int itemcnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2178 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2179 int lnum = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2180 affheader_T *cur_aff = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2181 int did_postpone_prefix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2182 int aff_todo = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2183 hashtab_T *tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2184 char_u *low = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2185 char_u *fol = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2186 char_u *upp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2187 int do_rep;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2188 int do_repsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2189 int do_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2190 int do_mapline;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2191 int found_map = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2192 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2193 int l;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2194 int compminlen = 0; // COMPOUNDMIN value
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2195 int compsylmax = 0; // COMPOUNDSYLMAX value
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2196 int compoptions = 0; // COMP_ flags
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2197 int compmax = 0; // COMPOUNDWORDMAX value
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2198 char_u *compflags = NULL; // COMPOUNDFLAG and COMPOUNDRULE
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2199 // concatenated
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2200 char_u *midword = NULL; // MIDWORD value
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2201 char_u *syllable = NULL; // SYLLABLE value
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2202 char_u *sofofrom = NULL; // SOFOFROM value
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2203 char_u *sofoto = NULL; // SOFOTO value
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2204
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2205 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2206 * Open the file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2207 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2208 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2209 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2210 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2211 semsg(_(e_notopen), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2212 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2213 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2214
14121
97814084264b patch 8.1.0078: "..." used inconsistently in messages
Christian Brabandt <cb@256bit.org>
parents: 13610
diff changeset
2215 vim_snprintf((char *)IObuff, IOSIZE, _("Reading affix file %s..."), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2216 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2217
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2218 // Only do REP lines when not done in another .aff file already.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2219 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
2220
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2221 // Only do REPSAL lines when not done in another .aff file already.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2222 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
2223
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2224 // Only do SAL lines when not done in another .aff file already.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2225 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
2226
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2227 // Only do MAP lines when not done in another .aff file already.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2228 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
2229
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2230 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2231 * Allocate and init the afffile_T structure.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2232 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2233 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
2234 if (aff == NULL)
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 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2237 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2238 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2239 hash_init(&aff->af_pref);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2240 hash_init(&aff->af_suff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2241 hash_init(&aff->af_comp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2242
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 * 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
2245 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2246 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
2247 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2248 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2249 ++lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2250
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2251 // Skip comment lines.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2252 if (*rline == '#')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2253 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2254
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2255 // Convert from "SET" to 'encoding' when needed.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2256 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2257 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
2258 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2259 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
2260 if (pc == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2261 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2262 smsg(_("Conversion failure for word in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2263 fname, lnum, rline);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2264 continue;
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 line = pc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2267 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2268 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2269 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2270 pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2271 line = rline;
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2274 // Split the line up in white separated items. Put a NUL after each
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2275 // item.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2276 itemcnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2277 for (p = line; ; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2278 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2279 while (*p != NUL && *p <= ' ') // skip white space and CR/NL
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2280 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2281 if (*p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2282 break;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2283 if (itemcnt == MAXITEMCNT) // too many items
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2284 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2285 items[itemcnt++] = p;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2286 // A few items have arbitrary text argument, don't split them.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2287 if (itemcnt == 2 && spell_info_item(items[0]))
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2288 while (*p >= ' ' || *p == TAB) // skip until CR/NL
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2289 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2290 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2291 while (*p > ' ') // skip until white space or CR/NL
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2292 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2293 if (*p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2294 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2295 *p++ = NUL;
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2298 // Handle non-empty lines.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2299 if (itemcnt > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2300 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2301 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
2302 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2303 // Setup for conversion from "ENC" to 'encoding'.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2304 aff->af_enc = enc_canonize(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2305 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
2306 && 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
2307 p_enc) == FAIL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2308 smsg(_("Conversion in %s not supported: from %s to %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2309 fname, aff->af_enc, p_enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2310 spin->si_conv.vc_fail = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2311 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2312 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
2313 && aff->af_flagtype == AFT_CHAR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2314 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2315 if (STRCMP(items[1], "long") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2316 aff->af_flagtype = AFT_LONG;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2317 else if (STRCMP(items[1], "num") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2318 aff->af_flagtype = AFT_NUM;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2319 else if (STRCMP(items[1], "caplong") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2320 aff->af_flagtype = AFT_CAPLONG;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2321 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2322 smsg(_("Invalid value for FLAG in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2323 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2324 if (aff->af_rare != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2325 || aff->af_keepcase != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2326 || aff->af_bad != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2327 || aff->af_needaffix != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2328 || aff->af_circumfix != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2329 || aff->af_needcomp != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2330 || aff->af_comproot != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2331 || aff->af_nosuggest != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2332 || compflags != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2333 || aff->af_suff.ht_used > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2334 || aff->af_pref.ht_used > 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2335 smsg(_("FLAG after using flags in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2336 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2337 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2338 else if (spell_info_item(items[0]))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2339 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2340 p = (char_u *)getroom(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2341 (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
2342 + STRLEN(items[0])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2343 + STRLEN(items[1]) + 3, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2344 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2345 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2346 if (spin->si_info != NULL)
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 STRCPY(p, spin->si_info);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2349 STRCAT(p, "\n");
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 STRCAT(p, items[0]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2352 STRCAT(p, " ");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2353 STRCAT(p, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2354 spin->si_info = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2355 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2356 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2357 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
2358 && midword == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2359 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2360 midword = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2361 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2362 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
2363 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2364 // ignored, we look in the tree for what chars may appear
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2365 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2366 // TODO: remove "RAR" later
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2367 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
2368 || is_aff_rule(items, itemcnt, "RARE", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2369 && aff->af_rare == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2370 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2371 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
2372 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2373 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2374 // TODO: remove "KEP" later
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2375 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
2376 || is_aff_rule(items, itemcnt, "KEEPCASE", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2377 && aff->af_keepcase == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2378 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2379 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
2380 fname, lnum);
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 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
2383 || is_aff_rule(items, itemcnt, "FORBIDDENWORD", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2384 && aff->af_bad == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2385 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2386 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
2387 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2388 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2389 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
2390 && aff->af_needaffix == 0)
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 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
2393 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2394 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2395 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
2396 && aff->af_circumfix == 0)
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 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
2399 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2400 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2401 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
2402 && aff->af_nosuggest == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2403 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2404 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
2405 fname, lnum);
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 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
2408 || is_aff_rule(items, itemcnt, "ONLYINCOMPOUND", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2409 && aff->af_needcomp == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2410 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2411 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
2412 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2413 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2414 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
2415 && aff->af_comproot == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2416 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2417 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
2418 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2419 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2420 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
2421 && aff->af_compforbid == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2422 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2423 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
2424 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2425 if (aff->af_pref.ht_used > 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2426 smsg(_("Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line %d"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2427 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2428 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2429 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
2430 && aff->af_comppermit == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2431 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2432 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
2433 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2434 if (aff->af_pref.ht_used > 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2435 smsg(_("Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line %d"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2436 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2437 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2438 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
2439 && compflags == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2440 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2441 // Turn flag "c" into COMPOUNDRULE compatible string "c+",
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2442 // "Na" into "Na+", "1234" into "1234+".
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2443 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
2444 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2445 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2446 STRCPY(p, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2447 STRCAT(p, "+");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2448 compflags = p;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2451 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
2452 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2453 // We don't use the count, but do check that it's a number and
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2454 // not COMPOUNDRULE mistyped.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2455 if (atoi((char *)items[1]) == 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2456 smsg(_("Wrong COMPOUNDRULES value in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2457 fname, lnum, items[1]);
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 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
2460 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2461 // Don't use the first rule if it is a number.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2462 if (compflags != NULL || *skipdigits(items[1]) != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2463 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2464 // Concatenate this string to previously defined ones,
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2465 // using a slash to separate them.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2466 l = (int)STRLEN(items[1]) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2467 if (compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2468 l += (int)STRLEN(compflags) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2469 p = getroom(spin, l, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2470 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2471 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2472 if (compflags != NULL)
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 STRCPY(p, compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2475 STRCAT(p, "/");
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 STRCAT(p, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2478 compflags = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2479 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2480 }
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 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
2483 && compmax == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2484 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2485 compmax = atoi((char *)items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2486 if (compmax == 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2487 smsg(_("Wrong COMPOUNDWORDMAX value in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2488 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2489 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2490 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
2491 && compminlen == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2492 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2493 compminlen = atoi((char *)items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2494 if (compminlen == 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2495 smsg(_("Wrong COMPOUNDMIN value in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2496 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2497 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2498 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
2499 && compsylmax == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2500 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2501 compsylmax = atoi((char *)items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2502 if (compsylmax == 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2503 smsg(_("Wrong COMPOUNDSYLMAX value in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2504 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2505 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2506 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
2507 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2508 compoptions |= COMP_CHECKDUP;
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 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
2511 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2512 compoptions |= COMP_CHECKREP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2513 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2514 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
2515 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2516 compoptions |= COMP_CHECKCASE;
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, "CHECKCOMPOUNDTRIPLE", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2519 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2520 compoptions |= COMP_CHECKTRIPLE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2521 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2522 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
2523 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2524 if (atoi((char *)items[1]) == 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2525 smsg(_("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2526 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2527 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2528 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
2529 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2530 garray_T *gap = &spin->si_comppat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2531 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2532
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2533 // Only add the couple if it isn't already there.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2534 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
2535 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
2536 && 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
2537 items[2]) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2538 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2539 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
2540 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2541 ((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
2542 = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2543 ((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
2544 = getroom_save(spin, items[2]);
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2547 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
2548 && syllable == NULL)
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 syllable = getroom_save(spin, items[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 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
2553 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2554 spin->si_nobreak = TRUE;
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 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
2557 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2558 spin->si_nosplitsugs = TRUE;
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 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
2561 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2562 spin->si_nocompoundsugs = TRUE;
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, "NOSUGFILE", 1))
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 spin->si_nosugfile = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2567 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2568 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
2569 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2570 aff->af_pfxpostpone = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2571 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2572 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
2573 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2574 aff->af_ignoreextra = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2575 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2576 else if ((STRCMP(items[0], "PFX") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2577 || STRCMP(items[0], "SFX") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2578 && aff_todo == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2579 && itemcnt >= 4)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2580 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2581 int lasti = 4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2582 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2584 if (*items[0] == 'P')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2585 tp = &aff->af_pref;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2586 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2587 tp = &aff->af_suff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2588
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2589 // Myspell allows the same affix name to be used multiple
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2590 // times. The affix files that do this have an undocumented
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2591 // "S" flag on all but the last block, thus we check for that
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2592 // and store it in ah_follows.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2593 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
2594 hi = hash_find(tp, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2595 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2596 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2597 cur_aff = HI2AH(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2598 if (cur_aff->ah_combine != (*items[2] == 'Y'))
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2599 smsg(_("Different combining flag in continued affix block in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2600 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2601 if (!cur_aff->ah_follows)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2602 smsg(_("Duplicate affix in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2603 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2604 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2605 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2606 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2607 // New affix letter.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2608 cur_aff = (affheader_T *)getroom(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2609 sizeof(affheader_T), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2610 if (cur_aff == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2611 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2612 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
2613 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2614 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
2615 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2616 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
2617 || cur_aff->ah_flag == aff->af_rare
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2618 || cur_aff->ah_flag == aff->af_keepcase
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2619 || cur_aff->ah_flag == aff->af_needaffix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2620 || cur_aff->ah_flag == aff->af_circumfix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2621 || cur_aff->ah_flag == aff->af_nosuggest
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2622 || cur_aff->ah_flag == aff->af_needcomp
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2623 || cur_aff->ah_flag == aff->af_comproot)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2624 smsg(_("Affix also used for BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2625 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2626 STRCPY(cur_aff->ah_key, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2627 hash_add(tp, cur_aff->ah_key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2628
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2629 cur_aff->ah_combine = (*items[2] == 'Y');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2630 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2631
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2632 // Check for the "S" flag, which apparently means that another
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2633 // block with the same affix name is following.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2634 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
2635 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2636 ++lasti;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2637 cur_aff->ah_follows = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2638 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2639 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2640 cur_aff->ah_follows = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2641
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2642 // Myspell allows extra text after the item, but that might
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2643 // mean mistakes go unnoticed. Require a comment-starter.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2644 if (itemcnt > lasti && *items[lasti] != '#')
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2645 smsg(_(e_afftrailing), fname, lnum, items[lasti]);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2646
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2647 if (STRCMP(items[2], "Y") != 0 && STRCMP(items[2], "N") != 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2648 smsg(_("Expected Y or N in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2649 fname, lnum, items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2650
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2651 if (*items[0] == 'P' && aff->af_pfxpostpone)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2652 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2653 if (cur_aff->ah_newID == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2654 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2655 // Use a new number in the .spl file later, to be able
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2656 // to handle multiple .aff files.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2657 check_renumber(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2658 cur_aff->ah_newID = ++spin->si_newprefID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2659
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2660 // We only really use ah_newID if the prefix is
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2661 // postponed. We know that only after handling all
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2662 // the items.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2663 did_postpone_prefix = FALSE;
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 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2666 // Did use the ID in a previous block.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2667 did_postpone_prefix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2668 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2669
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2670 aff_todo = atoi((char *)items[3]);
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 else if ((STRCMP(items[0], "PFX") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2673 || STRCMP(items[0], "SFX") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2674 && aff_todo > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2675 && 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
2676 && itemcnt >= 5)
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 affentry_T *aff_entry;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2679 int upper = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2680 int lasti = 5;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2681
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2682 // Myspell allows extra text after the item, but that might
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2683 // mean mistakes go unnoticed. Require a comment-starter,
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2684 // unless IGNOREEXTRA is used. Hunspell uses a "-" item.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2685 if (itemcnt > lasti
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2686 && !aff->af_ignoreextra
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2687 && *items[lasti] != '#'
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2688 && (STRCMP(items[lasti], "-") != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2689 || itemcnt != lasti + 1))
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2690 smsg(_(e_afftrailing), fname, lnum, items[lasti]);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2691
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2692 // New item for an affix letter.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2693 --aff_todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2694 aff_entry = (affentry_T *)getroom(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2695 sizeof(affentry_T), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2696 if (aff_entry == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2697 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2698
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2699 if (STRCMP(items[2], "0") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2700 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
2701 if (STRCMP(items[3], "0") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2702 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2703 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
2704
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2705 // Recognize flags on the affix: abcd/XYZ
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2706 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
2707 if (aff_entry->ae_flags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2708 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2709 *aff_entry->ae_flags++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2710 aff_process_flags(aff, aff_entry);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2711 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2712 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2713
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2714 // Don't use an affix entry with non-ASCII characters when
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2715 // "spin->si_ascii" is TRUE.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2716 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
2717 || has_non_ascii(aff_entry->ae_add)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2718 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2719 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
2720 cur_aff->ah_first = aff_entry;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2721
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2722 if (STRCMP(items[4], ".") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2723 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2724 char_u buf[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2725
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2726 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
2727 if (*items[0] == 'P')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2728 sprintf((char *)buf, "^%s", items[4]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2729 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2730 sprintf((char *)buf, "%s$", items[4]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2731 aff_entry->ae_prog = vim_regcomp(buf,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2732 RE_MAGIC + RE_STRING + RE_STRICT);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2733 if (aff_entry->ae_prog == NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2734 smsg(_("Broken condition in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2735 fname, lnum, items[4]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2736 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2737
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2738 // For postponed prefixes we need an entry in si_prefcond
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2739 // for the condition. Use an existing one if possible.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2740 // Can't be done for an affix with flags, ignoring
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2741 // COMPOUNDFORBIDFLAG and COMPOUNDPERMITFLAG.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2742 if (*items[0] == 'P' && aff->af_pfxpostpone
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2743 && aff_entry->ae_flags == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2744 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2745 // When the chop string is one lower-case letter and
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2746 // the add string ends in the upper-case letter we set
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2747 // the "upper" flag, clear "ae_chop" and remove the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2748 // letters from "ae_add". The condition must either
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2749 // be empty or start with the same letter.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2750 if (aff_entry->ae_chop != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2751 && aff_entry->ae_add != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2752 && aff_entry->ae_chop[(*mb_ptr2len)(
15605
62b3805506b3 patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
2753 aff_entry->ae_chop)] == NUL)
9583
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 int c, c_up;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2756
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2757 c = PTR2CHAR(aff_entry->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2758 c_up = SPELL_TOUPPER(c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2759 if (c_up != c
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2760 && (aff_entry->ae_cond == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2761 || PTR2CHAR(aff_entry->ae_cond) == c))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2762 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2763 p = aff_entry->ae_add
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2764 + 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
2765 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
2766 if (PTR2CHAR(p) == c_up)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2767 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2768 upper = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2769 aff_entry->ae_chop = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2770 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2771
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2772 // The condition is matched with the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2773 // actual word, thus must check for the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2774 // upper-case letter.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2775 if (aff_entry->ae_cond != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2776 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2777 char_u buf[MAXLINELEN];
15605
62b3805506b3 patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
2778
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2779 if (has_mbyte)
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 onecap_copy(items[4], buf, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2782 aff_entry->ae_cond = getroom_save(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2783 spin, buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2784 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2785 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2786 *aff_entry->ae_cond = c_up;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2787 if (aff_entry->ae_cond != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2788 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2789 sprintf((char *)buf, "^%s",
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2790 aff_entry->ae_cond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2791 vim_regfree(aff_entry->ae_prog);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2792 aff_entry->ae_prog = vim_regcomp(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2793 buf, RE_MAGIC + RE_STRING);
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 }
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2799
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2800 if (aff_entry->ae_chop == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2801 && aff_entry->ae_flags == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2802 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2803 int idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2804 char_u **pp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2805 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2806
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2807 // Find a previously used condition.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2808 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
2809 --idx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2810 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2811 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
2812 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
2813 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2814 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2815 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
2816 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2817 // Not found, add a new condition.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2818 idx = spin->si_prefcond.ga_len++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2819 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
2820 + idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2821 if (aff_entry->ae_cond == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2822 *pp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2823 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2824 *pp = getroom_save(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2825 aff_entry->ae_cond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2826 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2827
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2828 // Add the prefix to the prefix tree.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2829 if (aff_entry->ae_add == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2830 p = (char_u *)"";
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2831 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2832 p = aff_entry->ae_add;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2833
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2834 // PFX_FLAGS is a negative number, so that
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2835 // tree_add_word() knows this is the prefix tree.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2836 n = PFX_FLAGS;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2837 if (!cur_aff->ah_combine)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2838 n |= WFP_NC;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2839 if (upper)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2840 n |= WFP_UP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2841 if (aff_entry->ae_comppermit)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2842 n |= WFP_COMPPERMIT;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2843 if (aff_entry->ae_compforbid)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2844 n |= WFP_COMPFORBID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2845 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
2846 idx, cur_aff->ah_newID);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2847 did_postpone_prefix = TRUE;
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2850 // Didn't actually use ah_newID, backup si_newprefID.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2851 if (aff_todo == 0 && !did_postpone_prefix)
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 --spin->si_newprefID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2854 cur_aff->ah_newID = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2855 }
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 }
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 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
2860 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2861 fol = vim_strsave(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2862 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2863 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
2864 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2865 low = vim_strsave(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2866 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2867 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
2868 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2869 upp = vim_strsave(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2870 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2871 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
2872 || is_aff_rule(items, itemcnt, "REPSAL", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2873 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2874 // Ignore REP/REPSAL count
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2875 if (!isdigit(*items[1]))
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2876 smsg(_("Expected REP(SAL) count in %s line %d"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2877 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2878 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2879 else if ((STRCMP(items[0], "REP") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2880 || STRCMP(items[0], "REPSAL") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2881 && itemcnt >= 3)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2882 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2883 // REP/REPSAL item
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2884 // Myspell ignores extra arguments, we require it starts with
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2885 // # to detect mistakes.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2886 if (itemcnt > 3 && items[3][0] != '#')
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2887 smsg(_(e_afftrailing), fname, lnum, items[3]);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2888 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
2889 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2890 // Replace underscore with space (can't include a space
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2891 // directly).
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10974
diff changeset
2892 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
2893 if (*p == '_')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2894 *p = ' ';
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10974
diff changeset
2895 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
2896 if (*p == '_')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2897 *p = ' ';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2898 add_fromto(spin, items[0][3] == 'S'
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2899 ? &spin->si_repsal
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2900 : &spin->si_rep, items[1], items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2901 }
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 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
2904 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2905 // MAP item or count
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2906 if (!found_map)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2907 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2908 // First line contains the count.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2909 found_map = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2910 if (!isdigit(*items[1]))
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2911 smsg(_("Expected MAP count in %s line %d"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2912 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2913 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2914 else if (do_mapline)
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 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2917
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2918 // Check that every character appears only once.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2919 for (p = items[1]; *p != NUL; )
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 c = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2922 if ((spin->si_map.ga_len > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2923 && 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
2924 != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2925 || vim_strchr(p, c) != NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2926 smsg(_("Duplicate character in MAP in %s line %d"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2927 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2928 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2929
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2930 // We simply concatenate all the MAP strings, separated by
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2931 // slashes.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2932 ga_concat(&spin->si_map, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2933 ga_append(&spin->si_map, '/');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2934 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2935 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2936 // Accept "SAL from to" and "SAL from to #comment".
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2937 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
2938 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2939 if (do_sal)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2940 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2941 // SAL item (sounds-a-like)
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2942 // Either one of the known keys or a from-to pair.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2943 if (STRCMP(items[1], "followup") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2944 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
2945 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
2946 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
2947 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
2948 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
2949 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2950 // when "to" is "_" it means empty
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2951 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
2952 STRCMP(items[2], "_") == 0 ? (char_u *)""
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2953 : items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2954 }
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 (is_aff_rule(items, itemcnt, "SOFOFROM", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2957 && sofofrom == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2958 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2959 sofofrom = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2960 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2961 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
2962 && sofoto == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2963 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2964 sofoto = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2965 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2966 else if (STRCMP(items[0], "COMMON") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2967 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2968 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2969
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2970 for (i = 1; i < itemcnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2971 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2972 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
2973 items[i])))
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 p = vim_strsave(items[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2976 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2977 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2978 hash_add(&spin->si_commonwords, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2979 }
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 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
2983 smsg(_("Unrecognized or duplicate item in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2984 fname, lnum, items[0]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2985 }
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2988 if (fol != NULL || low != NULL || upp != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2989 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2990 if (spin->si_clear_chartab)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2991 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2992 // Clear the char type tables, don't want to use any of the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
2993 // currently used spell properties.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2994 init_spell_chartab();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2995 spin->si_clear_chartab = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2996 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2997
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2998 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2999 * 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
3000 * 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
3001 * 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
3002 * 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
3003 */
15605
62b3805506b3 patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
3004 if (!spin->si_ascii && !enc_utf8)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3005 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3006 if (fol == NULL || low == NULL || upp == NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3007 smsg(_("Missing FOL/LOW/UPP line in %s"), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3008 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3009 (void)set_spell_chartab(fol, low, upp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3010 }
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 vim_free(fol);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3013 vim_free(low);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3014 vim_free(upp);
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3017 // Use compound specifications of the .aff file for the spell info.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3018 if (compmax != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3019 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3020 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
3021 spin->si_compmax = compmax;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3022 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3023
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3024 if (compminlen != 0)
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 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
3027 spin->si_compminlen = compminlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3028 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3029
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3030 if (compsylmax != 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 if (syllable == NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3033 smsg(_("COMPOUNDSYLMAX used without SYLLABLE"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3034 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
3035 spin->si_compsylmax = compsylmax;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3036 }
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 if (compoptions != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3039 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3040 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
3041 spin->si_compoptions |= compoptions;
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 if (compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3045 process_compflags(spin, aff, compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3046
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3047 // Check that we didn't use too many renumbered flags.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3048 if (spin->si_newcompID < spin->si_newprefID)
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_newcompID == 127 || spin->si_newcompID == 255)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
3051 msg(_("Too many postponed prefixes"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3052 else if (spin->si_newprefID == 0 || spin->si_newprefID == 127)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
3053 msg(_("Too many compound flags"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3054 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
3055 msg(_("Too many postponed prefixes and/or compound flags"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3056 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3057
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3058 if (syllable != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3059 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3060 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
3061 spin->si_syllable = syllable;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3062 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3063
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3064 if (sofofrom != NULL || sofoto != NULL)
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 if (sofofrom == NULL || sofoto == NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3067 smsg(_("Missing SOFO%s line in %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3068 sofofrom == NULL ? "FROM" : "TO", fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3069 else if (spin->si_sal.ga_len > 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3070 smsg(_("Both SAL and SOFO lines in %s"), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3071 else
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 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
3074 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
3075 spin->si_sofofr = sofofrom;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3076 spin->si_sofoto = sofoto;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3077 }
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 (midword != NULL)
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 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
3083 spin->si_midword = midword;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3084 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3085
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3086 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3087 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3088 return aff;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3091 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3092 * 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
3093 * a comment is following after item "mincount".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3094 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3095 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3096 is_aff_rule(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3097 char_u **items,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3098 int itemcnt,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3099 char *rulename,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3100 int mincount)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3101 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3102 return (STRCMP(items[0], rulename) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3103 && (itemcnt == mincount
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3104 || (itemcnt > mincount && items[mincount][0] == '#')));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3105 }
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 * 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
3109 * 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
3110 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3111 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3112 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
3113 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3114 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3115 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3116 unsigned flag;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3117
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3118 if (entry->ae_flags != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3119 && (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
3120 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3121 for (p = entry->ae_flags; *p != NUL; )
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 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3124 flag = get_affitem(affile->af_flagtype, &p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3125 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
3126 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3127 STRMOVE(prevp, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3128 p = prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3129 if (flag == affile->af_comppermit)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3130 entry->ae_comppermit = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3131 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3132 entry->ae_compforbid = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3133 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3134 if (affile->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3135 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3136 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3137 if (*entry->ae_flags == NUL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3138 entry->ae_flags = NULL; // nothing left
9583
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3143 * 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
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 spell_info_item(char_u *s)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3147 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3148 return STRCMP(s, "NAME") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3149 || STRCMP(s, "HOME") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3150 || STRCMP(s, "VERSION") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3151 || STRCMP(s, "AUTHOR") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3152 || STRCMP(s, "EMAIL") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3153 || STRCMP(s, "COPYRIGHT") == 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3154 }
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 * 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
3158 * returns zero for failure.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3159 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3160 static unsigned
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3161 affitem2flag(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3162 int flagtype,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3163 char_u *item,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3164 char_u *fname,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3165 int lnum)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3166 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3167 unsigned res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3168 char_u *p = item;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3169
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3170 res = get_affitem(flagtype, &p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3171 if (res == 0)
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 if (flagtype == AFT_NUM)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3174 smsg(_("Flag is not a number in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3175 fname, lnum, item);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3176 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3177 smsg(_("Illegal flag in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3178 fname, lnum, item);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3179 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3180 if (*p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3181 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3182 smsg(_(e_affname), fname, lnum, item);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3183 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3184 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3185
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3186 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3187 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3188
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 * Get one affix name from "*pp" and advance the pointer.
18548
4fbfecbb968c patch 8.1.2268: spell file flag zero is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 17682
diff changeset
3191 * Returns ZERO_FLAG for "0".
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3192 * 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
3193 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3194 static unsigned
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3195 get_affitem(int flagtype, char_u **pp)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3196 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3197 int res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3198
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3199 if (flagtype == AFT_NUM)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3200 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3201 if (!VIM_ISDIGIT(**pp))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3202 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3203 ++*pp; // always advance, avoid getting stuck
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3204 return 0;
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 res = getdigits(pp);
18548
4fbfecbb968c patch 8.1.2268: spell file flag zero is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 17682
diff changeset
3207 if (res == 0)
4fbfecbb968c patch 8.1.2268: spell file flag zero is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 17682
diff changeset
3208 res = ZERO_FLAG;
9583
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3211 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3212 res = mb_ptr2char_adv(pp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3213 if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3214 && res >= 'A' && res <= 'Z'))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3215 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3216 if (**pp == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3217 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3218 res = mb_ptr2char_adv(pp) + (res << 16);
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3221 return res;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3224 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3225 * 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
3226 * spin->si_compflags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3227 * 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
3228 * they fit in one byte.
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 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3231 process_compflags(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3232 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3233 afffile_T *aff,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3234 char_u *compflags)
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 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3237 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3238 unsigned flag;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3239 compitem_T *ci;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3240 int id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3241 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3242 char_u *tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3243 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3244 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3245
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3246 // Make room for the old and the new compflags, concatenated with a / in
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3247 // between. Processing it makes it shorter, but we don't know by how
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3248 // much, thus allocate the maximum.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3249 len = (int)STRLEN(compflags) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3250 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3251 len += (int)STRLEN(spin->si_compflags) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3252 p = getroom(spin, len, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3253 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3254 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3255 if (spin->si_compflags != NULL)
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 STRCPY(p, spin->si_compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3258 STRCAT(p, "/");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3259 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3260 spin->si_compflags = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3261 tp = p + STRLEN(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3262
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3263 for (p = compflags; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3264 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3265 if (vim_strchr((char_u *)"/?*+[]", *p) != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3266 // Copy non-flag characters directly.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3267 *tp++ = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3268 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3269 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3270 // First get the flag number, also checks validity.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3271 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3272 flag = get_affitem(aff->af_flagtype, &p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3273 if (flag != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3274 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3275 // Find the flag in the hashtable. If it was used before, use
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3276 // the existing ID. Otherwise add a new entry.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3277 vim_strncpy(key, prevp, p - prevp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3278 hi = hash_find(&aff->af_comp, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3279 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3280 id = HI2CI(hi)->ci_newID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3281 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3282 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3283 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
3284 if (ci == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3285 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3286 STRCPY(ci->ci_key, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3287 ci->ci_flag = flag;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3288 // Avoid using a flag ID that has a special meaning in a
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3289 // regexp (also inside []).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3290 do
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3291 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3292 check_renumber(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3293 id = spin->si_newcompID--;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3294 } while (vim_strchr((char_u *)"/?*+[]\\-^", id) != NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3295 ci->ci_newID = id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3296 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
3297 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3298 *tp++ = id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3299 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3300 if (aff->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3301 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3302 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3303 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3304
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3305 *tp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3306 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3307
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3308 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3309 * 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
3310 * 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
3311 * 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
3312 * 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
3313 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3314 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3315 check_renumber(spellinfo_T *spin)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3316 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3317 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
3318 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3319 spin->si_newprefID = 127;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3320 spin->si_newcompID = 255;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3321 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3322 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3323
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 * 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
3326 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3327 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3328 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
3329 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3330 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3331 unsigned n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3332
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3333 switch (flagtype)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3334 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3335 case AFT_CHAR:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3336 return vim_strchr(afflist, flag) != NULL;
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 case AFT_CAPLONG:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3339 case AFT_LONG:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3340 for (p = afflist; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3341 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3342 n = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3343 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
3344 && *p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3345 n = mb_ptr2char_adv(&p) + (n << 16);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3346 if (n == flag)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3347 return TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3348 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3349 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3350
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3351 case AFT_NUM:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3352 for (p = afflist; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3353 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3354 n = getdigits(&p);
18548
4fbfecbb968c patch 8.1.2268: spell file flag zero is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 17682
diff changeset
3355 if (n == 0)
4fbfecbb968c patch 8.1.2268: spell file flag zero is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 17682
diff changeset
3356 n = ZERO_FLAG;
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3357 if (n == flag)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3358 return TRUE;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3359 if (*p != NUL) // skip over comma
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3360 ++p;
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 break;
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 return FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3365 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3366
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3367 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3368 * 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
3369 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3370 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3371 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
3372 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3373 if (spinval != 0 && spinval != affval)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3374 smsg(_("%s value differs from what is used in another .aff file"), name);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3375 }
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 * 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
3379 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3380 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3381 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
3382 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3383 if (spinval != NULL && STRCMP(spinval, affval) != 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3384 smsg(_("%s value differs from what is used in another .aff file"), name);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3385 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3386
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 * 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
3389 * NULL as equal.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3390 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3391 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3392 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
3393 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3394 if (s1 == NULL || s2 == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3395 return s1 == s2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3396 return STRCMP(s1, s2) == 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3397 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3398
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3399 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3400 * 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
3401 * They are stored case-folded.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3402 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3403 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3404 add_fromto(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3405 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3406 garray_T *gap,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3407 char_u *from,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3408 char_u *to)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3409 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3410 fromto_T *ftp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3411 char_u word[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3412
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3413 if (ga_grow(gap, 1) == OK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3414 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3415 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
3416 (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
3417 ftp->ft_from = getroom_save(spin, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3418 (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
3419 ftp->ft_to = getroom_save(spin, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3420 ++gap->ga_len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3421 }
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
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 * 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
3426 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3427 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3428 sal_to_bool(char_u *s)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3429 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3430 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
3431 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3432
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 * 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
3435 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3436 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3437 spell_free_aff(afffile_T *aff)
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 hashtab_T *ht;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3440 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3441 int todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3442 affheader_T *ah;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3443 affentry_T *ae;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3444
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3445 vim_free(aff->af_enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3446
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3447 // All this trouble to free the "ae_prog" items...
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3448 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
3449 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3450 todo = (int)ht->ht_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3451 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
3452 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3453 if (!HASHITEM_EMPTY(hi))
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 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3456 ah = HI2AH(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3457 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
3458 vim_regfree(ae->ae_prog);
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 if (ht == &aff->af_suff)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3462 break;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3465 hash_clear(&aff->af_pref);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3466 hash_clear(&aff->af_suff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3467 hash_clear(&aff->af_comp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3468 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3469
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 * Read dictionary file "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3472 * Returns OK or FAIL;
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3475 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
3476 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3477 hashtab_T ht;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3478 char_u line[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3479 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3480 char_u *afflist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3481 char_u store_afflist[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3482 int pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3483 int need_affix;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3484 char_u *dw;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3485 char_u *pc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3486 char_u *w;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3487 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3488 hash_T hash;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3489 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3490 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3491 int lnum = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3492 int non_ascii = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3493 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3494 char_u message[MAXLINELEN + MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3495 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3496 int duplicate = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3497
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3498 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3499 * Open the file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3500 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3501 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3502 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3503 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3504 semsg(_(e_notopen), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3505 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3506 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3507
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3508 // The hashtable is only used to detect duplicated words.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3509 hash_init(&ht);
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 vim_snprintf((char *)IObuff, IOSIZE,
14121
97814084264b patch 8.1.0078: "..." used inconsistently in messages
Christian Brabandt <cb@256bit.org>
parents: 13610
diff changeset
3512 _("Reading dictionary file %s..."), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3513 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3514
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3515 // start with a message for the first line
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3516 spin->si_msg_count = 999999;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3517
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3518 // Read and ignore the first line: word count.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3519 (void)vim_fgets(line, MAXLINELEN, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3520 if (!vim_isdigit(*skipwhite(line)))
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3521 semsg(_("E760: No word count in %s"), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3522
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3523 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3524 * 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
3525 * 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
3526 * the hashtable.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3527 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3528 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
3529 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3530 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3531 ++lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3532 if (line[0] == '#' || line[0] == '/')
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3533 continue; // comment line
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3534
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3535 // Remove CR, LF and white space from the end. White space halfway
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3536 // the word is kept to allow e.g., "et al.".
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3537 l = (int)STRLEN(line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3538 while (l > 0 && line[l - 1] <= ' ')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3539 --l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3540 if (l == 0)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3541 continue; // empty line
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3542 line[l] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3543
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3544 // Convert from "SET" to 'encoding' when needed.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3545 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
3546 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3547 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
3548 if (pc == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3549 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3550 smsg(_("Conversion failure for word in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3551 fname, lnum, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3552 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3553 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3554 w = pc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3555 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3556 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3557 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3558 pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3559 w = line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3560 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3561
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3562 // Truncate the word at the "/", set "afflist" to what follows.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3563 // Replace "\/" by "/" and "\\" by "\".
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3564 afflist = NULL;
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10974
diff changeset
3565 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
3566 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3567 if (*p == '\\' && (p[1] == '\\' || p[1] == '/'))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3568 STRMOVE(p, p + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3569 else if (*p == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3570 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3571 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3572 afflist = p + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3573 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3574 }
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3577 // Skip non-ASCII words when "spin->si_ascii" is TRUE.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3578 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
3579 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3580 ++non_ascii;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3581 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3582 continue;
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3585 // This takes time, print a message every 10000 words.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3586 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
3587 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3588 spin->si_msg_count = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3589 vim_snprintf((char *)message, sizeof(message),
13610
e76499e85744 patch 8.0.1677: no compiler warning for wrong format in vim_snprintf()
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
3590 _("line %6d, word %6ld - %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3591 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
3592 msg_start();
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
3593 msg_outtrans_long_attr(message, 0);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3594 msg_clr_eos();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3595 msg_didout = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3596 msg_col = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3597 out_flush();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3598 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3599
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3600 // Store the word in the hashtable to be able to find duplicates.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3601 dw = (char_u *)getroom_save(spin, w);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3602 if (dw == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3603 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3604 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3605 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3606 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3607 }
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 hash = hash_hash(dw);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3610 hi = hash_lookup(&ht, dw, hash);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3611 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3612 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3613 if (p_verbose > 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3614 smsg(_("Duplicate word in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3615 fname, lnum, dw);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3616 else if (duplicate == 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3617 smsg(_("First duplicate word in %s line %d: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3618 fname, lnum, dw);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3619 ++duplicate;
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3622 hash_add_item(&ht, hi, dw, hash);
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 flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3625 store_afflist[0] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3626 pfxlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3627 need_affix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3628 if (afflist != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3629 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3630 // Extract flags from the affix list.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3631 flags |= get_affix_flags(affile, afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3632
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3633 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
3634 affile->af_flagtype, afflist, affile->af_needaffix))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3635 need_affix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3636
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3637 if (affile->af_pfxpostpone)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3638 // Need to store the list of prefix IDs with the word.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3639 pfxlen = get_pfxlist(affile, afflist, store_afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3640
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3641 if (spin->si_compflags != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3642 // Need to store the list of compound flags with the word.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3643 // Concatenate them to the list of prefix IDs.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3644 get_compflags(affile, afflist, store_afflist + pfxlen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3645 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3646
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3647 // Add the word to the word tree(s).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3648 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
3649 store_afflist, need_affix) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3650 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3651
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3652 if (afflist != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3653 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3654 // Find all matching suffixes and add the resulting words.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3655 // Additionally do matching prefixes that combine.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3656 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
3657 &affile->af_suff, &affile->af_pref,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3658 CONDIT_SUF, flags, store_afflist, pfxlen) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3659 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3660
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3661 // Find all matching prefixes and add the resulting words.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3662 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
3663 &affile->af_pref, NULL,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3664 CONDIT_SUF, flags, store_afflist, pfxlen) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3665 retval = FAIL;
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
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 }
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 if (duplicate > 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3672 smsg(_("%d duplicate word(s) in %s"), duplicate, fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3673 if (spin->si_ascii && non_ascii > 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
3674 smsg(_("Ignored %d word(s) with non-ASCII characters in %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3675 non_ascii, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3676 hash_clear(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3677
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3678 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3679 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3680 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3681
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3682 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3683 * 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
3684 * Return WF_ flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3685 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3686 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3687 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
3688 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3689 int flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3690
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3691 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
3692 affile->af_flagtype, afflist, affile->af_keepcase))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3693 flags |= WF_KEEPCAP | WF_FIXCAP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3694 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
3695 affile->af_flagtype, afflist, affile->af_rare))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3696 flags |= WF_RARE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3697 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
3698 affile->af_flagtype, afflist, affile->af_bad))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3699 flags |= WF_BANNED;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3700 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
3701 affile->af_flagtype, afflist, affile->af_needcomp))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3702 flags |= WF_NEEDCOMP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3703 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
3704 affile->af_flagtype, afflist, affile->af_comproot))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3705 flags |= WF_COMPROOT;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3706 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
3707 affile->af_flagtype, afflist, affile->af_nosuggest))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3708 flags |= WF_NOSUGGEST;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3709 return flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3710 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3711
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3712 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3713 * 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
3714 * Used for PFXPOSTPONE.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3715 * 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
3716 * and return the number of affixes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3717 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3718 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3719 get_pfxlist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3720 afffile_T *affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3721 char_u *afflist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3722 char_u *store_afflist)
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 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3725 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3726 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3727 int id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3728 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3729 hashitem_T *hi;
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 for (p = afflist; *p != NUL; )
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 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3734 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
3735 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3736 // A flag is a postponed prefix flag if it appears in "af_pref"
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3737 // and its ID is not zero.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3738 vim_strncpy(key, prevp, p - prevp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3739 hi = hash_find(&affile->af_pref, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3740 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3741 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3742 id = HI2AH(hi)->ah_newID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3743 if (id != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3744 store_afflist[cnt++] = id;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3747 if (affile->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3748 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3749 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3750
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3751 store_afflist[cnt] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3752 return cnt;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3755 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3756 * 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
3757 * for compound words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3758 * Puts the flags in "store_afflist[]".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3759 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3760 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3761 get_compflags(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3762 afffile_T *affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3763 char_u *afflist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3764 char_u *store_afflist)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3765 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3766 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3767 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3768 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3769 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3770 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3771
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3772 for (p = afflist; *p != NUL; )
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 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3775 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
3776 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3777 // A flag is a compound flag if it appears in "af_comp".
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3778 vim_strncpy(key, prevp, p - prevp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3779 hi = hash_find(&affile->af_comp, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3780 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3781 store_afflist[cnt++] = HI2CI(hi)->ci_newID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3782 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3783 if (affile->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3784 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3785 }
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 store_afflist[cnt] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3788 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3789
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3790 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3791 * 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
3792 * "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
3793 * prefixes or suffixes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3794 * "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
3795 * the resulting words for combining affixes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3796 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3797 * Returns FAIL when out of memory.
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3800 store_aff_word(
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3801 spellinfo_T *spin, // spell info
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3802 char_u *word, // basic word start
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3803 char_u *afflist, // list of names of supported affixes
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3804 afffile_T *affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3805 hashtab_T *ht,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3806 hashtab_T *xht,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3807 int condit, // CONDIT_SUF et al.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3808 int flags, // flags for the word
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3809 char_u *pfxlist, // list of prefix IDs
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3810 int pfxlen) // nr of flags in "pfxlist" for prefixes, rest
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3811 // is compound flags
9583
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 int todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3814 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3815 affheader_T *ah;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3816 affentry_T *ae;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3817 char_u newword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3818 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3819 int i, j;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3820 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3821 int use_flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3822 char_u *use_pfxlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3823 int use_pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3824 int need_affix;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3825 char_u store_afflist[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3826 char_u pfx_pfxlist[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3827 size_t wordlen = STRLEN(word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3828 int use_condit;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3829
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3830 todo = (int)ht->ht_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3831 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
3832 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3833 if (!HASHITEM_EMPTY(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 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3836 ah = HI2AH(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3837
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3838 // Check that the affix combines, if required, and that the word
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3839 // supports this affix.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3840 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
3841 && flag_in_afflist(affile->af_flagtype, afflist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3842 ah->ah_flag))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3843 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3844 // Loop over all affix entries with this name.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3845 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
3846 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3847 // Check the condition. It's not logical to match case
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3848 // here, but it is required for compatibility with
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3849 // Myspell.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3850 // Another requirement from Myspell is that the chop
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3851 // string is shorter than the word itself.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3852 // For prefixes, when "PFXPOSTPONE" was used, only do
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3853 // prefixes with a chop string and/or flags.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3854 // When a previously added affix had CIRCUMFIX this one
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3855 // must have it too, if it had not then this one must not
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3856 // have one either.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3857 if ((xht != NULL || !affile->af_pfxpostpone
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3858 || ae->ae_chop != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3859 || ae->ae_flags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3860 && (ae->ae_chop == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3861 || STRLEN(ae->ae_chop) < wordlen)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3862 && (ae->ae_prog == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3863 || vim_regexec_prog(&ae->ae_prog, FALSE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3864 word, (colnr_T)0))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3865 && (((condit & CONDIT_CFIX) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3866 == ((condit & CONDIT_AFF) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3867 || ae->ae_flags == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3868 || !flag_in_afflist(affile->af_flagtype,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3869 ae->ae_flags, affile->af_circumfix))))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3870 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3871 // Match. Remove the chop and add the affix.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3872 if (xht == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3873 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3874 // prefix: chop/add at the start of the word
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3875 if (ae->ae_add == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3876 *newword = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3877 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3878 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
3879 p = word;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3880 if (ae->ae_chop != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3881 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3882 // Skip chop string.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3883 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3884 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3885 i = mb_charlen(ae->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3886 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
3887 MB_PTR_ADV(p);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3888 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3889 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3890 p += STRLEN(ae->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3891 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3892 STRCAT(newword, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3893 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3894 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3895 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3896 // suffix: chop/add at the end of the word
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3897 vim_strncpy(newword, word, MAXWLEN - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3898 if (ae->ae_chop != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3899 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3900 // Remove chop string.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3901 p = newword + STRLEN(newword);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3902 i = (int)MB_CHARLEN(ae->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3903 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
3904 MB_PTR_BACK(newword, p);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3905 *p = NUL;
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 if (ae->ae_add != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3908 STRCAT(newword, ae->ae_add);
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3911 use_flags = flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3912 use_pfxlist = pfxlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3913 use_pfxlen = pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3914 need_affix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3915 use_condit = condit | CONDIT_COMB | CONDIT_AFF;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3916 if (ae->ae_flags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3917 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3918 // Extract flags from the affix list.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3919 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
3920
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3921 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
3922 affile->af_flagtype, ae->ae_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3923 affile->af_needaffix))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3924 need_affix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3925
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3926 // When there is a CIRCUMFIX flag the other affix
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3927 // must also have it and we don't add the word
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3928 // with one affix.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3929 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
3930 affile->af_flagtype, ae->ae_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3931 affile->af_circumfix))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3932 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3933 use_condit |= CONDIT_CFIX;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3934 if ((condit & CONDIT_CFIX) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3935 need_affix = TRUE;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3938 if (affile->af_pfxpostpone
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3939 || spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3940 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3941 if (affile->af_pfxpostpone)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3942 // Get prefix IDS from the affix list.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3943 use_pfxlen = get_pfxlist(affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3944 ae->ae_flags, store_afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3945 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3946 use_pfxlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3947 use_pfxlist = store_afflist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3948
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3949 // Combine the prefix IDs. Avoid adding the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3950 // same ID twice.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3951 for (i = 0; i < pfxlen; ++i)
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 for (j = 0; j < use_pfxlen; ++j)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3954 if (pfxlist[i] == use_pfxlist[j])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3955 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3956 if (j == use_pfxlen)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3957 use_pfxlist[use_pfxlen++] = pfxlist[i];
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3960 if (spin->si_compflags != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3961 // Get compound IDS from the affix list.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3962 get_compflags(affile, ae->ae_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3963 use_pfxlist + use_pfxlen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3964
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3965 // Combine the list of compound flags.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3966 // Concatenate them to the prefix IDs list.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3967 // Avoid adding the same ID twice.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3968 for (i = pfxlen; pfxlist[i] != NUL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3969 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3970 for (j = use_pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3971 use_pfxlist[j] != NUL; ++j)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3972 if (pfxlist[i] == use_pfxlist[j])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3973 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3974 if (use_pfxlist[j] == NUL)
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_pfxlist[j++] = pfxlist[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3977 use_pfxlist[j] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3978 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3979 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3980 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3981 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3982
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3983 // Obey a "COMPOUNDFORBIDFLAG" of the affix: don't
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3984 // use the compound flags.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3985 if (use_pfxlist != NULL && ae->ae_compforbid)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3986 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3987 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
3988 use_pfxlist = pfx_pfxlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3989 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3990
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3991 // When there are postponed prefixes...
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3992 if (spin->si_prefroot != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3993 && spin->si_prefroot->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3994 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3995 // ... add a flag to indicate an affix was used.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3996 use_flags |= WF_HAS_AFF;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3997
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3998 // ... don't use a prefix list if combining
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
3999 // affixes is not allowed. But do use the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4000 // compound flags after them.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4001 if (!ah->ah_combine && use_pfxlist != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4002 use_pfxlist += use_pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4003 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4004
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4005 // When compounding is supported and there is no
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4006 // "COMPOUNDPERMITFLAG" then forbid compounding on the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4007 // side where the affix is applied.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4008 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
4009 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4010 if (xht != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4011 use_flags |= WF_NOCOMPAFT;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4012 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4013 use_flags |= WF_NOCOMPBEF;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4014 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4015
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4016 // Store the modified word.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4017 if (store_word(spin, newword, use_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4018 spin->si_region, use_pfxlist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4019 need_affix) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4020 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4021
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4022 // When added a prefix or a first suffix and the affix
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4023 // has flags may add a(nother) suffix. RECURSIVE!
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4024 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
4025 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
4026 affile, &affile->af_suff, xht,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4027 use_condit & (xht == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4028 ? ~0 : ~CONDIT_SUF),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4029 use_flags, use_pfxlist, pfxlen) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4030 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4031
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4032 // When added a suffix and combining is allowed also
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4033 // try adding a prefix additionally. Both for the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4034 // word flags and for the affix flags. RECURSIVE!
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4035 if (xht != NULL && ah->ah_combine)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4036 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4037 if (store_aff_word(spin, newword,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4038 afflist, affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4039 xht, NULL, use_condit,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4040 use_flags, use_pfxlist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4041 pfxlen) == FAIL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4042 || (ae->ae_flags != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4043 && store_aff_word(spin, newword,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4044 ae->ae_flags, affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4045 xht, NULL, use_condit,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4046 use_flags, use_pfxlist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4047 pfxlen) == FAIL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4048 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4049 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4050 }
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4053 }
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 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4057 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4058
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 * 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
4061 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4062 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4063 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
4064 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4065 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4066 long lnum = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4067 char_u rline[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4068 char_u *line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4069 char_u *pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4070 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4071 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4072 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4073 int did_word = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4074 int non_ascii = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4075 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4076 int regionmask;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4077
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4078 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4079 * Open the file.
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 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4082 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4083 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
4084 semsg(_(e_notopen), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4085 return 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
14121
97814084264b patch 8.1.0078: "..." used inconsistently in messages
Christian Brabandt <cb@256bit.org>
parents: 13610
diff changeset
4088 vim_snprintf((char *)IObuff, IOSIZE, _("Reading word file %s..."), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4089 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4090
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4091 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4092 * 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
4093 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4094 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
4095 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4096 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4097 ++lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4098
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4099 // Skip comment lines.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4100 if (*rline == '#')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4101 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4102
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4103 // Remove CR, LF and white space from the end.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4104 l = (int)STRLEN(rline);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4105 while (l > 0 && rline[l - 1] <= ' ')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4106 --l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4107 if (l == 0)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4108 continue; // empty or blank line
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4109 rline[l] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4110
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4111 // Convert from "/encoding={encoding}" to 'encoding' when needed.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4112 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4113 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
4114 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4115 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
4116 if (pc == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4117 {
19760
9daed26b788b patch 8.2.0436: no warnings for incorrect printf arguments
Bram Moolenaar <Bram@vim.org>
parents: 19075
diff changeset
4118 smsg(_("Conversion failure for word in %s line %ld: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4119 fname, lnum, rline);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4120 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4121 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4122 line = pc;
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4125 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4126 pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4127 line = rline;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4128 }
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 if (*line == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4131 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4132 ++line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4133 if (STRNCMP(line, "encoding=", 9) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4134 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4135 if (spin->si_conv.vc_type != CONV_NONE)
19760
9daed26b788b patch 8.2.0436: no warnings for incorrect printf arguments
Bram Moolenaar <Bram@vim.org>
parents: 19075
diff changeset
4136 smsg(_("Duplicate /encoding= line ignored in %s line %ld: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4137 fname, lnum, line - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4138 else if (did_word)
19760
9daed26b788b patch 8.2.0436: no warnings for incorrect printf arguments
Bram Moolenaar <Bram@vim.org>
parents: 19075
diff changeset
4139 smsg(_("/encoding= line after word ignored in %s line %ld: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4140 fname, lnum, line - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4141 else
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 char_u *enc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4144
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4145 // Setup for conversion to 'encoding'.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4146 line += 9;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4147 enc = enc_canonize(line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4148 if (enc != NULL && !spin->si_ascii
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4149 && convert_setup(&spin->si_conv, enc,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4150 p_enc) == FAIL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
4151 smsg(_("Conversion in %s not supported: from %s to %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4152 fname, line, p_enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4153 vim_free(enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4154 spin->si_conv.vc_fail = TRUE;
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 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4157 }
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 if (STRNCMP(line, "regions=", 8) == 0)
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 if (spin->si_region_count > 1)
19760
9daed26b788b patch 8.2.0436: no warnings for incorrect printf arguments
Bram Moolenaar <Bram@vim.org>
parents: 19075
diff changeset
4162 smsg(_("Duplicate /regions= line ignored in %s line %ld: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4163 fname, lnum, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4164 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4165 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4166 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
4167 if (STRLEN(line) > MAXREGIONS * 2)
19760
9daed26b788b patch 8.2.0436: no warnings for incorrect printf arguments
Bram Moolenaar <Bram@vim.org>
parents: 19075
diff changeset
4168 smsg(_("Too many regions in %s line %ld: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4169 fname, lnum, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4170 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4171 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4172 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
4173 STRCPY(spin->si_region_name, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4174
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4175 // Adjust the mask for a word valid in all regions.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4176 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
4177 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4178 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4179 continue;
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
19760
9daed26b788b patch 8.2.0436: no warnings for incorrect printf arguments
Bram Moolenaar <Bram@vim.org>
parents: 19075
diff changeset
4182 smsg(_("/ line ignored in %s line %ld: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4183 fname, lnum, line - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4184 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4185 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4186
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4187 flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4188 regionmask = spin->si_region;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4189
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4190 // Check for flags and region after a slash.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4191 p = vim_strchr(line, '/');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4192 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4193 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4194 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4195 while (*p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4196 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4197 if (*p == '=') // keep-case word
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4198 flags |= WF_KEEPCAP | WF_FIXCAP;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4199 else if (*p == '!') // Bad, bad, wicked word.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4200 flags |= WF_BANNED;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4201 else if (*p == '?') // Rare word.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4202 flags |= WF_RARE;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4203 else if (VIM_ISDIGIT(*p)) // region number(s)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4204 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4205 if ((flags & WF_REGION) == 0) // first one
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4206 regionmask = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4207 flags |= WF_REGION;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4208
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4209 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
4210 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
4211 {
19760
9daed26b788b patch 8.2.0436: no warnings for incorrect printf arguments
Bram Moolenaar <Bram@vim.org>
parents: 19075
diff changeset
4212 smsg(_("Invalid region nr in %s line %ld: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4213 fname, lnum, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4214 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4215 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4216 regionmask |= 1 << (l - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4217 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4218 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4219 {
19760
9daed26b788b patch 8.2.0436: no warnings for incorrect printf arguments
Bram Moolenaar <Bram@vim.org>
parents: 19075
diff changeset
4220 smsg(_("Unrecognized flags in %s line %ld: %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4221 fname, lnum, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4222 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4223 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4224 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4225 }
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4228 // Skip non-ASCII words when "spin->si_ascii" is TRUE.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4229 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
4230 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4231 ++non_ascii;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4232 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4233 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4234
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4235 // Normal word: store it.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4236 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
4237 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4238 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4239 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4240 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4241 did_word = TRUE;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4244 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4245 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4246
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4247 if (spin->si_ascii && non_ascii > 0)
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 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4250 _("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
4251 spell_message(spin, IObuff);
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4254 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4255 }
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 * 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
4259 * 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
4260 * track of them).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4261 * The memory is cleared to all zeros.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4262 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4263 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4264 static void *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4265 getroom(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4266 spellinfo_T *spin,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4267 size_t len, // length needed
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4268 int align) // align for pointer
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4269 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4270 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4271 sblock_T *bl = spin->si_blocks;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4272
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4273 if (align && bl != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4274 // Round size up for alignment. On some systems structures need to be
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4275 // aligned to the size of a pointer (e.g., SPARC).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4276 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
4277 & ~(sizeof(char *) - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4278
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4279 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
4280 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4281 if (len >= SBLOCKSIZE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4282 bl = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4283 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4284 // Allocate a block of memory. It is not freed until much later.
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
4285 bl = alloc_clear(sizeof(sblock_T) + SBLOCKSIZE);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4286 if (bl == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4287 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4288 if (!spin->si_did_emsg)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4289 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
4290 emsg(_("E845: Insufficient memory, word list will be incomplete"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4291 spin->si_did_emsg = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4292 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4293 return NULL;
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 bl->sb_next = spin->si_blocks;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4296 spin->si_blocks = bl;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4297 bl->sb_used = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4298 ++spin->si_blocks_cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4299 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4300
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4301 p = bl->sb_data + bl->sb_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4302 bl->sb_used += (int)len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4303
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4304 return p;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4307 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4308 * 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
4309 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4310 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4311 static char_u *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4312 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
4313 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4314 char_u *sc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4315
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4316 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
4317 if (sc != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4318 STRCPY(sc, s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4319 return sc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4320 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4321
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4322
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 * Free the list of allocated sblock_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4325 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4326 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4327 free_blocks(sblock_T *bl)
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 sblock_T *next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4330
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4331 while (bl != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4332 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4333 next = bl->sb_next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4334 vim_free(bl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4335 bl = next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4336 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4337 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4338
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4339 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4340 * Allocate the root of a word tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4341 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4342 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4343 static wordnode_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4344 wordtree_alloc(spellinfo_T *spin)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4345 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4346 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
4347 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4348
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 * Store a word in the tree(s).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4351 * 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
4352 * 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
4353 * used to find suggestions.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4354 * 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
4355 * 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
4356 * compound flag.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4357 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4358 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4359 store_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4360 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4361 char_u *word,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4362 int flags, // extra flags, WF_BANNED
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4363 int region, // supported region(s)
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4364 char_u *pfxlist, // list of prefix IDs or NULL
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4365 int need_affix) // only store word with affix ID
9583
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 int len = (int)STRLEN(word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4368 int ct = captype(word, word + len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4369 char_u foldword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4370 int res = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4371 char_u *p;
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 (void)spell_casefold(word, len, foldword, MAXWLEN);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4374 for (p = pfxlist; res == OK; ++p)
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 if (!need_affix || (p != NULL && *p != NUL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4377 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
4378 region, p == NULL ? 0 : *p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4379 if (p == NULL || *p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4380 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4381 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4382 ++spin->si_foldwcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4383
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4384 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
4385 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4386 for (p = pfxlist; res == OK; ++p)
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 if (!need_affix || (p != NULL && *p != NUL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4389 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
4390 region, p == NULL ? 0 : *p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4391 if (p == NULL || *p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4392 break;
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 ++spin->si_keepwcount;
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 return res;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4399 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4400 * 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
4401 * 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
4402 * "rare" and "region" is the condition nr.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4403 * Returns FAIL when out of memory.
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4406 tree_add_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4407 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4408 char_u *word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4409 wordnode_T *root,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4410 int flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4411 int region,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4412 int affixID)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4413 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4414 wordnode_T *node = root;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4415 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4416 wordnode_T *copyp, **copyprev;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4417 wordnode_T **prev = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4418 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4419
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4420 // Add each byte of the word to the tree, including the NUL at the end.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4421 for (i = 0; ; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4422 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4423 // When there is more than one reference to this node we need to make
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4424 // a copy, so that we can modify it. Copy the whole list of siblings
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4425 // (we don't optimize for a partly shared list of siblings).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4426 if (node != NULL && node->wn_refs > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4427 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4428 --node->wn_refs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4429 copyprev = prev;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4430 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
4431 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4432 // Allocate a new node and copy the info.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4433 np = get_wordnode(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4434 if (np == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4435 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4436 np->wn_child = copyp->wn_child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4437 if (np->wn_child != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4438 ++np->wn_child->wn_refs; // child gets extra ref
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4439 np->wn_byte = copyp->wn_byte;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4440 if (np->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4441 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4442 np->wn_flags = copyp->wn_flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4443 np->wn_region = copyp->wn_region;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4444 np->wn_affixID = copyp->wn_affixID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4445 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4446
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4447 // Link the new node in the list, there will be one ref.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4448 np->wn_refs = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4449 if (copyprev != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4450 *copyprev = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4451 copyprev = &np->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4452
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4453 // Let "node" point to the head of the copied list.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4454 if (copyp == node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4455 node = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4456 }
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4459 // Look for the sibling that has the same character. They are sorted
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4460 // on byte value, thus stop searching when a sibling is found with a
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4461 // higher byte value. For zero bytes (end of word) the sorting is
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4462 // done on flags and then on affixID.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4463 while (node != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4464 && (node->wn_byte < word[i]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4465 || (node->wn_byte == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4466 && (flags < 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4467 ? node->wn_affixID < (unsigned)affixID
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4468 : (node->wn_flags < (unsigned)(flags & WN_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4469 || (node->wn_flags == (flags & WN_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4470 && (spin->si_sugtree
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4471 ? (node->wn_region & 0xffff) < region
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4472 : node->wn_affixID
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4473 < (unsigned)affixID)))))))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4474 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4475 prev = &node->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4476 node = *prev;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4477 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4478 if (node == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4479 || node->wn_byte != word[i]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4480 || (word[i] == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4481 && (flags < 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4482 || spin->si_sugtree
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4483 || node->wn_flags != (flags & WN_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4484 || node->wn_affixID != affixID)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4485 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4486 // Allocate a new node.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4487 np = get_wordnode(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4488 if (np == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4489 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4490 np->wn_byte = word[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4491
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4492 // If "node" is NULL this is a new child or the end of the sibling
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4493 // list: ref count is one. Otherwise use ref count of sibling and
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4494 // make ref count of sibling one (matters when inserting in front
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4495 // of the list of siblings).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4496 if (node == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4497 np->wn_refs = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4498 else
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 np->wn_refs = node->wn_refs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4501 node->wn_refs = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4502 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4503 if (prev != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4504 *prev = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4505 np->wn_sibling = node;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4506 node = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4507 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4508
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4509 if (word[i] == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4510 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4511 node->wn_flags = flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4512 node->wn_region |= region;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4513 node->wn_affixID = affixID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4514 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4515 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4516 prev = &node->wn_child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4517 node = *prev;
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 #ifdef SPELL_PRINTTREE
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
4520 smsg("Added \"%s\"", word);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4521 spell_print_tree(root->wn_sibling);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4522 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4523
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4524 // count nr of words added since last message
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4525 ++spin->si_msg_count;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4526
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4527 if (spin->si_compress_cnt > 1)
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 if (--spin->si_compress_cnt == 1)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4530 // Did enough words to lower the block count limit.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4531 spin->si_blocks_cnt += compress_inc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4532 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4533
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4534 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4535 * 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
4536 * 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
4537 * 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
4538 * 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
4539 * "compress_start" blocks.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4540 * 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
4541 * 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
4542 * 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
4543 * (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
4544 * maximum word length.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4545 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4546 #ifndef SPELL_COMPRESS_ALLWAYS
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4547 if (spin->si_compress_cnt == 1
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4548 ? spin->si_free_count < MAXWLEN
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4549 : spin->si_blocks_cnt >= compress_start)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4550 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4551 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4552 // Decrement the block counter. The effect is that we compress again
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4553 // when the freed up room has been used and another "compress_inc"
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4554 // blocks have been allocated. Unless "compress_added" words have
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4555 // been added, then the limit is put back again.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4556 spin->si_blocks_cnt -= compress_inc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4557 spin->si_compress_cnt = compress_added;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4558
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4559 if (spin->si_verbose)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4560 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4561 msg_start();
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
4562 msg_puts(_(msg_compressing));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4563 msg_clr_eos();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4564 msg_didout = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4565 msg_col = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4566 out_flush();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4567 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4568
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4569 // Compress both trees. Either they both have many nodes, which makes
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4570 // compression useful, or one of them is small, which means
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4571 // compression goes fast. But when filling the soundfold word tree
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4572 // there is no keep-case tree.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4573 wordtree_compress(spin, spin->si_foldroot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4574 if (affixID >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4575 wordtree_compress(spin, spin->si_keeproot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4576 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4577
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4578 return OK;
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4582 * 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
4583 * allocate a new one.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4584 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4585 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4586 static wordnode_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4587 get_wordnode(spellinfo_T *spin)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4588 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4589 wordnode_T *n;
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 if (spin->si_first_free == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4592 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
4593 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4594 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4595 n = spin->si_first_free;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4596 spin->si_first_free = n->wn_child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4597 vim_memset(n, 0, sizeof(wordnode_T));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4598 --spin->si_free_count;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4599 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4600 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4601 if (n != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4602 n->wn_nr = ++spin->si_wordnode_nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4603 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4604 return n;
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4608 * 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
4609 * 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
4610 * siblings.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4611 * Returns the number of nodes actually freed.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4612 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4613 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4614 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
4615 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4616 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4617 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4618
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4619 if (--node->wn_refs == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4620 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4621 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
4622 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4623 if (np->wn_child != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4624 cnt += deref_wordnode(spin, np->wn_child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4625 free_wordnode(spin, np);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4626 ++cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4627 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4628 ++cnt; // length field
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4629 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4630 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4631 }
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4634 * 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
4635 * Only the "wn_child" field becomes invalid.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4636 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4637 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4638 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
4639 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4640 n->wn_child = spin->si_first_free;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4641 spin->si_first_free = n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4642 ++spin->si_free_count;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4643 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4644
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4645 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4646 * 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
4647 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4648 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4649 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
4650 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4651 hashtab_T ht;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4652 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4653 int tot = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4654 int perc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4655
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4656 // Skip the root itself, it's not actually used. The first sibling is the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4657 // start of the tree.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4658 if (root->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4659 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4660 hash_init(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4661 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
4662
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4663 #ifndef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4664 if (spin->si_verbose || p_verbose > 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4665 #endif
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 if (tot > 1000000)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4668 perc = (tot - n) / (tot / 100);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4669 else if (tot == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4670 perc = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4671 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4672 perc = (tot - n) * 100 / tot;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4673 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4674 _("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
4675 n, tot, tot - n, perc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4676 spell_message(spin, IObuff);
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 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4679 spell_print_tree(root->wn_sibling);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4680 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4681 hash_clear(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4682 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4683 }
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4686 * 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
4687 * Returns the number of compressed nodes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4688 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4689 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4690 node_compress(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4691 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4692 wordnode_T *node,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4693 hashtab_T *ht,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4694 int *tot) // total count of nodes before compressing,
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4695 // incremented while going through the tree
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4696 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4697 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4698 wordnode_T *tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4699 wordnode_T *child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4700 hash_T hash;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4701 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4702 int len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4703 unsigned nr, n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4704 int compressed = 0;
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4707 * 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
4708 * finding an identical child to replace it.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4709 * 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
4710 * 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
4711 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4712 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
4713 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4714 ++len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4715 if ((child = np->wn_child) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4716 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4717 // Compress the child first. This fills hashkey.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4718 compressed += node_compress(spin, child, ht, tot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4719
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4720 // Try to find an identical child.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4721 hash = hash_hash(child->wn_u1.hashkey);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4722 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
4723 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4724 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4725 // There are children we encountered before with a hash value
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4726 // identical to the current child. Now check if there is one
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4727 // that is really identical.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4728 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
4729 if (node_equal(child, tp))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4730 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4731 // Found one! Now use that child in place of the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4732 // current one. This means the current child and all
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4733 // its siblings is unlinked from the tree.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4734 ++tp->wn_refs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4735 compressed += deref_wordnode(spin, child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4736 np->wn_child = tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4737 break;
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 (tp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4740 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4741 // No other child with this hash value equals the child of
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4742 // the node, add it to the linked list after the first
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4743 // item.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4744 tp = HI2WN(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4745 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
4746 tp->wn_u2.next = child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4747 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4748 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4749 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4750 // No other child has this hash value, add it to the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4751 // hashtable.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4752 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
4753 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4754 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4755 *tot += len + 1; // add one for the node that stores the length
9583
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 * 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
4759 * 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
4760 * 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
4761 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4762 node->wn_u1.hashkey[0] = len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4763 nr = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4764 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
4765 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4766 if (np->wn_byte == NUL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4767 // end node: use wn_flags, wn_region and wn_affixID
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4768 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
4769 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4770 // byte node: use the byte value and the child pointer
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4771 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
4772 nr = nr * 101 + n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4773 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4774
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4775 // Avoid NUL bytes, it terminates the hash key.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4776 n = nr & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4777 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
4778 n = (nr >> 8) & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4779 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
4780 n = (nr >> 16) & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4781 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
4782 n = (nr >> 24) & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4783 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
4784 node->wn_u1.hashkey[5] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4785
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4786 // Check for CTRL-C pressed now and then.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4787 fast_breakcheck();
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 return compressed;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4790 }
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4793 * 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
4794 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4795 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4796 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
4797 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4798 wordnode_T *p1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4799 wordnode_T *p2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4800
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4801 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
4802 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
4803 if (p1->wn_byte != p2->wn_byte
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4804 || (p1->wn_byte == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4805 ? (p1->wn_flags != p2->wn_flags
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4806 || p1->wn_region != p2->wn_region
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4807 || p1->wn_affixID != p2->wn_affixID)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4808 : (p1->wn_child != p2->wn_child)))
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 return p1 == NULL && p2 == 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
16606
7e733046db1d patch 8.1.1306: Borland support is outdated and doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
4814 static int rep_compare(const void *s1, const void *s2);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4815
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4816 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4817 * 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
4818 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4819 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4820 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
4821 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4822 fromto_T *p1 = (fromto_T *)s1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4823 fromto_T *p2 = (fromto_T *)s2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4824
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4825 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
4826 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4827
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 * Write the Vim .spl file "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4830 * Return FAIL or OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4831 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4832 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4833 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
4834 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4835 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4836 int regionmask;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4837 int round;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4838 wordnode_T *tree;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4839 int nodecount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4840 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4841 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4842 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4843 fromto_T *ftp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4844 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4845 int rr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4846 int retval = OK;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4847 size_t fwv = 1; // collect return value of fwrite() to avoid
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4848 // warnings from picky compiler
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4849
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4850 fd = mch_fopen((char *)fname, "w");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4851 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4852 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
4853 semsg(_(e_notopen), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4854 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4855 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4856
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4857 // <HEADER>: <fileID> <versionnr>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4858 // <fileID>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4859 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
4860 if (fwv != (size_t)1)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4861 // Catch first write error, don't try writing more.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4862 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4863
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4864 putc(VIMSPELLVERSION, fd); // <versionnr>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4865
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 * <SECTIONS>: <section> ... <sectionend>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4868 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4869
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4870 // SN_INFO: <infotext>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4871 if (spin->si_info != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4872 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4873 putc(SN_INFO, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4874 putc(0, fd); // <sectionflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4875
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4876 i = (int)STRLEN(spin->si_info);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4877 put_bytes(fd, (long_u)i, 4); // <sectionlen>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4878 fwv &= fwrite(spin->si_info, (size_t)i, (size_t)1, fd); // <infotext>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4879 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4880
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4881 // SN_REGION: <regionname> ...
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4882 // Write the region names only if there is more than one.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4883 if (spin->si_region_count > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4884 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4885 putc(SN_REGION, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4886 putc(SNF_REQUIRED, fd); // <sectionflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4887 l = spin->si_region_count * 2;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4888 put_bytes(fd, (long_u)l, 4); // <sectionlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4889 fwv &= fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4890 // <regionname> ...
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4891 regionmask = (1 << spin->si_region_count) - 1;
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4894 regionmask = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4895
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4896 // SN_CHARFLAGS: <charflagslen> <charflags> <folcharslen> <folchars>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4897 //
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4898 // The table with character flags and the table for case folding.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4899 // This makes sure the same characters are recognized as word characters
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4900 // when generating an when using a spell file.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4901 // Skip this for ASCII, the table may conflict with the one used for
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4902 // 'encoding'.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4903 // Also skip this for an .add.spl file, the main spell file must contain
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4904 // the table (avoids that it conflicts). File is shorter too.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4905 if (!spin->si_ascii && !spin->si_add)
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 char_u folchars[128 * 8];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4908 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4909
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4910 putc(SN_CHARFLAGS, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4911 putc(SNF_REQUIRED, fd); // <sectionflags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4912
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4913 // Form the <folchars> string first, we need to know its length.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4914 l = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4915 for (i = 128; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4916 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4917 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4918 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
4919 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4920 folchars[l++] = spelltab.st_fold[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4921 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4922 put_bytes(fd, (long_u)(1 + 128 + 2 + l), 4); // <sectionlen>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4923
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4924 fputc(128, fd); // <charflagslen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4925 for (i = 128; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4926 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4927 flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4928 if (spelltab.st_isw[i])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4929 flags |= CF_WORD;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4930 if (spelltab.st_isu[i])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4931 flags |= CF_UPPER;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4932 fputc(flags, fd); // <charflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4933 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4934
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4935 put_bytes(fd, (long_u)l, 2); // <folcharslen>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4936 fwv &= fwrite(folchars, (size_t)l, (size_t)1, fd); // <folchars>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4937 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4938
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4939 // SN_MIDWORD: <midword>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4940 if (spin->si_midword != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4941 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4942 putc(SN_MIDWORD, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4943 putc(SNF_REQUIRED, fd); // <sectionflags>
9583
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 i = (int)STRLEN(spin->si_midword);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4946 put_bytes(fd, (long_u)i, 4); // <sectionlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4947 fwv &= fwrite(spin->si_midword, (size_t)i, (size_t)1, fd);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4948 // <midword>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4949 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4950
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4951 // SN_PREFCOND: <prefcondcnt> <prefcond> ...
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4952 if (spin->si_prefcond.ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4953 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4954 putc(SN_PREFCOND, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4955 putc(SNF_REQUIRED, fd); // <sectionflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4956
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4957 l = write_spell_prefcond(NULL, &spin->si_prefcond);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4958 put_bytes(fd, (long_u)l, 4); // <sectionlen>
9583
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 write_spell_prefcond(fd, &spin->si_prefcond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4961 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4962
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4963 // SN_REP: <repcount> <rep> ...
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4964 // SN_SAL: <salflags> <salcount> <sal> ...
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4965 // SN_REPSAL: <repcount> <rep> ...
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4966
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4967 // round 1: SN_REP section
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4968 // round 2: SN_SAL section (unless SN_SOFO is used)
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4969 // round 3: SN_REPSAL section
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4970 for (round = 1; round <= 3; ++round)
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 if (round == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4973 gap = &spin->si_rep;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4974 else if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4975 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4976 // Don't write SN_SAL when using a SN_SOFO section
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4977 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
4978 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4979 gap = &spin->si_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4980 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4981 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4982 gap = &spin->si_repsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4983
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4984 // Don't write the section if there are no items.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4985 if (gap->ga_len == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4986 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4987
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4988 // Sort the REP/REPSAL items.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4989 if (round != 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4990 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
4991 sizeof(fromto_T), rep_compare);
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 i = round == 1 ? SN_REP : (round == 2 ? SN_SAL : SN_REPSAL);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4994 putc(i, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4995
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4996 // This is for making suggestions, section is not required.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4997 putc(0, fd); // <sectionflags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4998
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
4999 // Compute the length of what follows.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5000 l = 2; // count <repcount> or <salcount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5001 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
5002 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5003 ftp = &((fromto_T *)gap->ga_data)[i];
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5004 l += 1 + (int)STRLEN(ftp->ft_from); // count <*fromlen> and <*from>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5005 l += 1 + (int)STRLEN(ftp->ft_to); // count <*tolen> and <*to>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5006 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5007 if (round == 2)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5008 ++l; // count <salflags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5009 put_bytes(fd, (long_u)l, 4); // <sectionlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5010
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5011 if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5012 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5013 i = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5014 if (spin->si_followup)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5015 i |= SAL_F0LLOWUP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5016 if (spin->si_collapse)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5017 i |= SAL_COLLAPSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5018 if (spin->si_rem_accents)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5019 i |= SAL_REM_ACCENTS;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5020 putc(i, fd); // <salflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5021 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5022
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5023 put_bytes(fd, (long_u)gap->ga_len, 2); // <repcount> or <salcount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5024 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
5025 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5026 // <rep> : <repfromlen> <repfrom> <reptolen> <repto>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5027 // <sal> : <salfromlen> <salfrom> <saltolen> <salto>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5028 ftp = &((fromto_T *)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5029 for (rr = 1; rr <= 2; ++rr)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5030 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5031 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
5032 l = (int)STRLEN(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5033 putc(l, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5034 if (l > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5035 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
5036 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5037 }
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5040
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5041 // SN_SOFO: <sofofromlen> <sofofrom> <sofotolen> <sofoto>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5042 // This is for making suggestions, section is not required.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5043 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
5044 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5045 putc(SN_SOFO, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5046 putc(0, fd); // <sectionflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5047
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5048 l = (int)STRLEN(spin->si_sofofr);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5049 put_bytes(fd, (long_u)(l + STRLEN(spin->si_sofoto) + 4), 4);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5050 // <sectionlen>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5051
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5052 put_bytes(fd, (long_u)l, 2); // <sofofromlen>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5053 fwv &= fwrite(spin->si_sofofr, l, (size_t)1, fd); // <sofofrom>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5054
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5055 l = (int)STRLEN(spin->si_sofoto);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5056 put_bytes(fd, (long_u)l, 2); // <sofotolen>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5057 fwv &= fwrite(spin->si_sofoto, l, (size_t)1, fd); // <sofoto>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5058 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5059
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5060 // SN_WORDS: <word> ...
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5061 // This is for making suggestions, section is not required.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5062 if (spin->si_commonwords.ht_used > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5063 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5064 putc(SN_WORDS, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5065 putc(0, fd); // <sectionflags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5066
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5067 // round 1: count the bytes
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5068 // round 2: write the bytes
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5069 for (round = 1; round <= 2; ++round)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5070 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5071 int todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5072 int len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5073 hashitem_T *hi;
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 todo = (int)spin->si_commonwords.ht_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5076 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
5077 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5078 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5079 l = (int)STRLEN(hi->hi_key) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5080 len += l;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5081 if (round == 2) // <word>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5082 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
5083 --todo;
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 if (round == 1)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5086 put_bytes(fd, (long_u)len, 4); // <sectionlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5087 }
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5090 // SN_MAP: <mapstr>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5091 // This is for making suggestions, section is not required.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5092 if (spin->si_map.ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5093 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5094 putc(SN_MAP, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5095 putc(0, fd); // <sectionflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5096 l = spin->si_map.ga_len;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5097 put_bytes(fd, (long_u)l, 4); // <sectionlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5098 fwv &= fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5099 // <mapstr>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5100 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5101
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5102 // SN_SUGFILE: <timestamp>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5103 // This is used to notify that a .sug file may be available and at the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5104 // same time allows for checking that a .sug file that is found matches
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5105 // with this .spl file. That's because the word numbers must be exactly
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5106 // right.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5107 if (!spin->si_nosugfile
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5108 && (spin->si_sal.ga_len > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5109 || (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
5110 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5111 putc(SN_SUGFILE, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5112 putc(0, fd); // <sectionflags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5113 put_bytes(fd, (long_u)8, 4); // <sectionlen>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5114
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5115 // Set si_sugtime and write it to the file.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5116 spin->si_sugtime = time(NULL);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5117 put_time(fd, spin->si_sugtime); // <timestamp>
9583
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5120 // SN_NOSPLITSUGS: nothing
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5121 // This is used to notify that no suggestions with word splits are to be
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5122 // made.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5123 if (spin->si_nosplitsugs)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5124 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5125 putc(SN_NOSPLITSUGS, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5126 putc(0, fd); // <sectionflags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5127 put_bytes(fd, (long_u)0, 4); // <sectionlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5128 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5129
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5130 // SN_NOCOMPUNDSUGS: nothing
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5131 // This is used to notify that no suggestions with compounds are to be
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5132 // made.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5133 if (spin->si_nocompoundsugs)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5134 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5135 putc(SN_NOCOMPOUNDSUGS, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5136 putc(0, fd); // <sectionflags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5137 put_bytes(fd, (long_u)0, 4); // <sectionlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5138 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5139
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5140 // SN_COMPOUND: compound info.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5141 // We don't mark it required, when not supported all compound words will
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5142 // be bad words.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5143 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5144 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5145 putc(SN_COMPOUND, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5146 putc(0, fd); // <sectionflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5147
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5148 l = (int)STRLEN(spin->si_compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5149 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
5150 l += (int)STRLEN(((char_u **)(spin->si_comppat.ga_data))[i]) + 1;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5151 put_bytes(fd, (long_u)(l + 7), 4); // <sectionlen>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5152
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5153 putc(spin->si_compmax, fd); // <compmax>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5154 putc(spin->si_compminlen, fd); // <compminlen>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5155 putc(spin->si_compsylmax, fd); // <compsylmax>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5156 putc(0, fd); // for Vim 7.0b compatibility
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5157 putc(spin->si_compoptions, fd); // <compoptions>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5158 put_bytes(fd, (long_u)spin->si_comppat.ga_len, 2);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5159 // <comppatcount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5160 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
5161 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5162 p = ((char_u **)(spin->si_comppat.ga_data))[i];
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5163 putc((int)STRLEN(p), fd); // <comppatlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5164 fwv &= fwrite(p, (size_t)STRLEN(p), (size_t)1, fd);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5165 // <comppattext>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5166 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5167 // <compflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5168 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
5169 (size_t)1, fd);
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5172 // SN_NOBREAK: NOBREAK flag
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5173 if (spin->si_nobreak)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5174 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5175 putc(SN_NOBREAK, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5176 putc(0, fd); // <sectionflags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5177
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5178 // It's empty, the presence of the section flags the feature.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5179 put_bytes(fd, (long_u)0, 4); // <sectionlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5180 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5181
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5182 // SN_SYLLABLE: syllable info.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5183 // We don't mark it required, when not supported syllables will not be
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5184 // counted.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5185 if (spin->si_syllable != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5186 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5187 putc(SN_SYLLABLE, fd); // <sectionID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5188 putc(0, fd); // <sectionflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5189
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5190 l = (int)STRLEN(spin->si_syllable);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5191 put_bytes(fd, (long_u)l, 4); // <sectionlen>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5192 fwv &= fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5193 // <syllable>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5194 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5195
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5196 // end of <SECTIONS>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5197 putc(SN_END, fd); // <sectionend>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5198
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5199
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 * <LWORDTREE> <KWORDTREE> <PREFIXTREE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5202 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5203 spin->si_memtot = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5204 for (round = 1; round <= 3; ++round)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5205 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5206 if (round == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5207 tree = spin->si_foldroot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5208 else if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5209 tree = spin->si_keeproot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5210 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5211 tree = spin->si_prefroot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5212
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5213 // Clear the index and wnode fields in the tree.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5214 clear_node(tree);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5215
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5216 // Count the number of nodes. Needed to be able to allocate the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5217 // memory when reading the nodes. Also fills in index for shared
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5218 // nodes.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5219 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
5220
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5221 // number of nodes in 4 bytes
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5222 put_bytes(fd, (long_u)nodecount, 4); // <nodecount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5223 spin->si_memtot += nodecount + nodecount * sizeof(int);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5224
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5225 // Write the nodes.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5226 (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
5227 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5228
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5229 // Write another byte to check for errors (file system full).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5230 if (putc(0, fd) == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5231 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5232 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5233 if (fclose(fd) == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5234 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5235
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5236 if (fwv != (size_t)1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5237 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5238 if (retval == FAIL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5239 emsg(_(e_write));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5240
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5241 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5242 }
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5245 * 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
5246 * 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
5247 * space.
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 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5250 clear_node(wordnode_T *node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5251 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5252 wordnode_T *np;
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 if (node != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5255 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
5256 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5257 np->wn_u1.index = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5258 np->wn_u2.wnode = NULL;
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 if (np->wn_byte != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5261 clear_node(np->wn_child);
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5265
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5266 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5267 * Dump a word tree at node "node".
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 * 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
5270 * byte recursively write the children.
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 * 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
5273 * 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
5274 * in the file).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5275 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5276 * Returns the number of nodes used.
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5279 put_node(
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5280 FILE *fd, // NULL when only counting
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5281 wordnode_T *node,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5282 int idx,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5283 int regionmask,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5284 int prefixtree) // TRUE for PREFIXTREE
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5285 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5286 int newindex = idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5287 int siblingcount = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5288 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5289 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5290
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5291 // If "node" is zero the tree is empty.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5292 if (node == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5293 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5294
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5295 // Store the index where this node is written.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5296 node->wn_u1.index = idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5297
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5298 // Count the number of siblings.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5299 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
5300 ++siblingcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5301
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5302 // Write the sibling count.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5303 if (fd != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5304 putc(siblingcount, fd); // <siblingcount>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5305
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5306 // Write each sibling byte and optionally extra info.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5307 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
5308 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5309 if (np->wn_byte == 0)
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 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5312 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5313 // For a NUL byte (end of word) write the flags etc.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5314 if (prefixtree)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5315 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5316 // In PREFIXTREE write the required affixID and the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5317 // associated condition nr (stored in wn_region). The
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5318 // byte value is misused to store the "rare" and "not
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5319 // combining" flags
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5320 if (np->wn_flags == (short_u)PFX_FLAGS)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5321 putc(BY_NOFLAGS, fd); // <byte>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5322 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5323 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5324 putc(BY_FLAGS, fd); // <byte>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5325 putc(np->wn_flags, fd); // <pflags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5326 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5327 putc(np->wn_affixID, fd); // <affixID>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5328 put_bytes(fd, (long_u)np->wn_region, 2); // <prefcondnr>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5329 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5330 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5331 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5332 // For word trees we write the flag/region items.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5333 flags = np->wn_flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5334 if (regionmask != 0 && np->wn_region != regionmask)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5335 flags |= WF_REGION;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5336 if (np->wn_affixID != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5337 flags |= WF_AFX;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5338 if (flags == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5339 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5340 // word without flags or region
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5341 putc(BY_NOFLAGS, fd); // <byte>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5342 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5343 else
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 if (np->wn_flags >= 0x100)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5346 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5347 putc(BY_FLAGS2, fd); // <byte>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5348 putc(flags, fd); // <flags>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5349 putc((unsigned)flags >> 8, fd); // <flags2>
9583
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5352 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5353 putc(BY_FLAGS, fd); // <byte>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5354 putc(flags, fd); // <flags>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5355 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5356 if (flags & WF_REGION)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5357 putc(np->wn_region, fd); // <region>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5358 if (flags & WF_AFX)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5359 putc(np->wn_affixID, fd); // <affixID>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5360 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5361 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5362 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5363 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5364 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5365 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5366 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
5367 && np->wn_child->wn_u2.wnode != node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5368 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5369 // The child is written elsewhere, write the reference.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5370 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5371 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5372 putc(BY_INDEX, fd); // <byte>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5373 // <nodeidx>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5374 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
5375 }
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 else if (np->wn_child->wn_u2.wnode == NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5378 // We will write the child below and give it an index.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5379 np->wn_child->wn_u2.wnode = node;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5380
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5381 if (fd != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5382 if (putc(np->wn_byte, fd) == EOF) // <byte> or <xbyte>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5383 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5384 emsg(_(e_write));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5385 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5386 }
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5389
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5390 // Space used in the array when reading: one for each sibling and one for
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5391 // the count.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5392 newindex += siblingcount + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5393
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5394 // Recursively dump the children of each sibling.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5395 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
5396 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
5397 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
5398 prefixtree);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5399
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5400 return newindex;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5401 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5402
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5403
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5404 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5405 * ":mkspell [-ascii] outfile infile ..."
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5406 * ":mkspell [-ascii] addfile"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5407 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5408 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5409 ex_mkspell(exarg_T *eap)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5410 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5411 int fcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5412 char_u **fnames;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5413 char_u *arg = eap->arg;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5414 int ascii = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5415
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5416 if (STRNCMP(arg, "-ascii", 6) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5417 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5418 ascii = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5419 arg = skipwhite(arg + 6);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5420 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5421
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5422 // Expand all the remaining arguments (e.g., $VIMRUNTIME).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5423 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
5424 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5425 mkspell(fcount, fnames, ascii, eap->forceit, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5426 FreeWild(fcount, fnames);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5427 }
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5430 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5431 * Create the .sug file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5432 * Uses the soundfold info in "spin".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5433 * 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
5434 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5435 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5436 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
5437 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5438 char_u *fname = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5439 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5440 slang_T *slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5441 int free_slang = FALSE;
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 * 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
5445 * 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
5446 * 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
5447 * of the code for the soundfolding stuff.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5448 * 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
5449 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5450 for (slang = first_lang; slang != NULL; slang = slang->sl_next)
16738
b52ea9c5f1db patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents: 16606
diff changeset
5451 if (fullpathcmp(wfname, slang->sl_fname, FALSE, TRUE) == FPC_SAME)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5452 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5453 if (slang == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5454 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5455 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
5456 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
5457 if (slang == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5458 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5459 free_slang = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5460 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5461
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 * 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
5464 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5465 spin->si_blocks = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5466 spin->si_blocks_cnt = 0;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5467 spin->si_compress_cnt = 0; // will stay at 0 all the time
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5468 spin->si_free_count = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5469 spin->si_first_free = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5470 spin->si_foldwcount = 0;
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5473 * 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
5474 * the soundfold trie.
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 spell_message(spin, (char_u *)_("Performing soundfolding..."));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5477 if (sug_filltree(spin, slang) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5478 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5479
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5480 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5481 * 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
5482 * 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
5483 * 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
5484 * compression possible.
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 if (sug_maketable(spin) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5487 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5488
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5489 smsg(_("Number of words after soundfolding: %ld"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5490 (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
5491
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 * Compress the soundfold trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5494 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5495 spell_message(spin, (char_u *)_(msg_compressing));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5496 wordtree_compress(spin, spin->si_foldroot);
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5499 * Write the .sug file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5500 * 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
5501 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5502 fname = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5503 if (fname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5504 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5505 vim_strncpy(fname, wfname, MAXPATHL - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5506 len = (int)STRLEN(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5507 fname[len - 2] = 'u';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5508 fname[len - 1] = 'g';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5509 sug_write(spin, fname);
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 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5512 vim_free(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5513 if (free_slang)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5514 slang_free(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5515 free_blocks(spin->si_blocks);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5516 close_spellbuf(spin->si_spellbuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5517 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5518
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 * Build the soundfold trie for language "slang".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5521 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5522 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5523 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
5524 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5525 char_u *byts;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5526 idx_T *idxs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5527 int depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5528 idx_T arridx[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5529 int curi[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5530 char_u tword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5531 char_u tsalword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5532 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5533 idx_T n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5534 unsigned words_done = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5535 int wordcount[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5536
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5537 // We use si_foldroot for the soundfolded trie.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5538 spin->si_foldroot = wordtree_alloc(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5539 if (spin->si_foldroot == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5540 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5541
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5542 // let tree_add_word() know we're adding to the soundfolded tree
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5543 spin->si_sugtree = TRUE;
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5546 * 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
5547 * in the trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5548 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5549 byts = slang->sl_fbyts;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5550 idxs = slang->sl_fidxs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5551
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5552 arridx[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5553 curi[0] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5554 wordcount[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5555
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5556 depth = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5557 while (depth >= 0 && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5558 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5559 if (curi[depth] > byts[arridx[depth]])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5560 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5561 // Done all bytes at this node, go up one level.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5562 idxs[arridx[depth]] = wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5563 if (depth > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5564 wordcount[depth - 1] += wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5565
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5566 --depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5567 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5568 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5569 else
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5572 // Do one more byte at this node.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5573 n = arridx[depth] + curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5574 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5575
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5576 c = byts[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5577 if (c == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5578 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5579 // Sound-fold the word.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5580 tword[depth] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5581 spell_soundfold(slang, tword, TRUE, tsalword);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5582
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5583 // We use the "flags" field for the MSB of the wordnr,
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5584 // "region" for the LSB of the wordnr.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5585 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
5586 words_done >> 16, words_done & 0xffff,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5587 0) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5588 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5589
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5590 ++words_done;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5591 ++wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5592
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5593 // Reset the block count each time to avoid compression
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5594 // kicking in.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5595 spin->si_blocks_cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5596
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5597 // Skip over any other NUL bytes (same word with different
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5598 // flags).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5599 while (byts[n + 1] == 0)
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 ++n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5602 ++curi[depth];
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5605 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5606 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5607 // Normal char, go one level deeper.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5608 tword[depth++] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5609 arridx[depth] = idxs[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5610 curi[depth] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5611 wordcount[depth] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5612 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5613 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5614 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5615
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5616 smsg(_("Total number of words: %d"), words_done);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5617
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5618 return OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5619 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5620
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5621 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5622 * 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
5623 * can be produced from.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5624 * 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
5625 * the table efficiently.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5626 * Returns FAIL when out of memory.
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5629 sug_maketable(spellinfo_T *spin)
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 garray_T ga;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5632 int res = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5633
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5634 // Allocate a buffer, open a memline for it and create the swap file
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5635 // (uses a temp file, not a .swp file).
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5636 spin->si_spellbuf = open_spellbuf();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5637 if (spin->si_spellbuf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5638 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5639
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5640 // Use a buffer to store the line info, avoids allocating many small
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5641 // pieces of memory.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5642 ga_init2(&ga, 1, 100);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5643
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5644 // recursively go through the tree
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5645 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
5646 res = FAIL;
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 ga_clear(&ga);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5649 return res;
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
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 * 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
5654 * 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
5655 * Returns -1 when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5656 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5657 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5658 sug_filltable(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5659 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5660 wordnode_T *node,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5661 int startwordnr,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5662 garray_T *gap) // place to store line of numbers
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5663 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5664 wordnode_T *p, *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5665 int wordnr = startwordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5666 int nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5667 int prev_nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5668
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5669 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
5670 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5671 if (p->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5672 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5673 gap->ga_len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5674 prev_nr = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5675 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
5676 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5677 if (ga_grow(gap, 10) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5678 return -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5679
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5680 nr = (np->wn_flags << 16) + (np->wn_region & 0xffff);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5681 // Compute the offset from the previous nr and store the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5682 // offset in a way that it takes a minimum number of bytes.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5683 // It's a bit like utf-8, but without the need to mark
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5684 // following bytes.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5685 nr -= prev_nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5686 prev_nr += nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5687 gap->ga_len += offset2bytes(nr,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5688 (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
5689 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5690
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5691 // add the NUL byte
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5692 ((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
5693
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5694 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
5695 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
5696 return -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5697 ++wordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5698
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5699 // Remove extra NUL entries, we no longer need them. We don't
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5700 // bother freeing the nodes, the won't be reused anyway.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5701 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
5702 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
5703
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5704 // Clear the flags on the remaining NUL node, so that compression
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5705 // works a lot better.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5706 p->wn_flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5707 p->wn_region = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5708 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5709 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5710 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5711 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
5712 if (wordnr == -1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5713 return -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5714 }
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 return wordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5717 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5718
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5719 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5720 * 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
5721 * 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
5722 * bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5723 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5724 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5725 offset2bytes(int nr, char_u *buf)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5726 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5727 int rem;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5728 int b1, b2, b3, b4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5729
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5730 // Split the number in parts of base 255. We need to avoid NUL bytes.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5731 b1 = nr % 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5732 rem = nr / 255;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5733 b2 = rem % 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5734 rem = rem / 255;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5735 b3 = rem % 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5736 b4 = rem / 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5737
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5738 if (b4 > 1 || b3 > 0x1f) // 4 bytes
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5739 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5740 buf[0] = 0xe0 + b4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5741 buf[1] = b3;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5742 buf[2] = b2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5743 buf[3] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5744 return 4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5745 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5746 if (b3 > 1 || b2 > 0x3f ) // 3 bytes
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5747 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5748 buf[0] = 0xc0 + b3;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5749 buf[1] = b2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5750 buf[2] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5751 return 3;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5752 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5753 if (b2 > 1 || b1 > 0x7f ) // 2 bytes
9583
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 buf[0] = 0x80 + b2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5756 buf[1] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5757 return 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5758 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5759 // 1 byte
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5760 buf[0] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5761 return 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5762 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5763
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5764 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5765 * Write the .sug file in "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5766 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5767 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5768 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
5769 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5770 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5771 wordnode_T *tree;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5772 int nodecount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5773 int wcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5774 char_u *line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5775 linenr_T lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5776 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5777
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5778 // Create the file. Note that an existing file is silently overwritten!
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5779 fd = mch_fopen((char *)fname, "w");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5780 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5781 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5782 semsg(_(e_notopen), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5783 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5784 }
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 vim_snprintf((char *)IObuff, IOSIZE,
14121
97814084264b patch 8.1.0078: "..." used inconsistently in messages
Christian Brabandt <cb@256bit.org>
parents: 13610
diff changeset
5787 _("Writing suggestion file %s..."), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5788 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5789
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 * <SUGHEADER>: <fileID> <versionnr> <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5792 */
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5793 if (fwrite(VIMSUGMAGIC, VIMSUGMAGICL, (size_t)1, fd) != 1) // <fileID>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5794 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5795 emsg(_(e_write));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5796 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5797 }
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5798 putc(VIMSUGVERSION, fd); // <versionnr>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5799
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5800 // Write si_sugtime to the file.
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5801 put_time(fd, spin->si_sugtime); // <timestamp>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5802
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5803 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5804 * <SUGWORDTREE>
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 spin->si_memtot = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5807 tree = spin->si_foldroot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5808
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5809 // Clear the index and wnode fields in the tree.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5810 clear_node(tree);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5811
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5812 // Count the number of nodes. Needed to be able to allocate the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5813 // memory when reading the nodes. Also fills in index for shared
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5814 // nodes.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5815 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
5816
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5817 // number of nodes in 4 bytes
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5818 put_bytes(fd, (long_u)nodecount, 4); // <nodecount>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5819 spin->si_memtot += nodecount + nodecount * sizeof(int);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5820
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5821 // Write the nodes.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5822 (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
5823
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5824 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5825 * <SUGTABLE>: <sugwcount> <sugline> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5826 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5827 wcount = spin->si_spellbuf->b_ml.ml_line_count;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5828 put_bytes(fd, (long_u)wcount, 4); // <sugwcount>
9583
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 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
5831 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5832 // <sugline>: <sugnr> ... NUL
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5833 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
5834 len = (int)STRLEN(line) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5835 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
5836 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5837 emsg(_(e_write));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5838 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5839 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5840 spin->si_memtot += len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5841 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5842
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5843 // Write another byte to check for errors.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5844 if (putc(0, fd) == EOF)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5845 emsg(_(e_write));
9583
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 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5848 _("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
5849 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5850
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5851 theend:
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5852 // close the file
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5853 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5854 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5855
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5856
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5857 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5858 * 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
5859 * "fnames[0]" is the output file name.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5860 * "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
5861 * 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
5862 * 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
5863 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5864 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5865 mkspell(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5866 int fcount,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5867 char_u **fnames,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5868 int ascii, // -ascii argument given
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5869 int over_write, // overwrite existing output file
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5870 int added_word) // invoked through "zg"
9583
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 char_u *fname = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5873 char_u *wfname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5874 char_u **innames;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5875 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
5876 afffile_T *(afile[MAXREGIONS]);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5877 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5878 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5879 stat_T st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5880 int error = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5881 spellinfo_T spin;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5882
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5883 vim_memset(&spin, 0, sizeof(spin));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5884 spin.si_verbose = !added_word;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5885 spin.si_ascii = ascii;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5886 spin.si_followup = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5887 spin.si_rem_accents = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5888 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
5889 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
5890 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
5891 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
5892 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
5893 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
5894 hash_init(&spin.si_commonwords);
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5895 spin.si_newcompID = 127; // start compound ID at first maximum
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5896
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5897 // default: fnames[0] is output file, following are input files
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5898 innames = &fnames[1];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5899 incount = fcount - 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5900
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5901 wfname = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5902 if (wfname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5903 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5904
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5905 if (fcount >= 1)
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 len = (int)STRLEN(fnames[0]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5908 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
5909 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5910 // For ":mkspell path/en.latin1.add" output file is
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5911 // "path/en.latin1.add.spl".
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5912 innames = &fnames[0];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5913 incount = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5914 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
5915 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5916 else if (fcount == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5917 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5918 // For ":mkspell path/vim" output file is "path/vim.latin1.spl".
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5919 innames = &fnames[0];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5920 incount = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5921 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
5922 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
5923 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5924 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
5925 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5926 // Name ends in ".spl", use as the file name.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5927 vim_strncpy(wfname, fnames[0], MAXPATHL - 1);
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 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5930 // Name should be language, make the file name from it.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5931 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
5932 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
5933
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5934 // Check for .ascii.spl.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5935 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
5936 spin.si_ascii = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5937
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5938 // Check for .add.spl.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5939 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
5940 spin.si_add = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5941 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5942
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5943 if (incount <= 0)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5944 emsg(_(e_invarg)); // need at least output and input names
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5945 else if (vim_strchr(gettail(wfname), '_') != NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5946 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
5947 else if (incount > MAXREGIONS)
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
5948 semsg(_("E754: Only up to %d regions supported"), MAXREGIONS);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5949 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5950 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5951 // Check for overwriting before doing things that may take a lot of
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
5952 // time.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5953 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
5954 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5955 emsg(_(e_exists));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5956 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5957 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5958 if (mch_isdir(wfname))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5959 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5960 semsg(_(e_isadir2), wfname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5961 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5962 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5963
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5964 fname = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5965 if (fname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5966 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5967
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5968 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5969 * Init the aff and dic pointers.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5970 * 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
5971 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5972 for (i = 0; i < incount; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5973 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5974 afile[i] = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5975
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5976 if (incount > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5977 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5978 len = (int)STRLEN(innames[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5979 if (STRLEN(gettail(innames[i])) < 5
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5980 || innames[i][len - 3] != '_')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5981 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5982 semsg(_("E755: Invalid region in %s"), innames[i]);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5983 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5984 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5985 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
5986 spin.si_region_name[i * 2 + 1] =
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5987 TOLOWER_ASC(innames[i][len - 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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5990 spin.si_region_count = incount;
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 spin.si_foldroot = wordtree_alloc(&spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5993 spin.si_keeproot = wordtree_alloc(&spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5994 spin.si_prefroot = wordtree_alloc(&spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5995 if (spin.si_foldroot == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5996 || spin.si_keeproot == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5997 || spin.si_prefroot == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5998 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5999 free_blocks(spin.si_blocks);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6000 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6001 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6002
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6003 // When not producing a .add.spl file clear the character table when
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6004 // we encounter one in the .aff file. This means we dump the current
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6005 // one in the .spl file if the .aff file doesn't define one. That's
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6006 // better than guessing the contents, the table will match a
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6007 // previously loaded spell file.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6008 if (!spin.si_add)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6009 spin.si_clear_chartab = TRUE;
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6012 * Read all the .aff and .dic files.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6013 * Text is converted to 'encoding'.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6014 * 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
6015 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6016 for (i = 0; i < incount && !error; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6017 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6018 spin.si_conv.vc_type = CONV_NONE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6019 spin.si_region = 1 << i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6020
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6021 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
6022 if (mch_stat((char *)fname, &st) >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6023 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6024 // Read the .aff file. Will init "spin->si_conv" based on the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6025 // "SET" line.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6026 afile[i] = spell_read_aff(&spin, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6027 if (afile[i] == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6028 error = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6029 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6030 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6031 // Read the .dic file and store the words in the trees.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6032 vim_snprintf((char *)fname, MAXPATHL, "%s.dic",
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6033 innames[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6034 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
6035 error = TRUE;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6038 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6039 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6040 // No .aff file, try reading the file as a word list. Store
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6041 // the words in the trees.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6042 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
6043 error = TRUE;
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
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6046 // Free any conversion stuff.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6047 convert_setup(&spin.si_conv, NULL, NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6048 }
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 if (spin.si_compflags != NULL && spin.si_nobreak)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
6051 msg(_("Warning: both compounding and NOBREAK specified"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6052
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6053 if (!error && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6054 {
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 * Combine tails in the tree.
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 spell_message(&spin, (char_u *)_(msg_compressing));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6059 wordtree_compress(&spin, spin.si_foldroot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6060 wordtree_compress(&spin, spin.si_keeproot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6061 wordtree_compress(&spin, spin.si_prefroot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6062 }
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 if (!error && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6065 {
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 * Write the info in the spell file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6068 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6069 vim_snprintf((char *)IObuff, IOSIZE,
14121
97814084264b patch 8.1.0078: "..." used inconsistently in messages
Christian Brabandt <cb@256bit.org>
parents: 13610
diff changeset
6070 _("Writing spell file %s..."), wfname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6071 spell_message(&spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6072
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6073 error = write_vim_spell(&spin, wfname) == FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6074
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6075 spell_message(&spin, (char_u *)_("Done!"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6076 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6077 _("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
6078 spell_message(&spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6079
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 * 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
6082 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6083 if (!error)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6084 spell_reload_one(wfname, added_word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6085 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6086
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6087 // Free the allocated memory.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6088 ga_clear(&spin.si_rep);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6089 ga_clear(&spin.si_repsal);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6090 ga_clear(&spin.si_sal);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6091 ga_clear(&spin.si_map);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6092 ga_clear(&spin.si_comppat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6093 ga_clear(&spin.si_prefcond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6094 hash_clear_all(&spin.si_commonwords, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6095
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6096 // Free the .aff file structures.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6097 for (i = 0; i < incount; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6098 if (afile[i] != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6099 spell_free_aff(afile[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6100
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6101 // Free all the bits and pieces at once.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6102 free_blocks(spin.si_blocks);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6103
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6104 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6105 * 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
6106 * .sug file with the soundfolded word trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6107 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6108 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
6109 spell_make_sugfile(&spin, wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6110
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6111 }
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 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6114 vim_free(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6115 vim_free(wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6116 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6117
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 * 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
6120 * ":mkspell". "str" can be IObuff.
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 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6123 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
6124 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6125 if (spin->si_verbose || p_verbose > 2)
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 if (!spin->si_verbose)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6128 verbose_enter();
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
6129 msg((char *)str);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6130 out_flush();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6131 if (!spin->si_verbose)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6132 verbose_leave();
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6135
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 * ":[count]spellgood {word}"
17682
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6138 * ":[count]spellwrong {word}"
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6139 * ":[count]spellundo {word}"
17682
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6140 * ":[count]spellrare {word}"
9583
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 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6143 ex_spell(exarg_T *eap)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6144 {
17682
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6145 spell_add_word(eap->arg, (int)STRLEN(eap->arg),
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6146 eap->cmdidx == CMD_spellwrong ? SPELL_ADD_BAD :
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6147 eap->cmdidx == CMD_spellrare ? SPELL_ADD_RARE : SPELL_ADD_GOOD,
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6148 eap->forceit ? 0 : (int)eap->line2,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6149 eap->cmdidx == CMD_spellundo);
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6152 /*
17682
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6153 * Add "word[len]" to 'spellfile' as a good, rare or bad word.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6154 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6155 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6156 spell_add_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6157 char_u *word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6158 int len,
17682
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6159 int what, // SPELL_ADD_ values
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6160 int idx, // "zG" and "zW": zero, otherwise index in
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6161 // 'spellfile'
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6162 int undo) // TRUE for "zug", "zuG", "zuw" and "zuW"
9583
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 FILE *fd = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6165 buf_T *buf = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6166 int new_spf = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6167 char_u *fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6168 char_u *fnamebuf = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6169 char_u line[MAXWLEN * 2];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6170 long fpos, fpos_next = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6171 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6172 char_u *spf;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6173
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6174 if (idx == 0) // use internal wordlist
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6175 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6176 if (int_wordlist == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6177 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6178 int_wordlist = vim_tempname('s', FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6179 if (int_wordlist == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6180 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6181 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6182 fname = int_wordlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6183 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6184 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6185 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6186 // If 'spellfile' isn't set figure out a good default value.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6187 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
6188 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6189 init_spellfile();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6190 new_spf = TRUE;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6193 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
6194 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6195 semsg(_(e_notset), "spellfile");
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6196 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6197 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6198 fnamebuf = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6199 if (fnamebuf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6200 return;
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 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
6203 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6204 copy_option_part(&spf, fnamebuf, MAXPATHL, ",");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6205 if (i == idx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6206 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6207 if (*spf == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6208 {
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
6209 semsg(_("E765: 'spellfile' does not have %d entries"), idx);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6210 vim_free(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6211 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6212 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6213 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6214
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6215 // Check that the user isn't editing the .add file somewhere.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6216 buf = buflist_findname_exp(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6217 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
6218 buf = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6219 if (buf != NULL && bufIsChanged(buf))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6220 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6221 emsg(_(e_bufloaded));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6222 vim_free(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6223 return;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6226 fname = fnamebuf;
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
17682
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6229 if (what == SPELL_ADD_BAD || undo)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6230 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6231 // When the word appears as good word we need to remove that one,
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6232 // since its flags sort before the one with WF_BANNED.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6233 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6234 if (fd != NULL)
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 while (!vim_fgets(line, MAXWLEN * 2, fd))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6237 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6238 fpos = fpos_next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6239 fpos_next = ftell(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6240 if (STRNCMP(word, line, len) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6241 && (line[len] == '/' || line[len] < ' '))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6242 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6243 // Found duplicate word. Remove it by writing a '#' at
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6244 // the start of the line. Mixing reading and writing
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6245 // doesn't work for all systems, close the file first.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6246 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6247 fd = mch_fopen((char *)fname, "r+");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6248 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6249 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6250 if (fseek(fd, fpos, SEEK_SET) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6251 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6252 fputc('#', fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6253 if (undo)
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 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE);
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6256 smsg(_("Word '%.*s' removed from %s"),
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6257 len, word, NameBuff);
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6260 fseek(fd, fpos_next, SEEK_SET);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6261 }
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 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6264 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6265 }
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6268 if (!undo)
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 fd = mch_fopen((char *)fname, "a");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6271 if (fd == NULL && new_spf)
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 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6274
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6275 // We just initialized the 'spellfile' option and can't open the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6276 // file. We may need to create the "spell" directory first. We
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6277 // already checked the runtime directory is writable in
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6278 // init_spellfile().
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6279 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
6280 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6281 int c = *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6282
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6283 // The directory doesn't exist. Try creating it and opening
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6284 // the file again.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6285 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6286 vim_mkdir(fname, 0755);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6287 *p = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6288 fd = mch_fopen((char *)fname, "a");
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6291
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6292 if (fd == NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6293 semsg(_(e_notopen), fname);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6294 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6295 {
17682
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6296 if (what == SPELL_ADD_BAD)
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6297 fprintf(fd, "%.*s/!\n", len, word);
17682
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6298 else if (what == SPELL_ADD_RARE)
3dbff5d37520 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6299 fprintf(fd, "%.*s/?\n", len, word);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6300 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6301 fprintf(fd, "%.*s\n", len, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6302 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6303
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6304 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE);
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6305 smsg(_("Word '%.*s' added to %s"), len, word, NameBuff);
9583
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 }
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 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6310 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6311 // Update the .add.spl file.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6312 mkspell(1, &fname, FALSE, TRUE, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6313
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6314 // If the .add file is edited somewhere, reload it.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6315 if (buf != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6316 buf_reload(buf, buf->b_orig_mode);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6317
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6318 redraw_all_later(SOME_VALID);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6319 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6320 vim_free(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6321 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6322
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 * Initialize 'spellfile' for the current buffer.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6325 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6326 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6327 init_spellfile(void)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6328 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6329 char_u *buf;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6330 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6331 char_u *fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6332 char_u *rtp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6333 char_u *lend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6334 int aspath = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6335 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
6336
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6337 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
6338 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6339 buf = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6340 if (buf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6341 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6342
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6343 // Find the end of the language name. Exclude the region. If there
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6344 // is a path separator remember the start of the tail.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6345 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
6346 && vim_strchr((char_u *)",._", *lend) == NULL; ++lend)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6347 if (vim_ispathsep(*lend))
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 aspath = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6350 lstart = lend + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6351 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6352
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6353 // Loop over all entries in 'runtimepath'. Use the first one where we
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6354 // are allowed to write.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6355 rtp = p_rtp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6356 while (*rtp != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6357 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6358 if (aspath)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6359 // Use directory of an entry with path, e.g., for
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6360 // "/dir/lg.utf-8.spl" use "/dir".
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6361 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
6362 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
6363 else
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6364 // Copy the path from 'runtimepath' to buf[].
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6365 copy_option_part(&rtp, buf, MAXPATHL, ",");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6366 if (filewritable(buf) == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6367 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6368 // Use the first language name from 'spelllang' and the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6369 // encoding used in the first loaded .spl file.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6370 if (aspath)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6371 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
6372 lend - curbuf->b_s.b_p_spl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6373 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6374 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6375 // Create the "spell" directory if it doesn't exist yet.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6376 l = (int)STRLEN(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6377 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
6378 if (filewritable(buf) != 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6379 vim_mkdir(buf, 0755);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6380
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6381 l = (int)STRLEN(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6382 vim_snprintf((char *)buf + l, MAXPATHL - l,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6383 "/%.*s", (int)(lend - lstart), lstart);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6384 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6385 l = (int)STRLEN(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6386 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
6387 ->lp_slang->sl_fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6388 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
6389 fname != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6390 && strstr((char *)gettail(fname), ".ascii.") != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6391 ? (char_u *)"ascii" : spell_enc());
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6392 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
6393 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6394 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6395 aspath = FALSE;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6398 vim_free(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6399 }
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
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 * 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
6406 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6407 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6408 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
6409 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6410 // We build the new tables here first, so that we can compare with the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6411 // previous one.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6412 spelltab_T new_st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6413 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
6414 int f, l, u;
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 clear_spell_chartab(&new_st);
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 while (*pf != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6419 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6420 if (*pl == NUL || *pu == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6421 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6422 emsg(_(e_affform));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6423 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6424 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6425 f = mb_ptr2char_adv(&pf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6426 l = mb_ptr2char_adv(&pl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6427 u = mb_ptr2char_adv(&pu);
15605
62b3805506b3 patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
6428
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6429 // Every character that appears is a word character.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6430 if (f < 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6431 new_st.st_isw[f] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6432 if (l < 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6433 new_st.st_isw[l] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6434 if (u < 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6435 new_st.st_isw[u] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6436
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6437 // if "LOW" and "FOL" are not the same the "LOW" char needs
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6438 // case-folding
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6439 if (l < 256 && l != f)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6440 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6441 if (f >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6442 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6443 emsg(_(e_affrange));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6444 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6445 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6446 new_st.st_fold[l] = f;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6447 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6448
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6449 // if "UPP" and "FOL" are not the same the "UPP" char needs
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6450 // case-folding, it's upper case and the "UPP" is the upper case of
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6451 // "FOL" .
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6452 if (u < 256 && u != f)
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 if (f >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6455 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6456 emsg(_(e_affrange));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6457 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6458 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6459 new_st.st_fold[u] = f;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6460 new_st.st_isu[u] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6461 new_st.st_upper[f] = u;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6462 }
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6465 if (*pl != NUL || *pu != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6466 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6467 emsg(_(e_affform));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6468 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6469 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6470
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6471 return set_spell_finish(&new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6472 }
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6475 * 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
6476 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6477 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6478 set_spell_charflags(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6479 char_u *flags,
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6480 int cnt, // length of "flags"
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6481 char_u *fol)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6482 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6483 // We build the new tables here first, so that we can compare with the
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6484 // previous one.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6485 spelltab_T new_st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6486 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6487 char_u *p = fol;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6488 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6489
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6490 clear_spell_chartab(&new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6491
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6492 for (i = 0; i < 128; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6493 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6494 if (i < cnt)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6495 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6496 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
6497 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
6498 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6499
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6500 if (*p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6501 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6502 c = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6503 new_st.st_fold[i + 128] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6504 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
6505 new_st.st_upper[c] = i + 128;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6506 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6507 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6508
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6509 (void)set_spell_finish(&new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6510 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6511
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6512 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6513 set_spell_finish(spelltab_T *new_st)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6514 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6515 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6516
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6517 if (did_set_spelltab)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6518 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6519 // check that it's the same table
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6520 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6521 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6522 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
6523 || 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
6524 || 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
6525 || 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
6526 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6527 emsg(_("E763: Word characters differ between spell files"));
9583
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 }
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6533 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6534 // copy the new spelltab into the one being used
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6535 spelltab = *new_st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6536 did_set_spelltab = TRUE;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6539 return OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6540 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6541
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 * 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
6544 * 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
6545 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6546 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6547 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
6548 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6549 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6550 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6551 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6552 int totlen;
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6553 size_t x = 1; // collect return value of fwrite()
9583
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 if (fd != NULL)
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6556 put_bytes(fd, (long_u)gap->ga_len, 2); // <prefcondcnt>
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6557
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6558 totlen = 2 + gap->ga_len; // length of <prefcondcnt> and <condlen> bytes
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6559
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6560 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
6561 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6562 // <prefcond> : <condlen> <condstr>
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6563 p = ((char_u **)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6564 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6565 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6566 len = (int)STRLEN(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6567 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6568 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6569 fputc(len, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6570 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
6571 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6572 totlen += len;
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 else if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6575 fputc(0, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6576 }
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 return totlen;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6581
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 * Use map string "map" for languages "lp".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6584 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6585 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6586 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
6587 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6588 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6589 int headc = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6590 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6591 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6592
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6593 if (*map == NUL)
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 lp->sl_has_map = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6596 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6597 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6598 lp->sl_has_map = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6599
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6600 // Init the array and hash tables empty.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6601 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6602 lp->sl_map_array[i] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6603 hash_init(&lp->sl_map_hash);
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6606 * 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
6607 * "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
6608 * 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
6609 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6610 for (p = map; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6611 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6612 c = mb_cptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6613 if (c == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6614 headc = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6615 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6616 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6617 if (headc == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6618 headc = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6619
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6620 // Characters above 255 don't fit in sl_map_array[], put them in
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6621 // the hash table. Each entry is the char, a NUL the headchar and
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6622 // a NUL.
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6623 if (c >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6624 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6625 int cl = mb_char2len(c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6626 int headcl = mb_char2len(headc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6627 char_u *b;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6628 hash_T hash;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6629 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6630
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16738
diff changeset
6631 b = alloc(cl + headcl + 2);
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6632 if (b == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6633 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6634 mb_char2bytes(c, b);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6635 b[cl] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6636 mb_char2bytes(headc, b + cl + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6637 b[cl + 1 + headcl] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6638 hash = hash_hash(b);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6639 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
6640 if (HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6641 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
6642 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6643 {
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6644 // This should have been checked when generating the .spl
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6645 // file.
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6646 emsg(_("E783: duplicate char in MAP entry"));
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6647 vim_free(b);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6648 }
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6651 lp->sl_map_array[c] = headc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6652 }
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6655
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6656
18814
7e7ec935e7c8 patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18548
diff changeset
6657 #endif // FEAT_SPELL