• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdespell2
 

tdespell2

  • tdespell2
  • plugins
  • ispell
ispell.h
1/* enchant
2 * Copyright (C) 2003 Dom Lachowicz
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 as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 * In addition, as a special exception, Dom Lachowicz
20 * gives permission to link the code of this program with
21 * non-LGPL Spelling Provider libraries (eg: a MSFT Office
22 * spell checker backend) and distribute linked combinations including
23 * the two. You must obey the GNU Lesser General Public License in all
24 * respects for all of the code used other than said providers. If you modify
25 * this file, you may extend this exception to your version of the
26 * file, but you are not obligated to do so. If you do not wish to
27 * do so, delete this exception statement from your version.
28 */
29
30#ifndef ISPELL_H
31#define ISPELL_H
32
33#include <sys/types.h>
34
35/*
36 * $Id$
37 */
38
39/*
40 * Copyright 1992, 1993, Geoff Kuenning, Granada Hills, CA
41 * All rights reserved.
42 *
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
45 * are met:
46 *
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All modifications to the source code must be clearly marked as
53 * such. Binary redistributions based on modified source code
54 * must be clearly marked as modified versions in the documentation
55 * and/or other materials provided with the distribution.
56 * 4. All advertising materials mentioning features or use of this software
57 * must display the following acknowledgment:
58 * This product includes software developed by Geoff Kuenning and
59 * other unpaid contributors.
60 * 5. The name of Geoff Kuenning may not be used to endorse or promote
61 * products derived from this software without specific prior
62 * written permission.
63 *
64 * THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
65 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
66 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
67 * ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
68 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
69 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
70 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
71 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
72 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
73 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
74 * SUCH DAMAGE.
75 */
76
77/*
78 * $Log$
79 * Revision 1.1 2004/01/31 16:44:12 zrusin
80 * ISpell plugin.
81 *
82 * Revision 1.4 2003/08/14 17:51:27 dom
83 * update license - exception clause should be Lesser GPL
84 *
85 * Revision 1.3 2003/07/28 20:40:26 dom
86 * fix up the license clause, further win32-registry proof some directory getting functions
87 *
88 * Revision 1.2 2003/07/16 22:52:40 dom
89 * LGPL + exception license
90 *
91 * Revision 1.1 2003/07/15 01:15:06 dom
92 * ispell enchant backend
93 *
94 * Revision 1.10 2003/01/24 05:52:33 hippietrail
95 *
96 * Refactored ispell code. Old ispell global variables had been put into
97 * an allocated structure, a pointer to which was passed to many functions.
98 * I have now made all such functions and variables private members of the
99 * ISpellChecker class. It was C OO, now it's C++ OO.
100 *
101 * I've fixed the makefiles and tested compilation but am unable to test
102 * operation. Please back out my changes if they cause problems which
103 * are not obvious or easy to fix.
104 *
105 * Revision 1.9 2002/09/19 05:31:15 hippietrail
106 *
107 * More Ispell cleanup. Conditional globals and DEREF macros are removed.
108 * K&R function declarations removed, converted to Doxygen style comments
109 * where possible. No code has been changed (I hope). Compiles for me but
110 * unable to test.
111 *
112 * Revision 1.8 2002/09/17 03:03:29 hippietrail
113 *
114 * After seeking permission on the developer list I've reformatted all the
115 * spelling source which seemed to have parts which used 2, 3, 4, and 8
116 * spaces for tabs. It should all look good with our standard 4-space
117 * tabs now.
118 * I've concentrated just on indentation in the actual code. More prettying
119 * could be done.
120 * * NO code changes were made *
121 *
122 * Revision 1.7 2002/03/22 14:31:57 dom
123 * fix mg's compile problem
124 *
125 * Revision 1.6 2002/03/05 16:55:52 dom
126 * compound word support, tested against swedish
127 *
128 * Revision 1.5 2001/08/10 18:32:40 dom
129 * Spelling and iconv updates. god, i hate iconv
130 *
131 * Revision 1.4 2001/06/26 16:33:27 dom
132 * 128 StringChars and some other stuff
133 *
134 * Revision 1.3 2001/05/12 16:05:42 thomasf
135 * Big pseudo changes to ispell to make it pass around a structure rather
136 * than rely on all sorts of gloabals willy nilly here and there. Also
137 * fixed our spelling class to work with accepting suggestions once more.
138 * This code is dirty, gross and ugly (not to mention still not supporting
139 * multiple hash sized just yet) but it works on my machine and will no
140 * doubt break other machines.
141 *
142 * Revision 1.2 2001/04/18 00:59:36 thomasf
143 * Removed the duplicate declarations of variables that was causing build
144 * to bail. This new ispell stuff is a total mess.
145 *
146 * Revision 1.1 2001/04/15 16:01:24 tomas_f
147 * moving to spell/xp
148 *
149 * Revision 1.13 2001/04/13 12:33:12 tamlin
150 * ispell can now be used from C++
151 *
152 * Revision 1.12 2001/03/25 01:30:02 tomb
153 * 1. Fixed ispell #define problems on Win32
154 * 2. Changed the way that togglable toolbars are tracked so that Full
155 * Screen mode works right on Windows
156 * 3. Fixed SET_GATHER macro in ap_Win32Dialog_Options.h
157 * 4. Fixed Toggle Case dialog to default to Sentence Case when loaded
158 * 5. Added #define for Auto Save checkbox (though I haven't updated the
159 * Prefs dialog yet)
160 *
161 * Revision 1.11 2001/03/24 23:28:41 dom
162 * Make C++ aware and watch out for VOID on Win32
163 *
164 * Revision 1.10 1999/12/21 18:46:29 sterwill
165 * ispell patch for non-English dictionaries by Henrik Berg <henrik@lansen.se>
166 *
167 * Revision 1.9 1999/10/20 03:19:35 paul
168 * Hacked ispell code to ignore any characters that don't fit in the lookup tables loaded from the dictionary. It ain't pretty, but at least we don't crash there any more.
169 *
170 * Revision 1.8 1999/09/29 23:33:32 justin
171 * Updates to the underlying ispell-based code to support suggested corrections.
172 *
173 * Revision 1.7 1999/04/13 17:12:51 jeff
174 * Applied "Darren O. Benham" <gecko@benham.net> spell check changes.
175 * Fixed crash on Win32 with the new code.
176 *
177 * Revision 1.6 1999/01/07 05:14:22 sterwill
178 * So it builds on Unix... it might break win32 in ispell, since ut_types
179 * is no longer included. This is a temporary solution to a larger problem
180 * of including C++ headers in C source files.
181 *
182 * Revision 1.6 1999/01/07 05:14:22 sterwill
183 * So it builds on Unix... it might break win32 in ispell, since ut_types
184 * is no longer included. This is a temporary solution to a larger problem
185 * of including C++ headers in C source files.
186 *
187 * Revision 1.5 1999/01/07 05:02:25 sterwill
188 * Checking in half-broken to avoid tree lossage
189 *
190 * Revision 1.4 1999/01/07 01:07:48 paul
191 * Fixed spell leaks.
192 *
193 * Revision 1.3 1998/12/29 15:03:54 eric
194 *
195 * minor fix to ispell.h to get things to compile on Linux again.
196 *
197 * Revision 1.2 1998/12/29 14:55:33 eric
198 *
199 * I've doctored the ispell code pretty extensively here. It is now
200 * warning-free on Win32. It also *works* on Win32 now, since I
201 * replaced all the I/O calls with ANSI standard ones.
202 *
203 * Revision 1.1 1998/12/28 18:04:43 davet
204 * Spell checker code stripped from ispell. At this point, there are
205 * two external routines... the Init routine, and a check-a-word routine
206 * which returns a boolean value, and takes a 16 bit char string.
207 * The code resembles the ispell code as much as possible still.
208 *
209 * Revision 1.68 1995/03/06 02:42:41 geoff
210 * Be vastly more paranoid about parenthesizing macro arguments. This
211 * fixes a bug in defmt.c where a complex argument was passed to
212 * isstringch.
213 *
214 * Revision 1.67 1995/01/03 19:24:12 geoff
215 * Get rid of a non-global declaration.
216 *
217 * Revision 1.66 1994/12/27 23:08:49 geoff
218 * Fix a lot of subtly bad assumptions about the widths of ints and longs
219 * which only show up on 64-bit machines like the Cray and the DEC Alpha.
220 *
221 * Revision 1.65 1994/11/02 06:56:10 geoff
222 * Remove the anyword feature, which I've decided is a bad idea.
223 *
224 * Revision 1.64 1994/10/25 05:46:18 geoff
225 * Add the FF_ANYWORD flag for defining an affix that will apply to any
226 * word, even if not explicitly specified. (Good for French.)
227 *
228 * Revision 1.63 1994/09/16 04:48:28 geoff
229 * Make stringdups and laststringch unsigned ints, and dupnos a plain
230 * int, so that we can handle more than 128 stringchars and stringchar
231 * types.
232 *
233 * Revision 1.62 1994/09/01 06:06:39 geoff
234 * Change erasechar/killchar to uerasechar/ukillchar to avoid
235 * shared-library problems on HP systems.
236 *
237 * Revision 1.61 1994/08/31 05:58:35 geoff
238 * Add contextoffset, used in -a mode to handle extremely long lines.
239 *
240 * Revision 1.60 1994/05/17 06:44:15 geoff
241 * Add support for controlled compound formation and the COMPOUNDONLY
242 * option to affix flags.
243 *
244 * Revision 1.59 1994/03/15 06:25:16 geoff
245 * Change deftflag's initialization so we can tell if -t/-n appeared.
246 *
247 * Revision 1.58 1994/02/07 05:53:28 geoff
248 * Add typecasts to the the 7-bit versions of ichar* routines
249 *
250 * Revision 1.57 1994/01/25 07:11:48 geoff
251 * Get rid of all old RCS log lines in preparation for the 3.1 release.
252 *
253 */
254
255#include <stdio.h>
256/* #include "ut_types.h" */
257
258#include "ispell_def.h"
259
260#ifdef __cplusplus
261extern "C" {
262#endif /* c++ */
263
264/* largest amount that a word might be extended by adding affixes */
265#ifndef MAXAFFIXLEN
266#define MAXAFFIXLEN 20
267#endif
268
269/*
270** Number of mask bits (affix flags) supported. Must be 32, 64, 128, or
271** 256. If MASKBITS is 32 or 64, there are really only 26 or 58 flags
272** available, respectively. If it is 32, the flags are named with the
273** 26 English uppercase letters; lowercase will be converted to uppercase.
274** If MASKBITS is 64, the 58 flags are named 'A' through 'z' in ASCII
275** order, including the 6 special characters from 'Z' to 'a': "[\]^_`".
276** If MASKBITS is 128 or 256, all the 7-bit or 8-bit characters,
277** respectively, are theoretically available, though a few (newline, slash,
278** null byte) are pretty hard to actually use successfully.
279**
280** Note that a number of non-English affix files depend on having a
281** larger value for MASKBITS. See the affix files for more
282** information.
283*/
284
285#ifndef MASKBITS
286#define MASKBITS 64
287#endif
288
289extern int gnMaskBits;
290
291/*
292** C type to use for masks. This should be a type that the processor
293** accesses efficiently.
294**
295** MASKTYPE_WIDTH must correctly reflect the number of bits in a
296** MASKTYPE. Unfortunately, it is also required to be a constant at
297** preprocessor time, which means you can't use the sizeof operator to
298** define it.
299**
300** Note that MASKTYPE *must* match MASKTYPE_WIDTH or you may get
301** division-by-zero errors!
302*/
303#ifndef MASKTYPE
304#define MASKTYPE long
305#endif
306#ifndef MASKTYPE_WIDTH
307#define MASKTYPE_WIDTH 32
308#endif
309
310 /* program: this should be coded now in init */
311
312#if MASKBITS < MASKTYPE_WIDTH
313#undef MASKBITS
314#define MASKBITS MASKTYPE_WIDTH
315#endif /* MASKBITS < MASKTYPE_WIDTH */
316
317/*
318** Maximum hash table fullness percentage. Larger numbers trade space
319** for time.
320**/
321#ifndef MAXPCT
322#define MAXPCT 70 /* Expand table when 70% full */
323#endif
324
325/*
326** Maximum number of "string" characters that can be defined in a
327** language (affix) file. Don't forget that an upper/lower string
328** character counts as two!
329*/
330#ifndef MAXSTRINGCHARS
331#define MAXSTRINGCHARS 128
332#endif /* MAXSTRINGCHARS */
333
334/*
335** Maximum length of a "string" character. The default is appropriate for
336** nroff-style characters starting with a backslash.
337*/
338#ifndef MAXSTRINGCHARLEN
339#define MAXSTRINGCHARLEN 10
340#endif /* MAXSTRINGCHARLEN */
341
342/*
343** Maximum number of "hits" expected on a word. This is basically the
344** number of different ways different affixes can produce the same word.
345** For example, with "english.aff", "brothers" can be produced 3 ways:
346** "brothers," "brother+s", or "broth+ers". If this is too low, no major
347** harm will be done, but ispell may occasionally forget a capitalization.
348*/
349#ifndef MAX_HITS
350#define MAX_HITS 10
351#endif
352
353/*
354** Maximum number of capitalization variations expected in any word.
355** Besides the obvious all-lower, all-upper, and capitalized versions,
356** this includes followcase variants. If this is too low, no real
357** harm will be done, but ispell may occasionally fail to suggest a
358** correct capitalization.
359*/
360#ifndef MAX_CAPS
361#define MAX_CAPS 10
362#endif /* MAX_CAPS */
363
364/* buffer size to use for file names if not in sys/param.h */
365#ifndef MAXPATHLEN
366#define MAXPATHLEN 512
367#endif
368
369/*
370** Maximum language-table search size. Smaller numbers make ispell
371** run faster, at the expense of more memory (the lowest reasonable value
372** is 2). If a given character appears in a significant position in
373** more than MAXSEARCH suffixes, it will be given its own index table.
374** If you change this, define INDEXDUMP in lookup.c to be sure your
375** index table looks reasonable.
376*/
377#ifndef MAXSEARCH
378#define MAXSEARCH 4
379#endif
380
381#if defined(__STDC__) || defined(__cplusplus)
382#define P(x) x
383 #ifndef VOID
384 #define VOID void
385 #endif
386#else /* __STDC__ */
387#define P(x) ()
388 #ifndef VOID
389 #define VOID char
390 #endif
391#define const
392#endif /* __STDC__ */
393
394#ifdef NO8BIT
395#define SET_SIZE 128
396#else
397#define SET_SIZE 256
398#endif
399
400#define MASKSIZE (gnMaskBits / MASKTYPE_WIDTH)
401
402#ifdef lint
403extern int TSTMASKBIT P ((MASKTYPE * mask, int bit));
404#else /* lint */
405/* The following is really testing for MASKSIZE <= 1, but cpp can't do that */
406#define TSTMASKBIT(mask, bit) \
407 ((mask)[(bit) / MASKTYPE_WIDTH] & \
408 ((MASKTYPE) 1 << ((bit) & (MASKTYPE_WIDTH - 1))))
409#endif /* lint */
410
411#if MASKBITS > 64
412#define FULLMASKSET
413#endif
414
415#if MASKBITS <= 32
416 #define FLAGBASE ((MASKTYPE_WIDTH) - 6)
417#else
418 # if MASKBITS <= 64
419 #define FLAGBASE ((MASKTYPE_WIDTH) - 6)
420 # else
421 #define FLAGBASE 0
422 # endif
423#endif
424
425/*
426** Data type for internal word storage. If necessary, we use shorts rather
427** than chars so that string characters can be encoded as a single unit.
428*/
429#if (SET_SIZE + MAXSTRINGCHARS) <= 256
430#ifndef lint
431#define ICHAR_IS_CHAR
432#endif /* lint */
433#endif
434
435#ifdef ICHAR_IS_CHAR
436typedef unsigned char ichar_t; /* Internal character */
437#define icharlen(s) strlen ((char *) (s))
438#define icharcpy(a, b) strcpy ((char *) (a), (char *) (b))
439#define icharcmp(a, b) strcmp ((char *) (a), (char *) (b))
440#define icharncmp(a, b, n) strncmp ((char *) (a), (char *) (b), (n))
441#define chartoichar(x) ((ichar_t) (x))
442#else
443typedef unsigned short ichar_t; /* Internal character */
444#define chartoichar(x) ((ichar_t) (unsigned char) (x))
445
446/*
447 * Structure used to record data about successful lookups; these values
448 * are used in the ins_root_cap routine to produce correct capitalizations.
449 */
450struct success
451{
452 struct dent * dictent; /* Header of dict entry chain for wd */
453 struct flagent * prefix; /* Prefix flag used, or NULL */
454 struct flagent * suffix; /* Suffix flag used, or NULL */
455};
456
457ichar_t* icharcpy (ichar_t* out, ichar_t* in);
458int icharlen (ichar_t* in);
459int icharcmp (ichar_t* s1, ichar_t* s2);
460int icharncmp (ichar_t* s1, ichar_t* s2, int n);
461
462#endif
463
464struct dent
465{
466 struct dent * next;
467 char * word;
468 MASKTYPE mask[2];
469#ifdef FULLMASKSET
470 char flags;
471#endif
472};
473
474/*
475** Flags in the directory entry. If FULLMASKSET is undefined, these are
476** stored in the highest bits of the last longword of the mask field. If
477** FULLMASKSET is defined, they are stored in the extra "flags" field.
478#ifndef NO_CAPITALIZATION_SUPPORT
479**
480** If a word has only one capitalization form, and that form is not
481** FOLLOWCASE, it will have exactly one entry in the dictionary. The
482** legal capitalizations will be indicated by the 2-bit capitalization
483** field, as follows:
484**
485** ALLCAPS The word must appear in all capitals.
486** CAPITALIZED The word must be capitalized (e.g., London).
487** It will also be accepted in all capitals.
488** ANYCASE The word may appear in lowercase, capitalized,
489** or all-capitals.
490**
491** Regardless of the capitalization flags, the "word" field of the entry
492** will point to an all-uppercase copy of the word. This is to simplify
493** the large portion of the code that doesn't care about capitalization.
494** Ispell will generate the correct version when needed.
495**
496** If a word has more than one capitalization, there will be multiple
497** entries for it, linked together by the "next" field. The initial
498** entry for such words will be a dummy entry, primarily for use by code
499** that ignores capitalization. The "word" field of this entry will
500** again point to an all-uppercase copy of the word. The "mask" field
501** will contain the logical OR of the mask fields of all variants.
502** A header entry is indicated by a capitalization type of ALLCAPS,
503** with the MOREVARIANTS bit set.
504**
505** The following entries will define the individual variants. Each
506** entry except the last has the MOREVARIANTS flag set, and each
507** contains one of the following capitalization options:
508**
509** ALLCAPS The word must appear in all capitals.
510** CAPITALIZED The word must be capitalized (e.g., London).
511** It will also be accepted in all capitals.
512** FOLLOWCASE The word must be capitalized exactly like the
513** sample in the entry. Prefix (suffix) characters
514** must be rendered in the case of the first (last)
515** "alphabetic" character. It will also be accepted
516** in all capitals. ("Alphabetic" means "mentioned
517** in a 'casechars' statement".)
518** ANYCASE The word may appear in lowercase, capitalized,
519** or all-capitals.
520**
521** The "mask" field for the entry contains only the affix flag bits that
522** are legal for that capitalization. The "word" field will be null
523** except for FOLLOWCASE entries, where it will point to the
524** correctly-capitalized spelling of the root word.
525**
526** It is worth discussing why the ALLCAPS option is used in
527** the header entry. The header entry accepts an all-capitals
528** version of the root plus every affix (this is always legal, since
529** words get capitalized in headers and so forth). Further, all of
530** the following variant entries will reject any all-capitals form
531** that is illegal due to an affix.
532**
533** Finally, note that variations in the KEEP flag can cause a multiple-variant
534** entry as well. For example, if the personal dictionary contains "ALPHA",
535** (KEEP flag set) and the user adds "alpha" with the KEEP flag clear, a
536** multiple-variant entry will be created so that "alpha" will be accepted
537** but only "ALPHA" will actually be kept.
538#endif
539*/
540#ifdef FULLMASKSET
541#define flagfield flags
542#else
543#define flagfield mask[1]
544#endif
545#define USED ((MASKTYPE) 1 << (FLAGBASE + 0))
546#define KEEP ((MASKTYPE) 1 << (FLAGBASE + 1))
547#ifdef NO_CAPITALIZATION_SUPPORT
548#define ALLFLAGS (USED | KEEP)
549#else /* NO_CAPITALIZATION_SUPPORT */
550#define ANYCASE ((MASKTYPE) 0 << (FLAGBASE + 2))
551#define ALLCAPS ((MASKTYPE) 1 << (FLAGBASE + 2))
552#define CAPITALIZED ((MASKTYPE) 2 << (FLAGBASE + 2))
553#define FOLLOWCASE ((MASKTYPE) 3 << (FLAGBASE + 2))
554#define CAPTYPEMASK ((MASKTYPE) 3 << (FLAGBASE + 2))
555#define MOREVARIANTS ((MASKTYPE) 1 << (FLAGBASE + 4))
556#define ALLFLAGS (USED | KEEP | CAPTYPEMASK | MOREVARIANTS)
557#define captype(x) ((x) & CAPTYPEMASK)
558#endif /* NO_CAPITALIZATION_SUPPORT */
559
560/*
561 * Language tables used to encode prefix and suffix information.
562 */
563struct flagent
564{
565 ichar_t * strip; /* String to strip off */
566 ichar_t * affix; /* Affix to append */
567 short flagbit; /* Flag bit this ent matches */
568 short stripl; /* Length of strip */
569 short affl; /* Length of affix */
570 short numconds; /* Number of char conditions */
571 short flagflags; /* Modifiers on this flag */
572 char conds[SET_SIZE + MAXSTRINGCHARS]; /* Adj. char conds */
573};
574
575/*
576 * Bits in flagflags
577 */
578#define FF_CROSSPRODUCT (1 << 0) /* Affix does cross-products */
579#define FF_COMPOUNDONLY (1 << 1) /* Afx works in compounds */
580
581union ptr_union /* Aid for building flg ptrs */
582{
583 struct flagptr * fp; /* Pointer to more indexing */
584 struct flagent * ent; /* First of a list of ents */
585};
586
587struct flagptr
588{
589 union ptr_union pu; /* Ent list or more indexes */
590 int numents; /* If zero, pu.fp is valid */
591};
592
593/*
594 * Description of a single string character type.
595 */
596struct strchartype
597{
598 char * name; /* Name of the type */
599 char * deformatter; /* Deformatter to use */
600 char * suffixes; /* File suffixes, null seps */
601};
602
603/*
604 * Header placed at the beginning of the hash file.
605 */
606struct hashheader
607{
608 unsigned short magic; /* Magic number for ID */
609 unsigned short compileoptions; /* How we were compiled */
610 short maxstringchars; /* Max # strchrs we support */
611 short maxstringcharlen; /* Max strchr len supported */
612 short compoundmin; /* Min lth of compound parts */
613 short compoundbit; /* Flag 4 compounding roots */
614 int stringsize; /* Size of string table */
615 int lstringsize; /* Size of lang. str tbl */
616 int tblsize; /* No. entries in hash tbl */
617 int stblsize; /* No. entries in sfx tbl */
618 int ptblsize; /* No. entries in pfx tbl */
619 int sortval; /* Largest sort ID assigned */
620 int nstrchars; /* No. strchars defined */
621 int nstrchartype; /* No. strchar types */
622 int strtypestart; /* Start of strtype table */
623 char nrchars[5]; /* Nroff special characters */
624 char texchars[13]; /* TeX special characters */
625 char compoundflag; /* Compund-word handling */
626 char defhardflag; /* Default tryveryhard flag */
627 char flagmarker; /* "Start-of-flags" char */
628 unsigned short sortorder[SET_SIZE + MAXSTRINGCHARS]; /* Sort ordering */
629 ichar_t lowerconv[SET_SIZE + MAXSTRINGCHARS]; /* Lower-conversion table */
630 ichar_t upperconv[SET_SIZE + MAXSTRINGCHARS]; /* Upper-conversion table */
631 char wordchars[SET_SIZE + MAXSTRINGCHARS]; /* NZ for chars found in wrds */
632 char upperchars[SET_SIZE + MAXSTRINGCHARS]; /* NZ for uppercase chars */
633 char lowerchars[SET_SIZE + MAXSTRINGCHARS]; /* NZ for lowercase chars */
634 char boundarychars[SET_SIZE + MAXSTRINGCHARS]; /* NZ for boundary chars */
635 char stringstarts[SET_SIZE]; /* NZ if char can start str */
636 char stringchars[MAXSTRINGCHARS][MAXSTRINGCHARLEN + 1]; /* String chars */
637 unsigned int stringdups[MAXSTRINGCHARS]; /* No. of "base" char */
638 int dupnos[MAXSTRINGCHARS]; /* Dup char ID # */
639 unsigned short magic2; /* Second magic for dbl chk */
640};
641
642/* hash table magic number */
643#define MAGIC 0x9602
644
645/* compile options, put in the hash header for consistency checking */
646#ifdef NO8BIT
647# define MAGIC8BIT 0x01
648#else
649# define MAGIC8BIT 0x00
650#endif
651#ifdef NO_CAPITALIZATION_SUPPORT
652# define MAGICCAPITALIZATION 0x00
653#else
654# define MAGICCAPITALIZATION 0x02
655#endif
656# define MAGICMASKSET 0x04
657
658#if MASKBITS <= 32
659# define MAGICMASKSET 0x00
660#else
661# if MASKBITS <= 64
662# else
663# if MASKBITS <= 128
664# define MAGICMASKSET 0x08
665# else
666# define MAGICMASKSET 0x0C
667# endif
668# endif
669#endif
670
671#define COMPILEOPTIONS (MAGIC8BIT | MAGICCAPITALIZATION | MAGICMASKSET)
672
673/*
674** Offsets into the nroff special-character array
675*/
676#define NRLEFTPAREN hashheader.nrchars[0]
677#define NRRIGHTPAREN hashheader.nrchars[1]
678#define NRDOT hashheader.nrchars[2]
679#define NRBACKSLASH hashheader.nrchars[3]
680#define NRSTAR hashheader.nrchars[4]
681
682/*
683** Offsets into the TeX special-character array
684*/
685#define TEXLEFTPAREN hashheader.texchars[0]
686#define TEXRIGHTPAREN hashheader.texchars[1]
687#define TEXLEFTSQUARE hashheader.texchars[2]
688#define TEXRIGHTSQUARE hashheader.texchars[3]
689#define TEXLEFTCURLY hashheader.texchars[4]
690#define TEXRIGHTCURLY hashheader.texchars[5]
691#define TEXLEFTANGLE hashheader.texchars[6]
692#define TEXRIGHTANGLE hashheader.texchars[7]
693#define TEXBACKSLASH hashheader.texchars[8]
694#define TEXDOLLAR hashheader.texchars[9]
695#define TEXSTAR hashheader.texchars[10]
696#define TEXDOT hashheader.texchars[11]
697#define TEXPERCENT hashheader.texchars[12]
698
699/*
700** Values for compoundflag
701*/
702#define COMPOUND_NEVER 0 /* Compound words are never good */
703#define COMPOUND_ANYTIME 1 /* Accept run-together words */
704#define COMPOUND_CONTROLLED 2 /* Compounds controlled by afx flags */
705/*
706** These macros are similar to the ones above, but they take into account
707** the possibility of string characters. Note well that they take a POINTER,
708** not a character.
709**
710** The "l_" versions set "len" to the length of the string character as a
711** handy side effect. (Note that the global "laststringch" is also set,
712** and sometimes used, by these macros.)
713**
714** The "l1_" versions go one step further and guarantee that the "len"
715** field is valid for *all* characters, being set to 1 even if the macro
716** returns false. This macro is a great example of how NOT to write
717** readable C.
718*/
719/*TF NOTE: This is actually defined in code (makedent) now */
720#if 0
721#define isstringch(ptr, canon) (isstringstart (*(ptr)) \
722 && stringcharlen ((ptr), (canon)) > 0)
723#define l_isstringch(ptr, len, canon) \
724 (isstringstart (*(ptr)) \
725 && (len = stringcharlen ((ptr), (canon))) \
726 > 0)
727#define l1_isstringch(ptr, len, canon) \
728 (len = 1, \
729 isstringstart ((unsigned char)(*(ptr))) \
730 && ((len = \
731 stringcharlen ((ptr), (canon))) \
732 > 0 \
733 ? 1 : (len = 1, 0)))
734#endif
735
736/*
737 * Sizes of buffers returned by ichartosstr/strtosichar.
738 */
739#define ICHARTOSSTR_SIZE (INPUTWORDLEN + 4 * MAXAFFIXLEN + 4)
740#define STRTOSICHAR_SIZE ((INPUTWORDLEN + 4 * MAXAFFIXLEN + 4) \
741 * sizeof (ichar_t))
742/* TF CHANGE: We should fill this as a structure
743 and then use it throughout.
744*/
745
746/*
747 * Initialized variables. These are generated using macros so that they
748 * may be consistently declared in all programs. Numerous examples of
749 * usage are given below.
750 */
751#ifdef MAIN
752#define INIT(decl, init) decl = init
753#else
754#define INIT(decl, init) extern decl
755#endif
756
757#ifdef MINIMENU
758INIT (int minimenusize, 2); /* MUST be either 2 or zero */
759#else /* MINIMENU */
760INIT (int minimenusize, 0); /* MUST be either 2 or zero */
761#endif /* MINIMENU */
762
763INIT (int eflag, 0); /* NZ for expand mode */
764INIT (int dumpflag, 0); /* NZ to do dump mode */
765INIT (int fflag, 0); /* NZ if -f specified */
766#ifndef USG
767INIT (int sflag, 0); /* NZ to stop self after EOF */
768#endif
769INIT (int vflag, 0); /* NZ to display characters as M-xxx */
770INIT (int xflag, DEFNOBACKUPFLAG); /* NZ to suppress backups */
771INIT (int deftflag, -1); /* NZ for TeX mode by default */
772INIT (int tflag, DEFTEXFLAG); /* NZ for TeX mode in current file */
773INIT (int prefstringchar, -1); /* Preferred string character type */
774
775INIT (int terse, 0); /* NZ for "terse" mode */
776
777INIT (char tempfile[MAXPATHLEN], ""); /* Name of file we're spelling into */
778
779INIT (int minword, MINWORD); /* Longest always-legal word */
780INIT (int sortit, 1); /* Sort suggestions alphabetically */
781INIT (int compoundflag, -1); /* How to treat compounds: see above */
782INIT (int tryhardflag, -1); /* Always call tryveryhard */
783
784INIT (char * currentfile, NULL); /* Name of current input file */
785
786/* Odd numbers for math mode in LaTeX; even for LR or paragraph mode */
787INIT (int math_mode, 0);
788/* P -- paragraph or LR mode
789 * b -- parsing a \begin statement
790 * e -- parsing an \end statement
791 * r -- parsing a \ref type of argument.
792 * m -- looking for a \begin{minipage} argument.
793 */
794INIT (char LaTeX_Mode, 'P');
795
796#ifdef __cplusplus
797}
798#endif /* c++ */
799
800#endif /* ISPELL_H */

tdespell2

Skip menu "tdespell2"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

tdespell2

Skip menu "tdespell2"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdespell2 by doxygen 1.9.4
This website is maintained by Timothy Pearson.