Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / extensions / spellcheck / hunspell / src / affixmgr.hxx
blobf90ebd263a12d41f4682194f5918b65b1f5fc04f
1 /******* BEGIN LICENSE BLOCK *******
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Initial Developers of the Original Code are Kevin Hendricks (MySpell)
15 * and László Németh (Hunspell). Portions created by the Initial Developers
16 * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved.
18 * Contributor(s): Kevin Hendricks (kevin.hendricks@sympatico.ca)
19 * David Einstein (deinst@world.std.com)
20 * László Németh (nemethl@gyorsposta.hu)
21 * Davide Prina
22 * Giuseppe Modugno
23 * Gianluca Turconi
24 * Simon Brouwer
25 * Noll Janos
26 * Biro Arpad
27 * Goldman Eleonora
28 * Sarlos Tamas
29 * Bencsath Boldizsar
30 * Halacsy Peter
31 * Dvornik Laszlo
32 * Gefferth Andras
33 * Nagy Viktor
34 * Varga Daniel
35 * Chris Halls
36 * Rene Engelhard
37 * Bram Moolenaar
38 * Dafydd Jones
39 * Harri Pitkanen
40 * Andras Timar
41 * Tor Lillqvist
43 * Alternatively, the contents of this file may be used under the terms of
44 * either the GNU General Public License Version 2 or later (the "GPL"), or
45 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
46 * in which case the provisions of the GPL or the LGPL are applicable instead
47 * of those above. If you wish to allow use of your version of this file only
48 * under the terms of either the GPL or the LGPL, and not to allow others to
49 * use your version of this file under the terms of the MPL, indicate your
50 * decision by deleting the provisions above and replace them with the notice
51 * and other provisions required by the GPL or the LGPL. If you do not delete
52 * the provisions above, a recipient may use your version of this file under
53 * the terms of any one of the MPL, the GPL or the LGPL.
55 ******* END LICENSE BLOCK *******/
57 #ifndef _AFFIXMGR_HXX_
58 #define _AFFIXMGR_HXX_
60 #ifdef MOZILLA_CLIENT
61 #ifdef __SUNPRO_CC // for SunONE Studio compiler
62 using namespace std;
63 #endif
64 #include <stdio.h>
65 #else
66 #include <cstdio>
67 #endif
69 #include "atypes.hxx"
70 #include "baseaffix.hxx"
71 #include "hashmgr.hxx"
72 #include "phonet.hxx"
73 #include "replist.hxx"
75 // check flag duplication
76 #define dupSFX (1 << 0)
77 #define dupPFX (1 << 1)
79 class AffixMgr
82 AffEntry * pStart[SETSIZE];
83 AffEntry * sStart[SETSIZE];
84 AffEntry * pFlag[SETSIZE];
85 AffEntry * sFlag[SETSIZE];
86 HashMgr * pHMgr;
87 HashMgr ** alldic;
88 int * maxdic;
89 char * keystring;
90 char * trystring;
91 char * encoding;
92 struct cs_info * csconv;
93 int utf8;
94 int complexprefixes;
95 FLAG compoundflag;
96 FLAG compoundbegin;
97 FLAG compoundmiddle;
98 FLAG compoundend;
99 FLAG compoundroot;
100 FLAG compoundforbidflag;
101 FLAG compoundpermitflag;
102 int checkcompounddup;
103 int checkcompoundrep;
104 int checkcompoundcase;
105 int checkcompoundtriple;
106 int simplifiedtriple;
107 FLAG forbiddenword;
108 FLAG nosuggest;
109 FLAG needaffix;
110 int cpdmin;
111 int numrep;
112 replentry * reptable;
113 RepList * iconvtable;
114 RepList * oconvtable;
115 int nummap;
116 mapentry * maptable;
117 int numbreak;
118 char ** breaktable;
119 int numcheckcpd;
120 patentry * checkcpdtable;
121 int simplifiedcpd;
122 int numdefcpd;
123 flagentry * defcpdtable;
124 phonetable * phone;
125 int maxngramsugs;
126 int nosplitsugs;
127 int sugswithdots;
128 int cpdwordmax;
129 int cpdmaxsyllable;
130 char * cpdvowels;
131 w_char * cpdvowels_utf16;
132 int cpdvowels_utf16_len;
133 char * cpdsyllablenum;
134 const char * pfxappnd; // BUG: not stateless
135 const char * sfxappnd; // BUG: not stateless
136 FLAG sfxflag; // BUG: not stateless
137 char * derived; // BUG: not stateless
138 AffEntry * sfx; // BUG: not stateless
139 AffEntry * pfx; // BUG: not stateless
140 int checknum;
141 char * wordchars;
142 unsigned short * wordchars_utf16;
143 int wordchars_utf16_len;
144 char * ignorechars;
145 unsigned short * ignorechars_utf16;
146 int ignorechars_utf16_len;
147 char * version;
148 char * lang;
149 int langnum;
150 FLAG lemma_present;
151 FLAG circumfix;
152 FLAG onlyincompound;
153 FLAG keepcase;
154 FLAG substandard;
155 int checksharps;
156 int fullstrip;
158 int havecontclass; // boolean variable
159 char contclasses[CONTSIZE]; // flags of possible continuing classes (twofold affix)
161 public:
163 AffixMgr(const char * affpath, HashMgr** ptr, int * md,
164 const char * key = NULL);
165 ~AffixMgr();
166 struct hentry * affix_check(const char * word, int len,
167 const unsigned short needflag = (unsigned short) 0,
168 char in_compound = IN_CPD_NOT);
169 struct hentry * prefix_check(const char * word, int len,
170 char in_compound, const FLAG needflag = FLAG_NULL);
171 inline int isSubset(const char * s1, const char * s2);
172 struct hentry * prefix_check_twosfx(const char * word, int len,
173 char in_compound, const FLAG needflag = FLAG_NULL);
174 inline int isRevSubset(const char * s1, const char * end_of_s2, int len);
175 struct hentry * suffix_check(const char * word, int len, int sfxopts,
176 AffEntry* ppfx, char ** wlst, int maxSug, int * ns,
177 const FLAG cclass = FLAG_NULL, const FLAG needflag = FLAG_NULL,
178 char in_compound = IN_CPD_NOT);
179 struct hentry * suffix_check_twosfx(const char * word, int len,
180 int sfxopts, AffEntry* ppfx, const FLAG needflag = FLAG_NULL);
182 char * affix_check_morph(const char * word, int len,
183 const FLAG needflag = FLAG_NULL, char in_compound = IN_CPD_NOT);
184 char * prefix_check_morph(const char * word, int len,
185 char in_compound, const FLAG needflag = FLAG_NULL);
186 char * suffix_check_morph (const char * word, int len, int sfxopts,
187 AffEntry * ppfx, const FLAG cclass = FLAG_NULL,
188 const FLAG needflag = FLAG_NULL, char in_compound = IN_CPD_NOT);
190 char * prefix_check_twosfx_morph(const char * word, int len,
191 char in_compound, const FLAG needflag = FLAG_NULL);
192 char * suffix_check_twosfx_morph(const char * word, int len,
193 int sfxopts, AffEntry * ppfx, const FLAG needflag = FLAG_NULL);
195 char * morphgen(char * ts, int wl, const unsigned short * ap,
196 unsigned short al, char * morph, char * targetmorph, int level);
198 int expand_rootword(struct guessword * wlst, int maxn, const char * ts,
199 int wl, const unsigned short * ap, unsigned short al, char * bad,
200 int, char *);
202 short get_syllable (const char * word, int wlen);
203 int cpdrep_check(const char * word, int len);
204 int cpdpat_check(const char * word, int len, hentry * r1, hentry * r2);
205 int defcpd_check(hentry *** words, short wnum, hentry * rv,
206 hentry ** rwords, char all);
207 int cpdcase_check(const char * word, int len);
208 inline int candidate_check(const char * word, int len);
209 void setcminmax(int * cmin, int * cmax, const char * word, int len);
210 struct hentry * compound_check(const char * word, int len, short wordnum,
211 short numsyllable, short maxwordnum, short wnum, hentry ** words,
212 char hu_mov_rule, char is_sug);
214 int compound_check_morph(const char * word, int len, short wordnum,
215 short numsyllable, short maxwordnum, short wnum, hentry ** words,
216 char hu_mov_rule, char ** result, char * partresult);
218 struct hentry * lookup(const char * word);
219 int get_numrep();
220 struct replentry * get_reptable();
221 RepList * get_iconvtable();
222 RepList * get_oconvtable();
223 struct phonetable * get_phonetable();
224 int get_nummap();
225 struct mapentry * get_maptable();
226 int get_numbreak();
227 char ** get_breaktable();
228 char * get_encoding();
229 int get_langnum();
230 char * get_key_string();
231 char * get_try_string();
232 const char * get_wordchars();
233 unsigned short * get_wordchars_utf16(int * len);
234 char * get_ignore();
235 unsigned short * get_ignore_utf16(int * len);
236 int get_compound();
237 FLAG get_compoundflag();
238 FLAG get_compoundbegin();
239 FLAG get_forbiddenword();
240 FLAG get_nosuggest();
241 FLAG get_needaffix();
242 FLAG get_onlyincompound();
243 FLAG get_compoundroot();
244 FLAG get_lemma_present();
245 int get_checknum();
246 char * get_possible_root();
247 const char * get_prefix();
248 const char * get_suffix();
249 const char * get_derived();
250 const char * get_version();
251 const int have_contclass();
252 int get_utf8();
253 int get_complexprefixes();
254 char * get_suffixed(char );
255 int get_maxngramsugs();
256 int get_nosplitsugs();
257 int get_sugswithdots(void);
258 FLAG get_keepcase(void);
259 int get_checksharps(void);
260 char * encode_flag(unsigned short aflag);
261 int get_fullstrip();
263 private:
264 int parse_file(const char * affpath, const char * key);
265 int parse_flag(char * line, unsigned short * out, FileMgr * af);
266 int parse_num(char * line, int * out, FileMgr * af);
267 int parse_cpdsyllable(char * line, FileMgr * af);
268 int parse_reptable(char * line, FileMgr * af);
269 int parse_convtable(char * line, FileMgr * af, RepList ** rl, const char * keyword);
270 int parse_phonetable(char * line, FileMgr * af);
271 int parse_maptable(char * line, FileMgr * af);
272 int parse_breaktable(char * line, FileMgr * af);
273 int parse_checkcpdtable(char * line, FileMgr * af);
274 int parse_defcpdtable(char * line, FileMgr * af);
275 int parse_affix(char * line, const char at, FileMgr * af, char * dupflags);
277 void reverse_condition(char *);
278 void debugflag(char * result, unsigned short flag);
279 int condlen(char *);
280 int encodeit(struct affentry * ptr, char * cs);
281 int build_pfxtree(AffEntry* pfxptr);
282 int build_sfxtree(AffEntry* sfxptr);
283 int process_pfx_order();
284 int process_sfx_order();
285 AffEntry * process_pfx_in_order(AffEntry * ptr, AffEntry * nptr);
286 AffEntry * process_sfx_in_order(AffEntry * ptr, AffEntry * nptr);
287 int process_pfx_tree_to_list();
288 int process_sfx_tree_to_list();
289 int redundant_condition(char, char * strip, int stripl,
290 const char * cond, int);
293 #endif