├── LICENSE ├── README.md ├── binding.gyp ├── deps └── hunspell │ ├── ABOUT-NLS │ ├── AUTHORS │ ├── AUTHORS.myspell │ ├── BUGS │ ├── COPYING │ ├── COPYING.LGPL │ ├── COPYING.MPL │ ├── ChangeLog │ ├── ChangeLog.O │ ├── INSTALL │ ├── NEWS │ ├── README │ ├── README.myspell │ ├── THANKS │ ├── TODO │ ├── binding.gyp │ ├── license.hunspell │ ├── license.myspell │ └── src │ ├── hunspell │ ├── README │ ├── affentry.cxx │ ├── affentry.hxx │ ├── affixmgr.cxx │ ├── affixmgr.hxx │ ├── atypes.hxx │ ├── baseaffix.hxx │ ├── config.h │ ├── csutil.cxx │ ├── csutil.hxx │ ├── dictmgr.cxx │ ├── dictmgr.hxx │ ├── filemgr.cxx │ ├── filemgr.hxx │ ├── hashmgr.cxx │ ├── hashmgr.hxx │ ├── htypes.hxx │ ├── hunspell.cxx │ ├── hunspell.h │ ├── hunspell.hxx │ ├── hunvisapi.h │ ├── hunzip.cxx │ ├── hunzip.hxx │ ├── langnum.hxx │ ├── license.hunspell │ ├── license.myspell │ ├── phonet.cxx │ ├── phonet.hxx │ ├── replist.cxx │ ├── replist.hxx │ ├── suggestmgr.cxx │ ├── suggestmgr.hxx │ └── w_char.hxx │ └── win_api │ ├── README │ └── config.h ├── index.js ├── package.json └── src └── spellcheck.cc /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Brian White. All rights reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to 5 | deal in the Software without restriction, including without limitation the 6 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | An async hunspell binding for [node.js](http://nodejs.org/). 5 | 6 | 7 | Requirements 8 | ============ 9 | 10 | * [node.js](http://nodejs.org/) -- v0.6.0 or newer 11 | * [Dictionary and affix files](http://wiki.services.openoffice.org/wiki/Dictionaries) 12 | 13 | 14 | Install 15 | ============ 16 | 17 | npm install spellcheck 18 | 19 | 20 | Examples 21 | ======== 22 | 23 | * Check a word: 24 | ```javascript 25 | // this example uses the en_US hunspell files from SCOWL: 26 | // http://wordlist.sourceforge.net/ 27 | var SpellCheck = require('spellcheck'), 28 | base = __dirname + (process.platform === 'win32' ? '\\' : '/'), 29 | spell = new SpellCheck(base + 'en_US.aff', base + 'en_US.dic'); 30 | 31 | spell.check('sain', function(err, correct, suggestions) { 32 | if (err) throw err; 33 | if (correct) 34 | console.log('Word is spelled correctly!'); 35 | else 36 | console.log('Word not recognized. Suggestions: ' + suggestions); 37 | }); 38 | 39 | // output: 40 | // Word not recognized. Suggestions: chain,sin,saint,satin,stain,slain,swain,rain,sail,lain,said,gain,main,spin,pain 41 | ``` 42 | 43 | 44 | API 45 | === 46 | 47 | Methods 48 | ------- 49 | 50 | * **(constructor)**(<_String_>affixPath, <_Integer_>dictPath) - Creates and returns a new SpellCheck instance. affixPath is an **absolute** path that points to an affix (.aff) file. dictPath is an **absolute** path that points to a dictionary (.dic) file. 51 | 52 | * **check**(<_String_>word, <_Function_>callback) - _(void)_ - Spell checks the given word. The callback receives three arguments: an <_Error_> object in case of error (null otherwise), a <_Boolean_> indicating if the word was spelled correctly, and if the word was not recognized, an <_Array_> of suggested words. 53 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'targets': [ 3 | { 4 | 'target_name': 'spellcheck', 5 | 'sources': [ 6 | 'src/spellcheck.cc', 7 | ], 8 | 'cflags': [ '-O3' ], 9 | 'dependencies': [ 10 | 'deps/hunspell/binding.gyp:hunspell', 11 | ], 12 | 'include_dirs': [ 13 | " is the original 15 | author and now maintainer of the MySpell codebase. Recent 16 | additions include ngram support, and related character maps 17 | to help improve and create suggestions for very poorly 18 | spelled words. 19 | 20 | Please send any and all contributions or improvements 21 | to him or to dev@lingucomponent.openoffice.org. 22 | 23 | 24 | David Einstein (Deinst@world.std.com) developed an almost 25 | complete rewrite of MySpell for use by the Mozilla project. 26 | David and I are now working on parallel development tracks 27 | to help our respective projects (Mozilla and OpenOffice.org) 28 | and we will maintain full affix file and dictionary file 29 | compatibility and work on merging our versions of MySpell 30 | back into a single tree. David has been a significant help 31 | in improving MySpell. 32 | 33 | 34 | Németh László is the author of 35 | the Hungarian dictionary and he developed and contributed 36 | extensive changes to MySpell including ... 37 | * code to support compound words in MySpell 38 | * fixed numerous problems with encoding case conversion tables. 39 | * designed/developed replacement tables to improve suggestions 40 | * changed affix file parsing to trees to greatly speed loading 41 | * removed the need for malloc/free pairs in suffix_check which 42 | speeds up spell checking in suffix rich languages by 20% 43 | 44 | Davide Prina , Giuseppe Modugno 45 | , Gianluca Turconi 46 | all from the it_IT OpenOffice.org team performed an 47 | extremely detailed code review of MySpell and generated 48 | fixes for bugs, leaks, and speedup improvements. 49 | 50 | Simon Brouwer for fixes and enhancements 51 | that have greatly improved MySpell auggestions 52 | * n-gram suggestions for an initcap word have an init. cap. 53 | * fix for too many n-gram suggestions from specialized dictionary, 54 | * fix for long suggestions rather than close ones in case of 55 | dictionaries with many compound words (kompuuter) 56 | * optionally disabling split-word suggestions (controlled 57 | by NOSPLITSUGS line in affix file) 58 | 59 | 60 | Special Thanks to all others who have either contributed ideas or 61 | testing for MySpell 62 | 63 | 64 | Thanks, 65 | 66 | Kevin Hendricks 67 | kevin.hendricks@sympatico.ca 68 | -------------------------------------------------------------------------------- /deps/hunspell/BUGS: -------------------------------------------------------------------------------- 1 | * Interactive interface has some visualization problem with long lines 2 | 3 | * Experimental -U, -u options don't support Unicode. 4 | 5 | * Compound handling is not thread safe in Hungarian specific code. 6 | -------------------------------------------------------------------------------- /deps/hunspell/COPYING: -------------------------------------------------------------------------------- 1 | GPL 2.0/LGPL 2.1/MPL 1.1 tri-license 2 | 3 | The contents of this software may be used under the terms of 4 | the GNU General Public License Version 2 or later (the "GPL"), or 5 | the GNU Lesser General Public License Version 2.1 or later (the "LGPL", 6 | see COPYING.LGPL) or (excepting the LGPLed GNU gettext library in the 7 | intl/ directory) the Mozilla Public License Version 1.1 or later 8 | (the "MPL", see COPYING.MPL). 9 | 10 | Software distributed under these licenses is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the licences 12 | for the specific language governing rights and limitations under the licenses. 13 | -------------------------------------------------------------------------------- /deps/hunspell/COPYING.LGPL: -------------------------------------------------------------------------------- 1 | 2 | GNU LESSER GENERAL PUBLIC LICENSE 3 | Version 2.1, February 1999 4 | 5 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 6 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | [This is the first released version of the Lesser GPL. It also counts 11 | as the successor of the GNU Library Public License, version 2, hence 12 | the version number 2.1.] 13 | 14 | Preamble 15 | 16 | The licenses for most software are designed to take away your 17 | freedom to share and change it. By contrast, the GNU General Public 18 | Licenses are intended to guarantee your freedom to share and change 19 | free software--to make sure the software is free for all its users. 20 | 21 | This license, the Lesser General Public License, applies to some 22 | specially designated software packages--typically libraries--of the 23 | Free Software Foundation and other authors who decide to use it. You 24 | can use it too, but we suggest you first think carefully about whether 25 | this license or the ordinary General Public License is the better 26 | strategy to use in any particular case, based on the explanations 27 | below. 28 | 29 | When we speak of free software, we are referring to freedom of use, 30 | not price. Our General Public Licenses are designed to make sure that 31 | you have the freedom to distribute copies of free software (and charge 32 | for this service if you wish); that you receive source code or can get 33 | it if you want it; that you can change the software and use pieces of 34 | it in new free programs; and that you are informed that you can do 35 | these things. 36 | 37 | To protect your rights, we need to make restrictions that forbid 38 | distributors to deny you these rights or to ask you to surrender these 39 | rights. These restrictions translate to certain responsibilities for 40 | you if you distribute copies of the library or if you modify it. 41 | 42 | For example, if you distribute copies of the library, whether gratis 43 | or for a fee, you must give the recipients all the rights that we gave 44 | you. You must make sure that they, too, receive or can get the source 45 | code. If you link other code with the library, you must provide 46 | complete object files to the recipients, so that they can relink them 47 | with the library after making changes to the library and recompiling 48 | it. And you must show them these terms so they know their rights. 49 | 50 | We protect your rights with a two-step method: (1) we copyright the 51 | library, and (2) we offer you this license, which gives you legal 52 | permission to copy, distribute and/or modify the library. 53 | 54 | To protect each distributor, we want to make it very clear that 55 | there is no warranty for the free library. Also, if the library is 56 | modified by someone else and passed on, the recipients should know 57 | that what they have is not the original version, so that the original 58 | author's reputation will not be affected by problems that might be 59 | introduced by others. 60 | ^L 61 | Finally, software patents pose a constant threat to the existence of 62 | any free program. We wish to make sure that a company cannot 63 | effectively restrict the users of a free program by obtaining a 64 | restrictive license from a patent holder. Therefore, we insist that 65 | any patent license obtained for a version of the library must be 66 | consistent with the full freedom of use specified in this license. 67 | 68 | Most GNU software, including some libraries, is covered by the 69 | ordinary GNU General Public License. This license, the GNU Lesser 70 | General Public License, applies to certain designated libraries, and 71 | is quite different from the ordinary General Public License. We use 72 | this license for certain libraries in order to permit linking those 73 | libraries into non-free programs. 74 | 75 | When a program is linked with a library, whether statically or using 76 | a shared library, the combination of the two is legally speaking a 77 | combined work, a derivative of the original library. The ordinary 78 | General Public License therefore permits such linking only if the 79 | entire combination fits its criteria of freedom. The Lesser General 80 | Public License permits more lax criteria for linking other code with 81 | the library. 82 | 83 | We call this license the "Lesser" General Public License because it 84 | does Less to protect the user's freedom than the ordinary General 85 | Public License. It also provides other free software developers Less 86 | of an advantage over competing non-free programs. These disadvantages 87 | are the reason we use the ordinary General Public License for many 88 | libraries. However, the Lesser license provides advantages in certain 89 | special circumstances. 90 | 91 | For example, on rare occasions, there may be a special need to 92 | encourage the widest possible use of a certain library, so that it 93 | becomes 94 | a de-facto standard. To achieve this, non-free programs must be 95 | allowed to use the library. A more frequent case is that a free 96 | library does the same job as widely used non-free libraries. In this 97 | case, there is little to gain by limiting the free library to free 98 | software only, so we use the Lesser General Public License. 99 | 100 | In other cases, permission to use a particular library in non-free 101 | programs enables a greater number of people to use a large body of 102 | free software. For example, permission to use the GNU C Library in 103 | non-free programs enables many more people to use the whole GNU 104 | operating system, as well as its variant, the GNU/Linux operating 105 | system. 106 | 107 | Although the Lesser General Public License is Less protective of the 108 | users' freedom, it does ensure that the user of a program that is 109 | linked with the Library has the freedom and the wherewithal to run 110 | that program using a modified version of the Library. 111 | 112 | The precise terms and conditions for copying, distribution and 113 | modification follow. Pay close attention to the difference between a 114 | "work based on the library" and a "work that uses the library". The 115 | former contains code derived from the library, whereas the latter must 116 | be combined with the library in order to run. 117 | ^L 118 | GNU LESSER GENERAL PUBLIC LICENSE 119 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 120 | 121 | 0. This License Agreement applies to any software library or other 122 | program which contains a notice placed by the copyright holder or 123 | other authorized party saying it may be distributed under the terms of 124 | this Lesser General Public License (also called "this License"). 125 | Each licensee is addressed as "you". 126 | 127 | A "library" means a collection of software functions and/or data 128 | prepared so as to be conveniently linked with application programs 129 | (which use some of those functions and data) to form executables. 130 | 131 | The "Library", below, refers to any such software library or work 132 | which has been distributed under these terms. A "work based on the 133 | Library" means either the Library or any derivative work under 134 | copyright law: that is to say, a work containing the Library or a 135 | portion of it, either verbatim or with modifications and/or translated 136 | straightforwardly into another language. (Hereinafter, translation is 137 | included without limitation in the term "modification".) 138 | 139 | "Source code" for a work means the preferred form of the work for 140 | making modifications to it. For a library, complete source code means 141 | all the source code for all modules it contains, plus any associated 142 | interface definition files, plus the scripts used to control 143 | compilation 144 | and installation of the library. 145 | 146 | Activities other than copying, distribution and modification are not 147 | covered by this License; they are outside its scope. The act of 148 | running a program using the Library is not restricted, and output from 149 | such a program is covered only if its contents constitute a work based 150 | on the Library (independent of the use of the Library in a tool for 151 | writing it). Whether that is true depends on what the Library does 152 | and what the program that uses the Library does. 153 | 154 | 1. You may copy and distribute verbatim copies of the Library's 155 | complete source code as you receive it, in any medium, provided that 156 | you conspicuously and appropriately publish on each copy an 157 | appropriate copyright notice and disclaimer of warranty; keep intact 158 | all the notices that refer to this License and to the absence of any 159 | warranty; and distribute a copy of this License along with the 160 | Library. 161 | 162 | You may charge a fee for the physical act of transferring a copy, 163 | and you may at your option offer warranty protection in exchange for a 164 | fee. 165 | 166 | 2. You may modify your copy or copies of the Library or any portion 167 | of it, thus forming a work based on the Library, and copy and 168 | distribute such modifications or work under the terms of Section 1 169 | above, provided that you also meet all of these conditions: 170 | 171 | a) The modified work must itself be a software library. 172 | 173 | b) You must cause the files modified to carry prominent notices 174 | stating that you changed the files and the date of any change. 175 | 176 | c) You must cause the whole of the work to be licensed at no 177 | charge to all third parties under the terms of this License. 178 | 179 | d) If a facility in the modified Library refers to a function or a 180 | table of data to be supplied by an application program that uses 181 | the facility, other than as an argument passed when the facility 182 | is invoked, then you must make a good faith effort to ensure that, 183 | in the event an application does not supply such function or 184 | table, the facility still operates, and performs whatever part of 185 | its purpose remains meaningful. 186 | 187 | (For example, a function in a library to compute square roots has 188 | a purpose that is entirely well-defined independent of the 189 | application. Therefore, Subsection 2d requires that any 190 | application-supplied function or table used by this function must 191 | be optional: if the application does not supply it, the square 192 | root function must still compute square roots.) 193 | 194 | These requirements apply to the modified work as a whole. If 195 | identifiable sections of that work are not derived from the Library, 196 | and can be reasonably considered independent and separate works in 197 | themselves, then this License, and its terms, do not apply to those 198 | sections when you distribute them as separate works. But when you 199 | distribute the same sections as part of a whole which is a work based 200 | on the Library, the distribution of the whole must be on the terms of 201 | this License, whose permissions for other licensees extend to the 202 | entire whole, and thus to each and every part regardless of who wrote 203 | it. 204 | 205 | Thus, it is not the intent of this section to claim rights or contest 206 | your rights to work written entirely by you; rather, the intent is to 207 | exercise the right to control the distribution of derivative or 208 | collective works based on the Library. 209 | 210 | In addition, mere aggregation of another work not based on the Library 211 | with the Library (or with a work based on the Library) on a volume of 212 | a storage or distribution medium does not bring the other work under 213 | the scope of this License. 214 | 215 | 3. You may opt to apply the terms of the ordinary GNU General Public 216 | License instead of this License to a given copy of the Library. To do 217 | this, you must alter all the notices that refer to this License, so 218 | that they refer to the ordinary GNU General Public License, version 2, 219 | instead of to this License. (If a newer version than version 2 of the 220 | ordinary GNU General Public License has appeared, then you can specify 221 | that version instead if you wish.) Do not make any other change in 222 | these notices. 223 | ^L 224 | Once this change is made in a given copy, it is irreversible for 225 | that copy, so the ordinary GNU General Public License applies to all 226 | subsequent copies and derivative works made from that copy. 227 | 228 | This option is useful when you wish to copy part of the code of 229 | the Library into a program that is not a library. 230 | 231 | 4. You may copy and distribute the Library (or a portion or 232 | derivative of it, under Section 2) in object code or executable form 233 | under the terms of Sections 1 and 2 above provided that you accompany 234 | it with the complete corresponding machine-readable source code, which 235 | must be distributed under the terms of Sections 1 and 2 above on a 236 | medium customarily used for software interchange. 237 | 238 | If distribution of object code is made by offering access to copy 239 | from a designated place, then offering equivalent access to copy the 240 | source code from the same place satisfies the requirement to 241 | distribute the source code, even though third parties are not 242 | compelled to copy the source along with the object code. 243 | 244 | 5. A program that contains no derivative of any portion of the 245 | Library, but is designed to work with the Library by being compiled or 246 | linked with it, is called a "work that uses the Library". Such a 247 | work, in isolation, is not a derivative work of the Library, and 248 | therefore falls outside the scope of this License. 249 | 250 | However, linking a "work that uses the Library" with the Library 251 | creates an executable that is a derivative of the Library (because it 252 | contains portions of the Library), rather than a "work that uses the 253 | library". The executable is therefore covered by this License. 254 | Section 6 states terms for distribution of such executables. 255 | 256 | When a "work that uses the Library" uses material from a header file 257 | that is part of the Library, the object code for the work may be a 258 | derivative work of the Library even though the source code is not. 259 | Whether this is true is especially significant if the work can be 260 | linked without the Library, or if the work is itself a library. The 261 | threshold for this to be true is not precisely defined by law. 262 | 263 | If such an object file uses only numerical parameters, data 264 | structure layouts and accessors, and small macros and small inline 265 | functions (ten lines or less in length), then the use of the object 266 | file is unrestricted, regardless of whether it is legally a derivative 267 | work. (Executables containing this object code plus portions of the 268 | Library will still fall under Section 6.) 269 | 270 | Otherwise, if the work is a derivative of the Library, you may 271 | distribute the object code for the work under the terms of Section 6. 272 | Any executables containing that work also fall under Section 6, 273 | whether or not they are linked directly with the Library itself. 274 | ^L 275 | 6. As an exception to the Sections above, you may also combine or 276 | link a "work that uses the Library" with the Library to produce a 277 | work containing portions of the Library, and distribute that work 278 | under terms of your choice, provided that the terms permit 279 | modification of the work for the customer's own use and reverse 280 | engineering for debugging such modifications. 281 | 282 | You must give prominent notice with each copy of the work that the 283 | Library is used in it and that the Library and its use are covered by 284 | this License. You must supply a copy of this License. If the work 285 | during execution displays copyright notices, you must include the 286 | copyright notice for the Library among them, as well as a reference 287 | directing the user to the copy of this License. Also, you must do one 288 | of these things: 289 | 290 | a) Accompany the work with the complete corresponding 291 | machine-readable source code for the Library including whatever 292 | changes were used in the work (which must be distributed under 293 | Sections 1 and 2 above); and, if the work is an executable linked 294 | with the Library, with the complete machine-readable "work that 295 | uses the Library", as object code and/or source code, so that the 296 | user can modify the Library and then relink to produce a modified 297 | executable containing the modified Library. (It is understood 298 | that the user who changes the contents of definitions files in the 299 | Library will not necessarily be able to recompile the application 300 | to use the modified definitions.) 301 | 302 | b) Use a suitable shared library mechanism for linking with the 303 | Library. A suitable mechanism is one that (1) uses at run time a 304 | copy of the library already present on the user's computer system, 305 | rather than copying library functions into the executable, and (2) 306 | will operate properly with a modified version of the library, if 307 | the user installs one, as long as the modified version is 308 | interface-compatible with the version that the work was made with. 309 | 310 | c) Accompany the work with a written offer, valid for at 311 | least three years, to give the same user the materials 312 | specified in Subsection 6a, above, for a charge no more 313 | than the cost of performing this distribution. 314 | 315 | d) If distribution of the work is made by offering access to copy 316 | from a designated place, offer equivalent access to copy the above 317 | specified materials from the same place. 318 | 319 | e) Verify that the user has already received a copy of these 320 | materials or that you have already sent this user a copy. 321 | 322 | For an executable, the required form of the "work that uses the 323 | Library" must include any data and utility programs needed for 324 | reproducing the executable from it. However, as a special exception, 325 | the materials to be distributed need not include anything that is 326 | normally distributed (in either source or binary form) with the major 327 | components (compiler, kernel, and so on) of the operating system on 328 | which the executable runs, unless that component itself accompanies 329 | the executable. 330 | 331 | It may happen that this requirement contradicts the license 332 | restrictions of other proprietary libraries that do not normally 333 | accompany the operating system. Such a contradiction means you cannot 334 | use both them and the Library together in an executable that you 335 | distribute. 336 | ^L 337 | 7. You may place library facilities that are a work based on the 338 | Library side-by-side in a single library together with other library 339 | facilities not covered by this License, and distribute such a combined 340 | library, provided that the separate distribution of the work based on 341 | the Library and of the other library facilities is otherwise 342 | permitted, and provided that you do these two things: 343 | 344 | a) Accompany the combined library with a copy of the same work 345 | based on the Library, uncombined with any other library 346 | facilities. This must be distributed under the terms of the 347 | Sections above. 348 | 349 | b) Give prominent notice with the combined library of the fact 350 | that part of it is a work based on the Library, and explaining 351 | where to find the accompanying uncombined form of the same work. 352 | 353 | 8. You may not copy, modify, sublicense, link with, or distribute 354 | the Library except as expressly provided under this License. Any 355 | attempt otherwise to copy, modify, sublicense, link with, or 356 | distribute the Library is void, and will automatically terminate your 357 | rights under this License. However, parties who have received copies, 358 | or rights, from you under this License will not have their licenses 359 | terminated so long as such parties remain in full compliance. 360 | 361 | 9. You are not required to accept this License, since you have not 362 | signed it. However, nothing else grants you permission to modify or 363 | distribute the Library or its derivative works. These actions are 364 | prohibited by law if you do not accept this License. Therefore, by 365 | modifying or distributing the Library (or any work based on the 366 | Library), you indicate your acceptance of this License to do so, and 367 | all its terms and conditions for copying, distributing or modifying 368 | the Library or works based on it. 369 | 370 | 10. Each time you redistribute the Library (or any work based on the 371 | Library), the recipient automatically receives a license from the 372 | original licensor to copy, distribute, link with or modify the Library 373 | subject to these terms and conditions. You may not impose any further 374 | restrictions on the recipients' exercise of the rights granted herein. 375 | You are not responsible for enforcing compliance by third parties with 376 | this License. 377 | ^L 378 | 11. If, as a consequence of a court judgment or allegation of patent 379 | infringement or for any other reason (not limited to patent issues), 380 | conditions are imposed on you (whether by court order, agreement or 381 | otherwise) that contradict the conditions of this License, they do not 382 | excuse you from the conditions of this License. If you cannot 383 | distribute so as to satisfy simultaneously your obligations under this 384 | License and any other pertinent obligations, then as a consequence you 385 | may not distribute the Library at all. For example, if a patent 386 | license would not permit royalty-free redistribution of the Library by 387 | all those who receive copies directly or indirectly through you, then 388 | the only way you could satisfy both it and this License would be to 389 | refrain entirely from distribution of the Library. 390 | 391 | If any portion of this section is held invalid or unenforceable under 392 | any particular circumstance, the balance of the section is intended to 393 | apply, and the section as a whole is intended to apply in other 394 | circumstances. 395 | 396 | It is not the purpose of this section to induce you to infringe any 397 | patents or other property right claims or to contest validity of any 398 | such claims; this section has the sole purpose of protecting the 399 | integrity of the free software distribution system which is 400 | implemented by public license practices. Many people have made 401 | generous contributions to the wide range of software distributed 402 | through that system in reliance on consistent application of that 403 | system; it is up to the author/donor to decide if he or she is willing 404 | to distribute software through any other system and a licensee cannot 405 | impose that choice. 406 | 407 | This section is intended to make thoroughly clear what is believed to 408 | be a consequence of the rest of this License. 409 | 410 | 12. If the distribution and/or use of the Library is restricted in 411 | certain countries either by patents or by copyrighted interfaces, the 412 | original copyright holder who places the Library under this License 413 | may add an explicit geographical distribution limitation excluding those 414 | countries, so that distribution is permitted only in or among 415 | countries not thus excluded. In such case, this License incorporates 416 | the limitation as if written in the body of this License. 417 | 418 | 13. The Free Software Foundation may publish revised and/or new 419 | versions of the Lesser General Public License from time to time. 420 | Such new versions will be similar in spirit to the present version, 421 | but may differ in detail to address new problems or concerns. 422 | 423 | Each version is given a distinguishing version number. If the Library 424 | specifies a version number of this License which applies to it and 425 | "any later version", you have the option of following the terms and 426 | conditions either of that version or of any later version published by 427 | the Free Software Foundation. If the Library does not specify a 428 | license version number, you may choose any version ever published by 429 | the Free Software Foundation. 430 | ^L 431 | 14. If you wish to incorporate parts of the Library into other free 432 | programs whose distribution conditions are incompatible with these, 433 | write to the author to ask for permission. For software which is 434 | copyrighted by the Free Software Foundation, write to the Free 435 | Software Foundation; we sometimes make exceptions for this. Our 436 | decision will be guided by the two goals of preserving the free status 437 | of all derivatives of our free software and of promoting the sharing 438 | and reuse of software generally. 439 | 440 | NO WARRANTY 441 | 442 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 443 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 444 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 445 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 446 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 447 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 448 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 449 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 450 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 451 | 452 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 453 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 454 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 455 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 456 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 457 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 458 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 459 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 460 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 461 | DAMAGES. 462 | 463 | END OF TERMS AND CONDITIONS 464 | ^L 465 | How to Apply These Terms to Your New Libraries 466 | 467 | If you develop a new library, and you want it to be of the greatest 468 | possible use to the public, we recommend making it free software that 469 | everyone can redistribute and change. You can do so by permitting 470 | redistribution under these terms (or, alternatively, under the terms 471 | of the ordinary General Public License). 472 | 473 | To apply these terms, attach the following notices to the library. 474 | It is safest to attach them to the start of each source file to most 475 | effectively convey the exclusion of warranty; and each file should 476 | have at least the "copyright" line and a pointer to where the full 477 | notice is found. 478 | 479 | 480 | 482 | Copyright (C) 483 | 484 | This library is free software; you can redistribute it and/or 485 | modify it under the terms of the GNU Lesser General Public 486 | License as published by the Free Software Foundation; either 487 | version 2 of the License, or (at your option) any later version. 488 | 489 | This library is distributed in the hope that it will be useful, 490 | but WITHOUT ANY WARRANTY; without even the implied warranty of 491 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 492 | Lesser General Public License for more details. 493 | 494 | You should have received a copy of the GNU Lesser General Public 495 | License along with this library; if not, write to the Free Software 496 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 497 | 498 | Also add information on how to contact you by electronic and paper 499 | mail. 500 | 501 | You should also get your employer (if you work as a programmer) or 502 | your 503 | school, if any, to sign a "copyright disclaimer" for the library, if 504 | necessary. Here is a sample; alter the names: 505 | 506 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 507 | library `Frob' (a library for tweaking knobs) written by James 508 | Random Hacker. 509 | 510 | , 1 April 1990 511 | Ty Coon, President of Vice 512 | 513 | That's all there is to it! 514 | 515 | 516 | -------------------------------------------------------------------------------- /deps/hunspell/COPYING.MPL: -------------------------------------------------------------------------------- 1 | MOZILLA PUBLIC LICENSE 2 | Version 1.1 3 | 4 | --------------- 5 | 6 | 1. Definitions. 7 | 8 | 1.0.1. "Commercial Use" means distribution or otherwise making the 9 | Covered Code available to a third party. 10 | 11 | 1.1. "Contributor" means each entity that creates or contributes to 12 | the creation of Modifications. 13 | 14 | 1.2. "Contributor Version" means the combination of the Original 15 | Code, prior Modifications used by a Contributor, and the Modifications 16 | made by that particular Contributor. 17 | 18 | 1.3. "Covered Code" means the Original Code or Modifications or the 19 | combination of the Original Code and Modifications, in each case 20 | including portions thereof. 21 | 22 | 1.4. "Electronic Distribution Mechanism" means a mechanism generally 23 | accepted in the software development community for the electronic 24 | transfer of data. 25 | 26 | 1.5. "Executable" means Covered Code in any form other than Source 27 | Code. 28 | 29 | 1.6. "Initial Developer" means the individual or entity identified 30 | as the Initial Developer in the Source Code notice required by Exhibit 31 | A. 32 | 33 | 1.7. "Larger Work" means a work which combines Covered Code or 34 | portions thereof with code not governed by the terms of this License. 35 | 36 | 1.8. "License" means this document. 37 | 38 | 1.8.1. "Licensable" means having the right to grant, to the maximum 39 | extent possible, whether at the time of the initial grant or 40 | subsequently acquired, any and all of the rights conveyed herein. 41 | 42 | 1.9. "Modifications" means any addition to or deletion from the 43 | substance or structure of either the Original Code or any previous 44 | Modifications. When Covered Code is released as a series of files, a 45 | Modification is: 46 | A. Any addition to or deletion from the contents of a file 47 | containing Original Code or previous Modifications. 48 | 49 | B. Any new file that contains any part of the Original Code or 50 | previous Modifications. 51 | 52 | 1.10. "Original Code" means Source Code of computer software code 53 | which is described in the Source Code notice required by Exhibit A as 54 | Original Code, and which, at the time of its release under this 55 | License is not already Covered Code governed by this License. 56 | 57 | 1.10.1. "Patent Claims" means any patent claim(s), now owned or 58 | hereafter acquired, including without limitation, method, process, 59 | and apparatus claims, in any patent Licensable by grantor. 60 | 61 | 1.11. "Source Code" means the preferred form of the Covered Code for 62 | making modifications to it, including all modules it contains, plus 63 | any associated interface definition files, scripts used to control 64 | compilation and installation of an Executable, or source code 65 | differential comparisons against either the Original Code or another 66 | well known, available Covered Code of the Contributor's choice. The 67 | Source Code can be in a compressed or archival form, provided the 68 | appropriate decompression or de-archiving software is widely available 69 | for no charge. 70 | 71 | 1.12. "You" (or "Your") means an individual or a legal entity 72 | exercising rights under, and complying with all of the terms of, this 73 | License or a future version of this License issued under Section 6.1. 74 | For legal entities, "You" includes any entity which controls, is 75 | controlled by, or is under common control with You. For purposes of 76 | this definition, "control" means (a) the power, direct or indirect, 77 | to cause the direction or management of such entity, whether by 78 | contract or otherwise, or (b) ownership of more than fifty percent 79 | (50%) of the outstanding shares or beneficial ownership of such 80 | entity. 81 | 82 | 2. Source Code License. 83 | 84 | 2.1. The Initial Developer Grant. 85 | The Initial Developer hereby grants You a world-wide, royalty-free, 86 | non-exclusive license, subject to third party intellectual property 87 | claims: 88 | (a) under intellectual property rights (other than patent or 89 | trademark) Licensable by Initial Developer to use, reproduce, 90 | modify, display, perform, sublicense and distribute the Original 91 | Code (or portions thereof) with or without Modifications, and/or 92 | as part of a Larger Work; and 93 | 94 | (b) under Patents Claims infringed by the making, using or 95 | selling of Original Code, to make, have made, use, practice, 96 | sell, and offer for sale, and/or otherwise dispose of the 97 | Original Code (or portions thereof). 98 | 99 | (c) the licenses granted in this Section 2.1(a) and (b) are 100 | effective on the date Initial Developer first distributes 101 | Original Code under the terms of this License. 102 | 103 | (d) Notwithstanding Section 2.1(b) above, no patent license is 104 | granted: 1) for code that You delete from the Original Code; 2) 105 | separate from the Original Code; or 3) for infringements caused 106 | by: i) the modification of the Original Code or ii) the 107 | combination of the Original Code with other software or devices. 108 | 109 | 2.2. Contributor Grant. 110 | Subject to third party intellectual property claims, each Contributor 111 | hereby grants You a world-wide, royalty-free, non-exclusive license 112 | 113 | (a) under intellectual property rights (other than patent or 114 | trademark) Licensable by Contributor, to use, reproduce, modify, 115 | display, perform, sublicense and distribute the Modifications 116 | created by such Contributor (or portions thereof) either on an 117 | unmodified basis, with other Modifications, as Covered Code 118 | and/or as part of a Larger Work; and 119 | 120 | (b) under Patent Claims infringed by the making, using, or 121 | selling of Modifications made by that Contributor either alone 122 | and/or in combination with its Contributor Version (or portions 123 | of such combination), to make, use, sell, offer for sale, have 124 | made, and/or otherwise dispose of: 1) Modifications made by that 125 | Contributor (or portions thereof); and 2) the combination of 126 | Modifications made by that Contributor with its Contributor 127 | Version (or portions of such combination). 128 | 129 | (c) the licenses granted in Sections 2.2(a) and 2.2(b) are 130 | effective on the date Contributor first makes Commercial Use of 131 | the Covered Code. 132 | 133 | (d) Notwithstanding Section 2.2(b) above, no patent license is 134 | granted: 1) for any code that Contributor has deleted from the 135 | Contributor Version; 2) separate from the Contributor Version; 136 | 3) for infringements caused by: i) third party modifications of 137 | Contributor Version or ii) the combination of Modifications made 138 | by that Contributor with other software (except as part of the 139 | Contributor Version) or other devices; or 4) under Patent Claims 140 | infringed by Covered Code in the absence of Modifications made by 141 | that Contributor. 142 | 143 | 3. Distribution Obligations. 144 | 145 | 3.1. Application of License. 146 | The Modifications which You create or to which You contribute are 147 | governed by the terms of this License, including without limitation 148 | Section 2.2. The Source Code version of Covered Code may be 149 | distributed only under the terms of this License or a future version 150 | of this License released under Section 6.1, and You must include a 151 | copy of this License with every copy of the Source Code You 152 | distribute. You may not offer or impose any terms on any Source Code 153 | version that alters or restricts the applicable version of this 154 | License or the recipients' rights hereunder. However, You may include 155 | an additional document offering the additional rights described in 156 | Section 3.5. 157 | 158 | 3.2. Availability of Source Code. 159 | Any Modification which You create or to which You contribute must be 160 | made available in Source Code form under the terms of this License 161 | either on the same media as an Executable version or via an accepted 162 | Electronic Distribution Mechanism to anyone to whom you made an 163 | Executable version available; and if made available via Electronic 164 | Distribution Mechanism, must remain available for at least twelve (12) 165 | months after the date it initially became available, or at least six 166 | (6) months after a subsequent version of that particular Modification 167 | has been made available to such recipients. You are responsible for 168 | ensuring that the Source Code version remains available even if the 169 | Electronic Distribution Mechanism is maintained by a third party. 170 | 171 | 3.3. Description of Modifications. 172 | You must cause all Covered Code to which You contribute to contain a 173 | file documenting the changes You made to create that Covered Code and 174 | the date of any change. You must include a prominent statement that 175 | the Modification is derived, directly or indirectly, from Original 176 | Code provided by the Initial Developer and including the name of the 177 | Initial Developer in (a) the Source Code, and (b) in any notice in an 178 | Executable version or related documentation in which You describe the 179 | origin or ownership of the Covered Code. 180 | 181 | 3.4. Intellectual Property Matters 182 | (a) Third Party Claims. 183 | If Contributor has knowledge that a license under a third party's 184 | intellectual property rights is required to exercise the rights 185 | granted by such Contributor under Sections 2.1 or 2.2, 186 | Contributor must include a text file with the Source Code 187 | distribution titled "LEGAL" which describes the claim and the 188 | party making the claim in sufficient detail that a recipient will 189 | know whom to contact. If Contributor obtains such knowledge after 190 | the Modification is made available as described in Section 3.2, 191 | Contributor shall promptly modify the LEGAL file in all copies 192 | Contributor makes available thereafter and shall take other steps 193 | (such as notifying appropriate mailing lists or newsgroups) 194 | reasonably calculated to inform those who received the Covered 195 | Code that new knowledge has been obtained. 196 | 197 | (b) Contributor APIs. 198 | If Contributor's Modifications include an application programming 199 | interface and Contributor has knowledge of patent licenses which 200 | are reasonably necessary to implement that API, Contributor must 201 | also include this information in the LEGAL file. 202 | 203 | (c) Representations. 204 | Contributor represents that, except as disclosed pursuant to 205 | Section 3.4(a) above, Contributor believes that Contributor's 206 | Modifications are Contributor's original creation(s) and/or 207 | Contributor has sufficient rights to grant the rights conveyed by 208 | this License. 209 | 210 | 3.5. Required Notices. 211 | You must duplicate the notice in Exhibit A in each file of the Source 212 | Code. If it is not possible to put such notice in a particular Source 213 | Code file due to its structure, then You must include such notice in a 214 | location (such as a relevant directory) where a user would be likely 215 | to look for such a notice. If You created one or more Modification(s) 216 | You may add your name as a Contributor to the notice described in 217 | Exhibit A. You must also duplicate this License in any documentation 218 | for the Source Code where You describe recipients' rights or ownership 219 | rights relating to Covered Code. You may choose to offer, and to 220 | charge a fee for, warranty, support, indemnity or liability 221 | obligations to one or more recipients of Covered Code. However, You 222 | may do so only on Your own behalf, and not on behalf of the Initial 223 | Developer or any Contributor. You must make it absolutely clear than 224 | any such warranty, support, indemnity or liability obligation is 225 | offered by You alone, and You hereby agree to indemnify the Initial 226 | Developer and every Contributor for any liability incurred by the 227 | Initial Developer or such Contributor as a result of warranty, 228 | support, indemnity or liability terms You offer. 229 | 230 | 3.6. Distribution of Executable Versions. 231 | You may distribute Covered Code in Executable form only if the 232 | requirements of Section 3.1-3.5 have been met for that Covered Code, 233 | and if You include a notice stating that the Source Code version of 234 | the Covered Code is available under the terms of this License, 235 | including a description of how and where You have fulfilled the 236 | obligations of Section 3.2. The notice must be conspicuously included 237 | in any notice in an Executable version, related documentation or 238 | collateral in which You describe recipients' rights relating to the 239 | Covered Code. You may distribute the Executable version of Covered 240 | Code or ownership rights under a license of Your choice, which may 241 | contain terms different from this License, provided that You are in 242 | compliance with the terms of this License and that the license for the 243 | Executable version does not attempt to limit or alter the recipient's 244 | rights in the Source Code version from the rights set forth in this 245 | License. If You distribute the Executable version under a different 246 | license You must make it absolutely clear that any terms which differ 247 | from this License are offered by You alone, not by the Initial 248 | Developer or any Contributor. You hereby agree to indemnify the 249 | Initial Developer and every Contributor for any liability incurred by 250 | the Initial Developer or such Contributor as a result of any such 251 | terms You offer. 252 | 253 | 3.7. Larger Works. 254 | You may create a Larger Work by combining Covered Code with other code 255 | not governed by the terms of this License and distribute the Larger 256 | Work as a single product. In such a case, You must make sure the 257 | requirements of this License are fulfilled for the Covered Code. 258 | 259 | 4. Inability to Comply Due to Statute or Regulation. 260 | 261 | If it is impossible for You to comply with any of the terms of this 262 | License with respect to some or all of the Covered Code due to 263 | statute, judicial order, or regulation then You must: (a) comply with 264 | the terms of this License to the maximum extent possible; and (b) 265 | describe the limitations and the code they affect. Such description 266 | must be included in the LEGAL file described in Section 3.4 and must 267 | be included with all distributions of the Source Code. Except to the 268 | extent prohibited by statute or regulation, such description must be 269 | sufficiently detailed for a recipient of ordinary skill to be able to 270 | understand it. 271 | 272 | 5. Application of this License. 273 | 274 | This License applies to code to which the Initial Developer has 275 | attached the notice in Exhibit A and to related Covered Code. 276 | 277 | 6. Versions of the License. 278 | 279 | 6.1. New Versions. 280 | Netscape Communications Corporation ("Netscape") may publish revised 281 | and/or new versions of the License from time to time. Each version 282 | will be given a distinguishing version number. 283 | 284 | 6.2. Effect of New Versions. 285 | Once Covered Code has been published under a particular version of the 286 | License, You may always continue to use it under the terms of that 287 | version. You may also choose to use such Covered Code under the terms 288 | of any subsequent version of the License published by Netscape. No one 289 | other than Netscape has the right to modify the terms applicable to 290 | Covered Code created under this License. 291 | 292 | 6.3. Derivative Works. 293 | If You create or use a modified version of this License (which you may 294 | only do in order to apply it to code which is not already Covered Code 295 | governed by this License), You must (a) rename Your license so that 296 | the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", 297 | "MPL", "NPL" or any confusingly similar phrase do not appear in your 298 | license (except to note that your license differs from this License) 299 | and (b) otherwise make it clear that Your version of the license 300 | contains terms which differ from the Mozilla Public License and 301 | Netscape Public License. (Filling in the name of the Initial 302 | Developer, Original Code or Contributor in the notice described in 303 | Exhibit A shall not of themselves be deemed to be modifications of 304 | this License.) 305 | 306 | 7. DISCLAIMER OF WARRANTY. 307 | 308 | COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, 309 | WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, 310 | WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF 311 | DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. 312 | THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE 313 | IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, 314 | YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE 315 | COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER 316 | OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF 317 | ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 318 | 319 | 8. TERMINATION. 320 | 321 | 8.1. This License and the rights granted hereunder will terminate 322 | automatically if You fail to comply with terms herein and fail to cure 323 | such breach within 30 days of becoming aware of the breach. All 324 | sublicenses to the Covered Code which are properly granted shall 325 | survive any termination of this License. Provisions which, by their 326 | nature, must remain in effect beyond the termination of this License 327 | shall survive. 328 | 329 | 8.2. If You initiate litigation by asserting a patent infringement 330 | claim (excluding declatory judgment actions) against Initial Developer 331 | or a Contributor (the Initial Developer or Contributor against whom 332 | You file such action is referred to as "Participant") alleging that: 333 | 334 | (a) such Participant's Contributor Version directly or indirectly 335 | infringes any patent, then any and all rights granted by such 336 | Participant to You under Sections 2.1 and/or 2.2 of this License 337 | shall, upon 60 days notice from Participant terminate prospectively, 338 | unless if within 60 days after receipt of notice You either: (i) 339 | agree in writing to pay Participant a mutually agreeable reasonable 340 | royalty for Your past and future use of Modifications made by such 341 | Participant, or (ii) withdraw Your litigation claim with respect to 342 | the Contributor Version against such Participant. If within 60 days 343 | of notice, a reasonable royalty and payment arrangement are not 344 | mutually agreed upon in writing by the parties or the litigation claim 345 | is not withdrawn, the rights granted by Participant to You under 346 | Sections 2.1 and/or 2.2 automatically terminate at the expiration of 347 | the 60 day notice period specified above. 348 | 349 | (b) any software, hardware, or device, other than such Participant's 350 | Contributor Version, directly or indirectly infringes any patent, then 351 | any rights granted to You by such Participant under Sections 2.1(b) 352 | and 2.2(b) are revoked effective as of the date You first made, used, 353 | sold, distributed, or had made, Modifications made by that 354 | Participant. 355 | 356 | 8.3. If You assert a patent infringement claim against Participant 357 | alleging that such Participant's Contributor Version directly or 358 | indirectly infringes any patent where such claim is resolved (such as 359 | by license or settlement) prior to the initiation of patent 360 | infringement litigation, then the reasonable value of the licenses 361 | granted by such Participant under Sections 2.1 or 2.2 shall be taken 362 | into account in determining the amount or value of any payment or 363 | license. 364 | 365 | 8.4. In the event of termination under Sections 8.1 or 8.2 above, 366 | all end user license agreements (excluding distributors and resellers) 367 | which have been validly granted by You or any distributor hereunder 368 | prior to termination shall survive termination. 369 | 370 | 9. LIMITATION OF LIABILITY. 371 | 372 | UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT 373 | (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL 374 | DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, 375 | OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR 376 | ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY 377 | CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, 378 | WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER 379 | COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN 380 | INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF 381 | LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY 382 | RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW 383 | PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE 384 | EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO 385 | THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. 386 | 387 | 10. U.S. GOVERNMENT END USERS. 388 | 389 | The Covered Code is a "commercial item," as that term is defined in 390 | 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer 391 | software" and "commercial computer software documentation," as such 392 | terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 393 | C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), 394 | all U.S. Government End Users acquire Covered Code with only those 395 | rights set forth herein. 396 | 397 | 11. MISCELLANEOUS. 398 | 399 | This License represents the complete agreement concerning subject 400 | matter hereof. If any provision of this License is held to be 401 | unenforceable, such provision shall be reformed only to the extent 402 | necessary to make it enforceable. This License shall be governed by 403 | California law provisions (except to the extent applicable law, if 404 | any, provides otherwise), excluding its conflict-of-law provisions. 405 | With respect to disputes in which at least one party is a citizen of, 406 | or an entity chartered or registered to do business in the United 407 | States of America, any litigation relating to this License shall be 408 | subject to the jurisdiction of the Federal Courts of the Northern 409 | District of California, with venue lying in Santa Clara County, 410 | California, with the losing party responsible for costs, including 411 | without limitation, court costs and reasonable attorneys' fees and 412 | expenses. The application of the United Nations Convention on 413 | Contracts for the International Sale of Goods is expressly excluded. 414 | Any law or regulation which provides that the language of a contract 415 | shall be construed against the drafter shall not apply to this 416 | License. 417 | 418 | 12. RESPONSIBILITY FOR CLAIMS. 419 | 420 | As between Initial Developer and the Contributors, each party is 421 | responsible for claims and damages arising, directly or indirectly, 422 | out of its utilization of rights under this License and You agree to 423 | work with Initial Developer and Contributors to distribute such 424 | responsibility on an equitable basis. Nothing herein is intended or 425 | shall be deemed to constitute any admission of liability. 426 | 427 | 13. MULTIPLE-LICENSED CODE. 428 | 429 | Initial Developer may designate portions of the Covered Code as 430 | "Multiple-Licensed". "Multiple-Licensed" means that the Initial 431 | Developer permits you to utilize portions of the Covered Code under 432 | Your choice of the NPL or the alternative licenses, if any, specified 433 | by the Initial Developer in the file described in Exhibit A. 434 | 435 | EXHIBIT A -Mozilla Public License. 436 | 437 | ``The contents of this file are subject to the Mozilla Public License 438 | Version 1.1 (the "License"); you may not use this file except in 439 | compliance with the License. You may obtain a copy of the License at 440 | http://www.mozilla.org/MPL/ 441 | 442 | Software distributed under the License is distributed on an "AS IS" 443 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 444 | License for the specific language governing rights and limitations 445 | under the License. 446 | 447 | The Original Code is ______________________________________. 448 | 449 | The Initial Developer of the Original Code is ________________________. 450 | Portions created by ______________________ are Copyright (C) ______ 451 | _______________________. All Rights Reserved. 452 | 453 | Contributor(s): ______________________________________. 454 | 455 | Alternatively, the contents of this file may be used under the terms 456 | of the _____ license (the "[___] License"), in which case the 457 | provisions of [______] License are applicable instead of those 458 | above. If you wish to allow use of your version of this file only 459 | under the terms of the [____] License and not to allow others to use 460 | your version of this file under the MPL, indicate your decision by 461 | deleting the provisions above and replace them with the notice and 462 | other provisions required by the [___] License. If you do not delete 463 | the provisions above, a recipient may use your version of this file 464 | under either the MPL or the [___] License." 465 | 466 | [NOTE: The text of this Exhibit A may differ slightly from the text of 467 | the notices in the Source Code files of the Original Code. You should 468 | use the text of this Exhibit A rather than the text found in the 469 | Original Code Source Code for Your Modifications.] 470 | 471 | -------------------------------------------------------------------------------- /deps/hunspell/ChangeLog.O: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mscdex/spellcheck/a3c02a826f6e04c34a82ff16a22b60f8e5d420c0/deps/hunspell/ChangeLog.O -------------------------------------------------------------------------------- /deps/hunspell/INSTALL: -------------------------------------------------------------------------------- 1 | Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software 2 | Foundation, Inc. 3 | 4 | This file is free documentation; the Free Software Foundation gives 5 | unlimited permission to copy, distribute and modify it. 6 | 7 | Basic Installation 8 | ================== 9 | 10 | These are generic installation instructions. 11 | 12 | The `configure' shell script attempts to guess correct values for 13 | various system-dependent variables used during compilation. It uses 14 | those values to create a `Makefile' in each directory of the package. 15 | It may also create one or more `.h' files containing system-dependent 16 | definitions. Finally, it creates a shell script `config.status' that 17 | you can run in the future to recreate the current configuration, and a 18 | file `config.log' containing compiler output (useful mainly for 19 | debugging `configure'). 20 | 21 | It can also use an optional file (typically called `config.cache' 22 | and enabled with `--cache-file=config.cache' or simply `-C') that saves 23 | the results of its tests to speed up reconfiguring. (Caching is 24 | disabled by default to prevent problems with accidental use of stale 25 | cache files.) 26 | 27 | If you need to do unusual things to compile the package, please try 28 | to figure out how `configure' could check whether to do them, and mail 29 | diffs or instructions to the address given in the `README' so they can 30 | be considered for the next release. If you are using the cache, and at 31 | some point `config.cache' contains results you don't want to keep, you 32 | may remove or edit it. 33 | 34 | The file `configure.ac' (or `configure.in') is used to create 35 | `configure' by a program called `autoconf'. You only need 36 | `configure.ac' if you want to change it or regenerate `configure' using 37 | a newer version of `autoconf'. 38 | 39 | The simplest way to compile this package is: 40 | 41 | 1. `cd' to the directory containing the package's source code and type 42 | `./configure' to configure the package for your system. If you're 43 | using `csh' on an old version of System V, you might need to type 44 | `sh ./configure' instead to prevent `csh' from trying to execute 45 | `configure' itself. 46 | 47 | Running `configure' takes awhile. While running, it prints some 48 | messages telling which features it is checking for. 49 | 50 | 2. Type `make' to compile the package. 51 | 52 | 3. Optionally, type `make check' to run any self-tests that come with 53 | the package. 54 | 55 | 4. Type `make install' to install the programs and any data files and 56 | documentation. 57 | 58 | 5. You can remove the program binaries and object files from the 59 | source code directory by typing `make clean'. To also remove the 60 | files that `configure' created (so you can compile the package for 61 | a different kind of computer), type `make distclean'. There is 62 | also a `make maintainer-clean' target, but that is intended mainly 63 | for the package's developers. If you use it, you may have to get 64 | all sorts of other programs in order to regenerate files that came 65 | with the distribution. 66 | 67 | Compilers and Options 68 | ===================== 69 | 70 | Some systems require unusual options for compilation or linking that 71 | the `configure' script does not know about. Run `./configure --help' 72 | for details on some of the pertinent environment variables. 73 | 74 | You can give `configure' initial values for configuration parameters 75 | by setting variables in the command line or in the environment. Here 76 | is an example: 77 | 78 | ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix 79 | 80 | *Note Defining Variables::, for more details. 81 | 82 | Compiling For Multiple Architectures 83 | ==================================== 84 | 85 | You can compile the package for more than one kind of computer at the 86 | same time, by placing the object files for each architecture in their 87 | own directory. To do this, you must use a version of `make' that 88 | supports the `VPATH' variable, such as GNU `make'. `cd' to the 89 | directory where you want the object files and executables to go and run 90 | the `configure' script. `configure' automatically checks for the 91 | source code in the directory that `configure' is in and in `..'. 92 | 93 | If you have to use a `make' that does not support the `VPATH' 94 | variable, you have to compile the package for one architecture at a 95 | time in the source code directory. After you have installed the 96 | package for one architecture, use `make distclean' before reconfiguring 97 | for another architecture. 98 | 99 | Installation Names 100 | ================== 101 | 102 | By default, `make install' will install the package's files in 103 | `/usr/local/bin', `/usr/local/man', etc. You can specify an 104 | installation prefix other than `/usr/local' by giving `configure' the 105 | option `--prefix=PATH'. 106 | 107 | You can specify separate installation prefixes for 108 | architecture-specific files and architecture-independent files. If you 109 | give `configure' the option `--exec-prefix=PATH', the package will use 110 | PATH as the prefix for installing programs and libraries. 111 | Documentation and other data files will still use the regular prefix. 112 | 113 | In addition, if you use an unusual directory layout you can give 114 | options like `--bindir=PATH' to specify different values for particular 115 | kinds of files. Run `configure --help' for a list of the directories 116 | you can set and what kinds of files go in them. 117 | 118 | If the package supports it, you can cause programs to be installed 119 | with an extra prefix or suffix on their names by giving `configure' the 120 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 121 | 122 | Optional Features 123 | ================= 124 | 125 | Some packages pay attention to `--enable-FEATURE' options to 126 | `configure', where FEATURE indicates an optional part of the package. 127 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 128 | is something like `gnu-as' or `x' (for the X Window System). The 129 | `README' should mention any `--enable-' and `--with-' options that the 130 | package recognizes. 131 | 132 | For packages that use the X Window System, `configure' can usually 133 | find the X include and library files automatically, but if it doesn't, 134 | you can use the `configure' options `--x-includes=DIR' and 135 | `--x-libraries=DIR' to specify their locations. 136 | 137 | Specifying the System Type 138 | ========================== 139 | 140 | There may be some features `configure' cannot figure out 141 | automatically, but needs to determine by the type of machine the package 142 | will run on. Usually, assuming the package is built to be run on the 143 | _same_ architectures, `configure' can figure that out, but if it prints 144 | a message saying it cannot guess the machine type, give it the 145 | `--build=TYPE' option. TYPE can either be a short name for the system 146 | type, such as `sun4', or a canonical name which has the form: 147 | 148 | CPU-COMPANY-SYSTEM 149 | 150 | where SYSTEM can have one of these forms: 151 | 152 | OS KERNEL-OS 153 | 154 | See the file `config.sub' for the possible values of each field. If 155 | `config.sub' isn't included in this package, then this package doesn't 156 | need to know the machine type. 157 | 158 | If you are _building_ compiler tools for cross-compiling, you should 159 | use the `--target=TYPE' option to select the type of system they will 160 | produce code for. 161 | 162 | If you want to _use_ a cross compiler, that generates code for a 163 | platform different from the build platform, you should specify the 164 | "host" platform (i.e., that on which the generated programs will 165 | eventually be run) with `--host=TYPE'. 166 | 167 | Sharing Defaults 168 | ================ 169 | 170 | If you want to set default values for `configure' scripts to share, 171 | you can create a site shell script called `config.site' that gives 172 | default values for variables like `CC', `cache_file', and `prefix'. 173 | `configure' looks for `PREFIX/share/config.site' if it exists, then 174 | `PREFIX/etc/config.site' if it exists. Or, you can set the 175 | `CONFIG_SITE' environment variable to the location of the site script. 176 | A warning: not all `configure' scripts look for a site script. 177 | 178 | Defining Variables 179 | ================== 180 | 181 | Variables not defined in a site shell script can be set in the 182 | environment passed to `configure'. However, some packages may run 183 | configure again during the build, and the customized values of these 184 | variables may be lost. In order to avoid this problem, you should set 185 | them in the `configure' command line, using `VAR=value'. For example: 186 | 187 | ./configure CC=/usr/local2/bin/gcc 188 | 189 | will cause the specified gcc to be used as the C compiler (unless it is 190 | overridden in the site shell script). 191 | 192 | `configure' Invocation 193 | ====================== 194 | 195 | `configure' recognizes the following options to control how it 196 | operates. 197 | 198 | `--help' 199 | `-h' 200 | Print a summary of the options to `configure', and exit. 201 | 202 | `--version' 203 | `-V' 204 | Print the version of Autoconf used to generate the `configure' 205 | script, and exit. 206 | 207 | `--cache-file=FILE' 208 | Enable the cache: use and save the results of the tests in FILE, 209 | traditionally `config.cache'. FILE defaults to `/dev/null' to 210 | disable caching. 211 | 212 | `--config-cache' 213 | `-C' 214 | Alias for `--cache-file=config.cache'. 215 | 216 | `--quiet' 217 | `--silent' 218 | `-q' 219 | Do not print messages saying which checks are being made. To 220 | suppress all normal output, redirect it to `/dev/null' (any error 221 | messages will still be shown). 222 | 223 | `--srcdir=DIR' 224 | Look for the package's source code in directory DIR. Usually 225 | `configure' can determine that directory automatically. 226 | 227 | `configure' also accepts some other, not widely useful, options. Run 228 | `configure --help' for more details. 229 | 230 | -------------------------------------------------------------------------------- /deps/hunspell/NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mscdex/spellcheck/a3c02a826f6e04c34a82ff16a22b60f8e5d420c0/deps/hunspell/NEWS -------------------------------------------------------------------------------- /deps/hunspell/README: -------------------------------------------------------------------------------- 1 | About Hunspell 2 | -------------- 3 | 4 | Hunspell is a spell checker and morphological analyzer library and program 5 | designed for languages with rich morphology and complex word compounding or 6 | character encoding. Hunspell interfaces: Ispell-like terminal interface 7 | using Curses library, Ispell pipe interface, OpenOffice.org UNO module. 8 | 9 | Hunspell's code base comes from the OpenOffice.org MySpell 10 | (http://lingucomponent.openoffice.org/MySpell-3.zip). See README.MYSPELL, 11 | AUTHORS.MYSPELL and license.myspell files. 12 | Hunspell is designed to eventually replace Myspell in OpenOffice.org. 13 | 14 | Main features of Hunspell spell checker and morphological analyzer: 15 | 16 | - Unicode support (affix rules work only with the first 65535 Unicode characters) 17 | 18 | - Morphological analysis (in custom item and arrangement style) and stemming 19 | 20 | - Max. 65535 affix classes and twofold affix stripping (for agglutinative 21 | languages, like Azeri, Basque, Estonian, Finnish, Hungarian, Turkish, etc.) 22 | 23 | - Support complex compoundings (for example, Hungarian and German) 24 | 25 | - Support language specific features (for example, special casing of 26 | Azeri and Turkish dotted i, or German sharp s) 27 | 28 | - Handle conditional affixes, circumfixes, fogemorphemes, 29 | forbidden words, pseudoroots and homonyms. 30 | 31 | - Free software (LGPL, GPL, MPL tri-license) 32 | 33 | Compiling on Unix/Linux 34 | ----------------------- 35 | 36 | ./configure 37 | make 38 | make install 39 | 40 | For dictionary development, use the --with-warnings option of configure. 41 | 42 | For interactive user interface of Hunspell executable, use the --with-ui option. 43 | 44 | The developer packages you need to compile Hunspell's interface: 45 | 46 | glibc-devel 47 | 48 | optional developer packages: 49 | 50 | ncurses (need for --with-ui) 51 | readline (for fancy input line editing, 52 | configure parameter: --with-readline) 53 | locale and gettext (but you can also use the 54 | --with-included-gettext configure parameter) 55 | 56 | Hunspell distribution uses new Autoconf (2.59) and Automake (1.9). 57 | 58 | Compiling on Windows 59 | -------------------- 60 | 61 | 1. Compiling with Windows SDK 62 | 63 | Download the free Windows SDK of Microsoft, open a command prompt 64 | window and cd into hunspell/src/win_api. Use the following command 65 | to compile hunspell: 66 | 67 | vcbuild 68 | 69 | 2. Compiling in Cygwin environment 70 | 71 | Download and install Cygwin environment for Windows with the following 72 | extra packages: 73 | 74 | make 75 | gcc-g++ development package 76 | mingw development package (for cygwin.dll free native Windows compilation) 77 | ncurses, readline (for user interface) 78 | iconv (character conversion) 79 | 80 | 2.1. Cygwin1.dll dependent compiling 81 | 82 | Open a Cygwin shell, cd into the hunspell root directory: 83 | 84 | ./configure 85 | make 86 | make install 87 | 88 | For dictionary development, use the --with-warnings option of configure. 89 | 90 | For interactive user interface of Hunspell executable, use the --with-ui option. 91 | 92 | readline configure parameter: --with-readline (for fancy input line editing) 93 | 94 | 1.2. Cygwin1.dll free compiling 95 | 96 | Open a Cygwin shell, cd into the hunspell/src/win_api and 97 | 98 | make -f Makefile.cygwin 99 | 100 | Testing 101 | ------- 102 | 103 | Testing Hunspell (see tests in tests/ subdirectory): 104 | 105 | make check 106 | 107 | or with Valgrind debugger: 108 | 109 | make check 110 | VALGRIND=[Valgrind_tool] make check 111 | 112 | For example: 113 | 114 | make check 115 | VALGRIND=memcheck make check 116 | 117 | Documentation 118 | ------------- 119 | 120 | features and dictionary format: 121 | man 4 hunspell 122 | 123 | man hunspell 124 | hunspell -h 125 | http://hunspell.sourceforge.net 126 | 127 | Usage 128 | ----- 129 | 130 | The src/tools dictionary contains ten executables after compiling 131 | (or some of them are in the src/win_api): 132 | 133 | affixcompress: dictionary generation from large (millions of words) vocabularies 134 | analyze: example of spell checking, stemming and morphological analysis 135 | chmorph: example of automatic morphological generation and conversion 136 | example: example of spell checking and suggestion 137 | hunspell: main program for spell checking and others (see manual) 138 | hunzip: decompressor of hzip format 139 | hzip: compressor of hzip format 140 | makealias: alias compression (Hunspell only, not back compatible with MySpell) 141 | munch: dictionary generation from vocabularies (it needs an affix file, too). 142 | unmunch: list all recognized words of a MySpell dictionary 143 | wordforms: word generation (Hunspell version of unmunch) 144 | 145 | After compiling and installing (see INSTALL) you can 146 | run the Hunspell spell checker (compiled with user interface) 147 | with a Hunspell or Myspell dictionary: 148 | 149 | hunspell -d en_US text.txt 150 | 151 | or without interface: 152 | 153 | hunspell 154 | hunspell -d en_UK -l 164 | 165 | Linking with Hunspell static library: 166 | g++ -lhunspell example.cxx 167 | 168 | Dictionaries 169 | ------------ 170 | 171 | Myspell & Hunspell dictionaries: 172 | http://wiki.services.openoffice.org/wiki/Dictionaries 173 | 174 | Aspell dictionaries (need some conversion): 175 | ftp://ftp.gnu.org/gnu/aspell/dict 176 | Conversion steps: see relevant feature request at http://hunspell.sf.net. 177 | 178 | László Németh 179 | nemeth at OOo 180 | -------------------------------------------------------------------------------- /deps/hunspell/README.myspell: -------------------------------------------------------------------------------- 1 | MySpell is a simple spell checker that uses affix 2 | compression and is modelled after the spell checker 3 | ispell. 4 | 5 | MySpell was written to explore how affix compression 6 | can be implemented. 7 | 8 | The Main features of MySpell are: 9 | 10 | 1. written in C++ to make it easier to interface with 11 | Pspell, OpenOffice, AbiWord, etc 12 | 13 | 2. it is stateless, uses no static variables and 14 | should be completely reentrant with almost no 15 | ifdefs 16 | 17 | 3. it tries to be as compatible with ispell to 18 | the extent it can. It can read slightly modified 19 | versions of munched ispell dictionaries (and it 20 | comes with a munched english wordlist borrowed from 21 | Kevin Atkinson's excellent Aspell. 22 | 23 | 4. it uses a heavily modified aff file format that 24 | can be derived from ispell aff files but uses 25 | the iso-8859-X character sets only 26 | 27 | 5. it is simple with *lots* of comments that 28 | describes how the affixes are stored 29 | and tested for (based on the approach used by 30 | ispell). 31 | 32 | 6. it supports improved suggestions with replacement 33 | tables and ngram-scoring based mechanisms in addition 34 | to the main suggestion mechanisms 35 | 36 | 7. like ispell it has a BSD license (and no 37 | advertising clause) 38 | 39 | But ... it has *no* support for adding words 40 | to a personal dictionary, *no* support for converting 41 | between various text encodings, and *no* command line 42 | interface (it is purely meant to be a library). 43 | 44 | It can not (in any way) replace all of the functionality 45 | of ispell or aspell/pspell. It is meant as a learning 46 | tool for understanding affix compression and for 47 | being used by front ends like OpenOffice, Abiword, etc. 48 | 49 | MySpell has been tested under Linux and Solaris 50 | and has the world's simplest Makefile and no 51 | configure support. 52 | 53 | It does come with a simple example program that 54 | spell checks some words and returns suggestions. 55 | 56 | To build a static library and an example 57 | program under Linux simply type: 58 | 59 | tar -zxvf myspell.tar.gz 60 | cd myspell2 61 | make 62 | 63 | To run the example program: 64 | ./example ./en_US.aff ./en_US.dic checkme.lst 65 | 66 | Please play around with it and let me know 67 | what you think. 68 | 69 | Please see the file CONTRIBUTORS for more info. 70 | -------------------------------------------------------------------------------- /deps/hunspell/THANKS: -------------------------------------------------------------------------------- 1 | Many thanks to the following contributors and supporters: 2 | 3 | Mehmet Akin 4 | Göran Andersson 5 | Lars Aronsson 6 | Ruud Baars 7 | Bartkó Zoltán 8 | Mathias Bauer 9 | Bencsáth Boldizsár 10 | Bíró Árpád 11 | Ingo H. de Boer 12 | Simon Brouwer 13 | Jeppe Bundsgaard 14 | Ginn Chen 15 | Aaron Digulla 16 | Dmitri Gabinski 17 | Dvornik László 18 | David Einstein 19 | Rene Engelhard 20 | Frederik Fouvry 21 | Flemming Frandsen 22 | Serge Gautherie 23 | Marek Gleń 24 | Gavins at OOo 25 | Gefferth András 26 | Godó Ferenc 27 | Goldman Eleonóra 28 | Steinar H. Gunderson 29 | Halácsy Péter 30 | Chris Halls 31 | Khaled Hosny 32 | Izsók András 33 | Björn Jacke 34 | Mike Tian-Jian Jiang 35 | Dafydd Jones 36 | Ryan Jones 37 | Jean-Christophe Helary 38 | Kevin Hendricks 39 | Martin Hollmichel 40 | Pavel Janík 41 | John Winters 42 | Mohamed Kebdani 43 | Kelemen Gábor 44 | Shewangizaw Gulilat 45 | Kéménczy Kálmán 46 | Dan Kenigsberg 47 | Pham Ngoc Khanh 48 | Khiraly László 49 | Koblinger Egmont 50 | Kornai András 51 | Tor Lillqvist 52 | Christian Lohmaier 53 | Robert Longson 54 | Marot at SF dot net 55 | Mark McClain 56 | Caolan McNamara 57 | Michael Meeks 58 | Moheb Mekhaiel 59 | Laurie Mercer 60 | Ladislav Michnovič 61 | Ellis Miller 62 | Giuseppe Modugno 63 | János Mohácsi 64 | Bram Moolenaar 65 | Daniel Naber 66 | Nagy Viktor 67 | John Nisly 68 | Noll János 69 | S Page 70 | Christophe Paris 71 | Malcolm Parsons 72 | Sylvain Paschein 73 | Volkov Peter 74 | Bryan Petty 75 | Harri Pitkänen 76 | Davide Prina 77 | Kevin F. Quinn 78 | Erdal Ronahi 79 | Olivier Ronez 80 | Bernhard Rosenkraenzer 81 | Sarlós Tamás 82 | Thobias Schlemmer 83 | Jan Seeger 84 | Jose da Silva 85 | Paulo Ney de Souza 86 | Roland Smith 87 | Munzir Taha 88 | Timeless at bemail dot org 89 | Tímár András 90 | Tonal at OOo 91 | Török László 92 | Trón Viktor 93 | Gianluca Turconi 94 | Ryan VanderMeulen 95 | Varga Dániel 96 | Elio Voci 97 | Miha Vrhovnik 98 | Martijn Wargers 99 | Michel Weimerskirch 100 | Brett Wilson 101 | Friedel Wolff 102 | Daniel Yacob 103 | Gábor Zahemszky 104 | Taha Zerrouki 105 | and others (see also AUTHORS.myspell) 106 | 107 | FSF.hu Foundation 108 | http://www.fsf.hu 109 | 110 | MOKK Research Centre 111 | Budapest University of Technology and Economics 112 | Sociology and Communications Department 113 | http://www.mokk.bme.hu 114 | 115 | Hungarian Ministry of Informatics and Telecommunications 116 | 117 | IMEDIA Kft. 118 | http://www.imedia.hu 119 | 120 | OpenOffice.org community 121 | http://www.openoffice.org 122 | 123 | OpenTaal Foundation, Netherlands and 124 | Dutch Language Union (Nederlandse Taalunie) 125 | http://opentaal.org 126 | 127 | UHU-Linux Kft. 128 | 129 | Thanks, 130 | 131 | Németh László 132 | nemeth at OOo 133 | -------------------------------------------------------------------------------- /deps/hunspell/TODO: -------------------------------------------------------------------------------- 1 | * shared dictionaries for multi-user environment 2 | * improve compound handling 3 | * Unicode unmunch (munch) 4 | * forbiddenword and pseudoword support in unmunch 5 | -------------------------------------------------------------------------------- /deps/hunspell/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'target_defaults': { 3 | 'default_configuration': 'Debug', 4 | 'configurations': { 5 | 'Debug': { 6 | 'defines': [ 'DEBUG', '_DEBUG' ], 7 | 'msvs_settings': { 8 | 'VCCLCompilerTool': { 9 | 'RuntimeLibrary': 1, # static debug 10 | }, 11 | }, 12 | }, 13 | 'Release': { 14 | 'defines': [ 'NDEBUG' ], 15 | 'msvs_settings': { 16 | 'VCCLCompilerTool': { 17 | 'RuntimeLibrary': 0, # static release 18 | }, 19 | }, 20 | } 21 | }, 22 | 'msvs_settings': { 23 | 'VCCLCompilerTool': { 24 | }, 25 | 'VCLibrarianTool': { 26 | }, 27 | 'VCLinkerTool': { 28 | 'GenerateDebugInformation': 'true', 29 | }, 30 | }, 31 | 'conditions': [ 32 | ['OS == "win"', { 33 | 'defines': [ 34 | 'WIN32' 35 | ], 36 | }] 37 | ], 38 | }, 39 | 40 | 'targets': [ 41 | { 42 | 'target_name': 'hunspell', 43 | 'type': 'static_library', 44 | 'include_dirs': [ 'src/hunspell' ], 45 | 'defines': [ 'HUNSPELL_STATIC' ], 46 | 'direct_dependent_settings': { 47 | 'include_dirs': [ 'src/hunspell' ], 48 | 'defines': [ 'HUNSPELL_STATIC' ], 49 | }, 50 | 'cflags': [ '-O3' ], 51 | 'sources': [ 52 | 'src/hunspell/affentry.cxx', 53 | 'src/hunspell/affentry.hxx', 54 | 'src/hunspell/affixmgr.cxx', 55 | 'src/hunspell/affixmgr.hxx', 56 | 'src/hunspell/atypes.hxx', 57 | 'src/hunspell/baseaffix.hxx', 58 | 'src/hunspell/csutil.cxx', 59 | 'src/hunspell/csutil.hxx', 60 | 'src/hunspell/dictmgr.cxx', 61 | 'src/hunspell/dictmgr.hxx', 62 | 'src/hunspell/filemgr.cxx', 63 | 'src/hunspell/filemgr.hxx', 64 | 'src/hunspell/hashmgr.cxx', 65 | 'src/hunspell/hashmgr.hxx', 66 | 'src/hunspell/htypes.hxx', 67 | 'src/hunspell/hunspell.cxx', 68 | 'src/hunspell/hunspell.hxx', 69 | 'src/hunspell/hunzip.cxx', 70 | 'src/hunspell/hunzip.hxx', 71 | 'src/hunspell/langnum.hxx', 72 | 'src/hunspell/phonet.cxx', 73 | 'src/hunspell/phonet.hxx', 74 | 'src/hunspell/replist.cxx', 75 | 'src/hunspell/replist.hxx', 76 | 'src/hunspell/suggestmgr.cxx', 77 | 'src/hunspell/suggestmgr.hxx', 78 | 'src/hunspell/w_char.hxx', 79 | ], 80 | 'conditions': [ 81 | ['OS=="win"', { 82 | 'include_dirs': [ 'src/win_api' ], 83 | 'sources': [ 84 | 'src/win_api/config.h', 85 | ], 86 | }, { 87 | 'sources': [ 88 | 'src/hunspell/config.h', 89 | ], 90 | }], 91 | ], 92 | }, 93 | ] 94 | } 95 | -------------------------------------------------------------------------------- /deps/hunspell/license.hunspell: -------------------------------------------------------------------------------- 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. 13 | * 14 | * The Original Code is Hunspell, based on MySpell. 15 | * 16 | * The Initial Developers of the Original Code are 17 | * Kevin Hendricks (MySpell) and Németh László (Hunspell). 18 | * Portions created by the Initial Developers are Copyright (C) 2002-2005 19 | * the Initial Developers. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * David Einstein 23 | * Davide Prina 24 | * Giuseppe Modugno 25 | * Gianluca Turconi 26 | * Simon Brouwer 27 | * Noll János 28 | * Bíró Árpád 29 | * Goldman Eleonóra 30 | * Sarlós Tamás 31 | * Bencsáth Boldizsár 32 | * Halácsy Péter 33 | * Dvornik László 34 | * Gefferth András 35 | * Nagy Viktor 36 | * Varga Dániel 37 | * Chris Halls 38 | * Rene Engelhard 39 | * Bram Moolenaar 40 | * Dafydd Jones 41 | * Harri Pitkänen 42 | * 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. 54 | * 55 | * ***** END LICENSE BLOCK ***** */ 56 | -------------------------------------------------------------------------------- /deps/hunspell/license.myspell: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada 3 | * And Contributors. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. All modifications to the source code must be clearly marked as 17 | * such. Binary redistributions based on modified source code 18 | * must be clearly marked as modified versions in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS 22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 25 | * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | * 34 | * 35 | * NOTE: A special thanks and credit goes to Geoff Kuenning 36 | * the creator of ispell. MySpell's affix algorithms were 37 | * based on those of ispell which should be noted is 38 | * copyright Geoff Kuenning et.al. and now available 39 | * under a BSD style license. For more information on ispell 40 | * and affix compression in general, please see: 41 | * http://www.cs.ucla.edu/ficus-members/geoff/ispell.html 42 | * (the home page for ispell) 43 | * 44 | * An almost complete rewrite of MySpell for use by 45 | * the Mozilla project has been developed by David Einstein 46 | * (Deinst@world.std.com). David and I are now 47 | * working on parallel development tracks to help 48 | * our respective projects (Mozilla and OpenOffice.org 49 | * and we will maintain full affix file and dictionary 50 | * file compatibility and work on merging our versions 51 | * of MySpell back into a single tree. David has been 52 | * a significant help in improving MySpell. 53 | * 54 | * Special thanks also go to La'szlo' Ne'meth 55 | * who is the author of the 56 | * Hungarian dictionary and who developed and contributed 57 | * the code to support compound words in MySpell 58 | * and fixed numerous problems with the encoding 59 | * case conversion tables. 60 | * 61 | */ 62 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/README: -------------------------------------------------------------------------------- 1 | Hunspell spell checker and morphological analyser library 2 | 3 | Documentation, tests, examples: http://hunspell.sourceforge.net 4 | 5 | Author of Hunspell: 6 | László Németh (nemethl (at) gyorsposta.hu) 7 | 8 | Hunspell based on OpenOffice.org's Myspell. MySpell's author: 9 | Kevin Hendricks (kevin.hendricks (at) sympatico.ca) 10 | 11 | License: GPL 2.0/LGPL 2.1/MPL 1.1 tri-license 12 | 13 | The contents of this library may be used under the terms of 14 | the GNU General Public License Version 2 or later (the "GPL"), or 15 | the GNU Lesser General Public License Version 2.1 or later (the "LGPL", 16 | see http://gnu.org/copyleft/lesser.html) or the Mozilla Public License 17 | Version 1.1 or later (the "MPL", see http://mozilla.org/MPL/MPL-1.1.html). 18 | 19 | Software distributed under these licenses is distributed on an "AS IS" basis, 20 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the licences 21 | for the specific language governing rights and limitations under the licenses. 22 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/affentry.hxx: -------------------------------------------------------------------------------- 1 | #ifndef _AFFIX_HXX_ 2 | #define _AFFIX_HXX_ 3 | 4 | #include "hunvisapi.h" 5 | 6 | #include "atypes.hxx" 7 | #include "baseaffix.hxx" 8 | #include "affixmgr.hxx" 9 | 10 | /* A Prefix Entry */ 11 | 12 | class LIBHUNSPELL_DLL_EXPORTED PfxEntry : protected AffEntry 13 | { 14 | AffixMgr* pmyMgr; 15 | 16 | PfxEntry * next; 17 | PfxEntry * nexteq; 18 | PfxEntry * nextne; 19 | PfxEntry * flgnxt; 20 | 21 | public: 22 | 23 | PfxEntry(AffixMgr* pmgr, affentry* dp ); 24 | ~PfxEntry(); 25 | 26 | inline bool allowCross() { return ((opts & aeXPRODUCT) != 0); } 27 | struct hentry * checkword(const char * word, int len, char in_compound, 28 | const FLAG needflag = FLAG_NULL); 29 | 30 | struct hentry * check_twosfx(const char * word, int len, char in_compound, const FLAG needflag = NULL); 31 | 32 | char * check_morph(const char * word, int len, char in_compound, 33 | const FLAG needflag = FLAG_NULL); 34 | 35 | char * check_twosfx_morph(const char * word, int len, 36 | char in_compound, const FLAG needflag = FLAG_NULL); 37 | 38 | inline FLAG getFlag() { return aflag; } 39 | inline const char * getKey() { return appnd; } 40 | char * add(const char * word, int len); 41 | 42 | inline short getKeyLen() { return appndl; } 43 | 44 | inline const char * getMorph() { return morphcode; } 45 | 46 | inline const unsigned short * getCont() { return contclass; } 47 | inline short getContLen() { return contclasslen; } 48 | 49 | inline PfxEntry * getNext() { return next; } 50 | inline PfxEntry * getNextNE() { return nextne; } 51 | inline PfxEntry * getNextEQ() { return nexteq; } 52 | inline PfxEntry * getFlgNxt() { return flgnxt; } 53 | 54 | inline void setNext(PfxEntry * ptr) { next = ptr; } 55 | inline void setNextNE(PfxEntry * ptr) { nextne = ptr; } 56 | inline void setNextEQ(PfxEntry * ptr) { nexteq = ptr; } 57 | inline void setFlgNxt(PfxEntry * ptr) { flgnxt = ptr; } 58 | 59 | inline char * nextchar(char * p); 60 | inline int test_condition(const char * st); 61 | }; 62 | 63 | 64 | 65 | 66 | /* A Suffix Entry */ 67 | 68 | class LIBHUNSPELL_DLL_EXPORTED SfxEntry : protected AffEntry 69 | { 70 | AffixMgr* pmyMgr; 71 | char * rappnd; 72 | 73 | SfxEntry * next; 74 | SfxEntry * nexteq; 75 | SfxEntry * nextne; 76 | SfxEntry * flgnxt; 77 | 78 | SfxEntry * l_morph; 79 | SfxEntry * r_morph; 80 | SfxEntry * eq_morph; 81 | 82 | public: 83 | 84 | SfxEntry(AffixMgr* pmgr, affentry* dp ); 85 | ~SfxEntry(); 86 | 87 | inline bool allowCross() { return ((opts & aeXPRODUCT) != 0); } 88 | struct hentry * checkword(const char * word, int len, int optflags, 89 | PfxEntry* ppfx, char ** wlst, int maxSug, int * ns, 90 | // const FLAG cclass = FLAG_NULL, const FLAG needflag = FLAG_NULL, char in_compound=IN_CPD_NOT); 91 | const FLAG cclass = FLAG_NULL, const FLAG needflag = FLAG_NULL, const FLAG badflag = 0); 92 | 93 | struct hentry * check_twosfx(const char * word, int len, int optflags, PfxEntry* ppfx, const FLAG needflag = NULL); 94 | 95 | char * check_twosfx_morph(const char * word, int len, int optflags, 96 | PfxEntry* ppfx, const FLAG needflag = FLAG_NULL); 97 | struct hentry * get_next_homonym(struct hentry * he); 98 | struct hentry * get_next_homonym(struct hentry * word, int optflags, PfxEntry* ppfx, 99 | const FLAG cclass, const FLAG needflag); 100 | 101 | 102 | inline FLAG getFlag() { return aflag; } 103 | inline const char * getKey() { return rappnd; } 104 | char * add(const char * word, int len); 105 | 106 | 107 | inline const char * getMorph() { return morphcode; } 108 | 109 | inline const unsigned short * getCont() { return contclass; } 110 | inline short getContLen() { return contclasslen; } 111 | inline const char * getAffix() { return appnd; } 112 | 113 | inline short getKeyLen() { return appndl; } 114 | 115 | inline SfxEntry * getNext() { return next; } 116 | inline SfxEntry * getNextNE() { return nextne; } 117 | inline SfxEntry * getNextEQ() { return nexteq; } 118 | 119 | inline SfxEntry * getLM() { return l_morph; } 120 | inline SfxEntry * getRM() { return r_morph; } 121 | inline SfxEntry * getEQM() { return eq_morph; } 122 | inline SfxEntry * getFlgNxt() { return flgnxt; } 123 | 124 | inline void setNext(SfxEntry * ptr) { next = ptr; } 125 | inline void setNextNE(SfxEntry * ptr) { nextne = ptr; } 126 | inline void setNextEQ(SfxEntry * ptr) { nexteq = ptr; } 127 | inline void setFlgNxt(SfxEntry * ptr) { flgnxt = ptr; } 128 | 129 | inline char * nextchar(char * p); 130 | inline int test_condition(const char * st, const char * begin); 131 | 132 | }; 133 | 134 | #endif 135 | 136 | 137 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/affixmgr.hxx: -------------------------------------------------------------------------------- 1 | #ifndef _AFFIXMGR_HXX_ 2 | #define _AFFIXMGR_HXX_ 3 | 4 | #include "hunvisapi.h" 5 | 6 | #include 7 | 8 | #include "atypes.hxx" 9 | #include "baseaffix.hxx" 10 | #include "hashmgr.hxx" 11 | #include "phonet.hxx" 12 | #include "replist.hxx" 13 | 14 | // check flag duplication 15 | #define dupSFX (1 << 0) 16 | #define dupPFX (1 << 1) 17 | 18 | class PfxEntry; 19 | class SfxEntry; 20 | 21 | class LIBHUNSPELL_DLL_EXPORTED AffixMgr 22 | { 23 | 24 | PfxEntry * pStart[SETSIZE]; 25 | SfxEntry * sStart[SETSIZE]; 26 | PfxEntry * pFlag[SETSIZE]; 27 | SfxEntry * sFlag[SETSIZE]; 28 | HashMgr * pHMgr; 29 | HashMgr ** alldic; 30 | int * maxdic; 31 | char * keystring; 32 | char * trystring; 33 | char * encoding; 34 | struct cs_info * csconv; 35 | int utf8; 36 | int complexprefixes; 37 | FLAG compoundflag; 38 | FLAG compoundbegin; 39 | FLAG compoundmiddle; 40 | FLAG compoundend; 41 | FLAG compoundroot; 42 | FLAG compoundforbidflag; 43 | FLAG compoundpermitflag; 44 | int checkcompounddup; 45 | int checkcompoundrep; 46 | int checkcompoundcase; 47 | int checkcompoundtriple; 48 | int simplifiedtriple; 49 | FLAG forbiddenword; 50 | FLAG nosuggest; 51 | FLAG nongramsuggest; 52 | FLAG needaffix; 53 | int cpdmin; 54 | int numrep; 55 | replentry * reptable; 56 | RepList * iconvtable; 57 | RepList * oconvtable; 58 | int nummap; 59 | mapentry * maptable; 60 | int numbreak; 61 | char ** breaktable; 62 | int numcheckcpd; 63 | patentry * checkcpdtable; 64 | int simplifiedcpd; 65 | int numdefcpd; 66 | flagentry * defcpdtable; 67 | phonetable * phone; 68 | int maxngramsugs; 69 | int maxcpdsugs; 70 | int maxdiff; 71 | int onlymaxdiff; 72 | int nosplitsugs; 73 | int sugswithdots; 74 | int cpdwordmax; 75 | int cpdmaxsyllable; 76 | char * cpdvowels; 77 | w_char * cpdvowels_utf16; 78 | int cpdvowels_utf16_len; 79 | char * cpdsyllablenum; 80 | const char * pfxappnd; // BUG: not stateless 81 | const char * sfxappnd; // BUG: not stateless 82 | FLAG sfxflag; // BUG: not stateless 83 | char * derived; // BUG: not stateless 84 | SfxEntry * sfx; // BUG: not stateless 85 | PfxEntry * pfx; // BUG: not stateless 86 | int checknum; 87 | char * wordchars; 88 | unsigned short * wordchars_utf16; 89 | int wordchars_utf16_len; 90 | char * ignorechars; 91 | unsigned short * ignorechars_utf16; 92 | int ignorechars_utf16_len; 93 | char * version; 94 | char * lang; 95 | int langnum; 96 | FLAG lemma_present; 97 | FLAG circumfix; 98 | FLAG onlyincompound; 99 | FLAG keepcase; 100 | FLAG forceucase; 101 | FLAG warn; 102 | int forbidwarn; 103 | FLAG substandard; 104 | int checksharps; 105 | int fullstrip; 106 | 107 | int havecontclass; // boolean variable 108 | char contclasses[CONTSIZE]; // flags of possible continuing classes (twofold affix) 109 | 110 | public: 111 | 112 | AffixMgr(const char * affpath, HashMgr** ptr, int * md, 113 | const char * key = NULL); 114 | ~AffixMgr(); 115 | struct hentry * affix_check(const char * word, int len, 116 | const unsigned short needflag = (unsigned short) 0, 117 | char in_compound = IN_CPD_NOT); 118 | struct hentry * prefix_check(const char * word, int len, 119 | char in_compound, const FLAG needflag = FLAG_NULL); 120 | inline int isSubset(const char * s1, const char * s2); 121 | struct hentry * prefix_check_twosfx(const char * word, int len, 122 | char in_compound, const FLAG needflag = FLAG_NULL); 123 | inline int isRevSubset(const char * s1, const char * end_of_s2, int len); 124 | struct hentry * suffix_check(const char * word, int len, int sfxopts, 125 | PfxEntry* ppfx, char ** wlst, int maxSug, int * ns, 126 | const FLAG cclass = FLAG_NULL, const FLAG needflag = FLAG_NULL, 127 | char in_compound = IN_CPD_NOT); 128 | struct hentry * suffix_check_twosfx(const char * word, int len, 129 | int sfxopts, PfxEntry* ppfx, const FLAG needflag = FLAG_NULL); 130 | 131 | char * affix_check_morph(const char * word, int len, 132 | const FLAG needflag = FLAG_NULL, char in_compound = IN_CPD_NOT); 133 | char * prefix_check_morph(const char * word, int len, 134 | char in_compound, const FLAG needflag = FLAG_NULL); 135 | char * suffix_check_morph (const char * word, int len, int sfxopts, 136 | PfxEntry * ppfx, const FLAG cclass = FLAG_NULL, 137 | const FLAG needflag = FLAG_NULL, char in_compound = IN_CPD_NOT); 138 | 139 | char * prefix_check_twosfx_morph(const char * word, int len, 140 | char in_compound, const FLAG needflag = FLAG_NULL); 141 | char * suffix_check_twosfx_morph(const char * word, int len, 142 | int sfxopts, PfxEntry * ppfx, const FLAG needflag = FLAG_NULL); 143 | 144 | char * morphgen(char * ts, int wl, const unsigned short * ap, 145 | unsigned short al, char * morph, char * targetmorph, int level); 146 | 147 | int expand_rootword(struct guessword * wlst, int maxn, const char * ts, 148 | int wl, const unsigned short * ap, unsigned short al, char * bad, 149 | int, char *); 150 | 151 | short get_syllable (const char * word, int wlen); 152 | int cpdrep_check(const char * word, int len); 153 | int cpdpat_check(const char * word, int len, hentry * r1, hentry * r2, 154 | const char affixed); 155 | int defcpd_check(hentry *** words, short wnum, hentry * rv, 156 | hentry ** rwords, char all); 157 | int cpdcase_check(const char * word, int len); 158 | inline int candidate_check(const char * word, int len); 159 | void setcminmax(int * cmin, int * cmax, const char * word, int len); 160 | struct hentry * compound_check(const char * word, int len, short wordnum, 161 | short numsyllable, short maxwordnum, short wnum, hentry ** words, 162 | char hu_mov_rule, char is_sug, int * info); 163 | 164 | int compound_check_morph(const char * word, int len, short wordnum, 165 | short numsyllable, short maxwordnum, short wnum, hentry ** words, 166 | char hu_mov_rule, char ** result, char * partresult); 167 | 168 | struct hentry * lookup(const char * word); 169 | int get_numrep() const; 170 | struct replentry * get_reptable() const; 171 | RepList * get_iconvtable() const; 172 | RepList * get_oconvtable() const; 173 | struct phonetable * get_phonetable() const; 174 | int get_nummap() const; 175 | struct mapentry * get_maptable() const; 176 | int get_numbreak() const; 177 | char ** get_breaktable() const; 178 | char * get_encoding(); 179 | int get_langnum() const; 180 | char * get_key_string(); 181 | char * get_try_string() const; 182 | const char * get_wordchars() const; 183 | unsigned short * get_wordchars_utf16(int * len) const; 184 | char * get_ignore() const; 185 | unsigned short * get_ignore_utf16(int * len) const; 186 | int get_compound() const; 187 | FLAG get_compoundflag() const; 188 | FLAG get_compoundbegin() const; 189 | FLAG get_forbiddenword() const; 190 | FLAG get_nosuggest() const; 191 | FLAG get_nongramsuggest() const; 192 | FLAG get_needaffix() const; 193 | FLAG get_onlyincompound() const; 194 | FLAG get_compoundroot() const; 195 | FLAG get_lemma_present() const; 196 | int get_checknum() const; 197 | const char * get_prefix() const; 198 | const char * get_suffix() const; 199 | const char * get_derived() const; 200 | const char * get_version() const; 201 | int have_contclass() const; 202 | int get_utf8() const; 203 | int get_complexprefixes() const; 204 | char * get_suffixed(char ) const; 205 | int get_maxngramsugs() const; 206 | int get_maxcpdsugs() const; 207 | int get_maxdiff() const; 208 | int get_onlymaxdiff() const; 209 | int get_nosplitsugs() const; 210 | int get_sugswithdots(void) const; 211 | FLAG get_keepcase(void) const; 212 | FLAG get_forceucase(void) const; 213 | FLAG get_warn(void) const; 214 | int get_forbidwarn(void) const; 215 | int get_checksharps(void) const; 216 | char * encode_flag(unsigned short aflag) const; 217 | int get_fullstrip() const; 218 | 219 | private: 220 | int parse_file(const char * affpath, const char * key); 221 | int parse_flag(char * line, unsigned short * out, FileMgr * af); 222 | int parse_num(char * line, int * out, FileMgr * af); 223 | int parse_cpdsyllable(char * line, FileMgr * af); 224 | int parse_reptable(char * line, FileMgr * af); 225 | int parse_convtable(char * line, FileMgr * af, RepList ** rl, const char * keyword); 226 | int parse_phonetable(char * line, FileMgr * af); 227 | int parse_maptable(char * line, FileMgr * af); 228 | int parse_breaktable(char * line, FileMgr * af); 229 | int parse_checkcpdtable(char * line, FileMgr * af); 230 | int parse_defcpdtable(char * line, FileMgr * af); 231 | int parse_affix(char * line, const char at, FileMgr * af, char * dupflags); 232 | 233 | void reverse_condition(char *); 234 | void debugflag(char * result, unsigned short flag); 235 | int condlen(char *); 236 | int encodeit(affentry &entry, char * cs); 237 | int build_pfxtree(PfxEntry* pfxptr); 238 | int build_sfxtree(SfxEntry* sfxptr); 239 | int process_pfx_order(); 240 | int process_sfx_order(); 241 | PfxEntry * process_pfx_in_order(PfxEntry * ptr, PfxEntry * nptr); 242 | SfxEntry * process_sfx_in_order(SfxEntry * ptr, SfxEntry * nptr); 243 | int process_pfx_tree_to_list(); 244 | int process_sfx_tree_to_list(); 245 | int redundant_condition(char, char * strip, int stripl, 246 | const char * cond, int); 247 | }; 248 | 249 | #endif 250 | 251 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/atypes.hxx: -------------------------------------------------------------------------------- 1 | #ifndef _ATYPES_HXX_ 2 | #define _ATYPES_HXX_ 3 | 4 | #ifndef HUNSPELL_WARNING 5 | #include 6 | #ifdef HUNSPELL_WARNING_ON 7 | #define HUNSPELL_WARNING fprintf 8 | #else 9 | // empty inline function to switch off warnings (instead of the C99 standard variadic macros) 10 | static inline void HUNSPELL_WARNING(FILE *, const char *, ...) {} 11 | #endif 12 | #endif 13 | 14 | // HUNSTEM def. 15 | #define HUNSTEM 16 | 17 | #include "hashmgr.hxx" 18 | #include "w_char.hxx" 19 | 20 | #define SETSIZE 256 21 | #define CONTSIZE 65536 22 | #define MAXWORDLEN 100 23 | #define MAXWORDUTF8LEN 256 24 | 25 | // affentry options 26 | #define aeXPRODUCT (1 << 0) 27 | #define aeUTF8 (1 << 1) 28 | #define aeALIASF (1 << 2) 29 | #define aeALIASM (1 << 3) 30 | #define aeLONGCOND (1 << 4) 31 | 32 | // compound options 33 | #define IN_CPD_NOT 0 34 | #define IN_CPD_BEGIN 1 35 | #define IN_CPD_END 2 36 | #define IN_CPD_OTHER 3 37 | 38 | // info options 39 | #define SPELL_COMPOUND (1 << 0) 40 | #define SPELL_FORBIDDEN (1 << 1) 41 | #define SPELL_ALLCAP (1 << 2) 42 | #define SPELL_NOCAP (1 << 3) 43 | #define SPELL_INITCAP (1 << 4) 44 | #define SPELL_ORIGCAP (1 << 5) 45 | #define SPELL_WARN (1 << 6) 46 | 47 | #define MAXLNLEN 8192 48 | 49 | #define MINCPDLEN 3 50 | #define MAXCOMPOUND 10 51 | #define MAXCONDLEN 20 52 | #define MAXCONDLEN_1 (MAXCONDLEN - sizeof(char *)) 53 | 54 | #define MAXACC 1000 55 | 56 | #define FLAG unsigned short 57 | #define FLAG_NULL 0x00 58 | #define FREE_FLAG(a) a = 0 59 | 60 | #define TESTAFF( a, b , c ) flag_bsearch((unsigned short *) a, (unsigned short) b, c) 61 | 62 | struct affentry 63 | { 64 | char * strip; 65 | char * appnd; 66 | unsigned char stripl; 67 | unsigned char appndl; 68 | char numconds; 69 | char opts; 70 | unsigned short aflag; 71 | unsigned short * contclass; 72 | short contclasslen; 73 | union { 74 | char conds[MAXCONDLEN]; 75 | struct { 76 | char conds1[MAXCONDLEN_1]; 77 | char * conds2; 78 | } l; 79 | } c; 80 | char * morphcode; 81 | }; 82 | 83 | struct guessword { 84 | char * word; 85 | bool allow; 86 | char * orig; 87 | }; 88 | 89 | struct mapentry { 90 | char ** set; 91 | int len; 92 | }; 93 | 94 | struct flagentry { 95 | FLAG * def; 96 | int len; 97 | }; 98 | 99 | struct patentry { 100 | char * pattern; 101 | char * pattern2; 102 | char * pattern3; 103 | FLAG cond; 104 | FLAG cond2; 105 | }; 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/baseaffix.hxx: -------------------------------------------------------------------------------- 1 | #ifndef _BASEAFF_HXX_ 2 | #define _BASEAFF_HXX_ 3 | 4 | #include "hunvisapi.h" 5 | 6 | class LIBHUNSPELL_DLL_EXPORTED AffEntry 7 | { 8 | protected: 9 | char * appnd; 10 | char * strip; 11 | unsigned char appndl; 12 | unsigned char stripl; 13 | char numconds; 14 | char opts; 15 | unsigned short aflag; 16 | union { 17 | char conds[MAXCONDLEN]; 18 | struct { 19 | char conds1[MAXCONDLEN_1]; 20 | char * conds2; 21 | } l; 22 | } c; 23 | char * morphcode; 24 | unsigned short * contclass; 25 | short contclasslen; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/config.h: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP 4 | systems. This function is required for `alloca.c' support on those systems. 5 | */ 6 | #undef CRAY_STACKSEG_END 7 | 8 | /* Define to 1 if using `alloca.c'. */ 9 | #undef C_ALLOCA 10 | 11 | /* Define to 1 if translation of program messages to the user's native 12 | language is requested. */ 13 | #undef ENABLE_NLS 14 | 15 | /* Define to 1 if you have `alloca', as a function or macro. */ 16 | #undef HAVE_ALLOCA 17 | 18 | /* Define to 1 if you have and it should be used (not on Ultrix). 19 | */ 20 | #undef HAVE_ALLOCA_H 21 | 22 | /* Define to 1 if you have the `argz_count' function. */ 23 | #undef HAVE_ARGZ_COUNT 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #undef HAVE_ARGZ_H 27 | 28 | /* Define to 1 if you have the `argz_next' function. */ 29 | #undef HAVE_ARGZ_NEXT 30 | 31 | /* Define to 1 if you have the `argz_stringify' function. */ 32 | #undef HAVE_ARGZ_STRINGIFY 33 | 34 | /* Define to 1 if you have the `asprintf' function. */ 35 | #undef HAVE_ASPRINTF 36 | 37 | /* Define to 1 if the compiler understands __builtin_expect. */ 38 | #undef HAVE_BUILTIN_EXPECT 39 | 40 | /* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the 41 | CoreFoundation framework. */ 42 | #undef HAVE_CFLOCALECOPYCURRENT 43 | 44 | /* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in 45 | the CoreFoundation framework. */ 46 | #undef HAVE_CFPREFERENCESCOPYAPPVALUE 47 | 48 | /* "Define if you have the header" */ 49 | #undef HAVE_CURSES_H 50 | 51 | /* Define if the GNU dcgettext() function is already present or preinstalled. 52 | */ 53 | #undef HAVE_DCGETTEXT 54 | 55 | /* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you 56 | don't. */ 57 | #undef HAVE_DECL_FEOF_UNLOCKED 58 | 59 | /* Define to 1 if you have the declaration of `fgets_unlocked', and to 0 if 60 | you don't. */ 61 | #undef HAVE_DECL_FGETS_UNLOCKED 62 | 63 | /* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you 64 | don't. */ 65 | #undef HAVE_DECL_GETC_UNLOCKED 66 | 67 | /* Define to 1 if you have the declaration of `_snprintf', and to 0 if you 68 | don't. */ 69 | #undef HAVE_DECL__SNPRINTF 70 | 71 | /* Define to 1 if you have the declaration of `_snwprintf', and to 0 if you 72 | don't. */ 73 | #undef HAVE_DECL__SNWPRINTF 74 | 75 | /* Define to 1 if you have the header file. */ 76 | #undef HAVE_DLFCN_H 77 | 78 | /* Define to 1 if you have the header file. */ 79 | #undef HAVE_ERROR_H 80 | 81 | /* Define to 1 if you have the header file. */ 82 | #undef HAVE_FCNTL_H 83 | 84 | /* Define to 1 if you have the `fwprintf' function. */ 85 | #undef HAVE_FWPRINTF 86 | 87 | /* Define to 1 if you have the `getcwd' function. */ 88 | #undef HAVE_GETCWD 89 | 90 | /* Define to 1 if you have the `getegid' function. */ 91 | #undef HAVE_GETEGID 92 | 93 | /* Define to 1 if you have the `geteuid' function. */ 94 | #undef HAVE_GETEUID 95 | 96 | /* Define to 1 if you have the `getgid' function. */ 97 | #undef HAVE_GETGID 98 | 99 | /* Define to 1 if you have the `getpagesize' function. */ 100 | #undef HAVE_GETPAGESIZE 101 | 102 | /* Define if the GNU gettext() function is already present or preinstalled. */ 103 | #undef HAVE_GETTEXT 104 | 105 | /* Define to 1 if you have the `getuid' function. */ 106 | #undef HAVE_GETUID 107 | 108 | /* Define if you have the iconv() function and it works. */ 109 | #undef HAVE_ICONV 110 | 111 | /* Define if you have the 'intmax_t' type in or . */ 112 | #undef HAVE_INTMAX_T 113 | 114 | /* Define to 1 if you have the header file. */ 115 | #undef HAVE_INTTYPES_H 116 | 117 | /* Define if exists, doesn't clash with , and 118 | declares uintmax_t. */ 119 | #undef HAVE_INTTYPES_H_WITH_UINTMAX 120 | 121 | /* Define if you have and nl_langinfo(CODESET). */ 122 | #undef HAVE_LANGINFO_CODESET 123 | 124 | /* Define if your file defines LC_MESSAGES. */ 125 | #undef HAVE_LC_MESSAGES 126 | 127 | /* Define to 1 if you have the header file. */ 128 | #undef HAVE_LIBINTL_H 129 | 130 | /* Define to 1 if you have the header file. */ 131 | #undef HAVE_LIMITS_H 132 | 133 | /* Define to 1 if you have the header file. */ 134 | #undef HAVE_LOCALE_H 135 | 136 | /* Define to 1 if the system has the type `long long int'. */ 137 | #undef HAVE_LONG_LONG_INT 138 | 139 | /* Define to 1 if you have the `memchr' function. */ 140 | #undef HAVE_MEMCHR 141 | 142 | /* Define to 1 if you have the header file. */ 143 | #undef HAVE_MEMORY_H 144 | 145 | /* Define to 1 if you have the `mempcpy' function. */ 146 | #undef HAVE_MEMPCPY 147 | 148 | /* Define to 1 if you have a working `mmap' system call. */ 149 | #undef HAVE_MMAP 150 | 151 | /* Define to 1 if you have the `munmap' function. */ 152 | #undef HAVE_MUNMAP 153 | 154 | /* "Define if you have the header" */ 155 | #undef HAVE_NCURSESW_H 156 | 157 | /* Define if you have and it defines the NL_LOCALE_NAME macro if 158 | _GNU_SOURCE is defined. */ 159 | #undef HAVE_NL_LOCALE_NAME 160 | 161 | /* Define if your printf() function supports format strings with positions. */ 162 | #undef HAVE_POSIX_PRINTF 163 | 164 | /* Define if the defines PTHREAD_MUTEX_RECURSIVE. */ 165 | #undef HAVE_PTHREAD_MUTEX_RECURSIVE 166 | 167 | /* Define if the POSIX multithreading library has read/write locks. */ 168 | #undef HAVE_PTHREAD_RWLOCK 169 | 170 | /* Define to 1 if you have the `putenv' function. */ 171 | #undef HAVE_PUTENV 172 | 173 | /* "Define if you have fancy command input editing with Readline" */ 174 | #undef HAVE_READLINE 175 | 176 | /* Define to 1 if you have the `setenv' function. */ 177 | #undef HAVE_SETENV 178 | 179 | /* Define to 1 if you have the `setlocale' function. */ 180 | #undef HAVE_SETLOCALE 181 | 182 | /* Define to 1 if you have the `snprintf' function. */ 183 | #undef HAVE_SNPRINTF 184 | 185 | /* Define to 1 if you have the header file. */ 186 | #undef HAVE_STDDEF_H 187 | 188 | /* Define to 1 if you have the header file. */ 189 | #undef HAVE_STDINT_H 190 | 191 | /* Define if exists, doesn't clash with , and declares 192 | uintmax_t. */ 193 | #undef HAVE_STDINT_H_WITH_UINTMAX 194 | 195 | /* Define to 1 if you have the header file. */ 196 | #undef HAVE_STDLIB_H 197 | 198 | /* Define to 1 if you have the `stpcpy' function. */ 199 | #undef HAVE_STPCPY 200 | 201 | /* Define to 1 if you have the `strcasecmp' function. */ 202 | #undef HAVE_STRCASECMP 203 | 204 | /* Define to 1 if you have the `strchr' function. */ 205 | #undef HAVE_STRCHR 206 | 207 | /* Define to 1 if you have the `strdup' function. */ 208 | #undef HAVE_STRDUP 209 | 210 | /* Define to 1 if you have the header file. */ 211 | #undef HAVE_STRINGS_H 212 | 213 | /* Define to 1 if you have the header file. */ 214 | #undef HAVE_STRING_H 215 | 216 | /* Define to 1 if you have the `strstr' function. */ 217 | #undef HAVE_STRSTR 218 | 219 | /* Define to 1 if you have the `strtoul' function. */ 220 | #undef HAVE_STRTOUL 221 | 222 | /* Define to 1 if you have the header file. */ 223 | #undef HAVE_SYS_PARAM_H 224 | 225 | /* Define to 1 if you have the header file. */ 226 | #undef HAVE_SYS_STAT_H 227 | 228 | /* Define to 1 if you have the header file. */ 229 | #undef HAVE_SYS_TYPES_H 230 | 231 | /* Define to 1 if you have the `tsearch' function. */ 232 | #undef HAVE_TSEARCH 233 | 234 | /* Define if you have the 'uintmax_t' type in or . */ 235 | #undef HAVE_UINTMAX_T 236 | 237 | /* Define to 1 if you have the header file. */ 238 | #undef HAVE_UNISTD_H 239 | 240 | /* Define to 1 if the system has the type `unsigned long long int'. */ 241 | #undef HAVE_UNSIGNED_LONG_LONG_INT 242 | 243 | /* Define to 1 or 0, depending whether the compiler supports simple visibility 244 | declarations. */ 245 | #undef HAVE_VISIBILITY 246 | 247 | /* Define if you have the 'wchar_t' type. */ 248 | #undef HAVE_WCHAR_T 249 | 250 | /* Define to 1 if you have the `wcslen' function. */ 251 | #undef HAVE_WCSLEN 252 | 253 | /* Define if you have the 'wint_t' type. */ 254 | #undef HAVE_WINT_T 255 | 256 | /* Define to 1 if you have the `__fsetlocking' function. */ 257 | #undef HAVE___FSETLOCKING 258 | 259 | /* "Define if you use exterimental functions" */ 260 | #undef HUNSPELL_EXPERIMENTAL 261 | 262 | /* "Define if you need warning messages" */ 263 | #undef HUNSPELL_WARNING_ON 264 | 265 | /* Define as const if the declaration of iconv() needs const. */ 266 | #undef ICONV_CONST 267 | 268 | /* Define if integer division by zero raises signal SIGFPE. */ 269 | #undef INTDIV0_RAISES_SIGFPE 270 | 271 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 272 | */ 273 | #undef LT_OBJDIR 274 | 275 | /* Name of package */ 276 | #undef PACKAGE 277 | 278 | /* Define to the address where bug reports for this package should be sent. */ 279 | #undef PACKAGE_BUGREPORT 280 | 281 | /* Define to the full name of this package. */ 282 | #undef PACKAGE_NAME 283 | 284 | /* Define to the full name and version of this package. */ 285 | #undef PACKAGE_STRING 286 | 287 | /* Define to the one symbol short name of this package. */ 288 | #undef PACKAGE_TARNAME 289 | 290 | /* Define to the home page for this package. */ 291 | #undef PACKAGE_URL 292 | 293 | /* Define to the version of this package. */ 294 | #undef PACKAGE_VERSION 295 | 296 | /* Define if exists and defines unusable PRI* macros. */ 297 | #undef PRI_MACROS_BROKEN 298 | 299 | /* Define if the pthread_in_use() detection is hard. */ 300 | #undef PTHREAD_IN_USE_DETECTION_HARD 301 | 302 | /* Define as the maximum value of type 'size_t', if the system doesn't define 303 | it. */ 304 | #undef SIZE_MAX 305 | 306 | /* If using the C implementation of alloca, define if you know the 307 | direction of stack growth for your system; otherwise it will be 308 | automatically deduced at runtime. 309 | STACK_DIRECTION > 0 => grows toward higher addresses 310 | STACK_DIRECTION < 0 => grows toward lower addresses 311 | STACK_DIRECTION = 0 => direction of growth unknown */ 312 | #undef STACK_DIRECTION 313 | 314 | /* Define to 1 if you have the ANSI C header files. */ 315 | #undef STDC_HEADERS 316 | 317 | /* Define if the POSIX multithreading library can be used. */ 318 | #undef USE_POSIX_THREADS 319 | 320 | /* Define if references to the POSIX multithreading library should be made 321 | weak. */ 322 | #undef USE_POSIX_THREADS_WEAK 323 | 324 | /* Define if the GNU Pth multithreading library can be used. */ 325 | #undef USE_PTH_THREADS 326 | 327 | /* Define if references to the GNU Pth multithreading library should be made 328 | weak. */ 329 | #undef USE_PTH_THREADS_WEAK 330 | 331 | /* Define if the old Solaris multithreading library can be used. */ 332 | #undef USE_SOLARIS_THREADS 333 | 334 | /* Define if references to the old Solaris multithreading library should be 335 | made weak. */ 336 | #undef USE_SOLARIS_THREADS_WEAK 337 | 338 | /* Enable extensions on AIX 3, Interix. */ 339 | #ifndef _ALL_SOURCE 340 | # undef _ALL_SOURCE 341 | #endif 342 | /* Enable GNU extensions on systems that have them. */ 343 | #ifndef _GNU_SOURCE 344 | # undef _GNU_SOURCE 345 | #endif 346 | /* Enable threading extensions on Solaris. */ 347 | #ifndef _POSIX_PTHREAD_SEMANTICS 348 | # undef _POSIX_PTHREAD_SEMANTICS 349 | #endif 350 | /* Enable extensions on HP NonStop. */ 351 | #ifndef _TANDEM_SOURCE 352 | # undef _TANDEM_SOURCE 353 | #endif 354 | /* Enable general extensions on Solaris. */ 355 | #ifndef __EXTENSIONS__ 356 | # undef __EXTENSIONS__ 357 | #endif 358 | 359 | 360 | /* Define if the Win32 multithreading API can be used. */ 361 | #undef USE_WIN32_THREADS 362 | 363 | /* Version number of package */ 364 | #undef VERSION 365 | 366 | /* Define to 1 if on MINIX. */ 367 | #undef _MINIX 368 | 369 | /* Define to 2 if the system does not provide POSIX.1 features except with 370 | this defined. */ 371 | #undef _POSIX_1_SOURCE 372 | 373 | /* Define to 1 if you need to in order for `stat' and other things to work. */ 374 | #undef _POSIX_SOURCE 375 | 376 | /* Define to empty if `const' does not conform to ANSI C. */ 377 | #undef const 378 | 379 | /* Define to `__inline__' or `__inline' if that's what the C compiler 380 | calls it, or to nothing if 'inline' is not supported under any name. */ 381 | #ifndef __cplusplus 382 | #undef inline 383 | #endif 384 | 385 | /* Define as the type of the result of subtracting two pointers, if the system 386 | doesn't define it. */ 387 | #undef ptrdiff_t 388 | 389 | /* Define to `unsigned int' if does not define. */ 390 | #undef size_t 391 | 392 | /* Define to unsigned long or unsigned long long if and 393 | don't define. */ 394 | #undef uintmax_t 395 | 396 | 397 | #define __libc_lock_t gl_lock_t 398 | #define __libc_lock_define gl_lock_define 399 | #define __libc_lock_define_initialized gl_lock_define_initialized 400 | #define __libc_lock_init gl_lock_init 401 | #define __libc_lock_lock gl_lock_lock 402 | #define __libc_lock_unlock gl_lock_unlock 403 | #define __libc_lock_recursive_t gl_recursive_lock_t 404 | #define __libc_lock_define_recursive gl_recursive_lock_define 405 | #define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized 406 | #define __libc_lock_init_recursive gl_recursive_lock_init 407 | #define __libc_lock_lock_recursive gl_recursive_lock_lock 408 | #define __libc_lock_unlock_recursive gl_recursive_lock_unlock 409 | #define glthread_in_use libintl_thread_in_use 410 | #define glthread_lock_init libintl_lock_init 411 | #define glthread_lock_lock libintl_lock_lock 412 | #define glthread_lock_unlock libintl_lock_unlock 413 | #define glthread_lock_destroy libintl_lock_destroy 414 | #define glthread_rwlock_init libintl_rwlock_init 415 | #define glthread_rwlock_rdlock libintl_rwlock_rdlock 416 | #define glthread_rwlock_wrlock libintl_rwlock_wrlock 417 | #define glthread_rwlock_unlock libintl_rwlock_unlock 418 | #define glthread_rwlock_destroy libintl_rwlock_destroy 419 | #define glthread_recursive_lock_init libintl_recursive_lock_init 420 | #define glthread_recursive_lock_lock libintl_recursive_lock_lock 421 | #define glthread_recursive_lock_unlock libintl_recursive_lock_unlock 422 | #define glthread_recursive_lock_destroy libintl_recursive_lock_destroy 423 | #define glthread_once libintl_once 424 | #define glthread_once_call libintl_once_call 425 | #define glthread_once_singlethreaded libintl_once_singlethreaded 426 | 427 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/dictmgr.cxx: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "dictmgr.hxx" 8 | 9 | DictMgr::DictMgr(const char * dictpath, const char * etype) : numdict(0) 10 | { 11 | // load list of etype entries 12 | pdentry = (dictentry *)malloc(MAXDICTIONARIES*sizeof(struct dictentry)); 13 | if (pdentry) { 14 | if (parse_file(dictpath, etype)) { 15 | numdict = 0; 16 | // no dictionary.lst found is okay 17 | } 18 | } 19 | } 20 | 21 | 22 | DictMgr::~DictMgr() 23 | { 24 | dictentry * pdict = NULL; 25 | if (pdentry) { 26 | pdict = pdentry; 27 | for (int i=0;ilang) { 29 | free(pdict->lang); 30 | pdict->lang = NULL; 31 | } 32 | if (pdict->region) { 33 | free(pdict->region); 34 | pdict->region=NULL; 35 | } 36 | if (pdict->filename) { 37 | free(pdict->filename); 38 | pdict->filename = NULL; 39 | } 40 | pdict++; 41 | } 42 | free(pdentry); 43 | pdentry = NULL; 44 | pdict = NULL; 45 | } 46 | numdict = 0; 47 | } 48 | 49 | 50 | // read in list of etype entries and build up structure to describe them 51 | int DictMgr::parse_file(const char * dictpath, const char * etype) 52 | { 53 | 54 | int i; 55 | char line[MAXDICTENTRYLEN+1]; 56 | dictentry * pdict = pdentry; 57 | 58 | // open the dictionary list file 59 | FILE * dictlst; 60 | dictlst = fopen(dictpath,"r"); 61 | if (!dictlst) { 62 | return 1; 63 | } 64 | 65 | // step one is to parse the dictionary list building up the 66 | // descriptive structures 67 | 68 | // read in each line ignoring any that dont start with etype 69 | while (fgets(line,MAXDICTENTRYLEN,dictlst)) { 70 | mychomp(line); 71 | 72 | /* parse in a dictionary entry */ 73 | if (strncmp(line,etype,4) == 0) { 74 | if (numdict < MAXDICTIONARIES) { 75 | char * tp = line; 76 | char * piece; 77 | i = 0; 78 | while ((piece=mystrsep(&tp,' '))) { 79 | if (*piece != '\0') { 80 | switch(i) { 81 | case 0: break; 82 | case 1: pdict->lang = mystrdup(piece); break; 83 | case 2: if (strcmp (piece, "ANY") == 0) 84 | pdict->region = mystrdup(""); 85 | else 86 | pdict->region = mystrdup(piece); 87 | break; 88 | case 3: pdict->filename = mystrdup(piece); break; 89 | default: break; 90 | } 91 | i++; 92 | } 93 | free(piece); 94 | } 95 | if (i == 4) { 96 | numdict++; 97 | pdict++; 98 | } else { 99 | switch (i) { 100 | case 3: 101 | free(pdict->region); 102 | pdict->region=NULL; 103 | case 2: //deliberate fallthrough 104 | free(pdict->lang); 105 | pdict->lang=NULL; 106 | default: 107 | break; 108 | } 109 | fprintf(stderr,"dictionary list corruption in line \"%s\"\n",line); 110 | fflush(stderr); 111 | } 112 | } 113 | } 114 | } 115 | fclose(dictlst); 116 | return 0; 117 | } 118 | 119 | // return text encoding of dictionary 120 | int DictMgr::get_list(dictentry ** ppentry) 121 | { 122 | *ppentry = pdentry; 123 | return numdict; 124 | } 125 | 126 | 127 | 128 | // strip strings into token based on single char delimiter 129 | // acts like strsep() but only uses a delim char and not 130 | // a delim string 131 | 132 | char * DictMgr::mystrsep(char ** stringp, const char delim) 133 | { 134 | char * rv = NULL; 135 | char * mp = *stringp; 136 | size_t n = strlen(mp); 137 | if (n > 0) { 138 | char * dp = (char *)memchr(mp,(int)((unsigned char)delim),n); 139 | if (dp) { 140 | *stringp = dp+1; 141 | size_t nc = dp - mp; 142 | rv = (char *) malloc(nc+1); 143 | if (rv) { 144 | memcpy(rv,mp,nc); 145 | *(rv+nc) = '\0'; 146 | } 147 | } else { 148 | rv = (char *) malloc(n+1); 149 | if (rv) { 150 | memcpy(rv, mp, n); 151 | *(rv+n) = '\0'; 152 | *stringp = mp + n; 153 | } 154 | } 155 | } 156 | return rv; 157 | } 158 | 159 | 160 | // replaces strdup with ansi version 161 | char * DictMgr::mystrdup(const char * s) 162 | { 163 | char * d = NULL; 164 | if (s) { 165 | int sl = strlen(s)+1; 166 | d = (char *) malloc(sl); 167 | if (d) memcpy(d,s,sl); 168 | } 169 | return d; 170 | } 171 | 172 | 173 | // remove cross-platform text line end characters 174 | void DictMgr:: mychomp(char * s) 175 | { 176 | int k = strlen(s); 177 | if ((k > 0) && ((*(s+k-1)=='\r') || (*(s+k-1)=='\n'))) *(s+k-1) = '\0'; 178 | if ((k > 1) && (*(s+k-2) == '\r')) *(s+k-2) = '\0'; 179 | } 180 | 181 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/dictmgr.hxx: -------------------------------------------------------------------------------- 1 | #ifndef _DICTMGR_HXX_ 2 | #define _DICTMGR_HXX_ 3 | 4 | #include "hunvisapi.h" 5 | 6 | #define MAXDICTIONARIES 100 7 | #define MAXDICTENTRYLEN 1024 8 | 9 | struct dictentry { 10 | char * filename; 11 | char * lang; 12 | char * region; 13 | }; 14 | 15 | 16 | class LIBHUNSPELL_DLL_EXPORTED DictMgr 17 | { 18 | 19 | int numdict; 20 | dictentry * pdentry; 21 | 22 | public: 23 | 24 | DictMgr(const char * dictpath, const char * etype); 25 | ~DictMgr(); 26 | int get_list(dictentry** ppentry); 27 | 28 | private: 29 | int parse_file(const char * dictpath, const char * etype); 30 | char * mystrsep(char ** stringp, const char delim); 31 | char * mystrdup(const char * s); 32 | void mychomp(char * s); 33 | 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/filemgr.cxx: -------------------------------------------------------------------------------- 1 | #include "license.hunspell" 2 | #include "license.myspell" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "filemgr.hxx" 9 | 10 | int FileMgr::fail(const char * err, const char * par) { 11 | fprintf(stderr, err, par); 12 | return -1; 13 | } 14 | 15 | FileMgr::FileMgr(const char * file, const char * key) { 16 | linenum = 0; 17 | hin = NULL; 18 | fin = fopen(file, "r"); 19 | if (!fin) { 20 | // check hzipped file 21 | char * st = (char *) malloc(strlen(file) + strlen(HZIP_EXTENSION) + 1); 22 | if (st) { 23 | strcpy(st, file); 24 | strcat(st, HZIP_EXTENSION); 25 | hin = new Hunzip(st, key); 26 | free(st); 27 | } 28 | } 29 | if (!fin && !hin) fail(MSG_OPEN, file); 30 | } 31 | 32 | FileMgr::~FileMgr() 33 | { 34 | if (fin) fclose(fin); 35 | if (hin) delete hin; 36 | } 37 | 38 | char * FileMgr::getline() { 39 | const char * l; 40 | linenum++; 41 | if (fin) return fgets(in, BUFSIZE - 1, fin); 42 | if (hin && (l = hin->getline())) return strcpy(in, l); 43 | linenum--; 44 | return NULL; 45 | } 46 | 47 | int FileMgr::getlinenum() { 48 | return linenum; 49 | } 50 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/filemgr.hxx: -------------------------------------------------------------------------------- 1 | /* file manager class - read lines of files [filename] OR [filename.hz] */ 2 | #ifndef _FILEMGR_HXX_ 3 | #define _FILEMGR_HXX_ 4 | 5 | #include "hunvisapi.h" 6 | 7 | #include "hunzip.hxx" 8 | #include 9 | 10 | class LIBHUNSPELL_DLL_EXPORTED FileMgr 11 | { 12 | protected: 13 | FILE * fin; 14 | Hunzip * hin; 15 | char in[BUFSIZE + 50]; // input buffer 16 | int fail(const char * err, const char * par); 17 | int linenum; 18 | 19 | public: 20 | FileMgr(const char * filename, const char * key = NULL); 21 | ~FileMgr(); 22 | char * getline(); 23 | int getlinenum(); 24 | }; 25 | #endif 26 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/hashmgr.cxx: -------------------------------------------------------------------------------- 1 | #include "license.hunspell" 2 | #include "license.myspell" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "hashmgr.hxx" 10 | #include "csutil.hxx" 11 | #include "atypes.hxx" 12 | 13 | // build a hash table from a munched word list 14 | 15 | HashMgr::HashMgr(const char * tpath, const char * apath, const char * key) 16 | { 17 | tablesize = 0; 18 | tableptr = NULL; 19 | flag_mode = FLAG_CHAR; 20 | complexprefixes = 0; 21 | utf8 = 0; 22 | langnum = 0; 23 | lang = NULL; 24 | enc = NULL; 25 | csconv = 0; 26 | ignorechars = NULL; 27 | ignorechars_utf16 = NULL; 28 | ignorechars_utf16_len = 0; 29 | numaliasf = 0; 30 | aliasf = NULL; 31 | numaliasm = 0; 32 | aliasm = NULL; 33 | forbiddenword = FORBIDDENWORD; // forbidden word signing flag 34 | load_config(apath, key); 35 | int ec = load_tables(tpath, key); 36 | if (ec) { 37 | /* error condition - what should we do here */ 38 | HUNSPELL_WARNING(stderr, "Hash Manager Error : %d\n",ec); 39 | if (tableptr) { 40 | free(tableptr); 41 | tableptr = NULL; 42 | } 43 | tablesize = 0; 44 | } 45 | } 46 | 47 | 48 | HashMgr::~HashMgr() 49 | { 50 | if (tableptr) { 51 | // now pass through hash table freeing up everything 52 | // go through column by column of the table 53 | for (int i=0; i < tablesize; i++) { 54 | struct hentry * pt = tableptr[i]; 55 | struct hentry * nt = NULL; 56 | while(pt) { 57 | nt = pt->next; 58 | if (pt->astr && (!aliasf || TESTAFF(pt->astr, ONLYUPCASEFLAG, pt->alen))) free(pt->astr); 59 | free(pt); 60 | pt = nt; 61 | } 62 | } 63 | free(tableptr); 64 | } 65 | tablesize = 0; 66 | 67 | if (aliasf) { 68 | for (int j = 0; j < (numaliasf); j++) free(aliasf[j]); 69 | free(aliasf); 70 | aliasf = NULL; 71 | if (aliasflen) { 72 | free(aliasflen); 73 | aliasflen = NULL; 74 | } 75 | } 76 | if (aliasm) { 77 | for (int j = 0; j < (numaliasm); j++) free(aliasm[j]); 78 | free(aliasm); 79 | aliasm = NULL; 80 | } 81 | 82 | #ifndef OPENOFFICEORG 83 | #ifndef MOZILLA_CLIENT 84 | if (utf8) free_utf_tbl(); 85 | #endif 86 | #endif 87 | 88 | if (enc) free(enc); 89 | if (lang) free(lang); 90 | 91 | if (ignorechars) free(ignorechars); 92 | if (ignorechars_utf16) free(ignorechars_utf16); 93 | 94 | #ifdef MOZILLA_CLIENT 95 | delete [] csconv; 96 | #endif 97 | } 98 | 99 | // lookup a root word in the hashtable 100 | 101 | struct hentry * HashMgr::lookup(const char *word) const 102 | { 103 | struct hentry * dp; 104 | if (tableptr) { 105 | dp = tableptr[hash(word)]; 106 | if (!dp) return NULL; 107 | for ( ; dp != NULL; dp = dp->next) { 108 | if (strcmp(word, dp->word) == 0) return dp; 109 | } 110 | } 111 | return NULL; 112 | } 113 | 114 | // add a word to the hash table (private) 115 | int HashMgr::add_word(const char * word, int wbl, int wcl, unsigned short * aff, 116 | int al, const char * desc, bool onlyupcase) 117 | { 118 | bool upcasehomonym = false; 119 | int descl = desc ? (aliasm ? sizeof(short) : strlen(desc) + 1) : 0; 120 | // variable-length hash record with word and optional fields 121 | struct hentry* hp = 122 | (struct hentry *) malloc (sizeof(struct hentry) + wbl + descl); 123 | if (!hp) return 1; 124 | char * hpw = hp->word; 125 | strcpy(hpw, word); 126 | if (ignorechars != NULL) { 127 | if (utf8) { 128 | remove_ignored_chars_utf(hpw, ignorechars_utf16, ignorechars_utf16_len); 129 | } else { 130 | remove_ignored_chars(hpw, ignorechars); 131 | } 132 | } 133 | if (complexprefixes) { 134 | if (utf8) reverseword_utf(hpw); else reverseword(hpw); 135 | } 136 | 137 | int i = hash(hpw); 138 | 139 | hp->blen = (unsigned char) wbl; 140 | hp->clen = (unsigned char) wcl; 141 | hp->alen = (short) al; 142 | hp->astr = aff; 143 | hp->next = NULL; 144 | hp->next_homonym = NULL; 145 | 146 | // store the description string or its pointer 147 | if (desc) { 148 | hp->var = H_OPT; 149 | if (aliasm) { 150 | hp->var += H_OPT_ALIASM; 151 | store_pointer(hpw + wbl + 1, get_aliasm(atoi(desc))); 152 | } else { 153 | strcpy(hpw + wbl + 1, desc); 154 | if (complexprefixes) { 155 | if (utf8) reverseword_utf(HENTRY_DATA(hp)); 156 | else reverseword(HENTRY_DATA(hp)); 157 | } 158 | } 159 | if (strstr(HENTRY_DATA(hp), MORPH_PHON)) hp->var += H_OPT_PHON; 160 | } else hp->var = 0; 161 | 162 | struct hentry * dp = tableptr[i]; 163 | if (!dp) { 164 | tableptr[i] = hp; 165 | return 0; 166 | } 167 | while (dp->next != NULL) { 168 | if ((!dp->next_homonym) && (strcmp(hp->word, dp->word) == 0)) { 169 | // remove hidden onlyupcase homonym 170 | if (!onlyupcase) { 171 | if ((dp->astr) && TESTAFF(dp->astr, ONLYUPCASEFLAG, dp->alen)) { 172 | free(dp->astr); 173 | dp->astr = hp->astr; 174 | dp->alen = hp->alen; 175 | free(hp); 176 | return 0; 177 | } else { 178 | dp->next_homonym = hp; 179 | } 180 | } else { 181 | upcasehomonym = true; 182 | } 183 | } 184 | dp=dp->next; 185 | } 186 | if (strcmp(hp->word, dp->word) == 0) { 187 | // remove hidden onlyupcase homonym 188 | if (!onlyupcase) { 189 | if ((dp->astr) && TESTAFF(dp->astr, ONLYUPCASEFLAG, dp->alen)) { 190 | free(dp->astr); 191 | dp->astr = hp->astr; 192 | dp->alen = hp->alen; 193 | free(hp); 194 | return 0; 195 | } else { 196 | dp->next_homonym = hp; 197 | } 198 | } else { 199 | upcasehomonym = true; 200 | } 201 | } 202 | if (!upcasehomonym) { 203 | dp->next = hp; 204 | } else { 205 | // remove hidden onlyupcase homonym 206 | if (hp->astr) free(hp->astr); 207 | free(hp); 208 | } 209 | return 0; 210 | } 211 | 212 | int HashMgr::add_hidden_capitalized_word(char * word, int wbl, int wcl, 213 | unsigned short * flags, int al, char * dp, int captype) 214 | { 215 | // add inner capitalized forms to handle the following allcap forms: 216 | // Mixed caps: OpenOffice.org -> OPENOFFICE.ORG 217 | // Allcaps with suffixes: CIA's -> CIA'S 218 | if (((captype == HUHCAP) || (captype == HUHINITCAP) || 219 | ((captype == ALLCAP) && (flags != NULL))) && 220 | !((flags != NULL) && TESTAFF(flags, forbiddenword, al))) { 221 | unsigned short * flags2 = (unsigned short *) malloc (sizeof(unsigned short) * (al+1)); 222 | if (!flags2) return 1; 223 | if (al) memcpy(flags2, flags, al * sizeof(unsigned short)); 224 | flags2[al] = ONLYUPCASEFLAG; 225 | if (utf8) { 226 | char st[BUFSIZE]; 227 | w_char w[BUFSIZE]; 228 | int wlen = u8_u16(w, BUFSIZE, word); 229 | mkallsmall_utf(w, wlen, langnum); 230 | mkallcap_utf(w, 1, langnum); 231 | u16_u8(st, BUFSIZE, w, wlen); 232 | return add_word(st,wbl,wcl,flags2,al+1,dp, true); 233 | } else { 234 | mkallsmall(word, csconv); 235 | mkinitcap(word, csconv); 236 | return add_word(word,wbl,wcl,flags2,al+1,dp, true); 237 | } 238 | } 239 | return 0; 240 | } 241 | 242 | // detect captype and modify word length for UTF-8 encoding 243 | int HashMgr::get_clen_and_captype(const char * word, int wbl, int * captype) { 244 | int len; 245 | if (utf8) { 246 | w_char dest_utf[BUFSIZE]; 247 | len = u8_u16(dest_utf, BUFSIZE, word); 248 | *captype = get_captype_utf8(dest_utf, len, langnum); 249 | } else { 250 | len = wbl; 251 | *captype = get_captype((char *) word, len, csconv); 252 | } 253 | return len; 254 | } 255 | 256 | // remove word (personal dictionary function for standalone applications) 257 | int HashMgr::remove(const char * word) 258 | { 259 | struct hentry * dp = lookup(word); 260 | while (dp) { 261 | if (dp->alen == 0 || !TESTAFF(dp->astr, forbiddenword, dp->alen)) { 262 | unsigned short * flags = 263 | (unsigned short *) malloc(sizeof(short) * (dp->alen + 1)); 264 | if (!flags) return 1; 265 | for (int i = 0; i < dp->alen; i++) flags[i] = dp->astr[i]; 266 | flags[dp->alen] = forbiddenword; 267 | dp->astr = flags; 268 | dp->alen++; 269 | flag_qsort(flags, 0, dp->alen); 270 | } 271 | dp = dp->next_homonym; 272 | } 273 | return 0; 274 | } 275 | 276 | /* remove forbidden flag to add a personal word to the hash */ 277 | int HashMgr::remove_forbidden_flag(const char * word) { 278 | struct hentry * dp = lookup(word); 279 | if (!dp) return 1; 280 | while (dp) { 281 | if (dp->astr && TESTAFF(dp->astr, forbiddenword, dp->alen)) { 282 | if (dp->alen == 1) dp->alen = 0; // XXX forbidden words of personal dic. 283 | else { 284 | unsigned short * flags2 = 285 | (unsigned short *) malloc(sizeof(short) * (dp->alen - 1)); 286 | if (!flags2) return 1; 287 | int i, j = 0; 288 | for (i = 0; i < dp->alen; i++) { 289 | if (dp->astr[i] != forbiddenword) flags2[j++] = dp->astr[i]; 290 | } 291 | dp->alen--; 292 | dp->astr = flags2; // XXX allowed forbidden words 293 | } 294 | } 295 | dp = dp->next_homonym; 296 | } 297 | return 0; 298 | } 299 | 300 | // add a custom dic. word to the hash table (public) 301 | int HashMgr::add(const char * word) 302 | { 303 | unsigned short * flags = NULL; 304 | int al = 0; 305 | if (remove_forbidden_flag(word)) { 306 | int captype; 307 | int wbl = strlen(word); 308 | int wcl = get_clen_and_captype(word, wbl, &captype); 309 | add_word(word, wbl, wcl, flags, al, NULL, false); 310 | return add_hidden_capitalized_word((char *) word, wbl, wcl, flags, al, NULL, captype); 311 | } 312 | return 0; 313 | } 314 | 315 | int HashMgr::add_with_affix(const char * word, const char * example) 316 | { 317 | // detect captype and modify word length for UTF-8 encoding 318 | struct hentry * dp = lookup(example); 319 | remove_forbidden_flag(word); 320 | if (dp && dp->astr) { 321 | int captype; 322 | int wbl = strlen(word); 323 | int wcl = get_clen_and_captype(word, wbl, &captype); 324 | if (aliasf) { 325 | add_word(word, wbl, wcl, dp->astr, dp->alen, NULL, false); 326 | } else { 327 | unsigned short * flags = (unsigned short *) malloc (dp->alen * sizeof(short)); 328 | if (flags) { 329 | memcpy((void *) flags, (void *) dp->astr, dp->alen * sizeof(short)); 330 | add_word(word, wbl, wcl, flags, dp->alen, NULL, false); 331 | } else return 1; 332 | } 333 | return add_hidden_capitalized_word((char *) word, wbl, wcl, dp->astr, dp->alen, NULL, captype); 334 | } 335 | return 1; 336 | } 337 | 338 | // walk the hash table entry by entry - null at end 339 | // initialize: col=-1; hp = NULL; hp = walk_hashtable(&col, hp); 340 | struct hentry * HashMgr::walk_hashtable(int &col, struct hentry * hp) const 341 | { 342 | if (hp && hp->next != NULL) return hp->next; 343 | for (col++; col < tablesize; col++) { 344 | if (tableptr[col]) return tableptr[col]; 345 | } 346 | // null at end and reset to start 347 | col = -1; 348 | return NULL; 349 | } 350 | 351 | // load a munched word list and build a hash table on the fly 352 | int HashMgr::load_tables(const char * tpath, const char * key) 353 | { 354 | int al; 355 | char * ap; 356 | char * dp; 357 | char * dp2; 358 | unsigned short * flags; 359 | char * ts; 360 | 361 | // open dictionary file 362 | FileMgr * dict = new FileMgr(tpath, key); 363 | if (dict == NULL) return 1; 364 | 365 | // first read the first line of file to get hash table size */ 366 | if (!(ts = dict->getline())) { 367 | HUNSPELL_WARNING(stderr, "error: empty dic file\n"); 368 | delete dict; 369 | return 2; 370 | } 371 | mychomp(ts); 372 | 373 | /* remove byte order mark */ 374 | if (strncmp(ts,"\xEF\xBB\xBF",3) == 0) { 375 | memmove(ts, ts+3, strlen(ts+3)+1); 376 | // warning: dic file begins with byte order mark: possible incompatibility with old Hunspell versions 377 | } 378 | 379 | tablesize = atoi(ts); 380 | if (tablesize == 0) { 381 | HUNSPELL_WARNING(stderr, "error: line 1: missing or bad word count in the dic file\n"); 382 | delete dict; 383 | return 4; 384 | } 385 | tablesize = tablesize + 5 + USERWORD; 386 | if ((tablesize %2) == 0) tablesize++; 387 | 388 | // allocate the hash table 389 | tableptr = (struct hentry **) malloc(tablesize * sizeof(struct hentry *)); 390 | if (! tableptr) { 391 | delete dict; 392 | return 3; 393 | } 394 | for (int i=0; igetline())) { 400 | mychomp(ts); 401 | // split each line into word and morphological description 402 | dp = ts; 403 | while ((dp = strchr(dp, ':'))) { 404 | if ((dp > ts + 3) && (*(dp - 3) == ' ' || *(dp - 3) == '\t')) { 405 | for (dp -= 4; dp >= ts && (*dp == ' ' || *dp == '\t'); dp--); 406 | if (dp < ts) { // missing word 407 | dp = NULL; 408 | } else { 409 | *(dp + 1) = '\0'; 410 | dp = dp + 2; 411 | } 412 | break; 413 | } 414 | dp++; 415 | } 416 | 417 | // tabulator is the old morphological field separator 418 | dp2 = strchr(ts, '\t'); 419 | if (dp2 && (!dp || dp2 < dp)) { 420 | *dp2 = '\0'; 421 | dp = dp2 + 1; 422 | } 423 | 424 | // split each line into word and affix char strings 425 | // "\/" signs slash in words (not affix separator) 426 | // "/" at beginning of the line is word character (not affix separator) 427 | ap = strchr(ts,'/'); 428 | while (ap) { 429 | if (ap == ts) { 430 | ap++; 431 | continue; 432 | } else if (*(ap - 1) != '\\') break; 433 | // replace "\/" with "/" 434 | for (char * sp = ap - 1; *sp; *sp = *(sp + 1), sp++); 435 | ap = strchr(ap,'/'); 436 | } 437 | 438 | if (ap) { 439 | *ap = '\0'; 440 | if (aliasf) { 441 | int index = atoi(ap + 1); 442 | al = get_aliasf(index, &flags, dict); 443 | if (!al) { 444 | HUNSPELL_WARNING(stderr, "error: line %d: bad flag vector alias\n", dict->getlinenum()); 445 | *ap = '\0'; 446 | } 447 | } else { 448 | al = decode_flags(&flags, ap + 1, dict); 449 | if (al == -1) { 450 | HUNSPELL_WARNING(stderr, "Can't allocate memory.\n"); 451 | delete dict; 452 | return 6; 453 | } 454 | flag_qsort(flags, 0, al); 455 | } 456 | } else { 457 | al = 0; 458 | ap = NULL; 459 | flags = NULL; 460 | } 461 | 462 | int captype; 463 | int wbl = strlen(ts); 464 | int wcl = get_clen_and_captype(ts, wbl, &captype); 465 | // add the word and its index plus its capitalized form optionally 466 | if (add_word(ts,wbl,wcl,flags,al,dp, false) || 467 | add_hidden_capitalized_word(ts, wbl, wcl, flags, al, dp, captype)) { 468 | delete dict; 469 | return 5; 470 | } 471 | } 472 | 473 | delete dict; 474 | return 0; 475 | } 476 | 477 | // the hash function is a simple load and rotate 478 | // algorithm borrowed 479 | 480 | int HashMgr::hash(const char * word) const 481 | { 482 | long hv = 0; 483 | for (int i=0; i < 4 && *word != 0; i++) 484 | hv = (hv << 8) | (*word++); 485 | while (*word != 0) { 486 | ROTATE(hv,ROTATE_LEN); 487 | hv ^= (*word++); 488 | } 489 | return (unsigned long) hv % tablesize; 490 | } 491 | 492 | int HashMgr::decode_flags(unsigned short ** result, char * flags, FileMgr * af) { 493 | int len; 494 | if (*flags == '\0') { 495 | *result = NULL; 496 | return 0; 497 | } 498 | switch (flag_mode) { 499 | case FLAG_LONG: { // two-character flags (1x2yZz -> 1x 2y Zz) 500 | len = strlen(flags); 501 | if (len%2 == 1) HUNSPELL_WARNING(stderr, "error: line %d: bad flagvector\n", af->getlinenum()); 502 | len /= 2; 503 | *result = (unsigned short *) malloc(len * sizeof(short)); 504 | if (!*result) return -1; 505 | for (int i = 0; i < len; i++) { 506 | (*result)[i] = (((unsigned short) flags[i * 2]) << 8) + (unsigned short) flags[i * 2 + 1]; 507 | } 508 | break; 509 | } 510 | case FLAG_NUM: { // decimal numbers separated by comma (4521,23,233 -> 4521 23 233) 511 | int i; 512 | len = 1; 513 | char * src = flags; 514 | unsigned short * dest; 515 | char * p; 516 | for (p = flags; *p; p++) { 517 | if (*p == ',') len++; 518 | } 519 | *result = (unsigned short *) malloc(len * sizeof(short)); 520 | if (!*result) return -1; 521 | dest = *result; 522 | for (p = flags; *p; p++) { 523 | if (*p == ',') { 524 | i = atoi(src); 525 | if (i >= DEFAULTFLAGS) HUNSPELL_WARNING(stderr, "error: line %d: flag id %d is too large (max: %d)\n", 526 | af->getlinenum(), i, DEFAULTFLAGS - 1); 527 | *dest = (unsigned short) i; 528 | if (*dest == 0) HUNSPELL_WARNING(stderr, "error: line %d: 0 is wrong flag id\n", af->getlinenum()); 529 | src = p + 1; 530 | dest++; 531 | } 532 | } 533 | i = atoi(src); 534 | if (i >= DEFAULTFLAGS) HUNSPELL_WARNING(stderr, "error: line %d: flag id %d is too large (max: %d)\n", 535 | af->getlinenum(), i, DEFAULTFLAGS - 1); 536 | *dest = (unsigned short) i; 537 | if (*dest == 0) HUNSPELL_WARNING(stderr, "error: line %d: 0 is wrong flag id\n", af->getlinenum()); 538 | break; 539 | } 540 | case FLAG_UNI: { // UTF-8 characters 541 | w_char w[BUFSIZE/2]; 542 | len = u8_u16(w, BUFSIZE/2, flags); 543 | *result = (unsigned short *) malloc(len * sizeof(short)); 544 | if (!*result) return -1; 545 | memcpy(*result, w, len * sizeof(short)); 546 | break; 547 | } 548 | default: { // Ispell's one-character flags (erfg -> e r f g) 549 | unsigned short * dest; 550 | len = strlen(flags); 551 | *result = (unsigned short *) malloc(len * sizeof(short)); 552 | if (!*result) return -1; 553 | dest = *result; 554 | for (unsigned char * p = (unsigned char *) flags; *p; p++) { 555 | *dest = (unsigned short) *p; 556 | dest++; 557 | } 558 | } 559 | } 560 | return len; 561 | } 562 | 563 | unsigned short HashMgr::decode_flag(const char * f) { 564 | unsigned short s = 0; 565 | int i; 566 | switch (flag_mode) { 567 | case FLAG_LONG: 568 | s = ((unsigned short) f[0] << 8) + (unsigned short) f[1]; 569 | break; 570 | case FLAG_NUM: 571 | i = atoi(f); 572 | if (i >= DEFAULTFLAGS) HUNSPELL_WARNING(stderr, "error: flag id %d is too large (max: %d)\n", i, DEFAULTFLAGS - 1); 573 | s = (unsigned short) i; 574 | break; 575 | case FLAG_UNI: 576 | u8_u16((w_char *) &s, 1, f); 577 | break; 578 | default: 579 | s = (unsigned short) *((unsigned char *)f); 580 | } 581 | if (s == 0) HUNSPELL_WARNING(stderr, "error: 0 is wrong flag id\n"); 582 | return s; 583 | } 584 | 585 | char * HashMgr::encode_flag(unsigned short f) { 586 | unsigned char ch[10]; 587 | if (f==0) return mystrdup("(NULL)"); 588 | if (flag_mode == FLAG_LONG) { 589 | ch[0] = (unsigned char) (f >> 8); 590 | ch[1] = (unsigned char) (f - ((f >> 8) << 8)); 591 | ch[2] = '\0'; 592 | } else if (flag_mode == FLAG_NUM) { 593 | sprintf((char *) ch, "%d", f); 594 | } else if (flag_mode == FLAG_UNI) { 595 | u16_u8((char *) &ch, 10, (w_char *) &f, 1); 596 | } else { 597 | ch[0] = (unsigned char) (f); 598 | ch[1] = '\0'; 599 | } 600 | return mystrdup((char *) ch); 601 | } 602 | 603 | // read in aff file and set flag mode 604 | int HashMgr::load_config(const char * affpath, const char * key) 605 | { 606 | char * line; // io buffers 607 | int firstline = 1; 608 | 609 | // open the affix file 610 | FileMgr * afflst = new FileMgr(affpath, key); 611 | if (!afflst) { 612 | HUNSPELL_WARNING(stderr, "Error - could not open affix description file %s\n",affpath); 613 | return 1; 614 | } 615 | 616 | // read in each line ignoring any that do not 617 | // start with a known line type indicator 618 | 619 | while ((line = afflst->getline())) { 620 | mychomp(line); 621 | 622 | /* remove byte order mark */ 623 | if (firstline) { 624 | firstline = 0; 625 | if (strncmp(line,"\xEF\xBB\xBF",3) == 0) memmove(line, line+3, strlen(line+3)+1); 626 | } 627 | 628 | /* parse in the try string */ 629 | if ((strncmp(line,"FLAG",4) == 0) && isspace(line[4])) { 630 | if (flag_mode != FLAG_CHAR) { 631 | HUNSPELL_WARNING(stderr, "error: line %d: multiple definitions of the FLAG affix file parameter\n", afflst->getlinenum()); 632 | } 633 | if (strstr(line, "long")) flag_mode = FLAG_LONG; 634 | if (strstr(line, "num")) flag_mode = FLAG_NUM; 635 | if (strstr(line, "UTF-8")) flag_mode = FLAG_UNI; 636 | if (flag_mode == FLAG_CHAR) { 637 | HUNSPELL_WARNING(stderr, "error: line %d: FLAG needs `num', `long' or `UTF-8' parameter\n", afflst->getlinenum()); 638 | } 639 | } 640 | if (strncmp(line,"FORBIDDENWORD",13) == 0) { 641 | char * st = NULL; 642 | if (parse_string(line, &st, afflst->getlinenum())) { 643 | delete afflst; 644 | return 1; 645 | } 646 | forbiddenword = decode_flag(st); 647 | free(st); 648 | } 649 | if (strncmp(line, "SET", 3) == 0) { 650 | if (parse_string(line, &enc, afflst->getlinenum())) { 651 | delete afflst; 652 | return 1; 653 | } 654 | if (strcmp(enc, "UTF-8") == 0) { 655 | utf8 = 1; 656 | #ifndef OPENOFFICEORG 657 | #ifndef MOZILLA_CLIENT 658 | initialize_utf_tbl(); 659 | #endif 660 | #endif 661 | } else csconv = get_current_cs(enc); 662 | } 663 | if (strncmp(line, "LANG", 4) == 0) { 664 | if (parse_string(line, &lang, afflst->getlinenum())) { 665 | delete afflst; 666 | return 1; 667 | } 668 | langnum = get_lang_num(lang); 669 | } 670 | 671 | /* parse in the ignored characters (for example, Arabic optional diacritics characters */ 672 | if (strncmp(line,"IGNORE",6) == 0) { 673 | if (parse_array(line, &ignorechars, &ignorechars_utf16, 674 | &ignorechars_utf16_len, utf8, afflst->getlinenum())) { 675 | delete afflst; 676 | return 1; 677 | } 678 | } 679 | 680 | if ((strncmp(line,"AF",2) == 0) && isspace(line[2])) { 681 | if (parse_aliasf(line, afflst)) { 682 | delete afflst; 683 | return 1; 684 | } 685 | } 686 | 687 | if ((strncmp(line,"AM",2) == 0) && isspace(line[2])) { 688 | if (parse_aliasm(line, afflst)) { 689 | delete afflst; 690 | return 1; 691 | } 692 | } 693 | 694 | if (strncmp(line,"COMPLEXPREFIXES",15) == 0) complexprefixes = 1; 695 | if (((strncmp(line,"SFX",3) == 0) || (strncmp(line,"PFX",3) == 0)) && isspace(line[3])) break; 696 | } 697 | if (csconv == NULL) csconv = get_current_cs(SPELL_ENCODING); 698 | delete afflst; 699 | return 0; 700 | } 701 | 702 | /* parse in the ALIAS table */ 703 | int HashMgr::parse_aliasf(char * line, FileMgr * af) 704 | { 705 | if (numaliasf != 0) { 706 | HUNSPELL_WARNING(stderr, "error: line %d: multiple table definitions\n", af->getlinenum()); 707 | return 1; 708 | } 709 | char * tp = line; 710 | char * piece; 711 | int i = 0; 712 | int np = 0; 713 | piece = mystrsep(&tp, 0); 714 | while (piece) { 715 | if (*piece != '\0') { 716 | switch(i) { 717 | case 0: { np++; break; } 718 | case 1: { 719 | numaliasf = atoi(piece); 720 | if (numaliasf < 1) { 721 | numaliasf = 0; 722 | aliasf = NULL; 723 | aliasflen = NULL; 724 | HUNSPELL_WARNING(stderr, "error: line %d: bad entry number\n", af->getlinenum()); 725 | return 1; 726 | } 727 | aliasf = (unsigned short **) malloc(numaliasf * sizeof(unsigned short *)); 728 | aliasflen = (unsigned short *) malloc(numaliasf * sizeof(short)); 729 | if (!aliasf || !aliasflen) { 730 | numaliasf = 0; 731 | if (aliasf) free(aliasf); 732 | if (aliasflen) free(aliasflen); 733 | aliasf = NULL; 734 | aliasflen = NULL; 735 | return 1; 736 | } 737 | np++; 738 | break; 739 | } 740 | default: break; 741 | } 742 | i++; 743 | } 744 | piece = mystrsep(&tp, 0); 745 | } 746 | if (np != 2) { 747 | numaliasf = 0; 748 | free(aliasf); 749 | free(aliasflen); 750 | aliasf = NULL; 751 | aliasflen = NULL; 752 | HUNSPELL_WARNING(stderr, "error: line %d: missing data\n", af->getlinenum()); 753 | return 1; 754 | } 755 | 756 | /* now parse the numaliasf lines to read in the remainder of the table */ 757 | char * nl; 758 | for (int j=0; j < numaliasf; j++) { 759 | if (!(nl = af->getline())) return 1; 760 | mychomp(nl); 761 | tp = nl; 762 | i = 0; 763 | aliasf[j] = NULL; 764 | aliasflen[j] = 0; 765 | piece = mystrsep(&tp, 0); 766 | while (piece) { 767 | if (*piece != '\0') { 768 | switch(i) { 769 | case 0: { 770 | if (strncmp(piece,"AF",2) != 0) { 771 | numaliasf = 0; 772 | free(aliasf); 773 | free(aliasflen); 774 | aliasf = NULL; 775 | aliasflen = NULL; 776 | HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); 777 | return 1; 778 | } 779 | break; 780 | } 781 | case 1: { 782 | aliasflen[j] = (unsigned short) decode_flags(&(aliasf[j]), piece, af); 783 | flag_qsort(aliasf[j], 0, aliasflen[j]); 784 | break; 785 | } 786 | default: break; 787 | } 788 | i++; 789 | } 790 | piece = mystrsep(&tp, 0); 791 | } 792 | if (!aliasf[j]) { 793 | free(aliasf); 794 | free(aliasflen); 795 | aliasf = NULL; 796 | aliasflen = NULL; 797 | numaliasf = 0; 798 | HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); 799 | return 1; 800 | } 801 | } 802 | return 0; 803 | } 804 | 805 | int HashMgr::is_aliasf() { 806 | return (aliasf != NULL); 807 | } 808 | 809 | int HashMgr::get_aliasf(int index, unsigned short ** fvec, FileMgr * af) { 810 | if ((index > 0) && (index <= numaliasf)) { 811 | *fvec = aliasf[index - 1]; 812 | return aliasflen[index - 1]; 813 | } 814 | HUNSPELL_WARNING(stderr, "error: line %d: bad flag alias index: %d\n", af->getlinenum(), index); 815 | *fvec = NULL; 816 | return 0; 817 | } 818 | 819 | /* parse morph alias definitions */ 820 | int HashMgr::parse_aliasm(char * line, FileMgr * af) 821 | { 822 | if (numaliasm != 0) { 823 | HUNSPELL_WARNING(stderr, "error: line %d: multiple table definitions\n", af->getlinenum()); 824 | return 1; 825 | } 826 | char * tp = line; 827 | char * piece; 828 | int i = 0; 829 | int np = 0; 830 | piece = mystrsep(&tp, 0); 831 | while (piece) { 832 | if (*piece != '\0') { 833 | switch(i) { 834 | case 0: { np++; break; } 835 | case 1: { 836 | numaliasm = atoi(piece); 837 | if (numaliasm < 1) { 838 | HUNSPELL_WARNING(stderr, "error: line %d: bad entry number\n", af->getlinenum()); 839 | return 1; 840 | } 841 | aliasm = (char **) malloc(numaliasm * sizeof(char *)); 842 | if (!aliasm) { 843 | numaliasm = 0; 844 | return 1; 845 | } 846 | np++; 847 | break; 848 | } 849 | default: break; 850 | } 851 | i++; 852 | } 853 | piece = mystrsep(&tp, 0); 854 | } 855 | if (np != 2) { 856 | numaliasm = 0; 857 | free(aliasm); 858 | aliasm = NULL; 859 | HUNSPELL_WARNING(stderr, "error: line %d: missing data\n", af->getlinenum()); 860 | return 1; 861 | } 862 | 863 | /* now parse the numaliasm lines to read in the remainder of the table */ 864 | char * nl = line; 865 | for (int j=0; j < numaliasm; j++) { 866 | if (!(nl = af->getline())) return 1; 867 | mychomp(nl); 868 | tp = nl; 869 | i = 0; 870 | aliasm[j] = NULL; 871 | piece = mystrsep(&tp, ' '); 872 | while (piece) { 873 | if (*piece != '\0') { 874 | switch(i) { 875 | case 0: { 876 | if (strncmp(piece,"AM",2) != 0) { 877 | HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); 878 | numaliasm = 0; 879 | free(aliasm); 880 | aliasm = NULL; 881 | return 1; 882 | } 883 | break; 884 | } 885 | case 1: { 886 | // add the remaining of the line 887 | if (*tp) { 888 | *(tp - 1) = ' '; 889 | tp = tp + strlen(tp); 890 | } 891 | if (complexprefixes) { 892 | if (utf8) reverseword_utf(piece); 893 | else reverseword(piece); 894 | } 895 | aliasm[j] = mystrdup(piece); 896 | if (!aliasm[j]) { 897 | numaliasm = 0; 898 | free(aliasm); 899 | aliasm = NULL; 900 | return 1; 901 | } 902 | break; } 903 | default: break; 904 | } 905 | i++; 906 | } 907 | piece = mystrsep(&tp, ' '); 908 | } 909 | if (!aliasm[j]) { 910 | numaliasm = 0; 911 | free(aliasm); 912 | aliasm = NULL; 913 | HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); 914 | return 1; 915 | } 916 | } 917 | return 0; 918 | } 919 | 920 | int HashMgr::is_aliasm() { 921 | return (aliasm != NULL); 922 | } 923 | 924 | char * HashMgr::get_aliasm(int index) { 925 | if ((index > 0) && (index <= numaliasm)) return aliasm[index - 1]; 926 | HUNSPELL_WARNING(stderr, "error: bad morph. alias index: %d\n", index); 927 | return NULL; 928 | } 929 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/hashmgr.hxx: -------------------------------------------------------------------------------- 1 | #ifndef _HASHMGR_HXX_ 2 | #define _HASHMGR_HXX_ 3 | 4 | #include "hunvisapi.h" 5 | 6 | #include 7 | 8 | #include "htypes.hxx" 9 | #include "filemgr.hxx" 10 | 11 | enum flag { FLAG_CHAR, FLAG_LONG, FLAG_NUM, FLAG_UNI }; 12 | 13 | class LIBHUNSPELL_DLL_EXPORTED HashMgr 14 | { 15 | int tablesize; 16 | struct hentry ** tableptr; 17 | int userword; 18 | flag flag_mode; 19 | int complexprefixes; 20 | int utf8; 21 | unsigned short forbiddenword; 22 | int langnum; 23 | char * enc; 24 | char * lang; 25 | struct cs_info * csconv; 26 | char * ignorechars; 27 | unsigned short * ignorechars_utf16; 28 | int ignorechars_utf16_len; 29 | int numaliasf; // flag vector `compression' with aliases 30 | unsigned short ** aliasf; 31 | unsigned short * aliasflen; 32 | int numaliasm; // morphological desciption `compression' with aliases 33 | char ** aliasm; 34 | 35 | 36 | public: 37 | HashMgr(const char * tpath, const char * apath, const char * key = NULL); 38 | ~HashMgr(); 39 | 40 | struct hentry * lookup(const char *) const; 41 | int hash(const char *) const; 42 | struct hentry * walk_hashtable(int & col, struct hentry * hp) const; 43 | 44 | int add(const char * word); 45 | int add_with_affix(const char * word, const char * pattern); 46 | int remove(const char * word); 47 | int decode_flags(unsigned short ** result, char * flags, FileMgr * af); 48 | unsigned short decode_flag(const char * flag); 49 | char * encode_flag(unsigned short flag); 50 | int is_aliasf(); 51 | int get_aliasf(int index, unsigned short ** fvec, FileMgr * af); 52 | int is_aliasm(); 53 | char * get_aliasm(int index); 54 | 55 | private: 56 | int get_clen_and_captype(const char * word, int wbl, int * captype); 57 | int load_tables(const char * tpath, const char * key); 58 | int add_word(const char * word, int wbl, int wcl, unsigned short * ap, 59 | int al, const char * desc, bool onlyupcase); 60 | int load_config(const char * affpath, const char * key); 61 | int parse_aliasf(char * line, FileMgr * af); 62 | int add_hidden_capitalized_word(char * word, int wbl, int wcl, 63 | unsigned short * flags, int al, char * dp, int captype); 64 | int parse_aliasm(char * line, FileMgr * af); 65 | int remove_forbidden_flag(const char * word); 66 | 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/htypes.hxx: -------------------------------------------------------------------------------- 1 | #ifndef _HTYPES_HXX_ 2 | #define _HTYPES_HXX_ 3 | 4 | #define ROTATE_LEN 5 5 | 6 | #define ROTATE(v,q) \ 7 | (v) = ((v) << (q)) | (((v) >> (32 - q)) & ((1 << (q))-1)); 8 | 9 | // hentry options 10 | #define H_OPT (1 << 0) 11 | #define H_OPT_ALIASM (1 << 1) 12 | #define H_OPT_PHON (1 << 2) 13 | 14 | // see also csutil.hxx 15 | #define HENTRY_WORD(h) &(h->word[0]) 16 | 17 | // approx. number of user defined words 18 | #define USERWORD 1000 19 | 20 | struct hentry 21 | { 22 | unsigned char blen; // word length in bytes 23 | unsigned char clen; // word length in characters (different for UTF-8 enc.) 24 | short alen; // length of affix flag vector 25 | unsigned short * astr; // affix flag vector 26 | struct hentry * next; // next word with same hash code 27 | struct hentry * next_homonym; // next homonym word (with same hash code) 28 | char var; // variable fields (only for special pronounciation yet) 29 | char word[1]; // variable-length word (8-bit or UTF-8 encoding) 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/hunspell.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYSPELLMGR_H_ 2 | #define _MYSPELLMGR_H_ 3 | 4 | #include "hunvisapi.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct Hunhandle Hunhandle; 11 | 12 | LIBHUNSPELL_DLL_EXPORTED Hunhandle *Hunspell_create(const char * affpath, const char * dpath); 13 | 14 | LIBHUNSPELL_DLL_EXPORTED Hunhandle *Hunspell_create_key(const char * affpath, const char * dpath, 15 | const char * key); 16 | 17 | LIBHUNSPELL_DLL_EXPORTED void Hunspell_destroy(Hunhandle *pHunspell); 18 | 19 | /* spell(word) - spellcheck word 20 | * output: 0 = bad word, not 0 = good word 21 | */ 22 | LIBHUNSPELL_DLL_EXPORTED int Hunspell_spell(Hunhandle *pHunspell, const char *); 23 | 24 | LIBHUNSPELL_DLL_EXPORTED char *Hunspell_get_dic_encoding(Hunhandle *pHunspell); 25 | 26 | /* suggest(suggestions, word) - search suggestions 27 | * input: pointer to an array of strings pointer and the (bad) word 28 | * array of strings pointer (here *slst) may not be initialized 29 | * output: number of suggestions in string array, and suggestions in 30 | * a newly allocated array of strings (*slts will be NULL when number 31 | * of suggestion equals 0.) 32 | */ 33 | LIBHUNSPELL_DLL_EXPORTED int Hunspell_suggest(Hunhandle *pHunspell, char*** slst, const char * word); 34 | 35 | /* morphological functions */ 36 | 37 | /* analyze(result, word) - morphological analysis of the word */ 38 | 39 | LIBHUNSPELL_DLL_EXPORTED int Hunspell_analyze(Hunhandle *pHunspell, char*** slst, const char * word); 40 | 41 | /* stem(result, word) - stemmer function */ 42 | 43 | LIBHUNSPELL_DLL_EXPORTED int Hunspell_stem(Hunhandle *pHunspell, char*** slst, const char * word); 44 | 45 | /* stem(result, analysis, n) - get stems from a morph. analysis 46 | * example: 47 | * char ** result, result2; 48 | * int n1 = Hunspell_analyze(result, "words"); 49 | * int n2 = Hunspell_stem2(result2, result, n1); 50 | */ 51 | 52 | LIBHUNSPELL_DLL_EXPORTED int Hunspell_stem2(Hunhandle *pHunspell, char*** slst, char** desc, int n); 53 | 54 | /* generate(result, word, word2) - morphological generation by example(s) */ 55 | 56 | LIBHUNSPELL_DLL_EXPORTED int Hunspell_generate(Hunhandle *pHunspell, char*** slst, const char * word, 57 | const char * word2); 58 | 59 | /* generate(result, word, desc, n) - generation by morph. description(s) 60 | * example: 61 | * char ** result; 62 | * char * affix = "is:plural"; // description depends from dictionaries, too 63 | * int n = Hunspell_generate2(result, "word", &affix, 1); 64 | * for (int i = 0; i < n; i++) printf("%s\n", result[i]); 65 | */ 66 | 67 | LIBHUNSPELL_DLL_EXPORTED int Hunspell_generate2(Hunhandle *pHunspell, char*** slst, const char * word, 68 | char** desc, int n); 69 | 70 | /* functions for run-time modification of the dictionary */ 71 | 72 | /* add word to the run-time dictionary */ 73 | 74 | LIBHUNSPELL_DLL_EXPORTED int Hunspell_add(Hunhandle *pHunspell, const char * word); 75 | 76 | /* add word to the run-time dictionary with affix flags of 77 | * the example (a dictionary word): Hunspell will recognize 78 | * affixed forms of the new word, too. 79 | */ 80 | 81 | LIBHUNSPELL_DLL_EXPORTED int Hunspell_add_with_affix(Hunhandle *pHunspell, const char * word, const char * example); 82 | 83 | /* remove word from the run-time dictionary */ 84 | 85 | LIBHUNSPELL_DLL_EXPORTED int Hunspell_remove(Hunhandle *pHunspell, const char * word); 86 | 87 | /* free suggestion lists */ 88 | 89 | LIBHUNSPELL_DLL_EXPORTED void Hunspell_free_list(Hunhandle *pHunspell, char *** slst, int n); 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/hunspell.hxx: -------------------------------------------------------------------------------- 1 | #include "hunvisapi.h" 2 | 3 | #include "hashmgr.hxx" 4 | #include "affixmgr.hxx" 5 | #include "suggestmgr.hxx" 6 | #include "langnum.hxx" 7 | 8 | #define SPELL_XML "" 9 | 10 | #define MAXDIC 20 11 | #define MAXSUGGESTION 15 12 | #define MAXSHARPS 5 13 | 14 | #define HUNSPELL_OK (1 << 0) 15 | #define HUNSPELL_OK_WARN (1 << 1) 16 | 17 | #ifndef _MYSPELLMGR_HXX_ 18 | #define _MYSPELLMGR_HXX_ 19 | 20 | class LIBHUNSPELL_DLL_EXPORTED Hunspell 21 | { 22 | AffixMgr* pAMgr; 23 | HashMgr* pHMgr[MAXDIC]; 24 | int maxdic; 25 | SuggestMgr* pSMgr; 26 | char * affixpath; 27 | char * encoding; 28 | struct cs_info * csconv; 29 | int langnum; 30 | int utf8; 31 | int complexprefixes; 32 | char** wordbreak; 33 | 34 | public: 35 | 36 | /* Hunspell(aff, dic) - constructor of Hunspell class 37 | * input: path of affix file and dictionary file 38 | */ 39 | 40 | Hunspell(const char * affpath, const char * dpath, const char * key = NULL); 41 | ~Hunspell(); 42 | 43 | /* load extra dictionaries (only dic files) */ 44 | int add_dic(const char * dpath, const char * key = NULL); 45 | 46 | /* spell(word) - spellcheck word 47 | * output: 0 = bad word, not 0 = good word 48 | * 49 | * plus output: 50 | * info: information bit array, fields: 51 | * SPELL_COMPOUND = a compound word 52 | * SPELL_FORBIDDEN = an explicit forbidden word 53 | * root: root (stem), when input is a word with affix(es) 54 | */ 55 | 56 | int spell(const char * word, int * info = NULL, char ** root = NULL); 57 | 58 | /* suggest(suggestions, word) - search suggestions 59 | * input: pointer to an array of strings pointer and the (bad) word 60 | * array of strings pointer (here *slst) may not be initialized 61 | * output: number of suggestions in string array, and suggestions in 62 | * a newly allocated array of strings (*slts will be NULL when number 63 | * of suggestion equals 0.) 64 | */ 65 | 66 | int suggest(char*** slst, const char * word); 67 | 68 | /* deallocate suggestion lists */ 69 | 70 | void free_list(char *** slst, int n); 71 | 72 | char * get_dic_encoding(); 73 | 74 | /* morphological functions */ 75 | 76 | /* analyze(result, word) - morphological analysis of the word */ 77 | 78 | int analyze(char*** slst, const char * word); 79 | 80 | /* stem(result, word) - stemmer function */ 81 | 82 | int stem(char*** slst, const char * word); 83 | 84 | /* stem(result, analysis, n) - get stems from a morph. analysis 85 | * example: 86 | * char ** result, result2; 87 | * int n1 = analyze(&result, "words"); 88 | * int n2 = stem(&result2, result, n1); 89 | */ 90 | 91 | int stem(char*** slst, char ** morph, int n); 92 | 93 | /* generate(result, word, word2) - morphological generation by example(s) */ 94 | 95 | int generate(char*** slst, const char * word, const char * word2); 96 | 97 | /* generate(result, word, desc, n) - generation by morph. description(s) 98 | * example: 99 | * char ** result; 100 | * char * affix = "is:plural"; // description depends from dictionaries, too 101 | * int n = generate(&result, "word", &affix, 1); 102 | * for (int i = 0; i < n; i++) printf("%s\n", result[i]); 103 | */ 104 | 105 | int generate(char*** slst, const char * word, char ** desc, int n); 106 | 107 | /* functions for run-time modification of the dictionary */ 108 | 109 | /* add word to the run-time dictionary */ 110 | 111 | int add(const char * word); 112 | 113 | /* add word to the run-time dictionary with affix flags of 114 | * the example (a dictionary word): Hunspell will recognize 115 | * affixed forms of the new word, too. 116 | */ 117 | 118 | int add_with_affix(const char * word, const char * example); 119 | 120 | /* remove word from the run-time dictionary */ 121 | 122 | int remove(const char * word); 123 | 124 | /* other */ 125 | 126 | /* get extra word characters definied in affix file for tokenization */ 127 | const char * get_wordchars(); 128 | unsigned short * get_wordchars_utf16(int * len); 129 | 130 | struct cs_info * get_csconv(); 131 | const char * get_version(); 132 | 133 | int get_langnum() const; 134 | 135 | /* experimental and deprecated functions */ 136 | 137 | #ifdef HUNSPELL_EXPERIMENTAL 138 | /* suffix is an affix flag string, similarly in dictionary files */ 139 | int put_word_suffix(const char * word, const char * suffix); 140 | char * morph_with_correction(const char * word); 141 | 142 | /* spec. suggestions */ 143 | int suggest_auto(char*** slst, const char * word); 144 | int suggest_pos_stems(char*** slst, const char * word); 145 | #endif 146 | 147 | private: 148 | int cleanword(char *, const char *, int * pcaptype, int * pabbrev); 149 | int cleanword2(char *, const char *, w_char *, int * w_len, int * pcaptype, int * pabbrev); 150 | void mkinitcap(char *); 151 | int mkinitcap2(char * p, w_char * u, int nc); 152 | int mkinitsmall2(char * p, w_char * u, int nc); 153 | void mkallcap(char *); 154 | int mkallcap2(char * p, w_char * u, int nc); 155 | void mkallsmall(char *); 156 | int mkallsmall2(char * p, w_char * u, int nc); 157 | struct hentry * checkword(const char *, int * info, char **root); 158 | char * sharps_u8_l1(char * dest, char * source); 159 | hentry * spellsharps(char * base, char *, int, int, char * tmp, int * info, char **root); 160 | int is_keepcase(const hentry * rv); 161 | int insert_sug(char ***slst, char * word, int ns); 162 | void cat_result(char * result, char * st); 163 | char * stem_description(const char * desc); 164 | int spellml(char*** slst, const char * word); 165 | int get_xml_par(char * dest, const char * par, int maxl); 166 | const char * get_xml_pos(const char * s, const char * attr); 167 | int get_xml_list(char ***slst, char * list, const char * tag); 168 | int check_xml_par(const char * q, const char * attr, const char * value); 169 | 170 | }; 171 | 172 | #endif 173 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/hunvisapi.h: -------------------------------------------------------------------------------- 1 | #ifndef _HUNSPELL_VISIBILITY_H_ 2 | #define _HUNSPELL_VISIBILITY_H_ 3 | 4 | #if defined(HUNSPELL_STATIC) 5 | # define LIBHUNSPELL_DLL_EXPORTED 6 | #elif defined(_MSC_VER) 7 | # if defined(BUILDING_LIBHUNSPELL) 8 | # define LIBHUNSPELL_DLL_EXPORTED __declspec(dllexport) 9 | # else 10 | # define LIBHUNSPELL_DLL_EXPORTED __declspec(dllimport) 11 | # endif 12 | #elif BUILDING_LIBHUNSPELL && 1 13 | # define LIBHUNSPELL_DLL_EXPORTED __attribute__((__visibility__("default"))) 14 | #else 15 | # define LIBHUNSPELL_DLL_EXPORTED 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/hunzip.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "hunzip.hxx" 6 | 7 | #define CODELEN 65536 8 | #define BASEBITREC 5000 9 | 10 | #define UNCOMPRESSED '\002' 11 | #define MAGIC "hz0" 12 | #define MAGIC_ENCRYPT "hz1" 13 | #define MAGICLEN (sizeof(MAGIC) - 1) 14 | 15 | int Hunzip::fail(const char * err, const char * par) { 16 | fprintf(stderr, err, par); 17 | return -1; 18 | } 19 | 20 | Hunzip::Hunzip(const char * file, const char * key) { 21 | bufsiz = 0; 22 | lastbit = 0; 23 | inc = 0; 24 | outc = 0; 25 | dec = NULL; 26 | fin = NULL; 27 | filename = (char *) malloc(strlen(file) + 1); 28 | if (filename) strcpy(filename, file); 29 | if (getcode(key) == -1) bufsiz = -1; 30 | else bufsiz = getbuf(); 31 | } 32 | 33 | int Hunzip::getcode(const char * key) { 34 | unsigned char c[2]; 35 | int i, j, n, p; 36 | int allocatedbit = BASEBITREC; 37 | const char * enc = key; 38 | 39 | if (!filename) return -1; 40 | 41 | fin = fopen(filename, "rb"); 42 | if (!fin) return -1; 43 | 44 | // read magic number 45 | if ((fread(in, 1, 3, fin) < MAGICLEN) 46 | || !(strncmp(MAGIC, in, MAGICLEN) == 0 || 47 | strncmp(MAGIC_ENCRYPT, in, MAGICLEN) == 0)) { 48 | return fail(MSG_FORMAT, filename); 49 | } 50 | 51 | // check encryption 52 | if (strncmp(MAGIC_ENCRYPT, in, MAGICLEN) == 0) { 53 | unsigned char cs; 54 | if (!key) return fail(MSG_KEY, filename); 55 | if (fread(&c, 1, 1, fin) < 1) return fail(MSG_FORMAT, filename); 56 | for (cs = 0; *enc; enc++) cs ^= *enc; 57 | if (cs != c[0]) return fail(MSG_KEY, filename); 58 | enc = key; 59 | } else key = NULL; 60 | 61 | // read record count 62 | if (fread(&c, 1, 2, fin) < 2) return fail(MSG_FORMAT, filename); 63 | 64 | if (key) { 65 | c[0] ^= *enc; 66 | if (*(++enc) == '\0') enc = key; 67 | c[1] ^= *enc; 68 | } 69 | 70 | n = ((int) c[0] << 8) + c[1]; 71 | dec = (struct bit *) malloc(BASEBITREC * sizeof(struct bit)); 72 | if (!dec) return fail(MSG_MEMORY, filename); 73 | dec[0].v[0] = 0; 74 | dec[0].v[1] = 0; 75 | 76 | // read codes 77 | for (i = 0; i < n; i++) { 78 | unsigned char l; 79 | if (fread(c, 1, 2, fin) < 2) return fail(MSG_FORMAT, filename); 80 | if (key) { 81 | if (*(++enc) == '\0') enc = key; 82 | c[0] ^= *enc; 83 | if (*(++enc) == '\0') enc = key; 84 | c[1] ^= *enc; 85 | } 86 | if (fread(&l, 1, 1, fin) < 1) return fail(MSG_FORMAT, filename); 87 | if (key) { 88 | if (*(++enc) == '\0') enc = key; 89 | l ^= *enc; 90 | } 91 | if (fread(in, 1, l/8+1, fin) < (size_t) l/8+1) return fail(MSG_FORMAT, filename); 92 | if (key) for (j = 0; j <= l/8; j++) { 93 | if (*(++enc) == '\0') enc = key; 94 | in[j] ^= *enc; 95 | } 96 | p = 0; 97 | for (j = 0; j < l; j++) { 98 | int b = (in[j/8] & (1 << (7 - (j % 8)))) ? 1 : 0; 99 | int oldp = p; 100 | p = dec[p].v[b]; 101 | if (p == 0) { 102 | lastbit++; 103 | if (lastbit == allocatedbit) { 104 | allocatedbit += BASEBITREC; 105 | dec = (struct bit *) realloc(dec, allocatedbit * sizeof(struct bit)); 106 | } 107 | dec[lastbit].v[0] = 0; 108 | dec[lastbit].v[1] = 0; 109 | dec[oldp].v[b] = lastbit; 110 | p = lastbit; 111 | } 112 | } 113 | dec[p].c[0] = c[0]; 114 | dec[p].c[1] = c[1]; 115 | } 116 | return 0; 117 | } 118 | 119 | Hunzip::~Hunzip() 120 | { 121 | if (dec) free(dec); 122 | if (fin) fclose(fin); 123 | if (filename) free(filename); 124 | } 125 | 126 | int Hunzip::getbuf() { 127 | int p = 0; 128 | int o = 0; 129 | do { 130 | if (inc == 0) inbits = fread(in, 1, BUFSIZE, fin) * 8; 131 | for (; inc < inbits; inc++) { 132 | int b = (in[inc / 8] & (1 << (7 - (inc % 8)))) ? 1 : 0; 133 | int oldp = p; 134 | p = dec[p].v[b]; 135 | if (p == 0) { 136 | if (oldp == lastbit) { 137 | fclose(fin); 138 | fin = NULL; 139 | // add last odd byte 140 | if (dec[lastbit].c[0]) out[o++] = dec[lastbit].c[1]; 141 | return o; 142 | } 143 | out[o++] = dec[oldp].c[0]; 144 | out[o++] = dec[oldp].c[1]; 145 | if (o == BUFSIZE) return o; 146 | p = dec[p].v[b]; 147 | } 148 | } 149 | inc = 0; 150 | } while (inbits == BUFSIZE * 8); 151 | return fail(MSG_FORMAT, filename); 152 | } 153 | 154 | const char * Hunzip::getline() { 155 | char linebuf[BUFSIZE]; 156 | int l = 0, eol = 0, left = 0, right = 0; 157 | if (bufsiz == -1) return NULL; 158 | while (l < bufsiz && !eol) { 159 | linebuf[l++] = out[outc]; 160 | switch (out[outc]) { 161 | case '\t': break; 162 | case 31: { // escape 163 | if (++outc == bufsiz) { 164 | bufsiz = getbuf(); 165 | outc = 0; 166 | } 167 | linebuf[l - 1] = out[outc]; 168 | break; 169 | } 170 | case ' ': break; 171 | default: if (((unsigned char) out[outc]) < 47) { 172 | if (out[outc] > 32) { 173 | right = out[outc] - 31; 174 | if (++outc == bufsiz) { 175 | bufsiz = getbuf(); 176 | outc = 0; 177 | } 178 | } 179 | if (out[outc] == 30) left = 9; else left = out[outc]; 180 | linebuf[l-1] = '\n'; 181 | eol = 1; 182 | } 183 | } 184 | if (++outc == bufsiz) { 185 | outc = 0; 186 | bufsiz = fin ? getbuf(): -1; 187 | } 188 | } 189 | if (right) strcpy(linebuf + l - 1, line + strlen(line) - right - 1); 190 | else linebuf[l] = '\0'; 191 | strcpy(line + left, linebuf); 192 | return line; 193 | } 194 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/hunzip.hxx: -------------------------------------------------------------------------------- 1 | /* hunzip: file decompression for sorted dictionaries with optional encryption, 2 | * algorithm: prefix-suffix encoding and 16-bit Huffman encoding */ 3 | 4 | #ifndef _HUNZIP_HXX_ 5 | #define _HUNZIP_HXX_ 6 | 7 | #include "hunvisapi.h" 8 | 9 | #include 10 | 11 | #define BUFSIZE 65536 12 | #define HZIP_EXTENSION ".hz" 13 | 14 | #define MSG_OPEN "error: %s: cannot open\n" 15 | #define MSG_FORMAT "error: %s: not in hzip format\n" 16 | #define MSG_MEMORY "error: %s: missing memory\n" 17 | #define MSG_KEY "error: %s: missing or bad password\n" 18 | 19 | struct bit { 20 | unsigned char c[2]; 21 | int v[2]; 22 | }; 23 | 24 | class LIBHUNSPELL_DLL_EXPORTED Hunzip 25 | { 26 | 27 | protected: 28 | char * filename; 29 | FILE * fin; 30 | int bufsiz, lastbit, inc, inbits, outc; 31 | struct bit * dec; // code table 32 | char in[BUFSIZE]; // input buffer 33 | char out[BUFSIZE + 1]; // Huffman-decoded buffer 34 | char line[BUFSIZE + 50]; // decoded line 35 | int getcode(const char * key); 36 | int getbuf(); 37 | int fail(const char * err, const char * par); 38 | 39 | public: 40 | Hunzip(const char * filename, const char * key = NULL); 41 | ~Hunzip(); 42 | const char * getline(); 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/langnum.hxx: -------------------------------------------------------------------------------- 1 | #ifndef _LANGNUM_HXX_ 2 | #define _LANGNUM_HXX_ 3 | 4 | /* 5 | language numbers for language specific codes 6 | see http://l10n.openoffice.org/languages.html 7 | */ 8 | 9 | enum { 10 | LANG_ar=96, 11 | LANG_az=100, // custom number 12 | LANG_bg=41, 13 | LANG_ca=37, 14 | LANG_cs=42, 15 | LANG_da=45, 16 | LANG_de=49, 17 | LANG_el=30, 18 | LANG_en=01, 19 | LANG_es=34, 20 | LANG_eu=10, 21 | LANG_fr=02, 22 | LANG_gl=38, 23 | LANG_hr=78, 24 | LANG_hu=36, 25 | LANG_it=39, 26 | LANG_la=99, // custom number 27 | LANG_lv=101, // custom number 28 | LANG_nl=31, 29 | LANG_pl=48, 30 | LANG_pt=03, 31 | LANG_ru=07, 32 | LANG_sv=50, 33 | LANG_tr=90, 34 | LANG_uk=80, 35 | LANG_xx=999 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/license.hunspell: -------------------------------------------------------------------------------- 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. 13 | * 14 | * The Original Code is Hunspell, based on MySpell. 15 | * 16 | * The Initial Developers of the Original Code are 17 | * Kevin Hendricks (MySpell) and Laszlo Nemeth (Hunspell). 18 | * Portions created by the Initial Developers are Copyright (C) 2002-2005 19 | * the Initial Developers. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * David Einstein 23 | * Davide Prina 24 | * Giuseppe Modugno 25 | * Gianluca Turconi 26 | * Simon Brouwer 27 | * Noll Janos 28 | * Biro Arpad 29 | * Goldman Eleonora 30 | * Sarlos Tamas 31 | * Bencsath Boldizsar 32 | * Halacsy Peter 33 | * Dvornik Laszlo 34 | * Gefferth Andras 35 | * Nagy Viktor 36 | * Varga Daniel 37 | * Chris Halls 38 | * Rene Engelhard 39 | * Bram Moolenaar 40 | * Dafydd Jones 41 | * Harri Pitkanen 42 | * Andras Timar 43 | * Tor Lillqvist 44 | * 45 | * Alternatively, the contents of this file may be used under the terms of 46 | * either the GNU General Public License Version 2 or later (the "GPL"), or 47 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 48 | * in which case the provisions of the GPL or the LGPL are applicable instead 49 | * of those above. If you wish to allow use of your version of this file only 50 | * under the terms of either the GPL or the LGPL, and not to allow others to 51 | * use your version of this file under the terms of the MPL, indicate your 52 | * decision by deleting the provisions above and replace them with the notice 53 | * and other provisions required by the GPL or the LGPL. If you do not delete 54 | * the provisions above, a recipient may use your version of this file under 55 | * the terms of any one of the MPL, the GPL or the LGPL. 56 | * 57 | * ***** END LICENSE BLOCK ***** */ 58 | 59 | #include "config.h" 60 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/license.myspell: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada 3 | * And Contributors. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. All modifications to the source code must be clearly marked as 17 | * such. Binary redistributions based on modified source code 18 | * must be clearly marked as modified versions in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS 22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 25 | * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | * 34 | * 35 | * NOTE: A special thanks and credit goes to Geoff Kuenning 36 | * the creator of ispell. MySpell's affix algorithms were 37 | * based on those of ispell which should be noted is 38 | * copyright Geoff Kuenning et.al. and now available 39 | * under a BSD style license. For more information on ispell 40 | * and affix compression in general, please see: 41 | * http://www.cs.ucla.edu/ficus-members/geoff/ispell.html 42 | * (the home page for ispell) 43 | * 44 | * An almost complete rewrite of MySpell for use by 45 | * the Mozilla project has been developed by David Einstein 46 | * (Deinst@world.std.com). David and I are now 47 | * working on parallel development tracks to help 48 | * our respective projects (Mozilla and OpenOffice.org 49 | * and we will maintain full affix file and dictionary 50 | * file compatibility and work on merging our versions 51 | * of MySpell back into a single tree. David has been 52 | * a significant help in improving MySpell. 53 | * 54 | * Special thanks also go to La'szlo' Ne'meth 55 | * who is the author of the 56 | * Hungarian dictionary and who developed and contributed 57 | * the code to support compound words in MySpell 58 | * and fixed numerous problems with the encoding 59 | * case conversion tables. 60 | * 61 | */ 62 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/phonet.cxx: -------------------------------------------------------------------------------- 1 | /* phonetic.c - generic replacement aglogithms for phonetic transformation 2 | Copyright (C) 2000 Bjoern Jacke 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License version 2.1 as published by the Free Software Foundation; 7 | 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public 14 | License along with this library; If not, see 15 | . 16 | 17 | Changelog: 18 | 19 | 2000-01-05 Bjoern Jacke 20 | Initial Release insprired by the article about phonetic 21 | transformations out of c't 25/1999 22 | 23 | 2007-07-26 Bjoern Jacke 24 | Released under MPL/GPL/LGPL tri-license for Hunspell 25 | 26 | 2007-08-23 Laszlo Nemeth 27 | Porting from Aspell to Hunspell using C-like structs 28 | */ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "csutil.hxx" 36 | #include "phonet.hxx" 37 | 38 | void init_phonet_hash(phonetable & parms) 39 | { 40 | int i, k; 41 | 42 | for (i = 0; i < HASHSIZE; i++) { 43 | parms.hash[i] = -1; 44 | } 45 | 46 | for (i = 0; parms.rules[i][0] != '\0'; i += 2) { 47 | /** set hash value **/ 48 | k = (unsigned char) parms.rules[i][0]; 49 | 50 | if (parms.hash[k] < 0) { 51 | parms.hash[k] = i; 52 | } 53 | } 54 | } 55 | 56 | // like strcpy but safe if the strings overlap 57 | // but only if dest < src 58 | static inline void strmove(char * dest, char * src) { 59 | while (*src) 60 | *dest++ = *src++; 61 | *dest = '\0'; 62 | } 63 | 64 | static int myisalpha(char ch) { 65 | if ((unsigned char) ch < 128) return isalpha(ch); 66 | return 1; 67 | } 68 | 69 | /* phonetic transcription algorithm */ 70 | /* see: http://aspell.net/man-html/Phonetic-Code.html */ 71 | /* convert string to uppercase before this call */ 72 | int phonet (const char * inword, char * target, 73 | int len, 74 | phonetable & parms) 75 | { 76 | /** Do phonetic transformation. **/ 77 | /** "len" = length of "inword" incl. '\0'. **/ 78 | 79 | /** result: >= 0: length of "target" **/ 80 | /** otherwise: error **/ 81 | 82 | int i,j,k=0,n,p,z; 83 | int k0,n0,p0=-333,z0; 84 | char c, c0; 85 | const char * s; 86 | typedef unsigned char uchar; 87 | char word[MAXPHONETUTF8LEN + 1]; 88 | if (len == -1) len = strlen(inword); 89 | if (len > MAXPHONETUTF8LEN) return 0; 90 | strcpy(word, inword); 91 | 92 | /** check word **/ 93 | i = j = z = 0; 94 | while ((c = word[i]) != '\0') { 95 | n = parms.hash[(uchar) c]; 96 | z0 = 0; 97 | 98 | if (n >= 0) { 99 | /** check all rules for the same letter **/ 100 | while (parms.rules[n][0] == c) { 101 | 102 | /** check whole string **/ 103 | k = 1; /** number of found letters **/ 104 | p = 5; /** default priority **/ 105 | s = parms.rules[n]; 106 | s++; /** important for (see below) "*(s-1)" **/ 107 | 108 | while (*s != '\0' && word[i+k] == *s 109 | && !isdigit ((unsigned char) *s) && strchr ("(-<^$", *s) == NULL) { 110 | k++; 111 | s++; 112 | } 113 | if (*s == '(') { 114 | /** check letters in "(..)" **/ 115 | if (myisalpha(word[i+k]) // ...could be implied? 116 | && strchr(s+1, word[i+k]) != NULL) { 117 | k++; 118 | while (*s != ')') 119 | s++; 120 | s++; 121 | } 122 | } 123 | p0 = (int) *s; 124 | k0 = k; 125 | while (*s == '-' && k > 1) { 126 | k--; 127 | s++; 128 | } 129 | if (*s == '<') 130 | s++; 131 | if (isdigit ((unsigned char) *s)) { 132 | /** determine priority **/ 133 | p = *s - '0'; 134 | s++; 135 | } 136 | if (*s == '^' && *(s+1) == '^') 137 | s++; 138 | 139 | if (*s == '\0' 140 | || (*s == '^' 141 | && (i == 0 || ! myisalpha(word[i-1])) 142 | && (*(s+1) != '$' 143 | || (! myisalpha(word[i+k0]) ))) 144 | || (*s == '$' && i > 0 145 | && myisalpha(word[i-1]) 146 | && (! myisalpha(word[i+k0]) ))) 147 | { 148 | /** search for followup rules, if: **/ 149 | /** parms.followup and k > 1 and NO '-' in searchstring **/ 150 | c0 = word[i+k-1]; 151 | n0 = parms.hash[(uchar) c0]; 152 | 153 | // if (parms.followup && k > 1 && n0 >= 0 154 | if (k > 1 && n0 >= 0 155 | && p0 != (int) '-' && word[i+k] != '\0') { 156 | /** test follow-up rule for "word[i+k]" **/ 157 | while (parms.rules[n0][0] == c0) { 158 | 159 | /** check whole string **/ 160 | k0 = k; 161 | p0 = 5; 162 | s = parms.rules[n0]; 163 | s++; 164 | while (*s != '\0' && word[i+k0] == *s 165 | && ! isdigit((unsigned char) *s) && strchr("(-<^$",*s) == NULL) { 166 | k0++; 167 | s++; 168 | } 169 | if (*s == '(') { 170 | /** check letters **/ 171 | if (myisalpha(word[i+k0]) 172 | && strchr (s+1, word[i+k0]) != NULL) { 173 | k0++; 174 | while (*s != ')' && *s != '\0') 175 | s++; 176 | if (*s == ')') 177 | s++; 178 | } 179 | } 180 | while (*s == '-') { 181 | /** "k0" gets NOT reduced **/ 182 | /** because "if (k0 == k)" **/ 183 | s++; 184 | } 185 | if (*s == '<') 186 | s++; 187 | if (isdigit ((unsigned char) *s)) { 188 | p0 = *s - '0'; 189 | s++; 190 | } 191 | 192 | if (*s == '\0' 193 | /** *s == '^' cuts **/ 194 | || (*s == '$' && ! myisalpha(word[i+k0]))) 195 | { 196 | if (k0 == k) { 197 | /** this is just a piece of the string **/ 198 | n0 += 2; 199 | continue; 200 | } 201 | 202 | if (p0 < p) { 203 | /** priority too low **/ 204 | n0 += 2; 205 | continue; 206 | } 207 | /** rule fits; stop search **/ 208 | break; 209 | } 210 | n0 += 2; 211 | } /** End of "while (parms.rules[n0][0] == c0)" **/ 212 | 213 | if (p0 >= p && parms.rules[n0][0] == c0) { 214 | n += 2; 215 | continue; 216 | } 217 | } /** end of follow-up stuff **/ 218 | 219 | /** replace string **/ 220 | s = parms.rules[n+1]; 221 | p0 = (parms.rules[n][0] != '\0' 222 | && strchr (parms.rules[n]+1,'<') != NULL) ? 1:0; 223 | if (p0 == 1 && z == 0) { 224 | /** rule with '<' is used **/ 225 | if (j > 0 && *s != '\0' 226 | && (target[j-1] == c || target[j-1] == *s)) { 227 | j--; 228 | } 229 | z0 = 1; 230 | z = 1; 231 | k0 = 0; 232 | while (*s != '\0' && word[i+k0] != '\0') { 233 | word[i+k0] = *s; 234 | k0++; 235 | s++; 236 | } 237 | if (k > k0) 238 | strmove (&word[0]+i+k0, &word[0]+i+k); 239 | 240 | /** new "actual letter" **/ 241 | c = word[i]; 242 | } 243 | else { /** no '<' rule used **/ 244 | i += k - 1; 245 | z = 0; 246 | while (*s != '\0' 247 | && *(s+1) != '\0' && j < len) { 248 | if (j == 0 || target[j-1] != *s) { 249 | target[j] = *s; 250 | j++; 251 | } 252 | s++; 253 | } 254 | /** new "actual letter" **/ 255 | c = *s; 256 | if (parms.rules[n][0] != '\0' 257 | && strstr (parms.rules[n]+1, "^^") != NULL) { 258 | if (c != '\0') { 259 | target[j] = c; 260 | j++; 261 | } 262 | strmove (&word[0], &word[0]+i+1); 263 | i = 0; 264 | z0 = 1; 265 | } 266 | } 267 | break; 268 | } /** end of follow-up stuff **/ 269 | n += 2; 270 | } /** end of while (parms.rules[n][0] == c) **/ 271 | } /** end of if (n >= 0) **/ 272 | if (z0 == 0) { 273 | // if (k && (assert(p0!=-333),!p0) && j < len && c != '\0' 274 | // && (!parms.collapse_result || j == 0 || target[j-1] != c)){ 275 | if (k && !p0 && j < len && c != '\0' 276 | && (1 || j == 0 || target[j-1] != c)){ 277 | /** condense only double letters **/ 278 | target[j] = c; 279 | ///printf("\n setting \n"); 280 | j++; 281 | } 282 | 283 | i++; 284 | z = 0; 285 | k=0; 286 | } 287 | } /** end of while ((c = word[i]) != '\0') **/ 288 | 289 | target[j] = '\0'; 290 | return (j); 291 | 292 | } /** end of function "phonet" **/ 293 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/phonet.hxx: -------------------------------------------------------------------------------- 1 | /* phonetic.c - generic replacement aglogithms for phonetic transformation 2 | Copyright (C) 2000 Bjoern Jacke 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License version 2.1 as published by the Free Software Foundation; 7 | 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public 14 | License along with this library; If not, see 15 | . 16 | 17 | Changelog: 18 | 19 | 2000-01-05 Bjoern Jacke 20 | Initial Release insprired by the article about phonetic 21 | transformations out of c't 25/1999 22 | 23 | 2007-07-26 Bjoern Jacke 24 | Released under MPL/GPL/LGPL tri-license for Hunspell 25 | 26 | 2007-08-23 Laszlo Nemeth 27 | Porting from Aspell to Hunspell using C-like structs 28 | */ 29 | 30 | #ifndef __PHONETHXX__ 31 | #define __PHONETHXX__ 32 | 33 | #define HASHSIZE 256 34 | #define MAXPHONETLEN 256 35 | #define MAXPHONETUTF8LEN (MAXPHONETLEN * 4) 36 | 37 | #include "hunvisapi.h" 38 | 39 | struct phonetable { 40 | char utf8; 41 | cs_info * lang; 42 | int num; 43 | char * * rules; 44 | int hash[HASHSIZE]; 45 | }; 46 | 47 | LIBHUNSPELL_DLL_EXPORTED void init_phonet_hash(phonetable & parms); 48 | 49 | LIBHUNSPELL_DLL_EXPORTED int phonet (const char * inword, char * target, 50 | int len, phonetable & phone); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/replist.cxx: -------------------------------------------------------------------------------- 1 | #include "license.hunspell" 2 | #include "license.myspell" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "replist.hxx" 9 | #include "csutil.hxx" 10 | 11 | RepList::RepList(int n) { 12 | dat = (replentry **) malloc(sizeof(replentry *) * n); 13 | if (dat == 0) size = 0; else size = n; 14 | pos = 0; 15 | } 16 | 17 | RepList::~RepList() 18 | { 19 | for (int i = 0; i < pos; i++) { 20 | free(dat[i]->pattern); 21 | free(dat[i]->pattern2); 22 | free(dat[i]); 23 | } 24 | free(dat); 25 | } 26 | 27 | int RepList::get_pos() { 28 | return pos; 29 | } 30 | 31 | replentry * RepList::item(int n) { 32 | return dat[n]; 33 | } 34 | 35 | int RepList::near(const char * word) { 36 | int p1 = 0; 37 | int p2 = pos; 38 | while ((p2 - p1) > 1) { 39 | int m = (p1 + p2) / 2; 40 | int c = strcmp(word, dat[m]->pattern); 41 | if (c <= 0) { 42 | if (c < 0) p2 = m; else p1 = p2 = m; 43 | } else p1 = m; 44 | } 45 | return p1; 46 | } 47 | 48 | int RepList::match(const char * word, int n) { 49 | if (strncmp(word, dat[n]->pattern, strlen(dat[n]->pattern)) == 0) return strlen(dat[n]->pattern); 50 | return 0; 51 | } 52 | 53 | int RepList::add(char * pat1, char * pat2) { 54 | if (pos >= size || pat1 == NULL || pat2 == NULL) return 1; 55 | replentry * r = (replentry *) malloc(sizeof(replentry)); 56 | if (r == NULL) return 1; 57 | r->pattern = mystrrep(pat1, "_", " "); 58 | r->pattern2 = mystrrep(pat2, "_", " "); 59 | r->start = false; 60 | r->end = false; 61 | dat[pos++] = r; 62 | for (int i = pos - 1; i > 0; i--) { 63 | r = dat[i]; 64 | if (strcmp(r->pattern, dat[i - 1]->pattern) < 0) { 65 | dat[i] = dat[i - 1]; 66 | dat[i - 1] = r; 67 | } else break; 68 | } 69 | return 0; 70 | } 71 | 72 | int RepList::conv(const char * word, char * dest) { 73 | int stl = 0; 74 | int change = 0; 75 | for (size_t i = 0; i < strlen(word); i++) { 76 | int n = near(word + i); 77 | int l = match(word + i, n); 78 | if (l) { 79 | strcpy(dest + stl, dat[n]->pattern2); 80 | stl += strlen(dat[n]->pattern2); 81 | i += l - 1; 82 | change = 1; 83 | } else dest[stl++] = word[i]; 84 | } 85 | dest[stl] = '\0'; 86 | return change; 87 | } 88 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/replist.hxx: -------------------------------------------------------------------------------- 1 | /* string replacement list class */ 2 | #ifndef _REPLIST_HXX_ 3 | #define _REPLIST_HXX_ 4 | 5 | #ifdef near 6 | # undef near 7 | #endif 8 | 9 | #include "hunvisapi.h" 10 | 11 | #include "w_char.hxx" 12 | 13 | class LIBHUNSPELL_DLL_EXPORTED RepList 14 | { 15 | protected: 16 | replentry ** dat; 17 | int size; 18 | int pos; 19 | 20 | public: 21 | RepList(int n); 22 | ~RepList(); 23 | 24 | int get_pos(); 25 | int add(char * pat1, char * pat2); 26 | replentry * item(int n); 27 | int near(const char * word); 28 | int match(const char * word, int n); 29 | int conv(const char * word, char * dest); 30 | }; 31 | #endif 32 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/suggestmgr.hxx: -------------------------------------------------------------------------------- 1 | #ifndef _SUGGESTMGR_HXX_ 2 | #define _SUGGESTMGR_HXX_ 3 | 4 | #define MAXSWL 100 5 | #define MAXSWUTF8L (MAXSWL * 4) 6 | #define MAX_ROOTS 100 7 | #define MAX_WORDS 100 8 | #define MAX_GUESS 200 9 | #define MAXNGRAMSUGS 4 10 | #define MAXPHONSUGS 2 11 | #define MAXCOMPOUNDSUGS 3 12 | 13 | // timelimit: max ~1/4 sec (process time on Linux) for a time consuming function 14 | #define TIMELIMIT (CLOCKS_PER_SEC >> 2) 15 | #define MINTIMER 100 16 | #define MAXPLUSTIMER 100 17 | 18 | #define NGRAM_LONGER_WORSE (1 << 0) 19 | #define NGRAM_ANY_MISMATCH (1 << 1) 20 | #define NGRAM_LOWERING (1 << 2) 21 | #define NGRAM_WEIGHTED (1 << 3) 22 | 23 | #include "hunvisapi.h" 24 | 25 | #include "atypes.hxx" 26 | #include "affixmgr.hxx" 27 | #include "hashmgr.hxx" 28 | #include "langnum.hxx" 29 | #include 30 | 31 | enum { LCS_UP, LCS_LEFT, LCS_UPLEFT }; 32 | 33 | class LIBHUNSPELL_DLL_EXPORTED SuggestMgr 34 | { 35 | char * ckey; 36 | int ckeyl; 37 | w_char * ckey_utf; 38 | 39 | char * ctry; 40 | int ctryl; 41 | w_char * ctry_utf; 42 | 43 | AffixMgr* pAMgr; 44 | int maxSug; 45 | struct cs_info * csconv; 46 | int utf8; 47 | int langnum; 48 | int nosplitsugs; 49 | int maxngramsugs; 50 | int maxcpdsugs; 51 | int complexprefixes; 52 | 53 | 54 | public: 55 | SuggestMgr(const char * tryme, int maxn, AffixMgr *aptr); 56 | ~SuggestMgr(); 57 | 58 | int suggest(char*** slst, const char * word, int nsug, int * onlycmpdsug); 59 | int ngsuggest(char ** wlst, char * word, int ns, HashMgr** pHMgr, int md); 60 | int suggest_auto(char*** slst, const char * word, int nsug); 61 | int suggest_stems(char*** slst, const char * word, int nsug); 62 | int suggest_pos_stems(char*** slst, const char * word, int nsug); 63 | 64 | char * suggest_morph(const char * word); 65 | char * suggest_gen(char ** pl, int pln, char * pattern); 66 | char * suggest_morph_for_spelling_error(const char * word); 67 | 68 | private: 69 | int testsug(char** wlst, const char * candidate, int wl, int ns, int cpdsuggest, 70 | int * timer, clock_t * timelimit); 71 | int checkword(const char *, int, int, int *, clock_t *); 72 | int check_forbidden(const char *, int); 73 | 74 | int capchars(char **, const char *, int, int); 75 | int replchars(char**, const char *, int, int); 76 | int doubletwochars(char**, const char *, int, int); 77 | int forgotchar(char **, const char *, int, int); 78 | int swapchar(char **, const char *, int, int); 79 | int longswapchar(char **, const char *, int, int); 80 | int movechar(char **, const char *, int, int); 81 | int extrachar(char **, const char *, int, int); 82 | int badcharkey(char **, const char *, int, int); 83 | int badchar(char **, const char *, int, int); 84 | int twowords(char **, const char *, int, int); 85 | int fixstems(char **, const char *, int); 86 | 87 | int capchars_utf(char **, const w_char *, int wl, int, int); 88 | int doubletwochars_utf(char**, const w_char *, int wl, int, int); 89 | int forgotchar_utf(char**, const w_char *, int wl, int, int); 90 | int extrachar_utf(char**, const w_char *, int wl, int, int); 91 | int badcharkey_utf(char **, const w_char *, int wl, int, int); 92 | int badchar_utf(char **, const w_char *, int wl, int, int); 93 | int swapchar_utf(char **, const w_char *, int wl, int, int); 94 | int longswapchar_utf(char **, const w_char *, int, int, int); 95 | int movechar_utf(char **, const w_char *, int, int, int); 96 | 97 | int mapchars(char**, const char *, int, int); 98 | int map_related(const char *, char *, int, int, char ** wlst, int, int, const mapentry*, int, int *, clock_t *); 99 | int ngram(int n, char * s1, const char * s2, int opt); 100 | int mystrlen(const char * word); 101 | int leftcommonsubstring(char * s1, const char * s2); 102 | int commoncharacterpositions(char * s1, const char * s2, int * is_swap); 103 | void bubblesort( char ** rwd, char ** rwd2, int * rsc, int n); 104 | void lcs(const char * s, const char * s2, int * l1, int * l2, char ** result); 105 | int lcslen(const char * s, const char* s2); 106 | char * suggest_hentry_gen(hentry * rv, char * pattern); 107 | 108 | }; 109 | 110 | #endif 111 | 112 | -------------------------------------------------------------------------------- /deps/hunspell/src/hunspell/w_char.hxx: -------------------------------------------------------------------------------- 1 | #ifndef __WCHARHXX__ 2 | #define __WCHARHXX__ 3 | 4 | #ifndef GCC 5 | typedef struct { 6 | #else 7 | typedef struct __attribute__ ((packed)) { 8 | #endif 9 | unsigned char l; 10 | unsigned char h; 11 | } w_char; 12 | 13 | // two character arrays 14 | struct replentry { 15 | char * pattern; 16 | char * pattern2; 17 | bool start; 18 | bool end; 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /deps/hunspell/src/win_api/README: -------------------------------------------------------------------------------- 1 | COMPILATION (static Hunspell executable) 2 | 3 | 1. download and install Cygwin environment for Windows with the following 4 | extra packages: 5 | 6 | make 7 | gcc-g++ development package 8 | mingw development package (for cygwin.dll free native Windows compilation) 9 | 10 | 2. open a Cygwin shell, cd into this directory and run make 11 | 12 | HUNSPELL DLL (not updated): 13 | 14 | hunspelldll.*: Hunspell API for Windows and Delphi 15 | Copyright (C) 2006 - Miha Vrhovnik (http://simail.sf.net, http://xcollect.sf.net) 16 | License: MPL 1.1/GPL 2.0/LGPL 2.1 17 | Usage: See Delphi example on Hunspell home page on Sourceforge. 18 | 19 | -------------------------------------------------------------------------------- /deps/hunspell/src/win_api/config.h: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP 4 | systems. This function is required for `alloca.c' support on those systems. 5 | */ 6 | #define CRAY_STACKSEG_END 1 7 | 8 | /* Define to 1 if using `alloca.c'. */ 9 | #define C_ALLOCA 1 10 | 11 | /* Define to 1 if translation of program messages to the user's native 12 | language is requested. */ 13 | #undef ENABLE_NLS 14 | 15 | /* Define to 1 if you have `alloca', as a function or macro. */ 16 | #define HAVE_ALLOCA 1 17 | 18 | /* Define to 1 if you have and it should be used (not on Ultrix). 19 | */ 20 | #define HAVE_ALLOCA_H 1 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_ARGZ_H 1 24 | 25 | /* "Define if you have the header" */ 26 | #undef HAVE_CURSES_H 27 | 28 | /* Define if the GNU dcgettext() function is already present or preinstalled. 29 | */ 30 | #define HAVE_DCGETTEXT 1 31 | 32 | /* Define to 1 if you have the header file. */ 33 | #define HAVE_DLFCN_H 1 34 | 35 | /* Define to 1 if you have the header file. */ 36 | #define HAVE_ERROR_H 1 37 | 38 | /* Define to 1 if you have the header file. */ 39 | #define HAVE_FCNTL_H 1 40 | 41 | /* Define to 1 if you have the `feof_unlocked' function. */ 42 | #define HAVE_FEOF_UNLOCKED 1 43 | 44 | /* Define to 1 if you have the `fgets_unlocked' function. */ 45 | #define HAVE_FGETS_UNLOCKED 1 46 | 47 | /* Define to 1 if you have the `getcwd' function. */ 48 | #define HAVE_GETCWD 1 49 | 50 | /* Define to 1 if you have the `getc_unlocked' function. */ 51 | #define HAVE_GETC_UNLOCKED 1 52 | 53 | /* Define to 1 if you have the `getegid' function. */ 54 | #define HAVE_GETEGID 1 55 | 56 | /* Define to 1 if you have the `geteuid' function. */ 57 | #define HAVE_GETEUID 1 58 | 59 | /* Define to 1 if you have the `getgid' function. */ 60 | #define HAVE_GETGID 1 61 | 62 | /* Define to 1 if you have the `getpagesize' function. */ 63 | #define HAVE_GETPAGESIZE 1 64 | 65 | /* Define if the GNU gettext() function is already present or preinstalled. */ 66 | #define HAVE_GETTEXT 1 67 | 68 | /* Define to 1 if you have the `getuid' function. */ 69 | #define HAVE_GETUID 1 70 | 71 | /* Define if you have the iconv() function. */ 72 | #undef HAVE_ICONV 73 | 74 | /* Define to 1 if you have the header file. */ 75 | #define HAVE_INTTYPES_H 1 76 | 77 | /* Define if you have and nl_langinfo(CODESET). */ 78 | #define HAVE_LANGINFO_CODESET 1 79 | 80 | /* Define if your file defines LC_MESSAGES. */ 81 | #define HAVE_LC_MESSAGES 1 82 | 83 | /* Define to 1 if you have the header file. */ 84 | #define HAVE_LIBINTL_H 1 85 | 86 | /* Define to 1 if you have the header file. */ 87 | #define HAVE_LIMITS_H 1 88 | 89 | /* Define to 1 if you have the header file. */ 90 | #define HAVE_LOCALE_H 1 91 | 92 | /* Define to 1 if you have the `memchr' function. */ 93 | #define HAVE_MEMCHR 1 94 | 95 | /* Define to 1 if you have the header file. */ 96 | #define HAVE_MEMORY_H 1 97 | 98 | /* Define to 1 if you have the `mempcpy' function. */ 99 | #define HAVE_MEMPCPY 1 100 | 101 | /* Define to 1 if you have a working `mmap' system call. */ 102 | #define HAVE_MMAP 1 103 | 104 | /* Define to 1 if you have the `munmap' function. */ 105 | #define HAVE_MUNMAP 1 106 | 107 | /* "Define if you have the header" */ 108 | #define HAVE_NCURSESW_H 1 109 | 110 | /* Define to 1 if you have the header file. */ 111 | #define HAVE_NL_TYPES_H 1 112 | 113 | /* Define to 1 if you have the `putenv' function. */ 114 | #define HAVE_PUTENV 1 115 | 116 | /* "Define if you have fancy command input editing with Readline" */ 117 | #undef HAVE_READLINE 118 | 119 | /* Define to 1 if you have the `setenv' function. */ 120 | #define HAVE_SETENV 1 121 | 122 | /* Define to 1 if you have the `setlocale' function. */ 123 | #define HAVE_SETLOCALE 1 124 | 125 | /* Define to 1 if you have the header file. */ 126 | #define HAVE_STDDEF_H 1 127 | 128 | /* Define to 1 if you have the header file. */ 129 | #define HAVE_STDINT_H 1 130 | 131 | /* Define to 1 if you have the header file. */ 132 | #define HAVE_STDLIB_H 1 133 | 134 | /* Define to 1 if you have the `stpcpy' function. */ 135 | #define HAVE_STPCPY 1 136 | 137 | /* Define to 1 if you have the `strcasecmp' function. */ 138 | #define HAVE_STRCASECMP 1 139 | 140 | /* Define to 1 if you have the `strchr' function. */ 141 | #define HAVE_STRCHR 1 142 | 143 | /* Define to 1 if you have the `strdup' function. */ 144 | #define HAVE_STRDUP 1 145 | 146 | /* Define to 1 if you have the header file. */ 147 | #define HAVE_STRINGS_H 1 148 | 149 | /* Define to 1 if you have the header file. */ 150 | #define HAVE_STRING_H 1 151 | 152 | /* Define to 1 if you have the `strstr' function. */ 153 | #define HAVE_STRSTR 1 154 | 155 | /* Define to 1 if you have the `strtoul' function. */ 156 | #define HAVE_STRTOUL 1 157 | 158 | /* Define to 1 if you have the header file. */ 159 | #define HAVE_SYS_PARAM_H 1 160 | 161 | /* Define to 1 if you have the header file. */ 162 | #define HAVE_SYS_STAT_H 1 163 | 164 | /* Define to 1 if you have the header file. */ 165 | #define HAVE_SYS_TYPES_H 1 166 | 167 | /* Define to 1 if you have the `tsearch' function. */ 168 | #define HAVE_TSEARCH 1 169 | 170 | /* Define to 1 if you have the header file. */ 171 | #define HAVE_UNISTD_H 1 172 | 173 | /* Define to 1 if you have the `__argz_count' function. */ 174 | #define HAVE___ARGZ_COUNT 1 175 | 176 | /* Define to 1 if you have the `__argz_next' function. */ 177 | #define HAVE___ARGZ_NEXT 1 178 | 179 | /* Define to 1 if you have the `__argz_stringify' function. */ 180 | #define HAVE___ARGZ_STRINGIFY 1 181 | 182 | /* "Define if you use exterimental functions" */ 183 | #undef HUNSPELL_EXPERIMENTAL 184 | 185 | /* "Define if you need warning messages" */ 186 | #define HUNSPELL_WARNING_ON 187 | 188 | /* Define as const if the declaration of iconv() needs const. */ 189 | #define ICONV_CONST 1 190 | 191 | /* Name of package */ 192 | #define PACKAGE 193 | 194 | /* Define to the address where bug reports for this package should be sent. */ 195 | #define PACKAGE_BUGREPORT 196 | 197 | /* Define to the full name of this package. */ 198 | #define PACKAGE_NAME 199 | 200 | /* Define to the full name and version of this package. */ 201 | #define PACKAGE_STRING 202 | 203 | /* Define to the one symbol short name of this package. */ 204 | #define PACKAGE_TARNAME 205 | 206 | /* Define to the version of this package. */ 207 | #define PACKAGE_VERSION "1.3.2" 208 | #define VERSION "1.3.2" 209 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./build/Release/spellcheck').SpellCheck; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { "name": "spellcheck", 2 | "version": "0.0.5", 3 | "author": "Brian White ", 4 | "description": "An async hunspell binding for node.js", 5 | "main": "./index", 6 | "engines": { "node" : ">=0.6.0" }, 7 | "keywords": [ "spell", "spellcheck", "hunspell", "spelling" ], 8 | "licenses": [ { "type": "MIT", "url": "http://github.com/mscdex/spellcheck/raw/master/LICENSE" } ], 9 | "repository" : { "type": "git", "url": "http://github.com/mscdex/spellcheck.git" }, 10 | "dependencies": { "nan": "^1.7.0" } 11 | } 12 | -------------------------------------------------------------------------------- /src/spellcheck.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "nan.h" 6 | #include "hunspell.hxx" 7 | 8 | using namespace node; 9 | using namespace v8; 10 | 11 | struct Baton { 12 | uv_work_t request; 13 | NanCallback *callback; 14 | 15 | char *word; 16 | 17 | // Hunspell handle 18 | Hunspell *spell; 19 | 20 | bool isCorrect; 21 | char **suggestions; 22 | int numSuggest; 23 | }; 24 | 25 | static Persistent constructor; 26 | 27 | class SpellCheck : public ObjectWrap { 28 | public: 29 | Hunspell *spell; 30 | 31 | SpellCheck(const char *affpath, const char *dpath) { 32 | spell = new Hunspell(affpath, dpath); 33 | } 34 | ~SpellCheck() { 35 | if (spell != NULL) 36 | delete spell; 37 | spell = NULL; 38 | } 39 | 40 | static NAN_METHOD(New) { 41 | NanScope(); 42 | const char *affpath; 43 | const char *dpath; 44 | 45 | if (!args.IsConstructCall()) { 46 | return NanThrowError( 47 | "Use `new` to create instances of this object."); 48 | } 49 | 50 | if (args.Length() != 2) { 51 | return NanThrowError("Expecting two arguments"); 52 | } else if (!args[0]->IsString()) { 53 | return NanThrowError("First argument must be a string"); 54 | } else if (!args[1]->IsString()) { 55 | return NanThrowError( 56 | "Second argument must be a string"); 57 | } 58 | 59 | String::Utf8Value affpathstr(args[0]->ToString()); 60 | String::Utf8Value dpathstr(args[1]->ToString()); 61 | affpath = (const char*)(*affpathstr); 62 | dpath = (const char*)(*dpathstr); 63 | 64 | SpellCheck* obj = new SpellCheck(affpath, dpath); 65 | obj->Wrap(args.This()); 66 | 67 | NanReturnValue(args.This()); 68 | } 69 | 70 | static NAN_METHOD(Check) { 71 | NanScope(); 72 | SpellCheck* obj = ObjectWrap::Unwrap(args.This()); 73 | 74 | if (!args[0]->IsString()) { 75 | return NanThrowError("First argument must be a string"); 76 | } 77 | if (!args[1]->IsFunction()) { 78 | return NanThrowError("Second argument must be a callback function"); 79 | } 80 | 81 | Local callbackHandle = args[1].As(); 82 | NanCallback *callback = new NanCallback(callbackHandle); 83 | 84 | String::Utf8Value str(args[0]->ToString()); 85 | 86 | Baton* baton = new Baton(); 87 | baton->request.data = baton; 88 | baton->callback = callback; 89 | baton->word = strdup((const char*)*str); 90 | baton->spell = obj->spell; 91 | baton->numSuggest = 0; 92 | baton->suggestions = NULL; 93 | 94 | int status = uv_queue_work(uv_default_loop(), 95 | &baton->request, 96 | SpellCheck::CheckWork, 97 | (uv_after_work_cb)SpellCheck::CheckAfter); 98 | assert(status == 0); 99 | 100 | NanReturnValue(NanUndefined()); 101 | } 102 | 103 | static void CheckWork(uv_work_t* req) { 104 | Baton* baton = static_cast(req->data); 105 | 106 | int dp = baton->spell->spell(baton->word); 107 | if (dp) 108 | baton->isCorrect = true; 109 | else { 110 | baton->isCorrect = false; 111 | baton->numSuggest = baton->spell->suggest(&(baton->suggestions), 112 | baton->word); 113 | } 114 | } 115 | 116 | static void CheckAfter(uv_work_t* req) { 117 | NanScope(); 118 | Baton* baton = static_cast(req->data); 119 | 120 | const unsigned int argc = 3; 121 | Local argv[argc]; 122 | argv[0] = NanNull(); 123 | argv[1] = NanNew(baton->isCorrect); 124 | if (baton->numSuggest > 0 && baton->suggestions != NULL) { 125 | Local suggestions = NanNew(baton->numSuggest); 126 | for (int i = 0; i < baton->numSuggest; ++i) 127 | suggestions->Set(i, NanNew(baton->suggestions[i])); 128 | baton->spell->free_list(&(baton->suggestions), baton->numSuggest); 129 | argv[2] = suggestions; 130 | } else 131 | argv[2] = NanUndefined(); 132 | 133 | free(baton->word); 134 | 135 | TryCatch try_catch; 136 | baton->callback->Call(argc, argv); 137 | if (try_catch.HasCaught()) 138 | FatalException(try_catch); 139 | 140 | delete baton->callback; 141 | delete baton; 142 | } 143 | 144 | static void Initialize(Handle exports) { 145 | NanScope(); 146 | 147 | Local tpl = NanNew(New); 148 | 149 | tpl->InstanceTemplate()->SetInternalFieldCount(1); 150 | tpl->SetClassName(NanNew("SpellCheck")); 151 | 152 | NODE_SET_PROTOTYPE_METHOD(tpl, "check", Check); 153 | 154 | NanAssignPersistent(constructor, tpl->GetFunction()); 155 | exports->Set(NanNew("SpellCheck"), tpl->GetFunction()); 156 | } 157 | }; 158 | 159 | extern "C" { 160 | void init(Handle exports) { 161 | NanScope(); 162 | SpellCheck::Initialize(exports); 163 | } 164 | 165 | NODE_MODULE(spellcheck, init); 166 | } 167 | --------------------------------------------------------------------------------