214 #include "ispell_checker.h"
217 int good P ((ichar_t * word,
int ignoreflagbits,
int allhits,
218 int pfxopts,
int sfxopts));
220 #ifndef NO_CAPITALIZATION_SUPPORT
231 static int entryhasaffixes (
struct dent *dent,
struct success *hit)
233 if (hit->prefix && !TSTMASKBIT (dent->mask, hit->prefix->flagbit))
235 if (hit->suffix && !TSTMASKBIT (dent->mask, hit->suffix->flagbit))
247 int ISpellChecker::cap_ok (ichar_t *word,
struct success *hit,
int len)
252 ichar_t dentword[INPUTWORDLEN + MAXAFFIXLEN];
260 thiscap = whatcap (word);
264 preadd = prestrip = sufadd = 0;
265 if (thiscap == ALLCAPS)
267 else if (thiscap == FOLLOWCASE)
272 preadd = hit->prefix->affl;
273 prestrip = hit->prefix->stripl;
276 preadd = prestrip = 0;
277 sufadd = hit->suffix ? hit->suffix->affl : 0;
287 dentcap = captype (dent->flagfield);
288 if (dentcap != thiscap)
290 if (dentcap == ANYCASE && thiscap == CAPITALIZED
291 && entryhasaffixes (dent, hit))
296 if (thiscap != FOLLOWCASE)
298 if (entryhasaffixes (dent, hit))
309 strtoichar (dentword, dent->word, INPUTWORDLEN, 1);
311 limit = word + preadd;
312 if (myupper (dword[prestrip]))
314 for (w = word; w < limit; w++)
322 for (w = word; w < limit; w++)
330 limit = dword + len - preadd - sufadd;
331 while (dword < limit)
333 if (*dword++ != *w++)
338 if (myupper (*dword))
358 if (entryhasaffixes (dent, hit))
363 if ((dent->flagfield & MOREVARIANTS) == 0)
373 #ifndef NO_CAPITALIZATION_SUPPORT
383 int ISpellChecker::good (ichar_t *w,
int ignoreflagbits,
int allhits,
int pfxopts,
int sfxopts)
386 int ISpellChecker::good (ichar_t *w,
int ignoreflagbits,
int dummy,
int pfxopts,
int sfxopts)
389 ichar_t nword[INPUTWORDLEN + MAXAFFIXLEN];
398 for (p = w, q = nword; *p; )
399 *q++ = mytoupper (*p++);
405 if ((dp = ispell_lookup (nword, 1)) != NULL)
407 m_hits[0].dictent = dp;
408 m_hits[0].prefix = NULL;
409 m_hits[0].suffix = NULL;
410 #ifndef NO_CAPITALIZATION_SUPPORT
411 if (allhits || cap_ok (w, &m_hits[0], n))
418 if (m_numhits && !allhits)
423 chk_aff (w, nword, n, ignoreflagbits, allhits, pfxopts, sfxopts);