1#ifndef DEFINE_FUNC_ATTRIBUTES
2# define DEFINE_FUNC_ATTRIBUTES
3#endif
4#include "nvim/func_attr.h"
5#undef DEFINE_FUNC_ATTRIBUTES
6static inline int spell_check_magic_string(FILE *const fd) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE;
7static void tree_count_words(char_u *byts, idx_T *idxs);
8static char_u *read_cnt_string(FILE *fd, int cnt_bytes, int *cntp);
9static int read_region_section(FILE *fd, slang_T *lp, int len);
10static int read_charflags_section(FILE *fd);
11static int read_prefcond_section(FILE *fd, slang_T *lp);
12static int read_rep_section(FILE *fd, garray_T *gap, int16_t *first);
13static int read_sal_section(FILE *fd, slang_T *slang);
14static int read_words_section(FILE *fd, slang_T *lp, int len);
15static int read_sofo_section(FILE *fd, slang_T *slang);
16static int read_compound(FILE *fd, slang_T *slang, int len);
17static int set_sofo(slang_T *lp, char_u *from, char_u *to);
18static void set_sal_first(slang_T *lp);
19static int *mb_str2wide(char_u *s);
20static int spell_read_tree(FILE *fd, char_u **bytsp, idx_T **idxsp, _Bool prefixtree, int prefixcnt );
21static idx_T read_tree_node(FILE *fd, char_u *byts, idx_T *idxs, int maxidx, idx_T startidx, _Bool prefixtree, int maxprefcondnr );
22static void spell_reload_one(char_u *fname, _Bool added_word );
23static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname);
24static _Bool is_aff_rule(char_u **items, int itemcnt, char *rulename, int mincount);
25static void aff_process_flags(afffile_T *affile, affentry_T *entry);
26static _Bool spell_info_item(char_u *s);
27static unsigned affitem2flag(int flagtype, char_u *item, char_u *fname, int lnum);
28static unsigned get_affitem(int flagtype, char_u **pp);
29static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compflags);
30static void check_renumber(spellinfo_T *spin);
31static _Bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag);
32static void aff_check_number(int spinval, int affval, char *name);
33static void aff_check_string(char_u *spinval, char_u *affval, char *name);
34static _Bool str_equal(char_u *s1, char_u *s2);
35static void add_fromto(spellinfo_T *spin, garray_T *gap, char_u *from, char_u *to);
36static _Bool sal_to_bool(char_u *s);
37static void spell_free_aff(afffile_T *aff);
38static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile);
39static int get_affix_flags(afffile_T *affile, char_u *afflist);
40static int get_pfxlist(afffile_T *affile, char_u *afflist, char_u *store_afflist);
41static void get_compflags(afffile_T *affile, char_u *afflist, char_u *store_afflist);
42static 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 );
43static int spell_read_wordfile(spellinfo_T *spin, char_u *fname);
44static void *getroom(spellinfo_T *spin, size_t len, _Bool align) FUNC_ATTR_NONNULL_RET;
45static char_u *getroom_save(spellinfo_T *spin, char_u *s);
46static void free_blocks(sblock_T *bl);
47static wordnode_T *wordtree_alloc(spellinfo_T *spin) FUNC_ATTR_NONNULL_RET;
48static int store_word(spellinfo_T *spin, char_u *word, int flags, int region, char_u *pfxlist, _Bool need_affix );
49static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int flags, int region, int affixID);
50static wordnode_T *get_wordnode(spellinfo_T *spin);
51static int deref_wordnode(spellinfo_T *spin, wordnode_T *node);
52static void free_wordnode(spellinfo_T *spin, wordnode_T *n);
53static void wordtree_compress(spellinfo_T *spin, wordnode_T *root);
54static int node_compress(spellinfo_T *spin, wordnode_T *node, hashtab_T *ht, int *tot );
55static _Bool node_equal(wordnode_T *n1, wordnode_T *n2);
56static int rep_compare(const void *s1, const void *s2);
57static int write_vim_spell(spellinfo_T *spin, char_u *fname);
58static void clear_node(wordnode_T *node);
59static int put_node(FILE *fd, wordnode_T *node, int idx, int regionmask, _Bool prefixtree );
60static void spell_make_sugfile(spellinfo_T *spin, char_u *wfname);
61static int sug_filltree(spellinfo_T *spin, slang_T *slang);
62static int sug_maketable(spellinfo_T *spin);
63static int sug_filltable(spellinfo_T *spin, wordnode_T *node, int startwordnr, garray_T *gap );
64static int offset2bytes(int nr, char_u *buf);
65static void sug_write(spellinfo_T *spin, char_u *fname);
66static void mkspell(int fcount, char_u **fnames, _Bool ascii, _Bool over_write, _Bool added_word );
67static void spell_message(spellinfo_T *spin, char_u *str);
68static void init_spellfile(void);
69static int set_spell_chartab(char_u *fol, char_u *low, char_u *upp);
70static void set_spell_charflags(char_u *flags, int cnt, char_u *fol );
71static int set_spell_finish(spelltab_T *new_st);
72static int write_spell_prefcond(FILE *fd, garray_T *gap);
73static void set_map_str(slang_T *lp, char_u *map);
74#include "nvim/func_attr.h"
75