annotate src/spellfile.c @ 9583:b0c7061d6439 v7.4.2069

commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jul 19 16:39:08 2016 +0200 patch 7.4.2069 Problem: spell.c is too big. Solution: Split it in spell file handling and spell checking.
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Jul 2016 16:45:06 +0200
parents
children 4aead6a9b7a9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9583
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
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> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 * <regionname> 2 bytes Up to 8 region names: ca, au, etc. Lower case.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 * First <regionname> is region 1.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 * sectionID == SN_CHARFLAGS: <charflagslen> <charflags>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 * <folcharslen> <folchars>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 * <charflagslen> 1 byte Number of bytes in <charflags> (should be 128).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 * <charflags> N bytes List of flags (first one is for character 128):
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 * 0x01 word character CF_WORD
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 * 0x02 upper-case character CF_UPPER
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 * <folcharslen> 2 bytes Number of bytes in <folchars>.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 * <folchars> N bytes Folded characters, first one is for character 128.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 * sectionID == SN_MIDWORD: <midword>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 * <midword> N bytes Characters that are word characters only when used
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 * in the middle of a word.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 * sectionID == SN_PREFCOND: <prefcondcnt> <prefcond> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 * <prefcondcnt> 2 bytes Number of <prefcond> items following.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 * <prefcond> : <condlen> <condstr>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 * <condlen> 1 byte Length of <condstr>.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 * <condstr> N bytes Condition for the prefix.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 * sectionID == SN_REP: <repcount> <rep> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 * <repcount> 2 bytes number of <rep> items, MSB first.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 * <rep> : <repfromlen> <repfrom> <reptolen> <repto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 * <repfromlen> 1 byte length of <repfrom>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 * <repfrom> N bytes "from" part of replacement
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 * <reptolen> 1 byte length of <repto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 * <repto> N bytes "to" part of replacement
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 * sectionID == SN_REPSAL: <repcount> <rep> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 * just like SN_REP but for soundfolded words
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 * sectionID == SN_SAL: <salflags> <salcount> <sal> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 * <salflags> 1 byte flags for soundsalike conversion:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 * SAL_F0LLOWUP
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 * SAL_COLLAPSE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 * SAL_REM_ACCENTS
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 * <salcount> 2 bytes number of <sal> items following
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 * <sal> : <salfromlen> <salfrom> <saltolen> <salto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 * <salfromlen> 1 byte length of <salfrom>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 * <salfrom> N bytes "from" part of soundsalike
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 * <saltolen> 1 byte length of <salto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 * <salto> N bytes "to" part of soundsalike
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 * sectionID == SN_SOFO: <sofofromlen> <sofofrom> <sofotolen> <sofoto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 * <sofofromlen> 2 bytes length of <sofofrom>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 * <sofofrom> N bytes "from" part of soundfold
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 * <sofotolen> 2 bytes length of <sofoto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 * <sofoto> N bytes "to" part of soundfold
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 * sectionID == SN_SUGFILE: <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 * <timestamp> 8 bytes time in seconds that must match with .sug file
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 * sectionID == SN_NOSPLITSUGS: nothing
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 * sectionID == SN_NOCOMPOUNDSUGS: nothing
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 * sectionID == SN_WORDS: <word> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 * <word> N bytes NUL terminated common word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 * sectionID == SN_MAP: <mapstr>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 * <mapstr> N bytes String with sequences of similar characters,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 * separated by slashes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 * sectionID == SN_COMPOUND: <compmax> <compminlen> <compsylmax> <compoptions>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 * <comppatcount> <comppattern> ... <compflags>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 * <compmax> 1 byte Maximum nr of words in compound word.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 * <compminlen> 1 byte Minimal word length for compounding.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 * <compsylmax> 1 byte Maximum nr of syllables in compound word.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 * <compoptions> 2 bytes COMP_ flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 * <comppatcount> 2 bytes number of <comppattern> following
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 * <compflags> N bytes Flags from COMPOUNDRULE items, separated by
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 * slashes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 * <comppattern>: <comppatlen> <comppattext>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 * <comppatlen> 1 byte length of <comppattext>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 * <comppattext> N bytes end or begin chars from CHECKCOMPOUNDPATTERN
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 * sectionID == SN_NOBREAK: (empty, its presence is what matters)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 * sectionID == SN_SYLLABLE: <syllable>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 * <syllable> N bytes String from SYLLABLE item.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 * <LWORDTREE>: <wordtree>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 * <KWORDTREE>: <wordtree>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 * <PREFIXTREE>: <wordtree>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 * <wordtree>: <nodecount> <nodedata> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 * <nodecount> 4 bytes Number of nodes following. MSB first.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 * <nodedata>: <siblingcount> <sibling> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 * <siblingcount> 1 byte Number of siblings in this node. The siblings
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 * follow in sorted order.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 * <sibling>: <byte> [ <nodeidx> <xbyte>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 * | <flags> [<flags2>] [<region>] [<affixID>]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 * | [<pflags>] <affixID> <prefcondnr> ]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 * <byte> 1 byte Byte value of the sibling. Special cases:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 * BY_NOFLAGS: End of word without flags and for all
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 * regions.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 * For PREFIXTREE <affixID> and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 * <prefcondnr> follow.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 * BY_FLAGS: End of word, <flags> follow.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 * For PREFIXTREE <pflags>, <affixID>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 * and <prefcondnr> follow.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 * BY_FLAGS2: End of word, <flags> and <flags2>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 * follow. Not used in PREFIXTREE.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 * BY_INDEX: Child of sibling is shared, <nodeidx>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 * and <xbyte> follow.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 * <nodeidx> 3 bytes Index of child for this sibling, MSB first.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 * <xbyte> 1 byte byte value of the sibling.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 * <flags> 1 byte bitmask of:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 * WF_ALLCAP word must have only capitals
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 * WF_ONECAP first char of word must be capital
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 * WF_KEEPCAP keep-case word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 * WF_FIXCAP keep-case word, all caps not allowed
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 * WF_RARE rare word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 * WF_BANNED bad word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 * WF_REGION <region> follows
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 * WF_AFX <affixID> follows
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 * <flags2> 1 byte Bitmask of:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 * WF_HAS_AFF >> 8 word includes affix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 * WF_NEEDCOMP >> 8 word only valid in compound
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 * WF_NOSUGGEST >> 8 word not used for suggestions
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 * WF_COMPROOT >> 8 word already a compound
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 * WF_NOCOMPBEF >> 8 no compounding before this word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 * WF_NOCOMPAFT >> 8 no compounding after this word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 * <pflags> 1 byte bitmask of:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 * WFP_RARE rare prefix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198 * WFP_NC non-combining prefix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199 * WFP_UP letter after prefix made upper case
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 * <region> 1 byte Bitmask for regions in which word is valid. When
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 * omitted it's valid in all regions.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 * Lowest bit is for region 1.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 * <affixID> 1 byte ID of affix that can be used with this word. In
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 * PREFIXTREE used for the required prefix ID.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 * <prefcondnr> 2 bytes Prefix condition number, index in <prefcond> list
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 * from HEADER.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 * All text characters are in 'encoding', but stored as single bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 * Vim .sug file format: <SUGHEADER>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 * <SUGWORDTREE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 * <SUGTABLE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 * <SUGHEADER>: <fileID> <versionnr> <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 * <fileID> 6 bytes "VIMsug"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 * <versionnr> 1 byte VIMSUGVERSION
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 * <timestamp> 8 bytes timestamp that must match with .spl file
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 * <SUGWORDTREE>: <wordtree> (see above, no flags or region used)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 * <SUGTABLE>: <sugwcount> <sugline> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 * <sugwcount> 4 bytes number of <sugline> following
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 * <sugline>: <sugnr> ... NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 * <sugnr>: X bytes word number that results in this soundfolded word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 * stored as an offset to the previous number in as
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 * few bytes as possible, see offset2bytes())
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240 #include "vim.h"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242 #if defined(FEAT_SPELL) || defined(PROTO)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244 #ifndef UNIX /* it's in os_unix.h for Unix */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245 # include <time.h> /* for time_t */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 #ifndef UNIX /* it's in os_unix.h for Unix */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 # include <time.h> /* for time_t */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 /* Special byte values for <byte>. Some are only used in the tree for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253 * postponed prefixes, some only in the other trees. This is a bit messy... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254 #define BY_NOFLAGS 0 /* end of word without flags or region; for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 * postponed prefix: no <pflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256 #define BY_INDEX 1 /* child is shared, index follows */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257 #define BY_FLAGS 2 /* end of word, <flags> byte follows; for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
258 * postponed prefix: <pflags> follows */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
259 #define BY_FLAGS2 3 /* end of word, <flags> and <flags2> bytes
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260 * follow; never used in prefix tree */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 #define BY_SPECIAL BY_FLAGS2 /* highest special byte value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 /* Flags used in .spl file for soundsalike flags. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 #define SAL_F0LLOWUP 1
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 #define SAL_COLLAPSE 2
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 #define SAL_REM_ACCENTS 4
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 #define VIMSPELLMAGIC "VIMspell" /* string at start of Vim spell file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
269 #define VIMSPELLMAGICL 8
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
270 #define VIMSPELLVERSION 50
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272 /* Section IDs. Only renumber them when VIMSPELLVERSION changes! */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 #define SN_REGION 0 /* <regionname> section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
274 #define SN_CHARFLAGS 1 /* charflags section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
275 #define SN_MIDWORD 2 /* <midword> section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 #define SN_PREFCOND 3 /* <prefcond> section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 #define SN_REP 4 /* REP items section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278 #define SN_SAL 5 /* SAL items section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
279 #define SN_SOFO 6 /* soundfolding section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280 #define SN_MAP 7 /* MAP items section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281 #define SN_COMPOUND 8 /* compound words section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282 #define SN_SYLLABLE 9 /* syllable section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 #define SN_NOBREAK 10 /* NOBREAK section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
284 #define SN_SUGFILE 11 /* timestamp for .sug file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
285 #define SN_REPSAL 12 /* REPSAL items section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
286 #define SN_WORDS 13 /* common words */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
287 #define SN_NOSPLITSUGS 14 /* don't split word for suggestions */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
288 #define SN_INFO 15 /* info section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
289 #define SN_NOCOMPOUNDSUGS 16 /* don't compound for suggestions */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
290 #define SN_END 255 /* end of sections */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
291
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292 #define SNF_REQUIRED 1 /* <sectionflags>: required section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 #define CF_WORD 0x01
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295 #define CF_UPPER 0x02
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 static int set_spell_finish(spelltab_T *new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298 static int write_spell_prefcond(FILE *fd, garray_T *gap);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 static char_u *read_cnt_string(FILE *fd, int cnt_bytes, int *lenp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300 static int read_region_section(FILE *fd, slang_T *slang, int len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 static int read_charflags_section(FILE *fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 static int read_prefcond_section(FILE *fd, slang_T *lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 static int read_rep_section(FILE *fd, garray_T *gap, short *first);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304 static int read_sal_section(FILE *fd, slang_T *slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305 static int read_words_section(FILE *fd, slang_T *lp, int len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306 static int read_sofo_section(FILE *fd, slang_T *slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307 static int read_compound(FILE *fd, slang_T *slang, int len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
308 static int set_sofo(slang_T *lp, char_u *from, char_u *to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
309 static void set_sal_first(slang_T *lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 static int *mb_str2wide(char_u *s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
312 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 static int spell_read_tree(FILE *fd, char_u **bytsp, idx_T **idxsp, int prefixtree, int prefixcnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 static idx_T read_tree_node(FILE *fd, char_u *byts, idx_T *idxs, int maxidx, idx_T startidx, int prefixtree, int maxprefcondnr);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315 static void spell_reload_one(char_u *fname, int added_word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316 static void set_spell_charflags(char_u *flags, int cnt, char_u *upp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317 static int set_spell_chartab(char_u *fol, char_u *low, char_u *upp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318 static void set_map_str(slang_T *lp, char_u *map);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
320
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321 static char *e_spell_trunc = N_("E758: Truncated spell file");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322 static char *e_afftrailing = N_("Trailing text in %s line %d: %s");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323 static char *e_affname = N_("Affix name too long in %s line %d: %s");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 static char *e_affform = N_("E761: Format error in affix file FOL, LOW or UPP");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325 static char *e_affrange = N_("E762: Character in FOL, LOW or UPP is out of range");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326 static char *msg_compressing = N_("Compressing word tree...");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 * Load one spell file and store the info into a slang_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
331 * This is invoked in three ways:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332 * - From spell_load_cb() to load a spell file for the first time. "lang" is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333 * the language name, "old_lp" is NULL. Will allocate an slang_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334 * - To reload a spell file that was changed. "lang" is NULL and "old_lp"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335 * points to the existing slang_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 * - Just after writing a .spl file; it's read back to produce the .sug file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337 * "old_lp" is NULL and "lang" is NULL. Will allocate an slang_T.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
338 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
339 * Returns the slang_T the spell file was loaded into. NULL for error.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 slang_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 spell_load_file(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343 char_u *fname,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
344 char_u *lang,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 slang_T *old_lp,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 int silent) /* no error if file doesn't exist */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
347 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 char_u buf[VIMSPELLMAGICL];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 char_u *save_sourcing_name = sourcing_name;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 linenr_T save_sourcing_lnum = sourcing_lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 slang_T *lp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 int c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 int res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 if (!silent)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365 else if (p_verbose > 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
366 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 verbose_enter();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 smsg((char_u *)e_notopen, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 verbose_leave();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373 if (p_verbose > 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
374 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375 verbose_enter();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
376 smsg((char_u *)_("Reading spell file \"%s\""), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377 verbose_leave();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380 if (old_lp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 lp = slang_alloc(lang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383 if (lp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 /* Remember the file name, used to reload the file when it's updated. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387 lp->sl_fname = vim_strsave(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388 if (lp->sl_fname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
391 /* Check for .add.spl (_add.spl for VMS). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
392 lp->sl_add = strstr((char *)gettail(fname), SPL_FNAME_ADD) != NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395 lp = old_lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 /* Set sourcing_name, so that error messages mention the file name. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 sourcing_name = fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 sourcing_lnum = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 * <HEADER>: <fileID>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
404 for (i = 0; i < VIMSPELLMAGICL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 buf[i] = getc(fd); /* <fileID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 if (STRNCMP(buf, VIMSPELLMAGIC, VIMSPELLMAGICL) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 EMSG(_("E757: This does not look like a spell file"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
409 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
410 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
411 c = getc(fd); /* <versionnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412 if (c < VIMSPELLVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 EMSG(_("E771: Old spell file, needs to be updated"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417 else if (c > VIMSPELLVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
418 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 EMSG(_("E772: Spell file is for newer version of Vim"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
422
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 * <SECTIONS>: <section> ... <sectionend>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 * <section>: <sectionID> <sectionflags> <sectionlen> (section contents)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 for (;;)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
429 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430 n = getc(fd); /* <sectionID> or <sectionend> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431 if (n == SN_END)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
433 c = getc(fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
434 len = get4c(fd); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
435 if (len < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436 goto truncerr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
437
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
438 res = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439 switch (n)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
440 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441 case SN_INFO:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 lp->sl_info = read_string(fd, len); /* <infotext> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443 if (lp->sl_info == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447 case SN_REGION:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
448 res = read_region_section(fd, lp, len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
449 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
450
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
451 case SN_CHARFLAGS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
452 res = read_charflags_section(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
455 case SN_MIDWORD:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
456 lp->sl_midword = read_string(fd, len); /* <midword> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
457 if (lp->sl_midword == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
461 case SN_PREFCOND:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
462 res = read_prefcond_section(fd, lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
463 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
464
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
465 case SN_REP:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
466 res = read_rep_section(fd, &lp->sl_rep, lp->sl_rep_first);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
467 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
468
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469 case SN_REPSAL:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470 res = read_rep_section(fd, &lp->sl_repsal, lp->sl_repsal_first);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
472
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
473 case SN_SAL:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
474 res = read_sal_section(fd, lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
475 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477 case SN_SOFO:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 res = read_sofo_section(fd, lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
481 case SN_MAP:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
482 p = read_string(fd, len); /* <mapstr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
483 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
485 set_map_str(lp, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486 vim_free(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
488
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
489 case SN_WORDS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
490 res = read_words_section(fd, lp, len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
491 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
493 case SN_SUGFILE:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494 lp->sl_sugtime = get8ctime(fd); /* <timestamp> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
495 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
496
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
497 case SN_NOSPLITSUGS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
498 lp->sl_nosplitsugs = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
499 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
500
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
501 case SN_NOCOMPOUNDSUGS:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
502 lp->sl_nocompoundsugs = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
503 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
504
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
505 case SN_COMPOUND:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
506 res = read_compound(fd, lp, len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
507 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
508
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
509 case SN_NOBREAK:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
510 lp->sl_nobreak = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
511 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
512
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
513 case SN_SYLLABLE:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
514 lp->sl_syllable = read_string(fd, len); /* <syllable> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
515 if (lp->sl_syllable == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
516 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
517 if (init_syl_tab(lp) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
518 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
519 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
520
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
521 default:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
522 /* Unsupported section. When it's required give an error
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
523 * message. When it's not required skip the contents. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
524 if (c & SNF_REQUIRED)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
525 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
526 EMSG(_("E770: Unsupported section in spell file"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
527 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529 while (--len >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530 if (getc(fd) < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531 goto truncerr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
533 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534 someerror:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
535 if (res == SP_FORMERROR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
536 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
537 EMSG(_(e_format));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
538 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
539 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
540 if (res == SP_TRUNCERROR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
541 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
542 truncerr:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
543 EMSG(_(e_spell_trunc));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546 if (res == SP_OTHERERROR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
547 goto endFAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
548 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
549
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
550 /* <LWORDTREE> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
551 res = spell_read_tree(fd, &lp->sl_fbyts, &lp->sl_fidxs, FALSE, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552 if (res != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
554
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555 /* <KWORDTREE> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
556 res = spell_read_tree(fd, &lp->sl_kbyts, &lp->sl_kidxs, FALSE, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
557 if (res != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
558 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
559
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
560 /* <PREFIXTREE> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
561 res = spell_read_tree(fd, &lp->sl_pbyts, &lp->sl_pidxs, TRUE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
562 lp->sl_prefixcnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
563 if (res != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
564 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
565
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
566 /* For a new file link it in the list of spell files. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
567 if (old_lp == NULL && lang != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
568 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
569 lp->sl_next = first_lang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
570 first_lang = lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
571 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
572
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573 goto endOK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
574
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 endFAIL:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
576 if (lang != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577 /* truncating the name signals the error to spell_load_lang() */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 *lang = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579 if (lp != NULL && old_lp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
580 slang_free(lp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
581 lp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583 endOK:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
585 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
586 sourcing_name = save_sourcing_name;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
587 sourcing_lnum = save_sourcing_lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
588
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
589 return lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
590 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
591
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
592 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593 * Fill in the wordcount fields for a trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
594 * Returns the total number of words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
596 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
597 tree_count_words(char_u *byts, idx_T *idxs)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
598 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
599 int depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
600 idx_T arridx[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
601 int curi[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
602 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603 idx_T n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
604 int wordcount[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
605
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 arridx[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607 curi[0] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608 wordcount[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609 depth = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 while (depth >= 0 && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612 if (curi[depth] > byts[arridx[depth]])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
613 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
614 /* Done all bytes at this node, go up one level. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
615 idxs[arridx[depth]] = wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
616 if (depth > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
617 wordcount[depth - 1] += wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
618
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
619 --depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
620 fast_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
621 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
622 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
623 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
624 /* Do one more byte at this node. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
625 n = arridx[depth] + curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
626 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
627
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
628 c = byts[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629 if (c == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
631 /* End of word, count it. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
632 ++wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
633
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
634 /* Skip over any other NUL bytes (same word with different
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
635 * flags). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
636 while (byts[n + 1] == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
637 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
638 ++n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
639 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
640 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
641 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
642 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
643 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
644 /* Normal char, go one level deeper to count the words. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
645 ++depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
646 arridx[depth] = idxs[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
647 curi[depth] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
648 wordcount[depth] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
649 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
650 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
651 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
652 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
653
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
654 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
655 * Load the .sug files for languages that have one and weren't loaded yet.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
656 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
657 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
658 suggest_load_files(void)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
659 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
660 langp_T *lp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
661 int lpi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
662 slang_T *slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
663 char_u *dotp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
664 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
665 char_u buf[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
666 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
667 time_t timestamp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
668 int wcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
669 int wordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
670 garray_T ga;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
671 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
672
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
673 /* Do this for all languages that support sound folding. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
674 for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
675 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
676 lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
677 slang = lp->lp_slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
678 if (slang->sl_sugtime != 0 && !slang->sl_sugloaded)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
679 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
680 /* Change ".spl" to ".sug" and open the file. When the file isn't
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
681 * found silently skip it. Do set "sl_sugloaded" so that we
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
682 * don't try again and again. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
683 slang->sl_sugloaded = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
684
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
685 dotp = vim_strrchr(slang->sl_fname, '.');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
686 if (dotp == NULL || fnamecmp(dotp, ".spl") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
687 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
688 STRCPY(dotp, ".sug");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
689 fd = mch_fopen((char *)slang->sl_fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
690 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
691 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
692
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
693 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
694 * <SUGHEADER>: <fileID> <versionnr> <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
695 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
696 for (i = 0; i < VIMSUGMAGICL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
697 buf[i] = getc(fd); /* <fileID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
698 if (STRNCMP(buf, VIMSUGMAGIC, VIMSUGMAGICL) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
699 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
700 EMSG2(_("E778: This does not look like a .sug file: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
701 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
702 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
703 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
704 c = getc(fd); /* <versionnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
705 if (c < VIMSUGVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
706 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
707 EMSG2(_("E779: Old .sug file, needs to be updated: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
708 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
709 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
710 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
711 else if (c > VIMSUGVERSION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
712 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
713 EMSG2(_("E780: .sug file is for newer version of Vim: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
715 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
716 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
717
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
718 /* Check the timestamp, it must be exactly the same as the one in
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
719 * the .spl file. Otherwise the word numbers won't match. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
720 timestamp = get8ctime(fd); /* <timestamp> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
721 if (timestamp != slang->sl_sugtime)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
722 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
723 EMSG2(_("E781: .sug file doesn't match .spl file: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
724 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
725 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
726 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
727
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
728 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
729 * <SUGWORDTREE>: <wordtree>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
730 * Read the trie with the soundfolded words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
731 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
732 if (spell_read_tree(fd, &slang->sl_sbyts, &slang->sl_sidxs,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
733 FALSE, 0) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
734 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
735 someerror:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
736 EMSG2(_("E782: error while reading .sug file: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
737 slang->sl_fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
738 slang_clear_sug(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
739 goto nextone;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
740 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
741
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
742 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
743 * <SUGTABLE>: <sugwcount> <sugline> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
744 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
745 * Read the table with word numbers. We use a file buffer for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
746 * this, because it's so much like a file with lines. Makes it
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
747 * possible to swap the info and save on memory use.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
748 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
749 slang->sl_sugbuf = open_spellbuf();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
750 if (slang->sl_sugbuf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
751 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
752 /* <sugwcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
753 wcount = get4c(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
754 if (wcount < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
755 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
757 /* Read all the wordnr lists into the buffer, one NUL terminated
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
758 * list per line. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
759 ga_init2(&ga, 1, 100);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
760 for (wordnr = 0; wordnr < wcount; ++wordnr)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
761 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
762 ga.ga_len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
763 for (;;)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
764 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
765 c = getc(fd); /* <sugline> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
766 if (c < 0 || ga_grow(&ga, 1) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
767 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
768 ((char_u *)ga.ga_data)[ga.ga_len++] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
769 if (c == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
770 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
771 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
772 if (ml_append_buf(slang->sl_sugbuf, (linenr_T)wordnr,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
773 ga.ga_data, ga.ga_len, TRUE) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
774 goto someerror;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
775 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
776 ga_clear(&ga);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
777
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
778 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
779 * Need to put word counts in the word tries, so that we can find
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
780 * a word by its number.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
781 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
782 tree_count_words(slang->sl_fbyts, slang->sl_fidxs);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
783 tree_count_words(slang->sl_sbyts, slang->sl_sidxs);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
784
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
785 nextone:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
786 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
787 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
788 STRCPY(dotp, ".spl");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
789 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
790 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
791 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
792
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
793
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
794 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
795 * Read a length field from "fd" in "cnt_bytes" bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
796 * Allocate memory, read the string into it and add a NUL at the end.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
797 * Returns NULL when the count is zero.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
798 * Sets "*cntp" to SP_*ERROR when there is an error, length of the result
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
799 * otherwise.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
800 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
801 static char_u *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
802 read_cnt_string(FILE *fd, int cnt_bytes, int *cntp)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
803 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
804 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
805 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
806 char_u *str;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
807
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
808 /* read the length bytes, MSB first */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
809 for (i = 0; i < cnt_bytes; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
810 cnt = (cnt << 8) + getc(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
811 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
812 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
813 *cntp = SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
814 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
815 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
816 *cntp = cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
817 if (cnt == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
818 return NULL; /* nothing to read, return NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
819
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
820 str = read_string(fd, cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
821 if (str == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
822 *cntp = SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
823 return str;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
824 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
825
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
826 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
827 * Read SN_REGION: <regionname> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
828 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
829 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
830 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
831 read_region_section(FILE *fd, slang_T *lp, int len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
832 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
833 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
834
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
835 if (len > 16)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
836 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
837 for (i = 0; i < len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
838 lp->sl_regions[i] = getc(fd); /* <regionname> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
839 lp->sl_regions[len] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
840 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
841 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
842
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
843 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
844 * Read SN_CHARFLAGS section: <charflagslen> <charflags>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
845 * <folcharslen> <folchars>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
846 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
847 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
848 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
849 read_charflags_section(FILE *fd)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
850 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
851 char_u *flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
852 char_u *fol;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
853 int flagslen, follen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
854
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
855 /* <charflagslen> <charflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
856 flags = read_cnt_string(fd, 1, &flagslen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
857 if (flagslen < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
858 return flagslen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
859
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
860 /* <folcharslen> <folchars> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
861 fol = read_cnt_string(fd, 2, &follen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
862 if (follen < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
863 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
864 vim_free(flags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
865 return follen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
866 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
867
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
868 /* Set the word-char flags and fill SPELL_ISUPPER() table. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
869 if (flags != NULL && fol != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
870 set_spell_charflags(flags, flagslen, fol);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
871
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
872 vim_free(flags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
873 vim_free(fol);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
874
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
875 /* When <charflagslen> is zero then <fcharlen> must also be zero. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
876 if ((flags == NULL) != (fol == NULL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
877 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
878 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
879 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
880
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
881 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
882 * Read SN_PREFCOND section.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
883 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
884 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
885 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
886 read_prefcond_section(FILE *fd, slang_T *lp)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
887 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
888 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
889 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
890 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
891 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
892 char_u buf[MAXWLEN + 1];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
893
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
894 /* <prefcondcnt> <prefcond> ... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
895 cnt = get2c(fd); /* <prefcondcnt> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
896 if (cnt <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
897 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
898
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
899 lp->sl_prefprog = (regprog_T **)alloc_clear(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
900 (unsigned)sizeof(regprog_T *) * cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
901 if (lp->sl_prefprog == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
902 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
903 lp->sl_prefixcnt = cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
904
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
905 for (i = 0; i < cnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
906 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
907 /* <prefcond> : <condlen> <condstr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
908 n = getc(fd); /* <condlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
909 if (n < 0 || n >= MAXWLEN)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
910 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
911
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
912 /* When <condlen> is zero we have an empty condition. Otherwise
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
913 * compile the regexp program used to check for the condition. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
914 if (n > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
915 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
916 buf[0] = '^'; /* always match at one position only */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
917 p = buf + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
918 while (n-- > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
919 *p++ = getc(fd); /* <condstr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
920 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
921 lp->sl_prefprog[i] = vim_regcomp(buf, RE_MAGIC + RE_STRING);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
922 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
923 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
924 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
925 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
926
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
927 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
928 * Read REP or REPSAL items section from "fd": <repcount> <rep> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
929 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
930 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
931 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
932 read_rep_section(FILE *fd, garray_T *gap, short *first)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
933 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
934 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
935 fromto_T *ftp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
936 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
937
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
938 cnt = get2c(fd); /* <repcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
939 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
940 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
941
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
942 if (ga_grow(gap, cnt) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
943 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
944
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
945 /* <rep> : <repfromlen> <repfrom> <reptolen> <repto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
946 for (; gap->ga_len < cnt; ++gap->ga_len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
947 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
948 ftp = &((fromto_T *)gap->ga_data)[gap->ga_len];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
949 ftp->ft_from = read_cnt_string(fd, 1, &i);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
950 if (i < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
951 return i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
952 if (i == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
953 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
954 ftp->ft_to = read_cnt_string(fd, 1, &i);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
955 if (i <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
956 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
957 vim_free(ftp->ft_from);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
958 if (i < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
959 return i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
960 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
961 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
962 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
963
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
964 /* Fill the first-index table. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
965 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
966 first[i] = -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
967 for (i = 0; i < gap->ga_len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
968 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
969 ftp = &((fromto_T *)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
970 if (first[*ftp->ft_from] == -1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
971 first[*ftp->ft_from] = i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
972 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
973 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
974 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
975
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
976 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
977 * Read SN_SAL section: <salflags> <salcount> <sal> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
978 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
979 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
980 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
981 read_sal_section(FILE *fd, slang_T *slang)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
982 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
983 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
984 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
985 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
986 salitem_T *smp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
987 int ccnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
988 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
989 int c = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
990
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
991 slang->sl_sofo = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
992
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
993 i = getc(fd); /* <salflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
994 if (i & SAL_F0LLOWUP)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
995 slang->sl_followup = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
996 if (i & SAL_COLLAPSE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
997 slang->sl_collapse = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
998 if (i & SAL_REM_ACCENTS)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
999 slang->sl_rem_accents = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1000
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1001 cnt = get2c(fd); /* <salcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1002 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1003 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1004
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1005 gap = &slang->sl_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1006 ga_init2(gap, sizeof(salitem_T), 10);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1007 if (ga_grow(gap, cnt + 1) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1008 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1009
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1010 /* <sal> : <salfromlen> <salfrom> <saltolen> <salto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1011 for (; gap->ga_len < cnt; ++gap->ga_len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1012 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1013 smp = &((salitem_T *)gap->ga_data)[gap->ga_len];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1014 ccnt = getc(fd); /* <salfromlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1015 if (ccnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1016 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1017 if ((p = alloc(ccnt + 2)) == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1018 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1019 smp->sm_lead = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1020
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1021 /* Read up to the first special char into sm_lead. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1022 for (i = 0; i < ccnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1023 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1024 c = getc(fd); /* <salfrom> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1025 if (vim_strchr((char_u *)"0123456789(-<^$", c) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1026 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1027 *p++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1028 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1029 smp->sm_leadlen = (int)(p - smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1030 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1031
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1032 /* Put (abc) chars in sm_oneof, if any. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1033 if (c == '(')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1034 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1035 smp->sm_oneof = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1036 for (++i; i < ccnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1037 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1038 c = getc(fd); /* <salfrom> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1039 if (c == ')')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1040 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1041 *p++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1042 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1043 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1044 if (++i < ccnt)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1045 c = getc(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1046 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1047 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1048 smp->sm_oneof = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1049
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1050 /* Any following chars go in sm_rules. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1051 smp->sm_rules = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1052 if (i < ccnt)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1053 /* store the char we got while checking for end of sm_lead */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1054 *p++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1055 for (++i; i < ccnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1056 *p++ = getc(fd); /* <salfrom> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1057 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1058
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1059 /* <saltolen> <salto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1060 smp->sm_to = read_cnt_string(fd, 1, &ccnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1061 if (ccnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1062 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1063 vim_free(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1064 return ccnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1065 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1066
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1067 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1068 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1069 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1070 /* convert the multi-byte strings to wide char strings */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1071 smp->sm_lead_w = mb_str2wide(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1072 smp->sm_leadlen = mb_charlen(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1073 if (smp->sm_oneof == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1074 smp->sm_oneof_w = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1075 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1076 smp->sm_oneof_w = mb_str2wide(smp->sm_oneof);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1077 if (smp->sm_to == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1078 smp->sm_to_w = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1079 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1080 smp->sm_to_w = mb_str2wide(smp->sm_to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1081 if (smp->sm_lead_w == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1082 || (smp->sm_oneof_w == NULL && smp->sm_oneof != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1083 || (smp->sm_to_w == NULL && smp->sm_to != NULL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1084 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1085 vim_free(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1086 vim_free(smp->sm_to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1087 vim_free(smp->sm_lead_w);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1088 vim_free(smp->sm_oneof_w);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1089 vim_free(smp->sm_to_w);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1090 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1091 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1092 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1093 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1094 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1095
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1096 if (gap->ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1097 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1098 /* Add one extra entry to mark the end with an empty sm_lead. Avoids
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1099 * that we need to check the index every time. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1100 smp = &((salitem_T *)gap->ga_data)[gap->ga_len];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1101 if ((p = alloc(1)) == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1102 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1103 p[0] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1104 smp->sm_lead = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1105 smp->sm_leadlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1106 smp->sm_oneof = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1107 smp->sm_rules = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1108 smp->sm_to = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1109 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1110 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1111 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1112 smp->sm_lead_w = mb_str2wide(smp->sm_lead);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1113 smp->sm_leadlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1114 smp->sm_oneof_w = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1115 smp->sm_to_w = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1116 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1117 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1118 ++gap->ga_len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1119 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1120
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1121 /* Fill the first-index table. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1122 set_sal_first(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1123
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1124 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1125 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1126
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1127 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1128 * Read SN_WORDS: <word> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1129 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1130 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1131 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1132 read_words_section(FILE *fd, slang_T *lp, int len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1133 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1134 int done = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1135 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1136 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1137 char_u word[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1138
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1139 while (done < len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1140 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1141 /* Read one word at a time. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1142 for (i = 0; ; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1143 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1144 c = getc(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1145 if (c == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1146 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1147 word[i] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1148 if (word[i] == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1149 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1150 if (i == MAXWLEN - 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1151 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1152 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1153
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1154 /* Init the count to 10. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1155 count_common_word(lp, word, -1, 10);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1156 done += i + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1157 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1158 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1159 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1160
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1161 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1162 * SN_SOFO: <sofofromlen> <sofofrom> <sofotolen> <sofoto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1163 * Return SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1164 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1165 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1166 read_sofo_section(FILE *fd, slang_T *slang)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1167 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1168 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1169 char_u *from, *to;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1170 int res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1171
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1172 slang->sl_sofo = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1173
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1174 /* <sofofromlen> <sofofrom> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1175 from = read_cnt_string(fd, 2, &cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1176 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1177 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1178
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1179 /* <sofotolen> <sofoto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1180 to = read_cnt_string(fd, 2, &cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1181 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1182 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1183 vim_free(from);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1184 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1185 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1186
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1187 /* Store the info in slang->sl_sal and/or slang->sl_sal_first. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1188 if (from != NULL && to != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1189 res = set_sofo(slang, from, to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1190 else if (from != NULL || to != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1191 res = SP_FORMERROR; /* only one of two strings is an error */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1192 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1193 res = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1194
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1195 vim_free(from);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1196 vim_free(to);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1197 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1198 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1199
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1200 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1201 * Read the compound section from the .spl file:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1202 * <compmax> <compminlen> <compsylmax> <compoptions> <compflags>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1203 * Returns SP_*ERROR flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1204 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1205 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1206 read_compound(FILE *fd, slang_T *slang, int len)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1207 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1208 int todo = len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1209 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1210 int atstart;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1211 char_u *pat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1212 char_u *pp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1213 char_u *cp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1214 char_u *ap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1215 char_u *crp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1216 int cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1217 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1218
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1219 if (todo < 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1220 return SP_FORMERROR; /* need at least two bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1221
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1222 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1223 c = getc(fd); /* <compmax> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1224 if (c < 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1225 c = MAXWLEN;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1226 slang->sl_compmax = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1227
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1228 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1229 c = getc(fd); /* <compminlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1230 if (c < 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1231 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1232 slang->sl_compminlen = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1233
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1234 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1235 c = getc(fd); /* <compsylmax> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1236 if (c < 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1237 c = MAXWLEN;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1238 slang->sl_compsylmax = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1239
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1240 c = getc(fd); /* <compoptions> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1241 if (c != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1242 ungetc(c, fd); /* be backwards compatible with Vim 7.0b */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1243 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1244 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1245 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1246 c = getc(fd); /* only use the lower byte for now */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1247 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1248 slang->sl_compoptions = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1249
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1250 gap = &slang->sl_comppat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1251 c = get2c(fd); /* <comppatcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1252 todo -= 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1253 ga_init2(gap, sizeof(char_u *), c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1254 if (ga_grow(gap, c) == OK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1255 while (--c >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1256 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1257 ((char_u **)(gap->ga_data))[gap->ga_len++] =
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1258 read_cnt_string(fd, 1, &cnt);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1259 /* <comppatlen> <comppattext> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1260 if (cnt < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1261 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1262 todo -= cnt + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1263 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1264 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1265 if (todo < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1266 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1267
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1268 /* Turn the COMPOUNDRULE items into a regexp pattern:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1269 * "a[bc]/a*b+" -> "^\(a[bc]\|a*b\+\)$".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1270 * Inserting backslashes may double the length, "^\(\)$<Nul>" is 7 bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1271 * Conversion to utf-8 may double the size. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1272 c = todo * 2 + 7;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1273 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1274 if (enc_utf8)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1275 c += todo * 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1276 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1277 pat = alloc((unsigned)c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1278 if (pat == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1279 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1280
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1281 /* We also need a list of all flags that can appear at the start and one
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1282 * for all flags. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1283 cp = alloc(todo + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1284 if (cp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1285 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1286 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1287 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1288 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1289 slang->sl_compstartflags = cp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1290 *cp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1291
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1292 ap = alloc(todo + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1293 if (ap == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1294 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1295 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1296 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1297 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1298 slang->sl_compallflags = ap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1299 *ap = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1300
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1301 /* And a list of all patterns in their original form, for checking whether
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1302 * compounding may work in match_compoundrule(). This is freed when we
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1303 * encounter a wildcard, the check doesn't work then. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1304 crp = alloc(todo + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1305 slang->sl_comprules = crp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1306
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1307 pp = pat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1308 *pp++ = '^';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1309 *pp++ = '\\';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1310 *pp++ = '(';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1311
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1312 atstart = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1313 while (todo-- > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1314 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1315 c = getc(fd); /* <compflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1316 if (c == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1317 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1318 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1319 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1320 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1321
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1322 /* Add all flags to "sl_compallflags". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1323 if (vim_strchr((char_u *)"?*+[]/", c) == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1324 && !byte_in_str(slang->sl_compallflags, c))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1325 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1326 *ap++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1327 *ap = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1328 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1329
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1330 if (atstart != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1331 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1332 /* At start of item: copy flags to "sl_compstartflags". For a
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1333 * [abc] item set "atstart" to 2 and copy up to the ']'. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1334 if (c == '[')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1335 atstart = 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1336 else if (c == ']')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1337 atstart = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1338 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1339 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1340 if (!byte_in_str(slang->sl_compstartflags, c))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1341 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1342 *cp++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1343 *cp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1344 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1345 if (atstart == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1346 atstart = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1347 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1348 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1349
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1350 /* Copy flag to "sl_comprules", unless we run into a wildcard. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1351 if (crp != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1352 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1353 if (c == '?' || c == '+' || c == '*')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1354 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1355 vim_free(slang->sl_comprules);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1356 slang->sl_comprules = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1357 crp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1358 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1359 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1360 *crp++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1361 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1362
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1363 if (c == '/') /* slash separates two items */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1364 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1365 *pp++ = '\\';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1366 *pp++ = '|';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1367 atstart = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1368 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1369 else /* normal char, "[abc]" and '*' are copied as-is */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1370 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1371 if (c == '?' || c == '+' || c == '~')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1372 *pp++ = '\\'; /* "a?" becomes "a\?", "a+" becomes "a\+" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1373 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1374 if (enc_utf8)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1375 pp += mb_char2bytes(c, pp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1376 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1377 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1378 *pp++ = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1379 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1380 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1381
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1382 *pp++ = '\\';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1383 *pp++ = ')';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1384 *pp++ = '$';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1385 *pp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1386
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1387 if (crp != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1388 *crp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1389
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1390 slang->sl_compprog = vim_regcomp(pat, RE_MAGIC + RE_STRING + RE_STRICT);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1391 vim_free(pat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1392 if (slang->sl_compprog == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1393 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1394
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1395 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1396 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1397
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1398 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1399 * Set the SOFOFROM and SOFOTO items in language "lp".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1400 * Returns SP_*ERROR flags when there is something wrong.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1401 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1402 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1403 set_sofo(slang_T *lp, char_u *from, char_u *to)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1404 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1405 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1406
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1407 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1408 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1409 char_u *s;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1410 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1411 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1412 int *inp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1413
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1414 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1415 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1416 /* Use "sl_sal" as an array with 256 pointers to a list of wide
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1417 * characters. The index is the low byte of the character.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1418 * The list contains from-to pairs with a terminating NUL.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1419 * sl_sal_first[] is used for latin1 "from" characters. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1420 gap = &lp->sl_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1421 ga_init2(gap, sizeof(int *), 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1422 if (ga_grow(gap, 256) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1423 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1424 vim_memset(gap->ga_data, 0, sizeof(int *) * 256);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1425 gap->ga_len = 256;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1426
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1427 /* First count the number of items for each list. Temporarily use
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1428 * sl_sal_first[] for this. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1429 for (p = from, s = to; *p != NUL && *s != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1430 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1431 c = mb_cptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1432 mb_cptr_adv(s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1433 if (c >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1434 ++lp->sl_sal_first[c & 0xff];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1435 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1436 if (*p != NUL || *s != NUL) /* lengths differ */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1437 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1438
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1439 /* Allocate the lists. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1440 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1441 if (lp->sl_sal_first[i] > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1442 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1443 p = alloc(sizeof(int) * (lp->sl_sal_first[i] * 2 + 1));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1444 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1445 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1446 ((int **)gap->ga_data)[i] = (int *)p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1447 *(int *)p = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1448 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1449
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1450 /* Put the characters up to 255 in sl_sal_first[] the rest in a sl_sal
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1451 * list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1452 vim_memset(lp->sl_sal_first, 0, sizeof(salfirst_T) * 256);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1453 for (p = from, s = to; *p != NUL && *s != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1454 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1455 c = mb_cptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1456 i = mb_cptr2char_adv(&s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1457 if (c >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1458 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1459 /* Append the from-to chars at the end of the list with
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1460 * the low byte. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1461 inp = ((int **)gap->ga_data)[c & 0xff];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1462 while (*inp != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1463 ++inp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1464 *inp++ = c; /* from char */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1465 *inp++ = i; /* to char */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1466 *inp++ = NUL; /* NUL at the end */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1467 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1468 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1469 /* mapping byte to char is done in sl_sal_first[] */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1470 lp->sl_sal_first[c] = i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1471 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1472 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1473 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1474 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1475 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1476 /* mapping bytes to bytes is done in sl_sal_first[] */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1477 if (STRLEN(from) != STRLEN(to))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1478 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1479
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1480 for (i = 0; to[i] != NUL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1481 lp->sl_sal_first[from[i]] = to[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1482 lp->sl_sal.ga_len = 1; /* indicates we have soundfolding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1483 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1484
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1485 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1486 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1487
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1488 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1489 * Fill the first-index table for "lp".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1490 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1491 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1492 set_sal_first(slang_T *lp)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1493 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1494 salfirst_T *sfirst;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1495 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1496 salitem_T *smp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1497 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1498 garray_T *gap = &lp->sl_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1499
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1500 sfirst = lp->sl_sal_first;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1501 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1502 sfirst[i] = -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1503 smp = (salitem_T *)gap->ga_data;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1504 for (i = 0; i < gap->ga_len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1505 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1506 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1507 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1508 /* Use the lowest byte of the first character. For latin1 it's
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1509 * the character, for other encodings it should differ for most
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1510 * characters. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1511 c = *smp[i].sm_lead_w & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1512 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1513 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1514 c = *smp[i].sm_lead;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1515 if (sfirst[c] == -1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1516 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1517 sfirst[c] = i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1518 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1519 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1520 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1521 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1522
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1523 /* Make sure all entries with this byte are following each
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1524 * other. Move the ones that are in the wrong position. Do
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1525 * keep the same ordering! */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1526 while (i + 1 < gap->ga_len
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1527 && (*smp[i + 1].sm_lead_w & 0xff) == c)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1528 /* Skip over entry with same index byte. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1529 ++i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1530
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1531 for (n = 1; i + n < gap->ga_len; ++n)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1532 if ((*smp[i + n].sm_lead_w & 0xff) == c)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1533 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1534 salitem_T tsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1535
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1536 /* Move entry with same index byte after the entries
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1537 * we already found. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1538 ++i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1539 --n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1540 tsal = smp[i + n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1541 mch_memmove(smp + i + 1, smp + i,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1542 sizeof(salitem_T) * n);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1543 smp[i] = tsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1544 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1545 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1546 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1547 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1548 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1549 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1550
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1551 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1552 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1553 * Turn a multi-byte string into a wide character string.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1554 * Return it in allocated memory (NULL for out-of-memory)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1555 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1556 static int *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1557 mb_str2wide(char_u *s)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1558 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1559 int *res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1560 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1561 int i = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1562
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1563 res = (int *)alloc(sizeof(int) * (mb_charlen(s) + 1));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1564 if (res != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1565 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1566 for (p = s; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1567 res[i++] = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1568 res[i] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1569 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1570 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1571 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1572 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1573
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1574 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1575 * Read a tree from the .spl or .sug file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1576 * Allocates the memory and stores pointers in "bytsp" and "idxsp".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1577 * This is skipped when the tree has zero length.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1578 * Returns zero when OK, SP_ value for an error.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1579 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1580 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1581 spell_read_tree(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1582 FILE *fd,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1583 char_u **bytsp,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1584 idx_T **idxsp,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1585 int prefixtree, /* TRUE for the prefix tree */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1586 int prefixcnt) /* when "prefixtree" is TRUE: prefix count */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1587 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1588 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1589 int idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1590 char_u *bp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1591 idx_T *ip;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1592
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1593 /* The tree size was computed when writing the file, so that we can
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1594 * allocate it as one long block. <nodecount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1595 len = get4c(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1596 if (len < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1597 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1598 if (len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1599 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1600 /* Allocate the byte array. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1601 bp = lalloc((long_u)len, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1602 if (bp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1603 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1604 *bytsp = bp;
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 /* Allocate the index array. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1607 ip = (idx_T *)lalloc_clear((long_u)(len * sizeof(int)), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1608 if (ip == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1609 return SP_OTHERERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1610 *idxsp = ip;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1611
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1612 /* Recursively read the tree and store it in the array. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1613 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
1614 if (idx < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1615 return idx;
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 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1618 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1619
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1620 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1621 * 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
1622 * "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
1623 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1624 * 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
1625 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1626 * Returns the index (>= 0) following the siblings.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1627 * 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
1628 * 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
1629 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1630 static idx_T
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1631 read_tree_node(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1632 FILE *fd,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1633 char_u *byts,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1634 idx_T *idxs,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1635 int maxidx, /* size of arrays */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1636 idx_T startidx, /* current index in "byts" and "idxs" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1637 int prefixtree, /* TRUE for reading PREFIXTREE */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1638 int maxprefcondnr) /* maximum for <prefcondnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1639 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1640 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1641 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1642 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1643 idx_T idx = startidx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1644 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1645 int c2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1646 #define SHARED_MASK 0x8000000
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1647
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1648 len = getc(fd); /* <siblingcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1649 if (len <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1650 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1651
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1652 if (startidx + len >= maxidx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1653 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1654 byts[idx++] = len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1655
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1656 /* Read the byte values, flag/region bytes and shared indexes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1657 for (i = 1; i <= len; ++i)
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 c = getc(fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1660 if (c < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1661 return SP_TRUNCERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1662 if (c <= BY_SPECIAL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1663 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1664 if (c == BY_NOFLAGS && !prefixtree)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1665 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1666 /* No flags, all regions. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1667 idxs[idx] = 0;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1670 else if (c != BY_INDEX)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1671 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1672 if (prefixtree)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1673 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1674 /* Read the optional pflags byte, the prefix ID and the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1675 * condition nr. In idxs[] store the prefix ID in the low
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1676 * byte, the condition index shifted up 8 bits, the flags
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1677 * shifted up 24 bits. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1678 if (c == BY_FLAGS)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1679 c = getc(fd) << 24; /* <pflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1680 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1681 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1682
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1683 c |= getc(fd); /* <affixID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1684
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1685 n = get2c(fd); /* <prefcondnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1686 if (n >= maxprefcondnr)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1687 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1688 c |= (n << 8);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1689 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1690 else /* c must be BY_FLAGS or BY_FLAGS2 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1691 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1692 /* Read flags and optional region and prefix ID. In
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1693 * idxs[] the flags go in the low two bytes, region above
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1694 * that and prefix ID above the region. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1695 c2 = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1696 c = getc(fd); /* <flags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1697 if (c2 == BY_FLAGS2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1698 c = (getc(fd) << 8) + c; /* <flags2> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1699 if (c & WF_REGION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1700 c = (getc(fd) << 16) + c; /* <region> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1701 if (c & WF_AFX)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1702 c = (getc(fd) << 24) + c; /* <affixID> */
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 idxs[idx] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1706 c = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1707 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1708 else /* c == BY_INDEX */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1709 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1710 /* <nodeidx> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1711 n = get3c(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1712 if (n < 0 || n >= maxidx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1713 return SP_FORMERROR;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1714 idxs[idx] = n + SHARED_MASK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1715 c = getc(fd); /* <xbyte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1716 }
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 byts[idx++] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1719 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1720
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1721 /* Recursively read the children for non-shared siblings.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1722 * Skip the end-of-word ones (zero byte value) and the shared ones (and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1723 * remove SHARED_MASK) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1724 for (i = 1; i <= len; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1725 if (byts[startidx + i] != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1726 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1727 if (idxs[startidx + i] & SHARED_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1728 idxs[startidx + i] &= ~SHARED_MASK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1729 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1730 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1731 idxs[startidx + i] = idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1732 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
1733 prefixtree, maxprefcondnr);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1734 if (idx < 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1735 break;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1738
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1739 return idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1740 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1741
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1742 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1743 * 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
1744 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1745 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1746 spell_reload_one(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1747 char_u *fname,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1748 int added_word) /* invoked through "zg" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1749 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1750 slang_T *slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1751 int didit = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1752
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1753 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
1754 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1755 if (fullpathcmp(fname, slang->sl_fname, FALSE) == FPC_SAME)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1756 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1757 slang_clear(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1758 if (spell_load_file(fname, NULL, slang, FALSE) == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1759 /* reloading failed, clear the language */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1760 slang_clear(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1761 redraw_all_later(SOME_VALID);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1762 didit = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1763 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1764 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1765
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1766 /* When "zg" was used and the file wasn't loaded yet, should redo
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1767 * 'spelllang' to load it now. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1768 if (added_word && !didit)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1769 did_set_spelllang(curwin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1770 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1771
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1772
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1773 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1774 * Functions for ":mkspell".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1775 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1776
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1777 #define MAXLINELEN 500 /* Maximum length in bytes of a line in a .aff
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1778 and .dic file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1779 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1780 * 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
1781 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1782 typedef struct afffile_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1783 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1784 char_u *af_enc; /* "SET", normalized, alloc'ed string or NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1785 int af_flagtype; /* AFT_CHAR, AFT_LONG, AFT_NUM or AFT_CAPLONG */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1786 unsigned af_rare; /* RARE ID for rare word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1787 unsigned af_keepcase; /* KEEPCASE ID for keep-case word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1788 unsigned af_bad; /* BAD ID for banned word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1789 unsigned af_needaffix; /* NEEDAFFIX ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1790 unsigned af_circumfix; /* CIRCUMFIX ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1791 unsigned af_needcomp; /* NEEDCOMPOUND ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1792 unsigned af_comproot; /* COMPOUNDROOT ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1793 unsigned af_compforbid; /* COMPOUNDFORBIDFLAG ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1794 unsigned af_comppermit; /* COMPOUNDPERMITFLAG ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1795 unsigned af_nosuggest; /* NOSUGGEST ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1796 int af_pfxpostpone; /* postpone prefixes without chop string and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1797 without flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1798 int af_ignoreextra; /* IGNOREEXTRA present */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1799 hashtab_T af_pref; /* hashtable for prefixes, affheader_T */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1800 hashtab_T af_suff; /* hashtable for suffixes, affheader_T */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1801 hashtab_T af_comp; /* hashtable for compound flags, compitem_T */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1802 } afffile_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1803
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1804 #define AFT_CHAR 0 /* flags are one character */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1805 #define AFT_LONG 1 /* flags are two characters */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1806 #define AFT_CAPLONG 2 /* flags are one or two characters */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1807 #define AFT_NUM 3 /* flags are numbers, comma separated */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1808
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1809 typedef struct affentry_S affentry_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1810 /* Affix entry from ".aff" file. Used for prefixes and suffixes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1811 struct affentry_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1812 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1813 affentry_T *ae_next; /* next affix with same name/number */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1814 char_u *ae_chop; /* text to chop off basic word (can be NULL) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1815 char_u *ae_add; /* text to add to basic word (can be NULL) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1816 char_u *ae_flags; /* flags on the affix (can be NULL) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1817 char_u *ae_cond; /* condition (NULL for ".") */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1818 regprog_T *ae_prog; /* regexp program for ae_cond or NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1819 char ae_compforbid; /* COMPOUNDFORBIDFLAG found */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1820 char ae_comppermit; /* COMPOUNDPERMITFLAG found */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1821 };
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 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1824 # define AH_KEY_LEN 17 /* 2 x 8 bytes + NUL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1825 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1826 # define AH_KEY_LEN 7 /* 6 digits + NUL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1827 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1828
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1829 /* Affix header from ".aff" file. Used for af_pref and af_suff. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1830 typedef struct affheader_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1831 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1832 char_u ah_key[AH_KEY_LEN]; /* key for hashtab == name of affix */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1833 unsigned ah_flag; /* affix name as number, uses "af_flagtype" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1834 int ah_newID; /* prefix ID after renumbering; 0 if not used */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1835 int ah_combine; /* suffix may combine with prefix */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1836 int ah_follows; /* another affix block should be following */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1837 affentry_T *ah_first; /* first affix entry */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1838 } affheader_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1839
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1840 #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
1841
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1842 /* Flag used in compound items. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1843 typedef struct compitem_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1844 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1845 char_u ci_key[AH_KEY_LEN]; /* key for hashtab == name of compound */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1846 unsigned ci_flag; /* affix name as number, uses "af_flagtype" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1847 int ci_newID; /* affix ID after renumbering. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1848 } compitem_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1849
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1850 #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
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 * 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
1854 * 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
1855 * once after ":mkspell" is done.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1856 * 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
1857 * "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
1858 * 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
1859 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1860 #define SBLOCKSIZE 16000 /* size of sb_data */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1861 typedef struct sblock_S sblock_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1862 struct sblock_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1863 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1864 int sb_used; /* nr of bytes already in use */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1865 sblock_T *sb_next; /* next block in list */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1866 char_u sb_data[1]; /* data, actually longer */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1867 };
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1868
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1869 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1870 * A node in the tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1871 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1872 typedef struct wordnode_S wordnode_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1873 struct wordnode_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1874 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1875 union /* shared to save space */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1876 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1877 char_u hashkey[6]; /* the hash key, only used while compressing */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1878 int index; /* index in written nodes (valid after first
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1879 round) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1880 } wn_u1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1881 union /* shared to save space */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1882 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1883 wordnode_T *next; /* next node with same hash key */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1884 wordnode_T *wnode; /* parent node that will write this node */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1885 } wn_u2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1886 wordnode_T *wn_child; /* child (next byte in word) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1887 wordnode_T *wn_sibling; /* next sibling (alternate byte in word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1888 always sorted) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1889 int wn_refs; /* Nr. of references to this node. Only
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1890 relevant for first node in a list of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1891 siblings, in following siblings it is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1892 always one. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1893 char_u wn_byte; /* Byte for this node. NUL for word end */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1894
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1895 /* Info for when "wn_byte" is NUL.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1896 * In PREFIXTREE "wn_region" is used for the prefcondnr.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1897 * In the soundfolded word tree "wn_flags" has the MSW of the wordnr and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1898 * "wn_region" the LSW of the wordnr. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1899 char_u wn_affixID; /* supported/required prefix ID or 0 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1900 short_u wn_flags; /* WF_ flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1901 short wn_region; /* region mask */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1902
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1903 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1904 int wn_nr; /* sequence nr for printing */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1905 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1906 };
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1907
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1908 #define WN_MASK 0xffff /* mask relevant bits of "wn_flags" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1909
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1910 #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
1911
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1912 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1913 * Info used while reading the spell files.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1914 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1915 typedef struct spellinfo_S
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1916 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1917 wordnode_T *si_foldroot; /* tree with case-folded words */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1918 long si_foldwcount; /* nr of words in si_foldroot */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1919
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1920 wordnode_T *si_keeproot; /* tree with keep-case words */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1921 long si_keepwcount; /* nr of words in si_keeproot */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1922
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1923 wordnode_T *si_prefroot; /* tree with postponed prefixes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1924
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1925 long si_sugtree; /* creating the soundfolding trie */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1926
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1927 sblock_T *si_blocks; /* memory blocks used */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1928 long si_blocks_cnt; /* memory blocks allocated */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1929 int si_did_emsg; /* TRUE when ran out of memory */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1930
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1931 long si_compress_cnt; /* words to add before lowering
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1932 compression limit */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1933 wordnode_T *si_first_free; /* List of nodes that have been freed during
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1934 compression, linked by "wn_child" field. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1935 long si_free_count; /* number of nodes in si_first_free */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1936 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1937 int si_wordnode_nr; /* sequence nr for nodes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1938 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1939 buf_T *si_spellbuf; /* buffer used to store soundfold word table */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1940
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1941 int si_ascii; /* handling only ASCII words */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1942 int si_add; /* addition file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1943 int si_clear_chartab; /* when TRUE clear char tables */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1944 int si_region; /* region mask */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1945 vimconv_T si_conv; /* for conversion to 'encoding' */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1946 int si_memtot; /* runtime memory used */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1947 int si_verbose; /* verbose messages */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1948 int si_msg_count; /* number of words added since last message */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1949 char_u *si_info; /* info text chars or NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1950 int si_region_count; /* number of regions supported (1 when there
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1951 are no regions) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1952 char_u si_region_name[17]; /* region names; used only if
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1953 * si_region_count > 1) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1954
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1955 garray_T si_rep; /* list of fromto_T entries from REP lines */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1956 garray_T si_repsal; /* list of fromto_T entries from REPSAL lines */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1957 garray_T si_sal; /* list of fromto_T entries from SAL lines */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1958 char_u *si_sofofr; /* SOFOFROM text */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1959 char_u *si_sofoto; /* SOFOTO text */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1960 int si_nosugfile; /* NOSUGFILE item found */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1961 int si_nosplitsugs; /* NOSPLITSUGS item found */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1962 int si_nocompoundsugs; /* NOCOMPOUNDSUGS item found */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1963 int si_followup; /* soundsalike: ? */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1964 int si_collapse; /* soundsalike: ? */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1965 hashtab_T si_commonwords; /* hashtable for common words */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1966 time_t si_sugtime; /* timestamp for .sug file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1967 int si_rem_accents; /* soundsalike: remove accents */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1968 garray_T si_map; /* MAP info concatenated */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1969 char_u *si_midword; /* MIDWORD chars or NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1970 int si_compmax; /* max nr of words for compounding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1971 int si_compminlen; /* minimal length for compounding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1972 int si_compsylmax; /* max nr of syllables for compounding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1973 int si_compoptions; /* COMP_ flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1974 garray_T si_comppat; /* CHECKCOMPOUNDPATTERN items, each stored as
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1975 a string */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1976 char_u *si_compflags; /* flags used for compounding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1977 char_u si_nobreak; /* NOBREAK */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1978 char_u *si_syllable; /* syllable string */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1979 garray_T si_prefcond; /* table with conditions for postponed
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1980 * prefixes, each stored as a string */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1981 int si_newprefID; /* current value for ah_newID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1982 int si_newcompID; /* current value for compound ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1983 } spellinfo_T;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1984
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1985 static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1986 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
1987 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
1988 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
1989 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
1990 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
1991 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
1992 static void check_renumber(spellinfo_T *spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1993 static int flag_in_afflist(int flagtype, char_u *afflist, unsigned flag);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1994 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
1995 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
1996 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
1997 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
1998 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
1999 static void spell_free_aff(afffile_T *aff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2000 static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2001 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
2002 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
2003 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
2004 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
2005 static int spell_read_wordfile(spellinfo_T *spin, char_u *fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2006 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
2007 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
2008 static void free_blocks(sblock_T *bl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2009 static wordnode_T *wordtree_alloc(spellinfo_T *spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2010 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
2011 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
2012 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
2013 static int deref_wordnode(spellinfo_T *spin, wordnode_T *node);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2014 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
2015 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
2016 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
2017 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
2018 static int write_vim_spell(spellinfo_T *spin, char_u *fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2019 static void clear_node(wordnode_T *node);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2020 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
2021 static void spell_make_sugfile(spellinfo_T *spin, char_u *wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2022 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
2023 static int sug_maketable(spellinfo_T *spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2024 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
2025 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
2026 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
2027 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
2028 static void init_spellfile(void);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2029
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2030 /* In the postponed prefixes tree wn_flags is used to store the WFP_ flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2031 * but it must be negative to indicate the prefix tree to tree_add_word().
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2032 * Use a negative number with the lower 8 bits zero. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2033 #define PFX_FLAGS -256
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2034
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2035 /* flags for "condit" argument of store_aff_word() */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2036 #define CONDIT_COMB 1 /* affix must combine */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2037 #define CONDIT_CFIX 2 /* affix must have CIRCUMFIX flag */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2038 #define CONDIT_SUF 4 /* add a suffix for matching flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2039 #define CONDIT_AFF 8 /* word already has an affix */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2040
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2041 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2042 * 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
2043 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2044 static long compress_start = 30000; /* memory / SBLOCKSIZE */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2045 static long compress_inc = 100; /* memory / SBLOCKSIZE */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2046 static long compress_added = 500000; /* word count */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2047
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2048 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2049 * 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
2050 * Sets "sps_flags".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2051 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2052 int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2053 spell_check_msm(void)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2054 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2055 char_u *p = p_msm;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2056 long start = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2057 long incr = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2058 long added = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2059
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2060 if (!VIM_ISDIGIT(*p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2061 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2062 /* block count = (value * 1024) / SBLOCKSIZE (but avoid overflow)*/
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2063 start = (getdigits(&p) * 10) / (SBLOCKSIZE / 102);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2064 if (*p != ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2065 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2066 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2067 if (!VIM_ISDIGIT(*p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2068 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2069 incr = (getdigits(&p) * 102) / (SBLOCKSIZE / 10);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2070 if (*p != ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2071 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2072 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2073 if (!VIM_ISDIGIT(*p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2074 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2075 added = getdigits(&p) * 1024;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2076 if (*p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2077 return FAIL;
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 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
2080 return FAIL;
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 compress_start = start;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2083 compress_inc = incr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2084 compress_added = added;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2085 return OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2086 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2087
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2088 #ifdef SPELL_PRINTTREE
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 * 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
2091 * 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
2092 * compressing the tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2093 * Based on code from Olaf Seibert.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2094 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2095 #define PRINTLINESIZE 1000
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2096 #define PRINTWIDTH 6
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2097
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2098 #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
2099 PRINTLINESIZE - PRINTWIDTH * depth, fmt, a1, a2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2100
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2101 static char line1[PRINTLINESIZE];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2102 static char line2[PRINTLINESIZE];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2103 static char line3[PRINTLINESIZE];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2104
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2105 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2106 spell_clear_flags(wordnode_T *node)
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 wordnode_T *np;
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 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
2111 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2112 np->wn_u1.index = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2113 spell_clear_flags(np->wn_child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2114 }
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2117 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2118 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
2119 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2120 if (node->wn_u1.index)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2121 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2122 /* Done this node before, print the reference. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2123 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
2124 PRINTSOME(line2, depth, " ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2125 PRINTSOME(line3, depth, " ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2126 msg((char_u *)line1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2127 msg((char_u *)line2);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2128 msg((char_u *)line3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2129 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2130 else
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 node->wn_u1.index = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2133
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2134 if (node->wn_byte != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2135 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2136 if (node->wn_child != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2137 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
2138 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2139 /* Cannot happen? */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2140 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
2141 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2142 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2143 PRINTSOME(line1, depth, " $ ", 0, 0);
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 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
2146
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2147 if (node->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2148 PRINTSOME(line3, depth, " | ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2149 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2150 PRINTSOME(line3, depth, " ", 0, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2151
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2152 if (node->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2153 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2154 msg((char_u *)line1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2155 msg((char_u *)line2);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2156 msg((char_u *)line3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2157 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2158
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2159 /* do the children */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2160 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
2161 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
2162
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2163 /* do the siblings */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2164 if (node->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2165 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2166 /* get rid of all parent details except | */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2167 STRCPY(line1, line3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2168 STRCPY(line2, line3);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2169 spell_print_node(node->wn_sibling, depth);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2170 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2171 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2172 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2173
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2174 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2175 spell_print_tree(wordnode_T *root)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2176 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2177 if (root != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2178 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2179 /* Clear the "wn_u1.index" fields, used to remember what has been
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2180 * done. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2181 spell_clear_flags(root);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2182
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2183 /* Recursively print the tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2184 spell_print_node(root, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2185 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2186 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2187 #endif /* SPELL_PRINTTREE */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2188
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2189 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2190 * Read the affix file "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2191 * 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
2192 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2193 static afffile_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2194 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
2195 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2196 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2197 afffile_T *aff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2198 char_u rline[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2199 char_u *line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2200 char_u *pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2201 #define MAXITEMCNT 30
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2202 char_u *(items[MAXITEMCNT]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2203 int itemcnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2204 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2205 int lnum = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2206 affheader_T *cur_aff = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2207 int did_postpone_prefix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2208 int aff_todo = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2209 hashtab_T *tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2210 char_u *low = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2211 char_u *fol = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2212 char_u *upp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2213 int do_rep;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2214 int do_repsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2215 int do_sal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2216 int do_mapline;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2217 int found_map = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2218 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2219 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2220 int compminlen = 0; /* COMPOUNDMIN value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2221 int compsylmax = 0; /* COMPOUNDSYLMAX value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2222 int compoptions = 0; /* COMP_ flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2223 int compmax = 0; /* COMPOUNDWORDMAX value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2224 char_u *compflags = NULL; /* COMPOUNDFLAG and COMPOUNDRULE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2225 concatenated */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2226 char_u *midword = NULL; /* MIDWORD value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2227 char_u *syllable = NULL; /* SYLLABLE value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2228 char_u *sofofrom = NULL; /* SOFOFROM value */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2229 char_u *sofoto = NULL; /* SOFOTO value */
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2232 * Open the file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2233 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2234 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2235 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2236 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2237 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2238 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2239 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2240
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2241 vim_snprintf((char *)IObuff, IOSIZE, _("Reading affix file %s ..."), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2242 spell_message(spin, IObuff);
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 /* Only do REP lines when not done in another .aff file already. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2245 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
2246
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2247 /* Only do REPSAL lines when not done in another .aff file already. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2248 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
2249
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2250 /* Only do SAL lines when not done in another .aff file already. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2251 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
2252
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2253 /* Only do MAP lines when not done in another .aff file already. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2254 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
2255
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2256 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2257 * Allocate and init the afffile_T structure.
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 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
2260 if (aff == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2261 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2262 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2263 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2264 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2265 hash_init(&aff->af_pref);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2266 hash_init(&aff->af_suff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2267 hash_init(&aff->af_comp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2268
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2269 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2270 * 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
2271 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2272 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
2273 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2274 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2275 ++lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2276
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2277 /* Skip comment lines. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2278 if (*rline == '#')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2279 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2280
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2281 /* Convert from "SET" to 'encoding' when needed. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2282 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2283 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2284 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
2285 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2286 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
2287 if (pc == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2288 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2289 smsg((char_u *)_("Conversion failure for word in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2290 fname, lnum, rline);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2291 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2292 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2293 line = pc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2294 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2295 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2296 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2297 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2298 pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2299 line = rline;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2302 /* Split the line up in white separated items. Put a NUL after each
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2303 * item. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2304 itemcnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2305 for (p = line; ; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2306 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2307 while (*p != NUL && *p <= ' ') /* skip white space and CR/NL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2308 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2309 if (*p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2310 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2311 if (itemcnt == MAXITEMCNT) /* too many items */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2312 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2313 items[itemcnt++] = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2314 /* A few items have arbitrary text argument, don't split them. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2315 if (itemcnt == 2 && spell_info_item(items[0]))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2316 while (*p >= ' ' || *p == TAB) /* skip until CR/NL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2317 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2318 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2319 while (*p > ' ') /* skip until white space or CR/NL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2320 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2321 if (*p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2322 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2323 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2324 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2325
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2326 /* Handle non-empty lines. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2327 if (itemcnt > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2328 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2329 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
2330 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2331 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2332 /* Setup for conversion from "ENC" to 'encoding'. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2333 aff->af_enc = enc_canonize(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2334 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
2335 && 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
2336 p_enc) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2337 smsg((char_u *)_("Conversion in %s not supported: from %s to %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2338 fname, aff->af_enc, p_enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2339 spin->si_conv.vc_fail = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2340 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2341 smsg((char_u *)_("Conversion in %s not supported"), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2342 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2343 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2344 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
2345 && aff->af_flagtype == AFT_CHAR)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2346 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2347 if (STRCMP(items[1], "long") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2348 aff->af_flagtype = AFT_LONG;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2349 else if (STRCMP(items[1], "num") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2350 aff->af_flagtype = AFT_NUM;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2351 else if (STRCMP(items[1], "caplong") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2352 aff->af_flagtype = AFT_CAPLONG;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2353 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2354 smsg((char_u *)_("Invalid value for FLAG in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2355 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2356 if (aff->af_rare != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2357 || aff->af_keepcase != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2358 || aff->af_bad != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2359 || aff->af_needaffix != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2360 || aff->af_circumfix != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2361 || aff->af_needcomp != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2362 || aff->af_comproot != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2363 || aff->af_nosuggest != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2364 || compflags != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2365 || aff->af_suff.ht_used > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2366 || aff->af_pref.ht_used > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2367 smsg((char_u *)_("FLAG after using flags in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2368 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2369 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2370 else if (spell_info_item(items[0]))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2371 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2372 p = (char_u *)getroom(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2373 (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
2374 + STRLEN(items[0])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2375 + STRLEN(items[1]) + 3, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2376 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2377 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2378 if (spin->si_info != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2379 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2380 STRCPY(p, spin->si_info);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2381 STRCAT(p, "\n");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2382 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2383 STRCAT(p, items[0]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2384 STRCAT(p, " ");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2385 STRCAT(p, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2386 spin->si_info = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2387 }
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, "MIDWORD", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2390 && midword == NULL)
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 midword = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2393 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2394 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
2395 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2396 /* ignored, we look in the tree for what chars may appear */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2397 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2398 /* TODO: remove "RAR" later */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2399 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
2400 || is_aff_rule(items, itemcnt, "RARE", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2401 && aff->af_rare == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2402 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2403 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
2404 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2405 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2406 /* TODO: remove "KEP" later */
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, "KEP", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2408 || is_aff_rule(items, itemcnt, "KEEPCASE", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2409 && aff->af_keepcase == 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_keepcase = 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, "BAD", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2415 || is_aff_rule(items, itemcnt, "FORBIDDENWORD", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2416 && aff->af_bad == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2417 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2418 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
2419 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2420 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2421 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
2422 && aff->af_needaffix == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2423 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2424 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
2425 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2426 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2427 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
2428 && aff->af_circumfix == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2429 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2430 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
2431 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2432 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2433 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
2434 && aff->af_nosuggest == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2435 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2436 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
2437 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2438 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2439 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
2440 || is_aff_rule(items, itemcnt, "ONLYINCOMPOUND", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2441 && aff->af_needcomp == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2442 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2443 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
2444 fname, lnum);
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 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
2447 && aff->af_comproot == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2448 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2449 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
2450 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2451 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2452 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
2453 && aff->af_compforbid == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2454 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2455 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
2456 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2457 if (aff->af_pref.ht_used > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2458 smsg((char_u *)_("Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line %d"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2459 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2460 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2461 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
2462 && aff->af_comppermit == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2463 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2464 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
2465 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2466 if (aff->af_pref.ht_used > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2467 smsg((char_u *)_("Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line %d"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2468 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2469 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2470 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
2471 && compflags == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2472 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2473 /* Turn flag "c" into COMPOUNDRULE compatible string "c+",
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2474 * "Na" into "Na+", "1234" into "1234+". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2475 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
2476 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2477 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2478 STRCPY(p, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2479 STRCAT(p, "+");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2480 compflags = p;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2483 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
2484 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2485 /* We don't use the count, but do check that it's a number and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2486 * not COMPOUNDRULE mistyped. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2487 if (atoi((char *)items[1]) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2488 smsg((char_u *)_("Wrong COMPOUNDRULES value in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2489 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2490 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2491 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
2492 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2493 /* Don't use the first rule if it is a number. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2494 if (compflags != NULL || *skipdigits(items[1]) != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2495 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2496 /* Concatenate this string to previously defined ones,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2497 * using a slash to separate them. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2498 l = (int)STRLEN(items[1]) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2499 if (compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2500 l += (int)STRLEN(compflags) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2501 p = getroom(spin, l, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2502 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2503 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2504 if (compflags != NULL)
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 STRCPY(p, compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2507 STRCAT(p, "/");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2508 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2509 STRCAT(p, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2510 compflags = p;
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 }
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, "COMPOUNDWORDMAX", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2515 && compmax == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2516 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2517 compmax = atoi((char *)items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2518 if (compmax == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2519 smsg((char_u *)_("Wrong COMPOUNDWORDMAX value in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2520 fname, lnum, items[1]);
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, "COMPOUNDMIN", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2523 && compminlen == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2524 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2525 compminlen = atoi((char *)items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2526 if (compminlen == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2527 smsg((char_u *)_("Wrong COMPOUNDMIN value in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2528 fname, lnum, items[1]);
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 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
2531 && compsylmax == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2532 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2533 compsylmax = atoi((char *)items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2534 if (compsylmax == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2535 smsg((char_u *)_("Wrong COMPOUNDSYLMAX value in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2536 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2537 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2538 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
2539 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2540 compoptions |= COMP_CHECKDUP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2541 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2542 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDREP", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2543 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2544 compoptions |= COMP_CHECKREP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2545 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2546 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDCASE", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2547 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2548 compoptions |= COMP_CHECKCASE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2549 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2550 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDTRIPLE", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2551 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2552 compoptions |= COMP_CHECKTRIPLE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2553 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2554 else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 2))
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 if (atoi((char *)items[1]) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2557 smsg((char_u *)_("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2558 fname, lnum, items[1]);
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, "CHECKCOMPOUNDPATTERN", 3))
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 garray_T *gap = &spin->si_comppat;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2563 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2564
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2565 /* Only add the couple if it isn't already there. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2566 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
2567 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
2568 && 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
2569 items[2]) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2570 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2571 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
2572 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2573 ((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
2574 = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2575 ((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
2576 = getroom_save(spin, items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2577 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2578 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2579 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
2580 && syllable == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2581 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2582 syllable = getroom_save(spin, items[1]);
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 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
2585 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2586 spin->si_nobreak = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2587 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2588 else if (is_aff_rule(items, itemcnt, "NOSPLITSUGS", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2589 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2590 spin->si_nosplitsugs = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2591 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2592 else if (is_aff_rule(items, itemcnt, "NOCOMPOUNDSUGS", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2593 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2594 spin->si_nocompoundsugs = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2595 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2596 else if (is_aff_rule(items, itemcnt, "NOSUGFILE", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2597 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2598 spin->si_nosugfile = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2599 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2600 else if (is_aff_rule(items, itemcnt, "PFXPOSTPONE", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2601 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2602 aff->af_pfxpostpone = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2603 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2604 else if (is_aff_rule(items, itemcnt, "IGNOREEXTRA", 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2605 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2606 aff->af_ignoreextra = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2607 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2608 else if ((STRCMP(items[0], "PFX") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2609 || STRCMP(items[0], "SFX") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2610 && aff_todo == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2611 && itemcnt >= 4)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2612 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2613 int lasti = 4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2614 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2615
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2616 if (*items[0] == 'P')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2617 tp = &aff->af_pref;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2618 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2619 tp = &aff->af_suff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2620
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2621 /* Myspell allows the same affix name to be used multiple
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2622 * times. The affix files that do this have an undocumented
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2623 * "S" flag on all but the last block, thus we check for that
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2624 * and store it in ah_follows. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2625 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
2626 hi = hash_find(tp, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2627 if (!HASHITEM_EMPTY(hi))
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 = HI2AH(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2630 if (cur_aff->ah_combine != (*items[2] == 'Y'))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2631 smsg((char_u *)_("Different combining flag in continued affix block in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2632 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2633 if (!cur_aff->ah_follows)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2634 smsg((char_u *)_("Duplicate affix in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2635 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2636 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2637 else
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 /* New affix letter. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2640 cur_aff = (affheader_T *)getroom(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2641 sizeof(affheader_T), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2642 if (cur_aff == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2643 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2644 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
2645 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2646 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
2647 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2648 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
2649 || cur_aff->ah_flag == aff->af_rare
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2650 || cur_aff->ah_flag == aff->af_keepcase
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2651 || cur_aff->ah_flag == aff->af_needaffix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2652 || cur_aff->ah_flag == aff->af_circumfix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2653 || cur_aff->ah_flag == aff->af_nosuggest
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2654 || cur_aff->ah_flag == aff->af_needcomp
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2655 || cur_aff->ah_flag == aff->af_comproot)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2656 smsg((char_u *)_("Affix also used for BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2657 fname, lnum, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2658 STRCPY(cur_aff->ah_key, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2659 hash_add(tp, cur_aff->ah_key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2660
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2661 cur_aff->ah_combine = (*items[2] == 'Y');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2662 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2663
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2664 /* Check for the "S" flag, which apparently means that another
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2665 * block with the same affix name is following. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2666 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
2667 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2668 ++lasti;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2669 cur_aff->ah_follows = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2670 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2671 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2672 cur_aff->ah_follows = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2673
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2674 /* Myspell allows extra text after the item, but that might
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2675 * mean mistakes go unnoticed. Require a comment-starter. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2676 if (itemcnt > lasti && *items[lasti] != '#')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2677 smsg((char_u *)_(e_afftrailing), fname, lnum, items[lasti]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2678
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2679 if (STRCMP(items[2], "Y") != 0 && STRCMP(items[2], "N") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2680 smsg((char_u *)_("Expected Y or N in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2681 fname, lnum, items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2682
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2683 if (*items[0] == 'P' && aff->af_pfxpostpone)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2684 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2685 if (cur_aff->ah_newID == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2686 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2687 /* Use a new number in the .spl file later, to be able
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2688 * to handle multiple .aff files. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2689 check_renumber(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2690 cur_aff->ah_newID = ++spin->si_newprefID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2691
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2692 /* We only really use ah_newID if the prefix is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2693 * postponed. We know that only after handling all
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2694 * the items. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2695 did_postpone_prefix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2696 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2697 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2698 /* Did use the ID in a previous block. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2699 did_postpone_prefix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2700 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2701
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2702 aff_todo = atoi((char *)items[3]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2703 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2704 else if ((STRCMP(items[0], "PFX") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2705 || STRCMP(items[0], "SFX") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2706 && aff_todo > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2707 && 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
2708 && itemcnt >= 5)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2709 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2710 affentry_T *aff_entry;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2711 int upper = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2712 int lasti = 5;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2713
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2714 /* Myspell allows extra text after the item, but that might
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2715 * mean mistakes go unnoticed. Require a comment-starter,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2716 * unless IGNOREEXTRA is used. Hunspell uses a "-" item. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2717 if (itemcnt > lasti
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2718 && !aff->af_ignoreextra
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2719 && *items[lasti] != '#'
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2720 && (STRCMP(items[lasti], "-") != 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2721 || itemcnt != lasti + 1))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2722 smsg((char_u *)_(e_afftrailing), fname, lnum, items[lasti]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2723
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2724 /* New item for an affix letter. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2725 --aff_todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2726 aff_entry = (affentry_T *)getroom(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2727 sizeof(affentry_T), TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2728 if (aff_entry == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2729 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2730
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2731 if (STRCMP(items[2], "0") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2732 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
2733 if (STRCMP(items[3], "0") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2734 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2735 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
2736
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2737 /* Recognize flags on the affix: abcd/XYZ */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2738 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
2739 if (aff_entry->ae_flags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2740 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2741 *aff_entry->ae_flags++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2742 aff_process_flags(aff, aff_entry);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2743 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2744 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2745
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2746 /* Don't use an affix entry with non-ASCII characters when
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2747 * "spin->si_ascii" is TRUE. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2748 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
2749 || has_non_ascii(aff_entry->ae_add)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2750 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2751 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
2752 cur_aff->ah_first = aff_entry;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2753
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2754 if (STRCMP(items[4], ".") != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2755 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2756 char_u buf[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2757
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2758 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
2759 if (*items[0] == 'P')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2760 sprintf((char *)buf, "^%s", items[4]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2761 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2762 sprintf((char *)buf, "%s$", items[4]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2763 aff_entry->ae_prog = vim_regcomp(buf,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2764 RE_MAGIC + RE_STRING + RE_STRICT);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2765 if (aff_entry->ae_prog == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2766 smsg((char_u *)_("Broken condition in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2767 fname, lnum, items[4]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2768 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2769
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2770 /* For postponed prefixes we need an entry in si_prefcond
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2771 * for the condition. Use an existing one if possible.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2772 * Can't be done for an affix with flags, ignoring
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2773 * COMPOUNDFORBIDFLAG and COMPOUNDPERMITFLAG. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2774 if (*items[0] == 'P' && aff->af_pfxpostpone
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2775 && aff_entry->ae_flags == 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 /* When the chop string is one lower-case letter and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2778 * the add string ends in the upper-case letter we set
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2779 * the "upper" flag, clear "ae_chop" and remove the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2780 * letters from "ae_add". The condition must either
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2781 * be empty or start with the same letter. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2782 if (aff_entry->ae_chop != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2783 && aff_entry->ae_add != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2784 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2785 && aff_entry->ae_chop[(*mb_ptr2len)(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2786 aff_entry->ae_chop)] == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2787 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2788 && aff_entry->ae_chop[1] == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2789 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2790 )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2791 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2792 int c, c_up;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2793
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2794 c = PTR2CHAR(aff_entry->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2795 c_up = SPELL_TOUPPER(c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2796 if (c_up != c
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2797 && (aff_entry->ae_cond == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2798 || PTR2CHAR(aff_entry->ae_cond) == c))
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 p = aff_entry->ae_add
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2801 + STRLEN(aff_entry->ae_add);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2802 mb_ptr_back(aff_entry->ae_add, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2803 if (PTR2CHAR(p) == c_up)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2804 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2805 upper = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2806 aff_entry->ae_chop = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2807 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2808
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2809 /* The condition is matched with the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2810 * actual word, thus must check for the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2811 * upper-case letter. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2812 if (aff_entry->ae_cond != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2813 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2814 char_u buf[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2815 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2816 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2817 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2818 onecap_copy(items[4], buf, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2819 aff_entry->ae_cond = getroom_save(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2820 spin, buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2821 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2822 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2823 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2824 *aff_entry->ae_cond = c_up;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2825 if (aff_entry->ae_cond != NULL)
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 sprintf((char *)buf, "^%s",
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2828 aff_entry->ae_cond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2829 vim_regfree(aff_entry->ae_prog);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2830 aff_entry->ae_prog = vim_regcomp(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2831 buf, RE_MAGIC + RE_STRING);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2832 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2833 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2834 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2835 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2836 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2837
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2838 if (aff_entry->ae_chop == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2839 && aff_entry->ae_flags == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2840 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2841 int idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2842 char_u **pp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2843 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2844
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2845 /* Find a previously used condition. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2846 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
2847 --idx)
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 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
2850 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
2851 break;
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 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
2854 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2855 /* Not found, add a new condition. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2856 idx = spin->si_prefcond.ga_len++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2857 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
2858 + idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2859 if (aff_entry->ae_cond == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2860 *pp = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2861 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2862 *pp = getroom_save(spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2863 aff_entry->ae_cond);
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2866 /* Add the prefix to the prefix tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2867 if (aff_entry->ae_add == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2868 p = (char_u *)"";
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2869 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2870 p = aff_entry->ae_add;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2871
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2872 /* PFX_FLAGS is a negative number, so that
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2873 * tree_add_word() knows this is the prefix tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2874 n = PFX_FLAGS;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2875 if (!cur_aff->ah_combine)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2876 n |= WFP_NC;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2877 if (upper)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2878 n |= WFP_UP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2879 if (aff_entry->ae_comppermit)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2880 n |= WFP_COMPPERMIT;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2881 if (aff_entry->ae_compforbid)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2882 n |= WFP_COMPFORBID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2883 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
2884 idx, cur_aff->ah_newID);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2885 did_postpone_prefix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2886 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2887
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2888 /* Didn't actually use ah_newID, backup si_newprefID. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2889 if (aff_todo == 0 && !did_postpone_prefix)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2890 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2891 --spin->si_newprefID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2892 cur_aff->ah_newID = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2893 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2894 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2895 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2896 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2897 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
2898 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2899 fol = vim_strsave(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2900 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2901 else if (is_aff_rule(items, itemcnt, "LOW", 2) && low == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2902 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2903 low = vim_strsave(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2904 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2905 else if (is_aff_rule(items, itemcnt, "UPP", 2) && upp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2906 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2907 upp = vim_strsave(items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2908 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2909 else if (is_aff_rule(items, itemcnt, "REP", 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2910 || is_aff_rule(items, itemcnt, "REPSAL", 2))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2911 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2912 /* Ignore REP/REPSAL count */;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2913 if (!isdigit(*items[1]))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2914 smsg((char_u *)_("Expected REP(SAL) count in %s line %d"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2915 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2916 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2917 else if ((STRCMP(items[0], "REP") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2918 || STRCMP(items[0], "REPSAL") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2919 && itemcnt >= 3)
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 /* REP/REPSAL item */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2922 /* Myspell ignores extra arguments, we require it starts with
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2923 * # to detect mistakes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2924 if (itemcnt > 3 && items[3][0] != '#')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2925 smsg((char_u *)_(e_afftrailing), fname, lnum, items[3]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2926 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
2927 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2928 /* Replace underscore with space (can't include a space
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2929 * directly). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2930 for (p = items[1]; *p != NUL; mb_ptr_adv(p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2931 if (*p == '_')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2932 *p = ' ';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2933 for (p = items[2]; *p != NUL; mb_ptr_adv(p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2934 if (*p == '_')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2935 *p = ' ';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2936 add_fromto(spin, items[0][3] == 'S'
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2937 ? &spin->si_repsal
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2938 : &spin->si_rep, items[1], items[2]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2939 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2940 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2941 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
2942 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2943 /* MAP item or count */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2944 if (!found_map)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2945 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2946 /* First line contains the count. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2947 found_map = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2948 if (!isdigit(*items[1]))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2949 smsg((char_u *)_("Expected MAP count in %s line %d"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2950 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2951 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2952 else if (do_mapline)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2953 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2954 int c;
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 /* Check that every character appears only once. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2957 for (p = items[1]; *p != NUL; )
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 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2960 c = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2961 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2962 c = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2963 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2964 if ((spin->si_map.ga_len > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2965 && 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
2966 != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2967 || vim_strchr(p, c) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2968 smsg((char_u *)_("Duplicate character in MAP in %s line %d"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2969 fname, lnum);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2970 }
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 /* We simply concatenate all the MAP strings, separated by
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2973 * slashes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2974 ga_concat(&spin->si_map, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2975 ga_append(&spin->si_map, '/');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2976 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2977 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2978 /* Accept "SAL from to" and "SAL from to #comment". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2979 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
2980 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2981 if (do_sal)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2982 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2983 /* SAL item (sounds-a-like)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2984 * Either one of the known keys or a from-to pair. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2985 if (STRCMP(items[1], "followup") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2986 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
2987 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
2988 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
2989 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
2990 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
2991 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2992 /* when "to" is "_" it means empty */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2993 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
2994 STRCMP(items[2], "_") == 0 ? (char_u *)""
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2995 : items[2]);
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 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
2999 && sofofrom == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3000 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3001 sofofrom = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3002 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3003 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
3004 && sofoto == NULL)
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 sofoto = getroom_save(spin, items[1]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3007 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3008 else if (STRCMP(items[0], "COMMON") == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3009 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3010 int i;
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 for (i = 1; i < itemcnt; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3013 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3014 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
3015 items[i])))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3016 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3017 p = vim_strsave(items[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3018 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3019 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3020 hash_add(&spin->si_commonwords, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3021 }
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3025 smsg((char_u *)_("Unrecognized or duplicate item in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3026 fname, lnum, items[0]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3027 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3028 }
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 (fol != NULL || low != NULL || upp != NULL)
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 (spin->si_clear_chartab)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3033 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3034 /* Clear the char type tables, don't want to use any of the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3035 * currently used spell properties. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3036 init_spell_chartab();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3037 spin->si_clear_chartab = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3038 }
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3041 * 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
3042 * 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
3043 * 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
3044 * 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
3045 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3046 if (!spin->si_ascii
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3047 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3048 && !enc_utf8
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3049 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3050 )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3051 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3052 if (fol == NULL || low == NULL || upp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3053 smsg((char_u *)_("Missing FOL/LOW/UPP line in %s"), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3054 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3055 (void)set_spell_chartab(fol, low, upp);
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 vim_free(fol);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3059 vim_free(low);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3060 vim_free(upp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3061 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3062
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3063 /* Use compound specifications of the .aff file for the spell info. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3064 if (compmax != 0)
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 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
3067 spin->si_compmax = compmax;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3068 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3069
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3070 if (compminlen != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3071 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3072 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
3073 spin->si_compminlen = compminlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3074 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3075
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3076 if (compsylmax != 0)
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 if (syllable == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3079 smsg((char_u *)_("COMPOUNDSYLMAX used without SYLLABLE"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3080 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
3081 spin->si_compsylmax = compsylmax;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3082 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3083
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3084 if (compoptions != 0)
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 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
3087 spin->si_compoptions |= compoptions;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3088 }
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 if (compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3091 process_compflags(spin, aff, compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3092
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3093 /* Check that we didn't use too many renumbered flags. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3094 if (spin->si_newcompID < spin->si_newprefID)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3095 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3096 if (spin->si_newcompID == 127 || spin->si_newcompID == 255)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3097 MSG(_("Too many postponed prefixes"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3098 else if (spin->si_newprefID == 0 || spin->si_newprefID == 127)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3099 MSG(_("Too many compound flags"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3100 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3101 MSG(_("Too many postponed prefixes and/or compound flags"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3102 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3103
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3104 if (syllable != NULL)
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 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
3107 spin->si_syllable = syllable;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3108 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3109
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3110 if (sofofrom != NULL || sofoto != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3111 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3112 if (sofofrom == NULL || sofoto == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3113 smsg((char_u *)_("Missing SOFO%s line in %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3114 sofofrom == NULL ? "FROM" : "TO", fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3115 else if (spin->si_sal.ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3116 smsg((char_u *)_("Both SAL and SOFO lines in %s"), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3117 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3118 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3119 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
3120 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
3121 spin->si_sofofr = sofofrom;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3122 spin->si_sofoto = sofoto;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3123 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3124 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3125
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3126 if (midword != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3127 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3128 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
3129 spin->si_midword = midword;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3130 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3131
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3132 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3133 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3134 return aff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3135 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3136
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3137 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3138 * 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
3139 * a comment is following after item "mincount".
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3142 is_aff_rule(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3143 char_u **items,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3144 int itemcnt,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3145 char *rulename,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3146 int mincount)
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(items[0], rulename) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3149 && (itemcnt == mincount
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3150 || (itemcnt > mincount && items[mincount][0] == '#')));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3151 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3152
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3153 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3154 * 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
3155 * 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
3156 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3157 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3158 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
3159 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3160 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3161 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3162 unsigned flag;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3163
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3164 if (entry->ae_flags != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3165 && (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
3166 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3167 for (p = entry->ae_flags; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3168 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3169 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3170 flag = get_affitem(affile->af_flagtype, &p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3171 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
3172 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3173 STRMOVE(prevp, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3174 p = prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3175 if (flag == affile->af_comppermit)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3176 entry->ae_comppermit = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3177 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3178 entry->ae_compforbid = TRUE;
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 (affile->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3181 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3182 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3183 if (*entry->ae_flags == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3184 entry->ae_flags = NULL; /* nothing left */
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 }
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 * 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
3190 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3191 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3192 spell_info_item(char_u *s)
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 return STRCMP(s, "NAME") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3195 || STRCMP(s, "HOME") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3196 || STRCMP(s, "VERSION") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3197 || STRCMP(s, "AUTHOR") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3198 || STRCMP(s, "EMAIL") == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3199 || STRCMP(s, "COPYRIGHT") == 0;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3202 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3203 * 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
3204 * returns zero for failure.
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 static unsigned
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3207 affitem2flag(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3208 int flagtype,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3209 char_u *item,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3210 char_u *fname,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3211 int lnum)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3212 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3213 unsigned res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3214 char_u *p = item;
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 res = get_affitem(flagtype, &p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3217 if (res == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3218 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3219 if (flagtype == AFT_NUM)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3220 smsg((char_u *)_("Flag is not a number in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3221 fname, lnum, item);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3222 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3223 smsg((char_u *)_("Illegal flag in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3224 fname, lnum, item);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3225 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3226 if (*p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3227 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3228 smsg((char_u *)_(e_affname), fname, lnum, item);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3229 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3230 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3231
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3232 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3233 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3234
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3235 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3236 * Get one affix name from "*pp" and advance the pointer.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3237 * 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
3238 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3239 static unsigned
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3240 get_affitem(int flagtype, char_u **pp)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3241 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3242 int res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3243
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3244 if (flagtype == AFT_NUM)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3245 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3246 if (!VIM_ISDIGIT(**pp))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3247 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3248 ++*pp; /* always advance, avoid getting stuck */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3249 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3250 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3251 res = getdigits(pp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3252 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3253 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3254 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3255 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3256 res = mb_ptr2char_adv(pp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3257 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3258 res = *(*pp)++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3259 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3260 if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3261 && res >= 'A' && res <= 'Z'))
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 if (**pp == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3264 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3265 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3266 res = mb_ptr2char_adv(pp) + (res << 16);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3267 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3268 res = *(*pp)++ + (res << 16);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3269 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3270 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3271 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3272 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3273 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3274
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3275 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3276 * 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
3277 * spin->si_compflags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3278 * 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
3279 * they fit in one byte.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3280 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3281 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3282 process_compflags(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3283 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3284 afffile_T *aff,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3285 char_u *compflags)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3286 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3287 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3288 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3289 unsigned flag;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3290 compitem_T *ci;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3291 int id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3292 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3293 char_u *tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3294 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3295 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3296
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3297 /* Make room for the old and the new compflags, concatenated with a / in
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3298 * between. Processing it makes it shorter, but we don't know by how
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3299 * much, thus allocate the maximum. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3300 len = (int)STRLEN(compflags) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3301 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3302 len += (int)STRLEN(spin->si_compflags) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3303 p = getroom(spin, len, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3304 if (p == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3305 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3306 if (spin->si_compflags != NULL)
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 STRCPY(p, spin->si_compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3309 STRCAT(p, "/");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3310 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3311 spin->si_compflags = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3312 tp = p + STRLEN(p);
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 for (p = compflags; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3315 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3316 if (vim_strchr((char_u *)"/?*+[]", *p) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3317 /* Copy non-flag characters directly. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3318 *tp++ = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3319 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3320 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3321 /* First get the flag number, also checks validity. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3322 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3323 flag = get_affitem(aff->af_flagtype, &p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3324 if (flag != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3325 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3326 /* Find the flag in the hashtable. If it was used before, use
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3327 * the existing ID. Otherwise add a new entry. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3328 vim_strncpy(key, prevp, p - prevp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3329 hi = hash_find(&aff->af_comp, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3330 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3331 id = HI2CI(hi)->ci_newID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3332 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3333 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3334 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
3335 if (ci == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3336 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3337 STRCPY(ci->ci_key, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3338 ci->ci_flag = flag;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3339 /* Avoid using a flag ID that has a special meaning in a
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3340 * regexp (also inside []). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3341 do
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3342 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3343 check_renumber(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3344 id = spin->si_newcompID--;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3345 } while (vim_strchr((char_u *)"/?*+[]\\-^", id) != NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3346 ci->ci_newID = id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3347 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
3348 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3349 *tp++ = id;
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 if (aff->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3352 ++p;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3355
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3356 *tp = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3357 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3358
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3359 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3360 * 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
3361 * 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
3362 * 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
3363 * 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
3364 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3365 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3366 check_renumber(spellinfo_T *spin)
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 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
3369 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3370 spin->si_newprefID = 127;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3371 spin->si_newcompID = 255;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3374
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 * 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
3377 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3378 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3379 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
3380 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3381 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3382 unsigned n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3383
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3384 switch (flagtype)
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 case AFT_CHAR:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3387 return vim_strchr(afflist, flag) != NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3388
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3389 case AFT_CAPLONG:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3390 case AFT_LONG:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3391 for (p = afflist; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3392 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3393 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3394 n = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3395 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3396 n = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3397 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3398 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
3399 && *p != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3400 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3401 n = mb_ptr2char_adv(&p) + (n << 16);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3402 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3403 n = *p++ + (n << 16);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3404 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3405 if (n == flag)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3406 return TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3407 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3408 break;
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 case AFT_NUM:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3411 for (p = afflist; *p != NUL; )
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 n = getdigits(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3414 if (n == flag)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3415 return TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3416 if (*p != NUL) /* skip over comma */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3417 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3418 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3419 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3420 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3421 return FALSE;
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 * 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
3426 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3427 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3428 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
3429 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3430 if (spinval != 0 && spinval != affval)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3431 smsg((char_u *)_("%s value differs from what is used in another .aff file"), name);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3435 * 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
3436 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3437 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3438 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
3439 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3440 if (spinval != NULL && STRCMP(spinval, affval) != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3441 smsg((char_u *)_("%s value differs from what is used in another .aff file"), name);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3442 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3443
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3444 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3445 * 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
3446 * NULL as equal.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3447 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3448 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3449 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
3450 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3451 if (s1 == NULL || s2 == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3452 return s1 == s2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3453 return STRCMP(s1, s2) == 0;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3456 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3457 * 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
3458 * They are stored case-folded.
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 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3461 add_fromto(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3462 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3463 garray_T *gap,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3464 char_u *from,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3465 char_u *to)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3466 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3467 fromto_T *ftp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3468 char_u word[MAXWLEN];
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 if (ga_grow(gap, 1) == OK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3471 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3472 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
3473 (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
3474 ftp->ft_from = getroom_save(spin, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3475 (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
3476 ftp->ft_to = getroom_save(spin, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3477 ++gap->ga_len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3478 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3479 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3480
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3481 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3482 * 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
3483 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3484 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3485 sal_to_bool(char_u *s)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3486 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3487 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
3488 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3489
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3490 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3491 * 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
3492 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3493 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3494 spell_free_aff(afffile_T *aff)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3495 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3496 hashtab_T *ht;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3497 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3498 int todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3499 affheader_T *ah;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3500 affentry_T *ae;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3501
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3502 vim_free(aff->af_enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3503
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3504 /* All this trouble to free the "ae_prog" items... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3505 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
3506 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3507 todo = (int)ht->ht_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3508 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
3509 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3510 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3511 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3512 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3513 ah = HI2AH(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3514 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
3515 vim_regfree(ae->ae_prog);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3516 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3517 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3518 if (ht == &aff->af_suff)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3519 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3520 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3521
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3522 hash_clear(&aff->af_pref);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3523 hash_clear(&aff->af_suff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3524 hash_clear(&aff->af_comp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3525 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3526
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 * Read dictionary file "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3529 * Returns OK or FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3530 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3531 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3532 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
3533 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3534 hashtab_T ht;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3535 char_u line[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3536 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3537 char_u *afflist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3538 char_u store_afflist[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3539 int pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3540 int need_affix;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3541 char_u *dw;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3542 char_u *pc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3543 char_u *w;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3544 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3545 hash_T hash;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3546 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3547 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3548 int lnum = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3549 int non_ascii = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3550 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3551 char_u message[MAXLINELEN + MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3552 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3553 int duplicate = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3554
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 * Open the file.
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 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3559 if (fd == NULL)
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 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3562 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3563 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3564
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3565 /* The hashtable is only used to detect duplicated words. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3566 hash_init(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3567
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3568 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3569 _("Reading dictionary file %s ..."), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3570 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3571
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3572 /* start with a message for the first line */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3573 spin->si_msg_count = 999999;
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 /* Read and ignore the first line: word count. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3576 (void)vim_fgets(line, MAXLINELEN, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3577 if (!vim_isdigit(*skipwhite(line)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3578 EMSG2(_("E760: No word count in %s"), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3579
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3580 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3581 * 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
3582 * 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
3583 * the hashtable.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3584 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3585 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
3586 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3587 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3588 ++lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3589 if (line[0] == '#' || line[0] == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3590 continue; /* comment line */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3591
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3592 /* Remove CR, LF and white space from the end. White space halfway
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3593 * the word is kept to allow e.g., "et al.". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3594 l = (int)STRLEN(line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3595 while (l > 0 && line[l - 1] <= ' ')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3596 --l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3597 if (l == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3598 continue; /* empty line */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3599 line[l] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3600
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3601 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3602 /* Convert from "SET" to 'encoding' when needed. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3603 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
3604 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3605 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
3606 if (pc == NULL)
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 smsg((char_u *)_("Conversion failure for word in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3609 fname, lnum, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3610 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3611 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3612 w = pc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3613 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3614 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3615 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3616 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3617 pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3618 w = line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3619 }
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 /* Truncate the word at the "/", set "afflist" to what follows.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3622 * Replace "\/" by "/" and "\\" by "\". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3623 afflist = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3624 for (p = w; *p != NUL; mb_ptr_adv(p))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3625 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3626 if (*p == '\\' && (p[1] == '\\' || p[1] == '/'))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3627 STRMOVE(p, p + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3628 else if (*p == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3629 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3630 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3631 afflist = p + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3632 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3633 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3634 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3635
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3636 /* Skip non-ASCII words when "spin->si_ascii" is TRUE. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3637 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
3638 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3639 ++non_ascii;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3640 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3641 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3642 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3643
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3644 /* This takes time, print a message every 10000 words. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3645 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
3646 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3647 spin->si_msg_count = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3648 vim_snprintf((char *)message, sizeof(message),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3649 _("line %6d, word %6d - %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3650 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
3651 msg_start();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3652 msg_puts_long_attr(message, 0);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3653 msg_clr_eos();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3654 msg_didout = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3655 msg_col = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3656 out_flush();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3657 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3658
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3659 /* Store the word in the hashtable to be able to find duplicates. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3660 dw = (char_u *)getroom_save(spin, w);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3661 if (dw == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3662 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3663 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3664 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3665 break;
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 hash = hash_hash(dw);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3669 hi = hash_lookup(&ht, dw, hash);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3670 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3671 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3672 if (p_verbose > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3673 smsg((char_u *)_("Duplicate word in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3674 fname, lnum, dw);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3675 else if (duplicate == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3676 smsg((char_u *)_("First duplicate word in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3677 fname, lnum, dw);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3678 ++duplicate;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3679 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3680 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3681 hash_add_item(&ht, hi, dw, hash);
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 flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3684 store_afflist[0] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3685 pfxlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3686 need_affix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3687 if (afflist != NULL)
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 /* Extract flags from the affix list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3690 flags |= get_affix_flags(affile, afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3691
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3692 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
3693 affile->af_flagtype, afflist, affile->af_needaffix))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3694 need_affix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3695
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3696 if (affile->af_pfxpostpone)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3697 /* Need to store the list of prefix IDs with the word. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3698 pfxlen = get_pfxlist(affile, afflist, store_afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3699
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3700 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3701 /* Need to store the list of compound flags with the word.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3702 * Concatenate them to the list of prefix IDs. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3703 get_compflags(affile, afflist, store_afflist + pfxlen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3704 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3705
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3706 /* Add the word to the word tree(s). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3707 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
3708 store_afflist, need_affix) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3709 retval = FAIL;
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 if (afflist != NULL)
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 /* Find all matching suffixes and add the resulting words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3714 * Additionally do matching prefixes that combine. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3715 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
3716 &affile->af_suff, &affile->af_pref,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3717 CONDIT_SUF, flags, store_afflist, pfxlen) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3718 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3719
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3720 /* Find all matching prefixes and add the resulting words. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3721 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
3722 &affile->af_pref, NULL,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3723 CONDIT_SUF, flags, store_afflist, pfxlen) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3724 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3725 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3726
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3727 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3728 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3729
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3730 if (duplicate > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3731 smsg((char_u *)_("%d duplicate word(s) in %s"), duplicate, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3732 if (spin->si_ascii && non_ascii > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3733 smsg((char_u *)_("Ignored %d word(s) with non-ASCII characters in %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3734 non_ascii, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3735 hash_clear(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3736
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3737 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3738 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3739 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3740
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3741 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3742 * 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
3743 * Return WF_ flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3744 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3745 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3746 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
3747 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3748 int flags = 0;
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 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
3751 affile->af_flagtype, afflist, affile->af_keepcase))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3752 flags |= WF_KEEPCAP | WF_FIXCAP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3753 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
3754 affile->af_flagtype, afflist, affile->af_rare))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3755 flags |= WF_RARE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3756 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
3757 affile->af_flagtype, afflist, affile->af_bad))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3758 flags |= WF_BANNED;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3759 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
3760 affile->af_flagtype, afflist, affile->af_needcomp))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3761 flags |= WF_NEEDCOMP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3762 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
3763 affile->af_flagtype, afflist, affile->af_comproot))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3764 flags |= WF_COMPROOT;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3765 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
3766 affile->af_flagtype, afflist, affile->af_nosuggest))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3767 flags |= WF_NOSUGGEST;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3768 return flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3769 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3770
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 * 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
3773 * Used for PFXPOSTPONE.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3774 * 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
3775 * and return the number of affixes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3776 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3777 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3778 get_pfxlist(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3779 afffile_T *affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3780 char_u *afflist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3781 char_u *store_afflist)
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 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3784 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3785 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3786 int id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3787 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3788 hashitem_T *hi;
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 for (p = afflist; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3791 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3792 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3793 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
3794 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3795 /* A flag is a postponed prefix flag if it appears in "af_pref"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3796 * and it's ID is not zero. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3797 vim_strncpy(key, prevp, p - prevp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3798 hi = hash_find(&affile->af_pref, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3799 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3800 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3801 id = HI2AH(hi)->ah_newID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3802 if (id != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3803 store_afflist[cnt++] = id;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3804 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3805 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3806 if (affile->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3807 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3808 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3809
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3810 store_afflist[cnt] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3811 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3812 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3813
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3814 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3815 * 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
3816 * for compound words.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3817 * Puts the flags in "store_afflist[]".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3818 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3819 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3820 get_compflags(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3821 afffile_T *affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3822 char_u *afflist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3823 char_u *store_afflist)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3824 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3825 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3826 char_u *prevp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3827 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3828 char_u key[AH_KEY_LEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3829 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3830
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3831 for (p = afflist; *p != NUL; )
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 prevp = p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3834 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
3835 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3836 /* A flag is a compound flag if it appears in "af_comp". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3837 vim_strncpy(key, prevp, p - prevp);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3838 hi = hash_find(&affile->af_comp, key);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3839 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3840 store_afflist[cnt++] = HI2CI(hi)->ci_newID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3841 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3842 if (affile->af_flagtype == AFT_NUM && *p == ',')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3843 ++p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3844 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3845
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3846 store_afflist[cnt] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3847 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3848
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3849 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3850 * 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
3851 * "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
3852 * prefixes or suffixes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3853 * "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
3854 * the resulting words for combining affixes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3855 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3856 * Returns FAIL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3857 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3858 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3859 store_aff_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3860 spellinfo_T *spin, /* spell info */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3861 char_u *word, /* basic word start */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3862 char_u *afflist, /* list of names of supported affixes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3863 afffile_T *affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3864 hashtab_T *ht,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3865 hashtab_T *xht,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3866 int condit, /* CONDIT_SUF et al. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3867 int flags, /* flags for the word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3868 char_u *pfxlist, /* list of prefix IDs */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3869 int pfxlen) /* nr of flags in "pfxlist" for prefixes, rest
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3870 * is compound flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3871 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3872 int todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3873 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3874 affheader_T *ah;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3875 affentry_T *ae;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3876 char_u newword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3877 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3878 int i, j;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3879 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3880 int use_flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3881 char_u *use_pfxlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3882 int use_pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3883 int need_affix;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3884 char_u store_afflist[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3885 char_u pfx_pfxlist[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3886 size_t wordlen = STRLEN(word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3887 int use_condit;
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 todo = (int)ht->ht_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3890 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
3891 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3892 if (!HASHITEM_EMPTY(hi))
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 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3895 ah = HI2AH(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3896
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3897 /* Check that the affix combines, if required, and that the word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3898 * supports this affix. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3899 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
3900 && flag_in_afflist(affile->af_flagtype, afflist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3901 ah->ah_flag))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3902 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3903 /* Loop over all affix entries with this name. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3904 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
3905 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3906 /* Check the condition. It's not logical to match case
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3907 * here, but it is required for compatibility with
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3908 * Myspell.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3909 * Another requirement from Myspell is that the chop
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3910 * string is shorter than the word itself.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3911 * For prefixes, when "PFXPOSTPONE" was used, only do
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3912 * prefixes with a chop string and/or flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3913 * When a previously added affix had CIRCUMFIX this one
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3914 * must have it too, if it had not then this one must not
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3915 * have one either. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3916 if ((xht != NULL || !affile->af_pfxpostpone
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3917 || ae->ae_chop != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3918 || ae->ae_flags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3919 && (ae->ae_chop == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3920 || STRLEN(ae->ae_chop) < wordlen)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3921 && (ae->ae_prog == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3922 || vim_regexec_prog(&ae->ae_prog, FALSE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3923 word, (colnr_T)0))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3924 && (((condit & CONDIT_CFIX) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3925 == ((condit & CONDIT_AFF) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3926 || ae->ae_flags == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3927 || !flag_in_afflist(affile->af_flagtype,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3928 ae->ae_flags, affile->af_circumfix))))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3929 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3930 /* Match. Remove the chop and add the affix. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3931 if (xht == NULL)
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 /* prefix: chop/add at the start of the word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3934 if (ae->ae_add == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3935 *newword = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3936 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3937 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
3938 p = word;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3939 if (ae->ae_chop != 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 /* Skip chop string. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3942 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3943 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3944 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3945 i = mb_charlen(ae->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3946 for ( ; i > 0; --i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3947 mb_ptr_adv(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3948 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3949 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3950 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3951 p += STRLEN(ae->ae_chop);
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 STRCAT(newword, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3954 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3955 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3956 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3957 /* suffix: chop/add at the end of the word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3958 vim_strncpy(newword, word, MAXWLEN - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3959 if (ae->ae_chop != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3960 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3961 /* Remove chop string. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3962 p = newword + STRLEN(newword);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3963 i = (int)MB_CHARLEN(ae->ae_chop);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3964 for ( ; i > 0; --i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3965 mb_ptr_back(newword, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3966 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3967 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3968 if (ae->ae_add != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3969 STRCAT(newword, ae->ae_add);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3970 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3971
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3972 use_flags = flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3973 use_pfxlist = pfxlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3974 use_pfxlen = pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3975 need_affix = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3976 use_condit = condit | CONDIT_COMB | CONDIT_AFF;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3977 if (ae->ae_flags != NULL)
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 /* Extract flags from the affix list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3980 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
3981
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3982 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
3983 affile->af_flagtype, ae->ae_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3984 affile->af_needaffix))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3985 need_affix = TRUE;
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 /* When there is a CIRCUMFIX flag the other affix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3988 * must also have it and we don't add the word
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3989 * with one affix. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3990 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
3991 affile->af_flagtype, ae->ae_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3992 affile->af_circumfix))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3993 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3994 use_condit |= CONDIT_CFIX;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3995 if ((condit & CONDIT_CFIX) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3996 need_affix = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3997 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3998
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3999 if (affile->af_pfxpostpone
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4000 || spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4001 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4002 if (affile->af_pfxpostpone)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4003 /* Get prefix IDS from the affix list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4004 use_pfxlen = get_pfxlist(affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4005 ae->ae_flags, store_afflist);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4006 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4007 use_pfxlen = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4008 use_pfxlist = store_afflist;
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 /* Combine the prefix IDs. Avoid adding the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4011 * same ID twice. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4012 for (i = 0; i < pfxlen; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4013 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4014 for (j = 0; j < use_pfxlen; ++j)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4015 if (pfxlist[i] == use_pfxlist[j])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4016 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4017 if (j == use_pfxlen)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4018 use_pfxlist[use_pfxlen++] = pfxlist[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4019 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4020
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4021 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4022 /* Get compound IDS from the affix list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4023 get_compflags(affile, ae->ae_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4024 use_pfxlist + use_pfxlen);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4025
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4026 /* Combine the list of compound flags.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4027 * Concatenate them to the prefix IDs list.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4028 * Avoid adding the same ID twice. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4029 for (i = pfxlen; pfxlist[i] != NUL; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4030 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4031 for (j = use_pfxlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4032 use_pfxlist[j] != NUL; ++j)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4033 if (pfxlist[i] == use_pfxlist[j])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4034 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4035 if (use_pfxlist[j] == NUL)
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 use_pfxlist[j++] = pfxlist[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4038 use_pfxlist[j] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4039 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4040 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4041 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4042 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4043
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4044 /* Obey a "COMPOUNDFORBIDFLAG" of the affix: don't
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4045 * use the compound flags. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4046 if (use_pfxlist != NULL && ae->ae_compforbid)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4047 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4048 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
4049 use_pfxlist = pfx_pfxlist;
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 /* When there are postponed prefixes... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4053 if (spin->si_prefroot != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4054 && spin->si_prefroot->wn_sibling != NULL)
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 /* ... add a flag to indicate an affix was used. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4057 use_flags |= WF_HAS_AFF;
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 /* ... don't use a prefix list if combining
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4060 * affixes is not allowed. But do use the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4061 * compound flags after them. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4062 if (!ah->ah_combine && use_pfxlist != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4063 use_pfxlist += use_pfxlen;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4066 /* When compounding is supported and there is no
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4067 * "COMPOUNDPERMITFLAG" then forbid compounding on the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4068 * side where the affix is applied. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4069 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
4070 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4071 if (xht != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4072 use_flags |= WF_NOCOMPAFT;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4073 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4074 use_flags |= WF_NOCOMPBEF;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4075 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4076
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4077 /* Store the modified word. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4078 if (store_word(spin, newword, use_flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4079 spin->si_region, use_pfxlist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4080 need_affix) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4081 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4082
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4083 /* When added a prefix or a first suffix and the affix
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4084 * has flags may add a(nother) suffix. RECURSIVE! */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4085 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
4086 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
4087 affile, &affile->af_suff, xht,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4088 use_condit & (xht == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4089 ? ~0 : ~CONDIT_SUF),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4090 use_flags, use_pfxlist, pfxlen) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4091 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4092
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4093 /* When added a suffix and combining is allowed also
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4094 * try adding a prefix additionally. Both for the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4095 * word flags and for the affix flags. RECURSIVE! */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4096 if (xht != NULL && ah->ah_combine)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4097 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4098 if (store_aff_word(spin, newword,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4099 afflist, affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4100 xht, NULL, use_condit,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4101 use_flags, use_pfxlist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4102 pfxlen) == FAIL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4103 || (ae->ae_flags != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4104 && store_aff_word(spin, newword,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4105 ae->ae_flags, affile,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4106 xht, NULL, use_condit,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4107 use_flags, use_pfxlist,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4108 pfxlen) == FAIL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4109 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4110 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4111 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4112 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4113 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4114 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4115 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4116
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4117 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4118 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4119
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4120 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4121 * 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
4122 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4123 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4124 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
4125 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4126 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4127 long lnum = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4128 char_u rline[MAXLINELEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4129 char_u *line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4130 char_u *pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4131 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4132 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4133 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4134 int did_word = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4135 int non_ascii = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4136 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4137 int regionmask;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4138
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4139 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4140 * Open the file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4141 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4142 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4143 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4144 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4145 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4146 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4147 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4148
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4149 vim_snprintf((char *)IObuff, IOSIZE, _("Reading word file %s ..."), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4150 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4151
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4152 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4153 * 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
4154 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4155 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
4156 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4157 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4158 ++lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4159
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4160 /* Skip comment lines. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4161 if (*rline == '#')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4162 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4163
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4164 /* Remove CR, LF and white space from the end. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4165 l = (int)STRLEN(rline);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4166 while (l > 0 && rline[l - 1] <= ' ')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4167 --l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4168 if (l == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4169 continue; /* empty or blank line */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4170 rline[l] = NUL;
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 /* Convert from "/encoding={encoding}" to 'encoding' when needed. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4173 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4174 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4175 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
4176 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4177 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
4178 if (pc == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4179 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4180 smsg((char_u *)_("Conversion failure for word in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4181 fname, lnum, rline);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4182 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4183 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4184 line = pc;
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4187 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4188 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4189 pc = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4190 line = rline;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4191 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4192
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4193 if (*line == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4194 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4195 ++line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4196 if (STRNCMP(line, "encoding=", 9) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4197 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4198 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
4199 smsg((char_u *)_("Duplicate /encoding= line ignored in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4200 fname, lnum, line - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4201 else if (did_word)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4202 smsg((char_u *)_("/encoding= line after word ignored in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4203 fname, lnum, line - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4204 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4205 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4206 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4207 char_u *enc;
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 /* Setup for conversion to 'encoding'. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4210 line += 9;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4211 enc = enc_canonize(line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4212 if (enc != NULL && !spin->si_ascii
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4213 && convert_setup(&spin->si_conv, enc,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4214 p_enc) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4215 smsg((char_u *)_("Conversion in %s not supported: from %s to %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4216 fname, line, p_enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4217 vim_free(enc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4218 spin->si_conv.vc_fail = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4219 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4220 smsg((char_u *)_("Conversion in %s not supported"), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4221 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4222 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4223 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4224 }
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 if (STRNCMP(line, "regions=", 8) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4227 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4228 if (spin->si_region_count > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4229 smsg((char_u *)_("Duplicate /regions= line ignored in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4230 fname, lnum, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4231 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4232 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4233 line += 8;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4234 if (STRLEN(line) > 16)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4235 smsg((char_u *)_("Too many regions in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4236 fname, lnum, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4237 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4238 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4239 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
4240 STRCPY(spin->si_region_name, line);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4241
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4242 /* Adjust the mask for a word valid in all regions. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4243 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
4244 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4245 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4246 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4247 }
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 smsg((char_u *)_("/ line ignored in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4250 fname, lnum, line - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4251 continue;
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 flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4255 regionmask = spin->si_region;
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 /* Check for flags and region after a slash. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4258 p = vim_strchr(line, '/');
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4259 if (p != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4260 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4261 *p++ = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4262 while (*p != NUL)
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 if (*p == '=') /* keep-case word */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4265 flags |= WF_KEEPCAP | WF_FIXCAP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4266 else if (*p == '!') /* Bad, bad, wicked word. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4267 flags |= WF_BANNED;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4268 else if (*p == '?') /* Rare word. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4269 flags |= WF_RARE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4270 else if (VIM_ISDIGIT(*p)) /* region number(s) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4271 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4272 if ((flags & WF_REGION) == 0) /* first one */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4273 regionmask = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4274 flags |= WF_REGION;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4275
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4276 l = *p - '0';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4277 if (l > spin->si_region_count)
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 smsg((char_u *)_("Invalid region nr in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4280 fname, lnum, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4281 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4282 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4283 regionmask |= 1 << (l - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4284 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4285 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4286 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4287 smsg((char_u *)_("Unrecognized flags in %s line %d: %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4288 fname, lnum, p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4289 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4290 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4291 ++p;
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 }
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 /* Skip non-ASCII words when "spin->si_ascii" is TRUE. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4296 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
4297 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4298 ++non_ascii;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4299 continue;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4302 /* Normal word: store it. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4303 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
4304 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4305 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4306 break;
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 did_word = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4309 }
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 vim_free(pc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4312 fclose(fd);
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 if (spin->si_ascii && non_ascii > 0)
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 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4317 _("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
4318 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4319 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4320
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4321 return retval;
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4325 * 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
4326 * 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
4327 * track of them).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4328 * The memory is cleared to all zeros.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4329 * Returns NULL when out of memory.
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 static void *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4332 getroom(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4333 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4334 size_t len, /* length needed */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4335 int align) /* align for pointer */
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 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4338 sblock_T *bl = spin->si_blocks;
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 if (align && bl != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4341 /* Round size up for alignment. On some systems structures need to be
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4342 * aligned to the size of a pointer (e.g., SPARC). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4343 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
4344 & ~(sizeof(char *) - 1);
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 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
4347 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4348 if (len >= SBLOCKSIZE)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4349 bl = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4350 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4351 /* Allocate a block of memory. It is not freed until much later. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4352 bl = (sblock_T *)alloc_clear(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4353 (unsigned)(sizeof(sblock_T) + SBLOCKSIZE));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4354 if (bl == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4355 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4356 if (!spin->si_did_emsg)
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 EMSG(_("E845: Insufficient memory, word list will be incomplete"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4359 spin->si_did_emsg = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4360 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4361 return NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4362 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4363 bl->sb_next = spin->si_blocks;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4364 spin->si_blocks = bl;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4365 bl->sb_used = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4366 ++spin->si_blocks_cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4367 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4368
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4369 p = bl->sb_data + bl->sb_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4370 bl->sb_used += (int)len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4371
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4372 return p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4373 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4374
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 * 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
4377 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4378 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4379 static char_u *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4380 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
4381 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4382 char_u *sc;
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 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
4385 if (sc != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4386 STRCPY(sc, s);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4387 return sc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4388 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4389
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4390
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4391 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4392 * Free the list of allocated sblock_T.
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 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4395 free_blocks(sblock_T *bl)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4396 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4397 sblock_T *next;
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 while (bl != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4400 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4401 next = bl->sb_next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4402 vim_free(bl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4403 bl = next;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4406
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4407 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4408 * Allocate the root of a word tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4409 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4410 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4411 static wordnode_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4412 wordtree_alloc(spellinfo_T *spin)
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 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
4415 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4416
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4417 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4418 * Store a word in the tree(s).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4419 * 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
4420 * 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
4421 * used to find suggestions.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4422 * 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
4423 * 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
4424 * compound flag.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4425 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4426 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4427 store_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4428 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4429 char_u *word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4430 int flags, /* extra flags, WF_BANNED */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4431 int region, /* supported region(s) */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4432 char_u *pfxlist, /* list of prefix IDs or NULL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4433 int need_affix) /* only store word with affix ID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4434 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4435 int len = (int)STRLEN(word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4436 int ct = captype(word, word + len);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4437 char_u foldword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4438 int res = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4439 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4440
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4441 (void)spell_casefold(word, len, foldword, MAXWLEN);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4442 for (p = pfxlist; res == OK; ++p)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4443 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4444 if (!need_affix || (p != NULL && *p != NUL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4445 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
4446 region, p == NULL ? 0 : *p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4447 if (p == NULL || *p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4448 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4449 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4450 ++spin->si_foldwcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4451
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4452 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
4453 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4454 for (p = pfxlist; res == OK; ++p)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4455 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4456 if (!need_affix || (p != NULL && *p != NUL))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4457 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
4458 region, p == NULL ? 0 : *p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4459 if (p == NULL || *p == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4460 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4461 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4462 ++spin->si_keepwcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4463 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4464 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4465 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4466
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4467 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4468 * 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
4469 * 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
4470 * "rare" and "region" is the condition nr.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4471 * Returns FAIL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4472 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4473 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4474 tree_add_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4475 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4476 char_u *word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4477 wordnode_T *root,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4478 int flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4479 int region,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4480 int affixID)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4481 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4482 wordnode_T *node = root;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4483 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4484 wordnode_T *copyp, **copyprev;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4485 wordnode_T **prev = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4486 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4487
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4488 /* Add each byte of the word to the tree, including the NUL at the end. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4489 for (i = 0; ; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4490 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4491 /* When there is more than one reference to this node we need to make
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4492 * a copy, so that we can modify it. Copy the whole list of siblings
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4493 * (we don't optimize for a partly shared list of siblings). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4494 if (node != NULL && node->wn_refs > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4495 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4496 --node->wn_refs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4497 copyprev = prev;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4498 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
4499 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4500 /* Allocate a new node and copy the info. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4501 np = get_wordnode(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4502 if (np == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4503 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4504 np->wn_child = copyp->wn_child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4505 if (np->wn_child != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4506 ++np->wn_child->wn_refs; /* child gets extra ref */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4507 np->wn_byte = copyp->wn_byte;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4508 if (np->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4509 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4510 np->wn_flags = copyp->wn_flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4511 np->wn_region = copyp->wn_region;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4512 np->wn_affixID = copyp->wn_affixID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4513 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4514
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4515 /* Link the new node in the list, there will be one ref. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4516 np->wn_refs = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4517 if (copyprev != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4518 *copyprev = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4519 copyprev = &np->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4520
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4521 /* Let "node" point to the head of the copied list. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4522 if (copyp == node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4523 node = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4524 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4525 }
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 /* Look for the sibling that has the same character. They are sorted
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4528 * on byte value, thus stop searching when a sibling is found with a
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4529 * higher byte value. For zero bytes (end of word) the sorting is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4530 * done on flags and then on affixID. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4531 while (node != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4532 && (node->wn_byte < word[i]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4533 || (node->wn_byte == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4534 && (flags < 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4535 ? node->wn_affixID < (unsigned)affixID
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4536 : (node->wn_flags < (unsigned)(flags & WN_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4537 || (node->wn_flags == (flags & WN_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4538 && (spin->si_sugtree
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4539 ? (node->wn_region & 0xffff) < region
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4540 : node->wn_affixID
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4541 < (unsigned)affixID)))))))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4542 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4543 prev = &node->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4544 node = *prev;
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 if (node == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4547 || node->wn_byte != word[i]
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4548 || (word[i] == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4549 && (flags < 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4550 || spin->si_sugtree
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4551 || node->wn_flags != (flags & WN_MASK)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4552 || node->wn_affixID != affixID)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4553 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4554 /* Allocate a new node. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4555 np = get_wordnode(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4556 if (np == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4557 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4558 np->wn_byte = word[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4559
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4560 /* If "node" is NULL this is a new child or the end of the sibling
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4561 * list: ref count is one. Otherwise use ref count of sibling and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4562 * make ref count of sibling one (matters when inserting in front
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4563 * of the list of siblings). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4564 if (node == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4565 np->wn_refs = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4566 else
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 np->wn_refs = node->wn_refs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4569 node->wn_refs = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4570 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4571 if (prev != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4572 *prev = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4573 np->wn_sibling = node;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4574 node = np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4575 }
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 if (word[i] == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4578 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4579 node->wn_flags = flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4580 node->wn_region |= region;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4581 node->wn_affixID = affixID;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4582 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4583 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4584 prev = &node->wn_child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4585 node = *prev;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4586 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4587 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4588 smsg((char_u *)"Added \"%s\"", word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4589 spell_print_tree(root->wn_sibling);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4590 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4591
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4592 /* count nr of words added since last message */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4593 ++spin->si_msg_count;
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 if (spin->si_compress_cnt > 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4596 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4597 if (--spin->si_compress_cnt == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4598 /* Did enough words to lower the block count limit. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4599 spin->si_blocks_cnt += compress_inc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4600 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4601
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4602 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4603 * 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
4604 * 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
4605 * 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
4606 * 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
4607 * "compress_start" blocks.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4608 * 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
4609 * 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
4610 * 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
4611 * (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
4612 * maximum word length.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4613 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4614 #ifndef SPELL_COMPRESS_ALLWAYS
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4615 if (spin->si_compress_cnt == 1
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4616 ? spin->si_free_count < MAXWLEN
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4617 : spin->si_blocks_cnt >= compress_start)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4618 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4619 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4620 /* Decrement the block counter. The effect is that we compress again
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4621 * when the freed up room has been used and another "compress_inc"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4622 * blocks have been allocated. Unless "compress_added" words have
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4623 * been added, then the limit is put back again. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4624 spin->si_blocks_cnt -= compress_inc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4625 spin->si_compress_cnt = compress_added;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4626
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4627 if (spin->si_verbose)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4628 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4629 msg_start();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4630 msg_puts((char_u *)_(msg_compressing));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4631 msg_clr_eos();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4632 msg_didout = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4633 msg_col = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4634 out_flush();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4635 }
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 /* Compress both trees. Either they both have many nodes, which makes
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4638 * compression useful, or one of them is small, which means
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4639 * compression goes fast. But when filling the soundfold word tree
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4640 * there is no keep-case tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4641 wordtree_compress(spin, spin->si_foldroot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4642 if (affixID >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4643 wordtree_compress(spin, spin->si_keeproot);
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 return OK;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4649 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4650 * 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
4651 * allocate a new one.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4652 * Returns NULL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4653 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4654 static wordnode_T *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4655 get_wordnode(spellinfo_T *spin)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4656 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4657 wordnode_T *n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4658
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4659 if (spin->si_first_free == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4660 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
4661 else
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 n = spin->si_first_free;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4664 spin->si_first_free = n->wn_child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4665 vim_memset(n, 0, sizeof(wordnode_T));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4666 --spin->si_free_count;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4667 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4668 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4669 if (n != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4670 n->wn_nr = ++spin->si_wordnode_nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4671 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4672 return n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4673 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4674
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4675 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4676 * 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
4677 * 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
4678 * siblings.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4679 * Returns the number of nodes actually freed.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4680 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4681 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4682 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
4683 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4684 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4685 int cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4686
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4687 if (--node->wn_refs == 0)
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 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
4690 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4691 if (np->wn_child != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4692 cnt += deref_wordnode(spin, np->wn_child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4693 free_wordnode(spin, np);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4694 ++cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4695 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4696 ++cnt; /* length field */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4697 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4698 return cnt;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4699 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4700
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4701 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4702 * 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
4703 * Only the "wn_child" field becomes invalid.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4704 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4705 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4706 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
4707 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4708 n->wn_child = spin->si_first_free;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4709 spin->si_first_free = n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4710 ++spin->si_free_count;
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
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 * 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
4715 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4716 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4717 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
4718 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4719 hashtab_T ht;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4720 int n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4721 int tot = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4722 int perc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4723
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4724 /* Skip the root itself, it's not actually used. The first sibling is the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4725 * start of the tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4726 if (root->wn_sibling != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4727 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4728 hash_init(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4729 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
4730
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4731 #ifndef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4732 if (spin->si_verbose || p_verbose > 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4733 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4734 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4735 if (tot > 1000000)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4736 perc = (tot - n) / (tot / 100);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4737 else if (tot == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4738 perc = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4739 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4740 perc = (tot - n) * 100 / tot;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4741 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4742 _("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
4743 n, tot, tot - n, perc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4744 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4745 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4746 #ifdef SPELL_PRINTTREE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4747 spell_print_tree(root->wn_sibling);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4748 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4749 hash_clear(&ht);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4750 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4751 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4752
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 * 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
4755 * Returns the number of compressed nodes.
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4758 node_compress(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4759 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4760 wordnode_T *node,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4761 hashtab_T *ht,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4762 int *tot) /* total count of nodes before compressing,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4763 incremented while going through the tree */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4764 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4765 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4766 wordnode_T *tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4767 wordnode_T *child;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4768 hash_T hash;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4769 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4770 int len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4771 unsigned nr, n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4772 int compressed = 0;
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4775 * 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
4776 * finding an identical child to replace it.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4777 * 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
4778 * 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
4779 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4780 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
4781 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4782 ++len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4783 if ((child = np->wn_child) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4784 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4785 /* Compress the child first. This fills hashkey. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4786 compressed += node_compress(spin, child, ht, tot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4787
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4788 /* Try to find an identical child. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4789 hash = hash_hash(child->wn_u1.hashkey);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4790 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
4791 if (!HASHITEM_EMPTY(hi))
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 /* There are children we encountered before with a hash value
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4794 * identical to the current child. Now check if there is one
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4795 * that is really identical. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4796 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
4797 if (node_equal(child, tp))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4798 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4799 /* Found one! Now use that child in place of the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4800 * current one. This means the current child and all
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4801 * its siblings is unlinked from the tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4802 ++tp->wn_refs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4803 compressed += deref_wordnode(spin, child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4804 np->wn_child = tp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4805 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4806 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4807 if (tp == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4808 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4809 /* No other child with this hash value equals the child of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4810 * the node, add it to the linked list after the first
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4811 * item. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4812 tp = HI2WN(hi);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4813 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
4814 tp->wn_u2.next = child;
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4818 /* No other child has this hash value, add it to the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4819 * hashtable. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4820 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
4821 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4822 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4823 *tot += len + 1; /* add one for the node that stores the length */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4824
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4825 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4826 * 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
4827 * 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
4828 * 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
4829 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4830 node->wn_u1.hashkey[0] = len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4831 nr = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4832 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
4833 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4834 if (np->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4835 /* end node: use wn_flags, wn_region and wn_affixID */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4836 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
4837 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4838 /* byte node: use the byte value and the child pointer */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4839 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
4840 nr = nr * 101 + n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4841 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4842
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4843 /* Avoid NUL bytes, it terminates the hash key. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4844 n = nr & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4845 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
4846 n = (nr >> 8) & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4847 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
4848 n = (nr >> 16) & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4849 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
4850 n = (nr >> 24) & 0xff;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4851 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
4852 node->wn_u1.hashkey[5] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4853
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4854 /* Check for CTRL-C pressed now and then. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4855 fast_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4856
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4857 return compressed;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4858 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4859
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4860 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4861 * Return 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
4862 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4863 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4864 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
4865 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4866 wordnode_T *p1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4867 wordnode_T *p2;
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 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
4870 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
4871 if (p1->wn_byte != p2->wn_byte
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4872 || (p1->wn_byte == NUL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4873 ? (p1->wn_flags != p2->wn_flags
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4874 || p1->wn_region != p2->wn_region
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4875 || p1->wn_affixID != p2->wn_affixID)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4876 : (p1->wn_child != p2->wn_child)))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4877 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4878
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4879 return p1 == NULL && p2 == NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4880 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4881
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4882 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4883 #ifdef __BORLANDC__
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4884 _RTLENTRYF
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4885 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4886 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
4887
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4888 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4889 * 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
4890 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4891 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4892 #ifdef __BORLANDC__
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4893 _RTLENTRYF
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4894 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4895 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
4896 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4897 fromto_T *p1 = (fromto_T *)s1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4898 fromto_T *p2 = (fromto_T *)s2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4899
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4900 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
4901 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4902
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4903 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4904 * Write the Vim .spl file "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4905 * Return FAIL or OK;
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4908 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
4909 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4910 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4911 int regionmask;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4912 int round;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4913 wordnode_T *tree;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4914 int nodecount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4915 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4916 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4917 garray_T *gap;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4918 fromto_T *ftp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4919 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4920 int rr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4921 int retval = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4922 size_t fwv = 1; /* collect return value of fwrite() to avoid
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4923 warnings from picky compiler */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4924
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4925 fd = mch_fopen((char *)fname, "w");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4926 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4927 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4928 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4929 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4930 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4931
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4932 /* <HEADER>: <fileID> <versionnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4933 /* <fileID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4934 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
4935 if (fwv != (size_t)1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4936 /* Catch first write error, don't try writing more. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4937 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4938
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4939 putc(VIMSPELLVERSION, fd); /* <versionnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4940
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4941 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4942 * <SECTIONS>: <section> ... <sectionend>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4943 */
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 /* SN_INFO: <infotext> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4946 if (spin->si_info != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4947 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4948 putc(SN_INFO, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4949 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4950
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4951 i = (int)STRLEN(spin->si_info);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4952 put_bytes(fd, (long_u)i, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4953 fwv &= fwrite(spin->si_info, (size_t)i, (size_t)1, fd); /* <infotext> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4954 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4955
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4956 /* SN_REGION: <regionname> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4957 * Write the region names only if there is more than one. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4958 if (spin->si_region_count > 1)
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 putc(SN_REGION, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4961 putc(SNF_REQUIRED, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4962 l = spin->si_region_count * 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4963 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4964 fwv &= fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4965 /* <regionname> ... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4966 regionmask = (1 << spin->si_region_count) - 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4967 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4968 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4969 regionmask = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4970
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4971 /* SN_CHARFLAGS: <charflagslen> <charflags> <folcharslen> <folchars>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4972 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4973 * The table with character flags and the table for case folding.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4974 * This makes sure the same characters are recognized as word characters
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4975 * when generating an when using a spell file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4976 * Skip this for ASCII, the table may conflict with the one used for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4977 * 'encoding'.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4978 * Also skip this for an .add.spl file, the main spell file must contain
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4979 * the table (avoids that it conflicts). File is shorter too.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4980 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4981 if (!spin->si_ascii && !spin->si_add)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4982 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4983 char_u folchars[128 * 8];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4984 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4985
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4986 putc(SN_CHARFLAGS, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4987 putc(SNF_REQUIRED, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4988
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4989 /* Form the <folchars> string first, we need to know its length. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4990 l = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4991 for (i = 128; i < 256; ++i)
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 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4994 if (has_mbyte)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4995 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
4996 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4997 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4998 folchars[l++] = spelltab.st_fold[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4999 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5000 put_bytes(fd, (long_u)(1 + 128 + 2 + l), 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5001
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5002 fputc(128, fd); /* <charflagslen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5003 for (i = 128; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5004 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5005 flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5006 if (spelltab.st_isw[i])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5007 flags |= CF_WORD;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5008 if (spelltab.st_isu[i])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5009 flags |= CF_UPPER;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5010 fputc(flags, fd); /* <charflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5011 }
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 put_bytes(fd, (long_u)l, 2); /* <folcharslen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5014 fwv &= fwrite(folchars, (size_t)l, (size_t)1, fd); /* <folchars> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5015 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5016
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5017 /* SN_MIDWORD: <midword> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5018 if (spin->si_midword != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5019 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5020 putc(SN_MIDWORD, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5021 putc(SNF_REQUIRED, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5022
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5023 i = (int)STRLEN(spin->si_midword);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5024 put_bytes(fd, (long_u)i, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5025 fwv &= fwrite(spin->si_midword, (size_t)i, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5026 /* <midword> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5027 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5028
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5029 /* SN_PREFCOND: <prefcondcnt> <prefcond> ... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5030 if (spin->si_prefcond.ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5031 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5032 putc(SN_PREFCOND, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5033 putc(SNF_REQUIRED, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5034
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5035 l = write_spell_prefcond(NULL, &spin->si_prefcond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5036 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5037
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5038 write_spell_prefcond(fd, &spin->si_prefcond);
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5041 /* SN_REP: <repcount> <rep> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5042 * SN_SAL: <salflags> <salcount> <sal> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5043 * SN_REPSAL: <repcount> <rep> ... */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5044
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5045 /* round 1: SN_REP section
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5046 * round 2: SN_SAL section (unless SN_SOFO is used)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5047 * round 3: SN_REPSAL section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5048 for (round = 1; round <= 3; ++round)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5049 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5050 if (round == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5051 gap = &spin->si_rep;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5052 else if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5053 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5054 /* Don't write SN_SAL when using a SN_SOFO section */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5055 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
5056 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5057 gap = &spin->si_sal;
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5060 gap = &spin->si_repsal;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5061
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5062 /* Don't write the section if there are no items. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5063 if (gap->ga_len == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5064 continue;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5065
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5066 /* Sort the REP/REPSAL items. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5067 if (round != 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5068 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
5069 sizeof(fromto_T), rep_compare);
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 i = round == 1 ? SN_REP : (round == 2 ? SN_SAL : SN_REPSAL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5072 putc(i, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5073
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5074 /* This is for making suggestions, section is not required. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5075 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5076
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5077 /* Compute the length of what follows. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5078 l = 2; /* count <repcount> or <salcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5079 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
5080 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5081 ftp = &((fromto_T *)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5082 l += 1 + (int)STRLEN(ftp->ft_from); /* count <*fromlen> and <*from> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5083 l += 1 + (int)STRLEN(ftp->ft_to); /* count <*tolen> and <*to> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5084 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5085 if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5086 ++l; /* count <salflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5087 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5088
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5089 if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5090 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5091 i = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5092 if (spin->si_followup)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5093 i |= SAL_F0LLOWUP;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5094 if (spin->si_collapse)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5095 i |= SAL_COLLAPSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5096 if (spin->si_rem_accents)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5097 i |= SAL_REM_ACCENTS;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5098 putc(i, fd); /* <salflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5099 }
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 put_bytes(fd, (long_u)gap->ga_len, 2); /* <repcount> or <salcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5102 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
5103 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5104 /* <rep> : <repfromlen> <repfrom> <reptolen> <repto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5105 /* <sal> : <salfromlen> <salfrom> <saltolen> <salto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5106 ftp = &((fromto_T *)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5107 for (rr = 1; rr <= 2; ++rr)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5108 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5109 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
5110 l = (int)STRLEN(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5111 putc(l, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5112 if (l > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5113 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
5114 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5115 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5116
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5117 }
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 /* SN_SOFO: <sofofromlen> <sofofrom> <sofotolen> <sofoto>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5120 * This is for making suggestions, section is not required. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5121 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
5122 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5123 putc(SN_SOFO, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5124 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5125
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5126 l = (int)STRLEN(spin->si_sofofr);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5127 put_bytes(fd, (long_u)(l + STRLEN(spin->si_sofoto) + 4), 4);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5128 /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5129
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5130 put_bytes(fd, (long_u)l, 2); /* <sofofromlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5131 fwv &= fwrite(spin->si_sofofr, l, (size_t)1, fd); /* <sofofrom> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5132
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5133 l = (int)STRLEN(spin->si_sofoto);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5134 put_bytes(fd, (long_u)l, 2); /* <sofotolen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5135 fwv &= fwrite(spin->si_sofoto, l, (size_t)1, fd); /* <sofoto> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5136 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5137
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5138 /* SN_WORDS: <word> ...
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5139 * This is for making suggestions, section is not required. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5140 if (spin->si_commonwords.ht_used > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5141 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5142 putc(SN_WORDS, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5143 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5144
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5145 /* round 1: count the bytes
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5146 * round 2: write the bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5147 for (round = 1; round <= 2; ++round)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5148 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5149 int todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5150 int len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5151 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5152
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5153 todo = (int)spin->si_commonwords.ht_used;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5154 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
5155 if (!HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5156 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5157 l = (int)STRLEN(hi->hi_key) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5158 len += l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5159 if (round == 2) /* <word> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5160 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
5161 --todo;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5162 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5163 if (round == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5164 put_bytes(fd, (long_u)len, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5165 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5166 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5167
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5168 /* SN_MAP: <mapstr>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5169 * This is for making suggestions, section is not required. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5170 if (spin->si_map.ga_len > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5171 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5172 putc(SN_MAP, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5173 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5174 l = spin->si_map.ga_len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5175 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5176 fwv &= fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5177 /* <mapstr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5178 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5179
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5180 /* SN_SUGFILE: <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5181 * This is used to notify that a .sug file may be available and at the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5182 * same time allows for checking that a .sug file that is found matches
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5183 * with this .spl file. That's because the word numbers must be exactly
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5184 * right. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5185 if (!spin->si_nosugfile
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5186 && (spin->si_sal.ga_len > 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5187 || (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
5188 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5189 putc(SN_SUGFILE, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5190 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5191 put_bytes(fd, (long_u)8, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5192
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5193 /* Set si_sugtime and write it to the file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5194 spin->si_sugtime = time(NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5195 put_time(fd, spin->si_sugtime); /* <timestamp> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5196 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5197
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5198 /* SN_NOSPLITSUGS: nothing
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5199 * This is used to notify that no suggestions with word splits are to be
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5200 * made. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5201 if (spin->si_nosplitsugs)
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 putc(SN_NOSPLITSUGS, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5204 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5205 put_bytes(fd, (long_u)0, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5206 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5207
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5208 /* SN_NOCOMPUNDSUGS: nothing
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5209 * This is used to notify that no suggestions with compounds are to be
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5210 * made. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5211 if (spin->si_nocompoundsugs)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5212 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5213 putc(SN_NOCOMPOUNDSUGS, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5214 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5215 put_bytes(fd, (long_u)0, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5216 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5217
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5218 /* SN_COMPOUND: compound info.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5219 * We don't mark it required, when not supported all compound words will
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5220 * be bad words. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5221 if (spin->si_compflags != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5222 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5223 putc(SN_COMPOUND, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5224 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5225
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5226 l = (int)STRLEN(spin->si_compflags);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5227 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
5228 l += (int)STRLEN(((char_u **)(spin->si_comppat.ga_data))[i]) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5229 put_bytes(fd, (long_u)(l + 7), 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5230
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5231 putc(spin->si_compmax, fd); /* <compmax> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5232 putc(spin->si_compminlen, fd); /* <compminlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5233 putc(spin->si_compsylmax, fd); /* <compsylmax> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5234 putc(0, fd); /* for Vim 7.0b compatibility */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5235 putc(spin->si_compoptions, fd); /* <compoptions> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5236 put_bytes(fd, (long_u)spin->si_comppat.ga_len, 2);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5237 /* <comppatcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5238 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
5239 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5240 p = ((char_u **)(spin->si_comppat.ga_data))[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5241 putc((int)STRLEN(p), fd); /* <comppatlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5242 fwv &= fwrite(p, (size_t)STRLEN(p), (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5243 /* <comppattext> */
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 /* <compflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5246 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
5247 (size_t)1, fd);
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5250 /* SN_NOBREAK: NOBREAK flag */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5251 if (spin->si_nobreak)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5252 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5253 putc(SN_NOBREAK, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5254 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5255
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5256 /* It's empty, the presence of the section flags the feature. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5257 put_bytes(fd, (long_u)0, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5258 }
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 /* SN_SYLLABLE: syllable info.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5261 * We don't mark it required, when not supported syllables will not be
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5262 * counted. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5263 if (spin->si_syllable != NULL)
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 putc(SN_SYLLABLE, fd); /* <sectionID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5266 putc(0, fd); /* <sectionflags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5267
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5268 l = (int)STRLEN(spin->si_syllable);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5269 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5270 fwv &= fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5271 /* <syllable> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5272 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5273
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5274 /* end of <SECTIONS> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5275 putc(SN_END, fd); /* <sectionend> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5276
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5277
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5278 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5279 * <LWORDTREE> <KWORDTREE> <PREFIXTREE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5280 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5281 spin->si_memtot = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5282 for (round = 1; round <= 3; ++round)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5283 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5284 if (round == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5285 tree = spin->si_foldroot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5286 else if (round == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5287 tree = spin->si_keeproot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5288 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5289 tree = spin->si_prefroot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5290
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5291 /* Clear the index and wnode fields in the tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5292 clear_node(tree);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5293
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5294 /* Count the number of nodes. Needed to be able to allocate the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5295 * memory when reading the nodes. Also fills in index for shared
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5296 * nodes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5297 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
5298
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5299 /* number of nodes in 4 bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5300 put_bytes(fd, (long_u)nodecount, 4); /* <nodecount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5301 spin->si_memtot += nodecount + nodecount * sizeof(int);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5302
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5303 /* Write the nodes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5304 (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
5305 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5306
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5307 /* Write another byte to check for errors (file system full). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5308 if (putc(0, fd) == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5309 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5310 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5311 if (fclose(fd) == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5312 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5313
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5314 if (fwv != (size_t)1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5315 retval = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5316 if (retval == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5317 EMSG(_(e_write));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5318
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5319 return retval;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5320 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5321
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5322 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5323 * 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
5324 * 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
5325 * space.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5326 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5327 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5328 clear_node(wordnode_T *node)
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 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5331
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5332 if (node != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5333 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
5334 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5335 np->wn_u1.index = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5336 np->wn_u2.wnode = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5337
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5338 if (np->wn_byte != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5339 clear_node(np->wn_child);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5340 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5341 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5342
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5343
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 * Dump a word tree at node "node".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5346 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5347 * 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
5348 * byte recursively write the children.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5349 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5350 * 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
5351 * 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
5352 * in the file).
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5353 *
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5354 * Returns the number of nodes used.
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 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5357 put_node(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5358 FILE *fd, /* NULL when only counting */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5359 wordnode_T *node,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5360 int idx,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5361 int regionmask,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5362 int prefixtree) /* TRUE for PREFIXTREE */
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 int newindex = idx;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5365 int siblingcount = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5366 wordnode_T *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5367 int flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5368
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5369 /* If "node" is zero the tree is empty. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5370 if (node == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5371 return 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5372
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5373 /* Store the index where this node is written. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5374 node->wn_u1.index = idx;
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 /* Count the number of siblings. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5377 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
5378 ++siblingcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5379
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5380 /* Write the sibling count. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5381 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5382 putc(siblingcount, fd); /* <siblingcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5383
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5384 /* Write each sibling byte and optionally extra info. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5385 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
5386 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5387 if (np->wn_byte == 0)
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 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5390 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5391 /* For a NUL byte (end of word) write the flags etc. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5392 if (prefixtree)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5393 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5394 /* In PREFIXTREE write the required affixID and the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5395 * associated condition nr (stored in wn_region). The
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5396 * byte value is misused to store the "rare" and "not
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5397 * combining" flags */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5398 if (np->wn_flags == (short_u)PFX_FLAGS)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5399 putc(BY_NOFLAGS, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5400 else
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 putc(BY_FLAGS, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5403 putc(np->wn_flags, fd); /* <pflags> */
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 putc(np->wn_affixID, fd); /* <affixID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5406 put_bytes(fd, (long_u)np->wn_region, 2); /* <prefcondnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5407 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5408 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5409 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5410 /* For word trees we write the flag/region items. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5411 flags = np->wn_flags;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5412 if (regionmask != 0 && np->wn_region != regionmask)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5413 flags |= WF_REGION;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5414 if (np->wn_affixID != 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5415 flags |= WF_AFX;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5416 if (flags == 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 /* word without flags or region */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5419 putc(BY_NOFLAGS, fd); /* <byte> */
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 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5422 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5423 if (np->wn_flags >= 0x100)
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 putc(BY_FLAGS2, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5426 putc(flags, fd); /* <flags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5427 putc((unsigned)flags >> 8, fd); /* <flags2> */
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 else
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 putc(BY_FLAGS, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5432 putc(flags, fd); /* <flags> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5433 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5434 if (flags & WF_REGION)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5435 putc(np->wn_region, fd); /* <region> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5436 if (flags & WF_AFX)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5437 putc(np->wn_affixID, fd); /* <affixID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5438 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5439 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5440 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5441 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5442 else
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 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
5445 && np->wn_child->wn_u2.wnode != node)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5446 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5447 /* The child is written elsewhere, write the reference. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5448 if (fd != NULL)
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 putc(BY_INDEX, fd); /* <byte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5451 /* <nodeidx> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5452 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
5453 }
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 else if (np->wn_child->wn_u2.wnode == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5456 /* We will write the child below and give it an index. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5457 np->wn_child->wn_u2.wnode = node;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5458
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5459 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5460 if (putc(np->wn_byte, fd) == EOF) /* <byte> or <xbyte> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5461 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5462 EMSG(_(e_write));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5463 return 0;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5466 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5467
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5468 /* Space used in the array when reading: one for each sibling and one for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5469 * the count. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5470 newindex += siblingcount + 1;
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 /* Recursively dump the children of each sibling. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5473 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
5474 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
5475 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
5476 prefixtree);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5477
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5478 return newindex;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5482 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5483 * ":mkspell [-ascii] outfile infile ..."
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5484 * ":mkspell [-ascii] addfile"
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 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5487 ex_mkspell(exarg_T *eap)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5488 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5489 int fcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5490 char_u **fnames;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5491 char_u *arg = eap->arg;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5492 int ascii = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5493
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5494 if (STRNCMP(arg, "-ascii", 6) == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5495 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5496 ascii = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5497 arg = skipwhite(arg + 6);
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5500 /* Expand all the remaining arguments (e.g., $VIMRUNTIME). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5501 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
5502 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5503 mkspell(fcount, fnames, ascii, eap->forceit, FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5504 FreeWild(fcount, fnames);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5505 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5506 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5507
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5508 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5509 * Create the .sug file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5510 * Uses the soundfold info in "spin".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5511 * 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
5512 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5513 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5514 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
5515 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5516 char_u *fname = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5517 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5518 slang_T *slang;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5519 int free_slang = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5520
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 * 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
5523 * 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
5524 * 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
5525 * of the code for the soundfolding stuff.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5526 * 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
5527 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5528 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
5529 if (fullpathcmp(wfname, slang->sl_fname, FALSE) == FPC_SAME)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5530 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5531 if (slang == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5532 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5533 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
5534 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
5535 if (slang == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5536 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5537 free_slang = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5538 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5539
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5540 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5541 * 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
5542 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5543 spin->si_blocks = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5544 spin->si_blocks_cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5545 spin->si_compress_cnt = 0; /* will stay at 0 all the time*/
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5546 spin->si_free_count = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5547 spin->si_first_free = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5548 spin->si_foldwcount = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5549
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5550 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5551 * 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
5552 * the soundfold trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5553 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5554 spell_message(spin, (char_u *)_("Performing soundfolding..."));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5555 if (sug_filltree(spin, slang) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5556 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5557
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5558 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5559 * 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
5560 * 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
5561 * 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
5562 * compression possible.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5563 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5564 if (sug_maketable(spin) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5565 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5566
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5567 smsg((char_u *)_("Number of words after soundfolding: %ld"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5568 (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
5569
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 * Compress the soundfold trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5572 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5573 spell_message(spin, (char_u *)_(msg_compressing));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5574 wordtree_compress(spin, spin->si_foldroot);
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5577 * Write the .sug file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5578 * 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
5579 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5580 fname = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5581 if (fname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5582 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5583 vim_strncpy(fname, wfname, MAXPATHL - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5584 len = (int)STRLEN(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5585 fname[len - 2] = 'u';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5586 fname[len - 1] = 'g';
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5587 sug_write(spin, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5588
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5589 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5590 vim_free(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5591 if (free_slang)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5592 slang_free(slang);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5593 free_blocks(spin->si_blocks);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5594 close_spellbuf(spin->si_spellbuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5595 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5596
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5597 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5598 * Build the soundfold trie for language "slang".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5599 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5600 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5601 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
5602 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5603 char_u *byts;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5604 idx_T *idxs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5605 int depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5606 idx_T arridx[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5607 int curi[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5608 char_u tword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5609 char_u tsalword[MAXWLEN];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5610 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5611 idx_T n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5612 unsigned words_done = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5613 int wordcount[MAXWLEN];
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 /* We use si_foldroot for the soundfolded trie. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5616 spin->si_foldroot = wordtree_alloc(spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5617 if (spin->si_foldroot == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5618 return FAIL;
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 /* let tree_add_word() know we're adding to the soundfolded tree */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5621 spin->si_sugtree = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5622
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5623 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5624 * 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
5625 * in the trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5626 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5627 byts = slang->sl_fbyts;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5628 idxs = slang->sl_fidxs;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5629
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5630 arridx[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5631 curi[0] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5632 wordcount[0] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5633
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5634 depth = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5635 while (depth >= 0 && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5636 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5637 if (curi[depth] > byts[arridx[depth]])
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5638 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5639 /* Done all bytes at this node, go up one level. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5640 idxs[arridx[depth]] = wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5641 if (depth > 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5642 wordcount[depth - 1] += wordcount[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5643
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5644 --depth;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5645 line_breakcheck();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5646 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5647 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5648 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5649
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5650 /* Do one more byte at this node. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5651 n = arridx[depth] + curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5652 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5653
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5654 c = byts[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5655 if (c == 0)
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 /* Sound-fold the word. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5658 tword[depth] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5659 spell_soundfold(slang, tword, TRUE, tsalword);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5660
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5661 /* We use the "flags" field for the MSB of the wordnr,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5662 * "region" for the LSB of the wordnr. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5663 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
5664 words_done >> 16, words_done & 0xffff,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5665 0) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5666 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5667
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5668 ++words_done;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5669 ++wordcount[depth];
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 /* Reset the block count each time to avoid compression
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5672 * kicking in. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5673 spin->si_blocks_cnt = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5674
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5675 /* Skip over any other NUL bytes (same word with different
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5676 * flags). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5677 while (byts[n + 1] == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5678 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5679 ++n;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5680 ++curi[depth];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5681 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5682 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5683 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5684 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5685 /* Normal char, go one level deeper. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5686 tword[depth++] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5687 arridx[depth] = idxs[n];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5688 curi[depth] = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5689 wordcount[depth] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5690 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5691 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5692 }
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 smsg((char_u *)_("Total number of words: %d"), words_done);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5695
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5696 return OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5697 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5698
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5699 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5700 * 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
5701 * can be produced from.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5702 * 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
5703 * the table efficiently.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5704 * Returns FAIL when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5705 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5706 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5707 sug_maketable(spellinfo_T *spin)
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 garray_T ga;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5710 int res = OK;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5711
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5712 /* Allocate a buffer, open a memline for it and create the swap file
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5713 * (uses a temp file, not a .swp file). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5714 spin->si_spellbuf = open_spellbuf();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5715 if (spin->si_spellbuf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5716 return FAIL;
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 /* Use a buffer to store the line info, avoids allocating many small
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5719 * pieces of memory. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5720 ga_init2(&ga, 1, 100);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5721
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5722 /* recursively go through the tree */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5723 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
5724 res = FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5725
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5726 ga_clear(&ga);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5727 return res;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5728 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5729
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5730 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5731 * 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
5732 * 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
5733 * Returns -1 when out of memory.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5734 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5735 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5736 sug_filltable(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5737 spellinfo_T *spin,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5738 wordnode_T *node,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5739 int startwordnr,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5740 garray_T *gap) /* place to store line of numbers */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5741 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5742 wordnode_T *p, *np;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5743 int wordnr = startwordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5744 int nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5745 int prev_nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5746
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5747 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
5748 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5749 if (p->wn_byte == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5750 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5751 gap->ga_len = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5752 prev_nr = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5753 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
5754 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5755 if (ga_grow(gap, 10) == FAIL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5756 return -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5757
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5758 nr = (np->wn_flags << 16) + (np->wn_region & 0xffff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5759 /* Compute the offset from the previous nr and store the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5760 * offset in a way that it takes a minimum number of bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5761 * It's a bit like utf-8, but without the need to mark
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5762 * following bytes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5763 nr -= prev_nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5764 prev_nr += nr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5765 gap->ga_len += offset2bytes(nr,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5766 (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
5767 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5768
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5769 /* add the NUL byte */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5770 ((char_u *)gap->ga_data)[gap->ga_len++] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5771
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5772 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
5773 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
5774 return -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5775 ++wordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5776
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5777 /* Remove extra NUL entries, we no longer need them. We don't
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5778 * bother freeing the nodes, the won't be reused anyway. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5779 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
5780 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
5781
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5782 /* Clear the flags on the remaining NUL node, so that compression
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5783 * works a lot better. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5784 p->wn_flags = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5785 p->wn_region = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5786 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5787 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5788 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5789 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
5790 if (wordnr == -1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5791 return -1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5792 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5793 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5794 return wordnr;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5795 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5796
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5797 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5798 * 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
5799 * 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
5800 * bytes.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5801 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5802 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5803 offset2bytes(int nr, char_u *buf)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5804 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5805 int rem;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5806 int b1, b2, b3, b4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5807
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5808 /* Split the number in parts of base 255. We need to avoid NUL bytes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5809 b1 = nr % 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5810 rem = nr / 255;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5811 b2 = rem % 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5812 rem = rem / 255;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5813 b3 = rem % 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5814 b4 = rem / 255 + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5815
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5816 if (b4 > 1 || b3 > 0x1f) /* 4 bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5817 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5818 buf[0] = 0xe0 + b4;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5819 buf[1] = b3;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5820 buf[2] = b2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5821 buf[3] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5822 return 4;
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 if (b3 > 1 || b2 > 0x3f ) /* 3 bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5825 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5826 buf[0] = 0xc0 + b3;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5827 buf[1] = b2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5828 buf[2] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5829 return 3;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5830 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5831 if (b2 > 1 || b1 > 0x7f ) /* 2 bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5832 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5833 buf[0] = 0x80 + b2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5834 buf[1] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5835 return 2;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5836 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5837 /* 1 byte */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5838 buf[0] = b1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5839 return 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5840 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5841
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5842 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5843 * Write the .sug file in "fname".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5844 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5845 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5846 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
5847 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5848 FILE *fd;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5849 wordnode_T *tree;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5850 int nodecount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5851 int wcount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5852 char_u *line;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5853 linenr_T lnum;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5854 int len;
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 /* Create the file. Note that an existing file is silently overwritten! */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5857 fd = mch_fopen((char *)fname, "w");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5858 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5859 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5860 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5861 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5862 }
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 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5865 _("Writing suggestion file %s ..."), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5866 spell_message(spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5867
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5868 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5869 * <SUGHEADER>: <fileID> <versionnr> <timestamp>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5870 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5871 if (fwrite(VIMSUGMAGIC, VIMSUGMAGICL, (size_t)1, fd) != 1) /* <fileID> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5872 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5873 EMSG(_(e_write));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5874 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5875 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5876 putc(VIMSUGVERSION, fd); /* <versionnr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5877
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5878 /* Write si_sugtime to the file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5879 put_time(fd, spin->si_sugtime); /* <timestamp> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5880
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5881 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5882 * <SUGWORDTREE>
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5883 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5884 spin->si_memtot = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5885 tree = spin->si_foldroot->wn_sibling;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5886
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5887 /* Clear the index and wnode fields in the tree. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5888 clear_node(tree);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5889
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5890 /* Count the number of nodes. Needed to be able to allocate the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5891 * memory when reading the nodes. Also fills in index for shared
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5892 * nodes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5893 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
5894
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5895 /* number of nodes in 4 bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5896 put_bytes(fd, (long_u)nodecount, 4); /* <nodecount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5897 spin->si_memtot += nodecount + nodecount * sizeof(int);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5898
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5899 /* Write the nodes. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5900 (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
5901
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5902 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5903 * <SUGTABLE>: <sugwcount> <sugline> ...
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 wcount = spin->si_spellbuf->b_ml.ml_line_count;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5906 put_bytes(fd, (long_u)wcount, 4); /* <sugwcount> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5907
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5908 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
5909 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5910 /* <sugline>: <sugnr> ... NUL */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5911 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
5912 len = (int)STRLEN(line) + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5913 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
5914 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5915 EMSG(_(e_write));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5916 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5917 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5918 spin->si_memtot += len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5919 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5920
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5921 /* Write another byte to check for errors. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5922 if (putc(0, fd) == EOF)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5923 EMSG(_(e_write));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5924
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5925 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5926 _("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
5927 spell_message(spin, IObuff);
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 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5930 /* close the file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5931 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5932 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5933
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5934
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5935 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5936 * 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
5937 * "fnames[0]" is the output file name.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5938 * "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
5939 * 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
5940 * 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
5941 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5942 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5943 mkspell(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5944 int fcount,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5945 char_u **fnames,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5946 int ascii, /* -ascii argument given */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5947 int over_write, /* overwrite existing output file */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5948 int added_word) /* invoked through "zg" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5949 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5950 char_u *fname = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5951 char_u *wfname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5952 char_u **innames;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5953 int incount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5954 afffile_T *(afile[8]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5955 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5956 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5957 stat_T st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5958 int error = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5959 spellinfo_T spin;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5960
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5961 vim_memset(&spin, 0, sizeof(spin));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5962 spin.si_verbose = !added_word;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5963 spin.si_ascii = ascii;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5964 spin.si_followup = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5965 spin.si_rem_accents = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5966 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
5967 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
5968 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
5969 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
5970 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
5971 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
5972 hash_init(&spin.si_commonwords);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5973 spin.si_newcompID = 127; /* start compound ID at first maximum */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5974
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5975 /* default: fnames[0] is output file, following are input files */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5976 innames = &fnames[1];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5977 incount = fcount - 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5978
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5979 wfname = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5980 if (wfname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5981 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5982
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5983 if (fcount >= 1)
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 len = (int)STRLEN(fnames[0]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5986 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
5987 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5988 /* For ":mkspell path/en.latin1.add" output file is
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5989 * "path/en.latin1.add.spl". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5990 innames = &fnames[0];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5991 incount = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5992 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
5993 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5994 else if (fcount == 1)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5995 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5996 /* For ":mkspell path/vim" output file is "path/vim.latin1.spl". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5997 innames = &fnames[0];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5998 incount = 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5999 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
6000 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
6001 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6002 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
6003 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6004 /* Name ends in ".spl", use as the file name. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6005 vim_strncpy(wfname, fnames[0], MAXPATHL - 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6006 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6007 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6008 /* Name should be language, make the file name from it. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6009 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
6010 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
6011
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6012 /* Check for .ascii.spl. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6013 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
6014 spin.si_ascii = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6015
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6016 /* Check for .add.spl. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6017 if (strstr((char *)gettail(wfname), SPL_FNAME_ADD) != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6018 spin.si_add = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6019 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6020
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6021 if (incount <= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6022 EMSG(_(e_invarg)); /* need at least output and input names */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6023 else if (vim_strchr(gettail(wfname), '_') != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6024 EMSG(_("E751: Output file name must not have region name"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6025 else if (incount > 8)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6026 EMSG(_("E754: Only up to 8 regions supported"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6027 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6028 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6029 /* Check for overwriting before doing things that may take a lot of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6030 * time. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6031 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
6032 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6033 EMSG(_(e_exists));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6034 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6035 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6036 if (mch_isdir(wfname))
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 EMSG2(_(e_isadir2), wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6039 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6040 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6041
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6042 fname = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6043 if (fname == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6044 goto theend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6045
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6046 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6047 * Init the aff and dic pointers.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6048 * 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
6049 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6050 for (i = 0; i < incount; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6051 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6052 afile[i] = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6053
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6054 if (incount > 1)
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 len = (int)STRLEN(innames[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6057 if (STRLEN(gettail(innames[i])) < 5
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6058 || innames[i][len - 3] != '_')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6059 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6060 EMSG2(_("E755: Invalid region in %s"), innames[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6061 goto theend;
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 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
6064 spin.si_region_name[i * 2 + 1] =
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6065 TOLOWER_ASC(innames[i][len - 1]);
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6068 spin.si_region_count = incount;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6069
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6070 spin.si_foldroot = wordtree_alloc(&spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6071 spin.si_keeproot = wordtree_alloc(&spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6072 spin.si_prefroot = wordtree_alloc(&spin);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6073 if (spin.si_foldroot == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6074 || spin.si_keeproot == NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6075 || spin.si_prefroot == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6076 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6077 free_blocks(spin.si_blocks);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6078 goto theend;
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 /* When not producing a .add.spl file clear the character table when
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6082 * we encounter one in the .aff file. This means we dump the current
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6083 * one in the .spl file if the .aff file doesn't define one. That's
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6084 * better than guessing the contents, the table will match a
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6085 * previously loaded spell file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6086 if (!spin.si_add)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6087 spin.si_clear_chartab = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6088
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6089 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6090 * Read all the .aff and .dic files.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6091 * Text is converted to 'encoding'.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6092 * 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
6093 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6094 for (i = 0; i < incount && !error; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6095 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6096 spin.si_conv.vc_type = CONV_NONE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6097 spin.si_region = 1 << i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6098
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6099 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
6100 if (mch_stat((char *)fname, &st) >= 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6101 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6102 /* Read the .aff file. Will init "spin->si_conv" based on the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6103 * "SET" line. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6104 afile[i] = spell_read_aff(&spin, fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6105 if (afile[i] == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6106 error = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6107 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6108 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6109 /* Read the .dic file and store the words in the trees. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6110 vim_snprintf((char *)fname, MAXPATHL, "%s.dic",
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6111 innames[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6112 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
6113 error = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6114 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6115 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6116 else
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 /* No .aff file, try reading the file as a word list. Store
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6119 * the words in the trees. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6120 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
6121 error = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6122 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6123
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6124 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6125 /* Free any conversion stuff. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6126 convert_setup(&spin.si_conv, NULL, NULL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6127 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6128 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6129
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6130 if (spin.si_compflags != NULL && spin.si_nobreak)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6131 MSG(_("Warning: both compounding and NOBREAK specified"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6132
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6133 if (!error && !got_int)
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 * Combine tails in the tree.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6137 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6138 spell_message(&spin, (char_u *)_(msg_compressing));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6139 wordtree_compress(&spin, spin.si_foldroot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6140 wordtree_compress(&spin, spin.si_keeproot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6141 wordtree_compress(&spin, spin.si_prefroot);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6142 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6143
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6144 if (!error && !got_int)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6145 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6146 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6147 * Write the info in the spell file.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6148 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6149 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6150 _("Writing spell file %s ..."), wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6151 spell_message(&spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6152
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6153 error = write_vim_spell(&spin, wfname) == FAIL;
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 spell_message(&spin, (char_u *)_("Done!"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6156 vim_snprintf((char *)IObuff, IOSIZE,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6157 _("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
6158 spell_message(&spin, IObuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6159
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6160 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6161 * 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
6162 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6163 if (!error)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6164 spell_reload_one(wfname, added_word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6165 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6166
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6167 /* Free the allocated memory. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6168 ga_clear(&spin.si_rep);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6169 ga_clear(&spin.si_repsal);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6170 ga_clear(&spin.si_sal);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6171 ga_clear(&spin.si_map);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6172 ga_clear(&spin.si_comppat);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6173 ga_clear(&spin.si_prefcond);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6174 hash_clear_all(&spin.si_commonwords, 0);
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 /* Free the .aff file structures. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6177 for (i = 0; i < incount; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6178 if (afile[i] != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6179 spell_free_aff(afile[i]);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6180
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6181 /* Free all the bits and pieces at once. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6182 free_blocks(spin.si_blocks);
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6185 * 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
6186 * .sug file with the soundfolded word trie.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6187 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6188 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
6189 spell_make_sugfile(&spin, wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6190
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 theend:
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6194 vim_free(fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6195 vim_free(wfname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6196 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6197
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6198 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6199 * 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
6200 * ":mkspell". "str" can be IObuff.
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 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6203 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
6204 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6205 if (spin->si_verbose || p_verbose > 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6206 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6207 if (!spin->si_verbose)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6208 verbose_enter();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6209 MSG(str);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6210 out_flush();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6211 if (!spin->si_verbose)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6212 verbose_leave();
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6215
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6216 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6217 * ":[count]spellgood {word}"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6218 * ":[count]spellwrong {word}"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6219 * ":[count]spellundo {word}"
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6220 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6221 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6222 ex_spell(exarg_T *eap)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6223 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6224 spell_add_word(eap->arg, (int)STRLEN(eap->arg), eap->cmdidx == CMD_spellwrong,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6225 eap->forceit ? 0 : (int)eap->line2,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6226 eap->cmdidx == CMD_spellundo);
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6229 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6230 * Add "word[len]" to 'spellfile' as a good or bad word.
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6231 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6232 void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6233 spell_add_word(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6234 char_u *word,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6235 int len,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6236 int bad,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6237 int idx, /* "zG" and "zW": zero, otherwise index in
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6238 'spellfile' */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6239 int undo) /* TRUE for "zug", "zuG", "zuw" and "zuW" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6240 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6241 FILE *fd = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6242 buf_T *buf = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6243 int new_spf = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6244 char_u *fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6245 char_u *fnamebuf = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6246 char_u line[MAXWLEN * 2];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6247 long fpos, fpos_next = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6248 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6249 char_u *spf;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6250
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6251 if (idx == 0) /* use internal wordlist */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6252 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6253 if (int_wordlist == NULL)
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 int_wordlist = vim_tempname('s', FALSE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6256 if (int_wordlist == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6257 return;
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 fname = int_wordlist;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6260 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6261 else
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 'spellfile' isn't set figure out a good default value. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6264 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
6265 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6266 init_spellfile();
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6267 new_spf = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6268 }
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 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
6271 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6272 EMSG2(_(e_notset), "spellfile");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6273 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6274 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6275 fnamebuf = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6276 if (fnamebuf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6277 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6278
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6279 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
6280 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6281 copy_option_part(&spf, fnamebuf, MAXPATHL, ",");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6282 if (i == idx)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6283 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6284 if (*spf == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6285 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6286 EMSGN(_("E765: 'spellfile' does not have %ld entries"), idx);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6287 vim_free(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6288 return;
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 /* Check that the user isn't editing the .add file somewhere. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6293 buf = buflist_findname_exp(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6294 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
6295 buf = NULL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6296 if (buf != NULL && bufIsChanged(buf))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6297 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6298 EMSG(_(e_bufloaded));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6299 vim_free(fnamebuf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6300 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6301 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6302
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6303 fname = fnamebuf;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6304 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6305
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6306 if (bad || undo)
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 /* When the word appears as good word we need to remove that one,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6309 * since its flags sort before the one with WF_BANNED. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6310 fd = mch_fopen((char *)fname, "r");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6311 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6312 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6313 while (!vim_fgets(line, MAXWLEN * 2, fd))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6314 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6315 fpos = fpos_next;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6316 fpos_next = ftell(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6317 if (STRNCMP(word, line, len) == 0
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6318 && (line[len] == '/' || line[len] < ' '))
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 /* Found duplicate word. Remove it by writing a '#' at
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6321 * the start of the line. Mixing reading and writing
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6322 * doesn't work for all systems, close the file first. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6323 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6324 fd = mch_fopen((char *)fname, "r+");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6325 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6326 break;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6327 if (fseek(fd, fpos, SEEK_SET) == 0)
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 fputc('#', fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6330 if (undo)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6331 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6332 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6333 smsg((char_u *)_("Word '%.*s' removed from %s"),
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6334 len, word, NameBuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6335 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6336 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6337 fseek(fd, fpos_next, SEEK_SET);
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6340 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6341 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6342 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6343 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6344
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6345 if (!undo)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6346 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6347 fd = mch_fopen((char *)fname, "a");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6348 if (fd == NULL && new_spf)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6349 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6350 char_u *p;
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 /* We just initialized the 'spellfile' option and can't open the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6353 * file. We may need to create the "spell" directory first. We
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6354 * already checked the runtime directory is writable in
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6355 * init_spellfile(). */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6356 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
6357 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6358 int c = *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6359
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6360 /* The directory doesn't exist. Try creating it and opening
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6361 * the file again. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6362 *p = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6363 vim_mkdir(fname, 0755);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6364 *p = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6365 fd = mch_fopen((char *)fname, "a");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6366 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6367 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6368
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6369 if (fd == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6370 EMSG2(_(e_notopen), fname);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6371 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6372 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6373 if (bad)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6374 fprintf(fd, "%.*s/!\n", len, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6375 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6376 fprintf(fd, "%.*s\n", len, word);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6377 fclose(fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6378
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6379 home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6380 smsg((char_u *)_("Word '%.*s' added to %s"), len, word, NameBuff);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6381 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6382 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6383
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6384 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6385 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6386 /* Update the .add.spl file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6387 mkspell(1, &fname, FALSE, TRUE, TRUE);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6388
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6389 /* If the .add file is edited somewhere, reload it. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6390 if (buf != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6391 buf_reload(buf, buf->b_orig_mode);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6392
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6393 redraw_all_later(SOME_VALID);
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 vim_free(fnamebuf);
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 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6399 * Initialize 'spellfile' for the current buffer.
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 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6402 init_spellfile(void)
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 char_u *buf;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6405 int l;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6406 char_u *fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6407 char_u *rtp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6408 char_u *lend;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6409 int aspath = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6410 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
6411
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6412 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
6413 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6414 buf = alloc(MAXPATHL);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6415 if (buf == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6416 return;
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 /* Find the end of the language name. Exclude the region. If there
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6419 * is a path separator remember the start of the tail. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6420 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
6421 && vim_strchr((char_u *)",._", *lend) == NULL; ++lend)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6422 if (vim_ispathsep(*lend))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6423 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6424 aspath = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6425 lstart = lend + 1;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6426 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6427
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6428 /* Loop over all entries in 'runtimepath'. Use the first one where we
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6429 * are allowed to write. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6430 rtp = p_rtp;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6431 while (*rtp != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6432 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6433 if (aspath)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6434 /* Use directory of an entry with path, e.g., for
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6435 * "/dir/lg.utf-8.spl" use "/dir". */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6436 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
6437 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
6438 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6439 /* Copy the path from 'runtimepath' to buf[]. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6440 copy_option_part(&rtp, buf, MAXPATHL, ",");
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6441 if (filewritable(buf) == 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6442 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6443 /* Use the first language name from 'spelllang' and the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6444 * encoding used in the first loaded .spl file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6445 if (aspath)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6446 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
6447 lend - curbuf->b_s.b_p_spl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6448 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6449 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6450 /* Create the "spell" directory if it doesn't exist yet. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6451 l = (int)STRLEN(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6452 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
6453 if (filewritable(buf) != 2)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6454 vim_mkdir(buf, 0755);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6455
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6456 l = (int)STRLEN(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6457 vim_snprintf((char *)buf + l, MAXPATHL - l,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6458 "/%.*s", (int)(lend - lstart), lstart);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6459 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6460 l = (int)STRLEN(buf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6461 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
6462 ->lp_slang->sl_fname;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6463 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
6464 fname != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6465 && strstr((char *)gettail(fname), ".ascii.") != NULL
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6466 ? (char_u *)"ascii" : spell_enc());
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6467 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
6468 break;
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 aspath = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6471 }
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 vim_free(buf);
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 }
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6478
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6479 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6480 * 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
6481 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6482 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6483 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
6484 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6485 /* We build the new tables here first, so that we can compare with the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6486 * previous one. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6487 spelltab_T new_st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6488 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
6489 int f, l, u;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6490
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6491 clear_spell_chartab(&new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6492
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6493 while (*pf != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6494 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6495 if (*pl == NUL || *pu == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6496 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6497 EMSG(_(e_affform));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6498 return FAIL;
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 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6501 f = mb_ptr2char_adv(&pf);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6502 l = mb_ptr2char_adv(&pl);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6503 u = mb_ptr2char_adv(&pu);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6504 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6505 f = *pf++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6506 l = *pl++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6507 u = *pu++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6508 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6509 /* Every character that appears is a word character. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6510 if (f < 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6511 new_st.st_isw[f] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6512 if (l < 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6513 new_st.st_isw[l] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6514 if (u < 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6515 new_st.st_isw[u] = TRUE;
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 "LOW" and "FOL" are not the same the "LOW" char needs
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6518 * case-folding */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6519 if (l < 256 && l != f)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6520 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6521 if (f >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6522 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6523 EMSG(_(e_affrange));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6524 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6525 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6526 new_st.st_fold[l] = f;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6527 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6528
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6529 /* if "UPP" and "FOL" are not the same the "UPP" char needs
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6530 * case-folding, it's upper case and the "UPP" is the upper case of
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6531 * "FOL" . */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6532 if (u < 256 && u != f)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6533 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6534 if (f >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6535 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6536 EMSG(_(e_affrange));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6537 return FAIL;
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 new_st.st_fold[u] = f;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6540 new_st.st_isu[u] = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6541 new_st.st_upper[f] = u;
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 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6544
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6545 if (*pl != NUL || *pu != NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6546 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6547 EMSG(_(e_affform));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6548 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6549 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6550
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6551 return set_spell_finish(&new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6552 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6553
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6554 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6555 * 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
6556 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6557 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6558 set_spell_charflags(
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6559 char_u *flags,
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6560 int cnt, /* length of "flags" */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6561 char_u *fol)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6562 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6563 /* We build the new tables here first, so that we can compare with the
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6564 * previous one. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6565 spelltab_T new_st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6566 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6567 char_u *p = fol;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6568 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6569
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6570 clear_spell_chartab(&new_st);
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 for (i = 0; i < 128; ++i)
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 if (i < cnt)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6575 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6576 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
6577 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
6578 }
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 if (*p != NUL)
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 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6583 c = mb_ptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6584 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6585 c = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6586 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6587 new_st.st_fold[i + 128] = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6588 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
6589 new_st.st_upper[c] = i + 128;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6590 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6591 }
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 (void)set_spell_finish(&new_st);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6594 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6595
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6596 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6597 set_spell_finish(spelltab_T *new_st)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6598 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6599 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6600
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6601 if (did_set_spelltab)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6602 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6603 /* check that it's the same table */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6604 for (i = 0; i < 256; ++i)
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 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
6607 || 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
6608 || 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
6609 || 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
6610 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6611 EMSG(_("E763: Word characters differ between spell files"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6612 return FAIL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6613 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6614 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6615 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6616 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6617 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6618 /* copy the new spelltab into the one being used */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6619 spelltab = *new_st;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6620 did_set_spelltab = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6621 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6622
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6623 return OK;
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
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6626 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6627 * 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
6628 * 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
6629 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6630 static int
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6631 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
6632 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6633 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6634 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6635 int len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6636 int totlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6637 size_t x = 1; /* collect return value of fwrite() */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6638
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6639 if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6640 put_bytes(fd, (long_u)gap->ga_len, 2); /* <prefcondcnt> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6641
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6642 totlen = 2 + gap->ga_len; /* length of <prefcondcnt> and <condlen> bytes */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6643
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6644 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
6645 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6646 /* <prefcond> : <condlen> <condstr> */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6647 p = ((char_u **)gap->ga_data)[i];
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6648 if (p != NULL)
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 len = (int)STRLEN(p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6651 if (fd != NULL)
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 fputc(len, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6654 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
6655 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6656 totlen += len;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6657 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6658 else if (fd != NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6659 fputc(0, fd);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6660 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6661
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6662 return totlen;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6663 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6664
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6665
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6666 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6667 * Use map string "map" for languages "lp".
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6668 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6669 static void
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6670 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
6671 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6672 char_u *p;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6673 int headc = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6674 int c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6675 int i;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6676
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6677 if (*map == NUL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6678 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6679 lp->sl_has_map = FALSE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6680 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6681 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6682 lp->sl_has_map = TRUE;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6683
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6684 /* Init the array and hash tables empty. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6685 for (i = 0; i < 256; ++i)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6686 lp->sl_map_array[i] = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6687 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6688 hash_init(&lp->sl_map_hash);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6689 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6690
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6691 /*
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6692 * 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
6693 * "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
6694 * 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
6695 */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6696 for (p = map; *p != NUL; )
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6697 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6698 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6699 c = mb_cptr2char_adv(&p);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6700 #else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6701 c = *p++;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6702 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6703 if (c == '/')
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6704 headc = 0;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6705 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6706 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6707 if (headc == 0)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6708 headc = c;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6709
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6710 #ifdef FEAT_MBYTE
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6711 /* Characters above 255 don't fit in sl_map_array[], put them in
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6712 * the hash table. Each entry is the char, a NUL the headchar and
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6713 * a NUL. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6714 if (c >= 256)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6715 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6716 int cl = mb_char2len(c);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6717 int headcl = mb_char2len(headc);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6718 char_u *b;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6719 hash_T hash;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6720 hashitem_T *hi;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6721
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6722 b = alloc((unsigned)(cl + headcl + 2));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6723 if (b == NULL)
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6724 return;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6725 mb_char2bytes(c, b);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6726 b[cl] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6727 mb_char2bytes(headc, b + cl + 1);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6728 b[cl + 1 + headcl] = NUL;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6729 hash = hash_hash(b);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6730 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
6731 if (HASHITEM_EMPTY(hi))
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6732 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
6733 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6734 {
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6735 /* This should have been checked when generating the .spl
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6736 * file. */
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6737 EMSG(_("E783: duplicate char in MAP entry"));
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6738 vim_free(b);
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6739 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6740 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6741 else
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6742 #endif
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6743 lp->sl_map_array[c] = headc;
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6744 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6745 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6746 }
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6747
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6748
b0c7061d6439 commit https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6749 #endif /* FEAT_SPELL */