215 #include "ispell_checker.h" 218 int good P ((ichar_t * word,
int ignoreflagbits,
int allhits,
219 int pfxopts,
int sfxopts));
221 #ifndef NO_CAPITALIZATION_SUPPORT 232 static int entryhasaffixes (
struct dent *dent,
struct success *hit)
234 if (hit->prefix && !TSTMASKBIT (dent->mask, hit->prefix->flagbit))
236 if (hit->suffix && !TSTMASKBIT (dent->mask, hit->suffix->flagbit))
248 int ISpellChecker::cap_ok (ichar_t *word,
struct success *hit,
int len)
253 ichar_t dentword[INPUTWORDLEN + MAXAFFIXLEN];
261 thiscap = whatcap (word);
265 preadd = prestrip = sufadd = 0;
266 if (thiscap == ALLCAPS)
268 else if (thiscap == FOLLOWCASE)
273 preadd = hit->prefix->affl;
274 prestrip = hit->prefix->stripl;
277 preadd = prestrip = 0;
278 sufadd = hit->suffix ? hit->suffix->affl : 0;
288 dentcap = captype (dent->flagfield);
289 if (dentcap != thiscap)
291 if (dentcap == ANYCASE && thiscap == CAPITALIZED
292 && entryhasaffixes (dent, hit))
297 if (thiscap != FOLLOWCASE)
299 if (entryhasaffixes (dent, hit))
310 strtoichar (dentword, dent->word, INPUTWORDLEN, 1);
312 limit = word + preadd;
313 if (myupper (dword[prestrip]))
315 for (w = word; w < limit; w++)
323 for (w = word; w < limit; w++)
331 limit = dword + len - preadd - sufadd;
332 while (dword < limit)
334 if (*dword++ != *w++)
339 if (myupper (*dword))
359 if (entryhasaffixes (dent, hit))
364 if ((dent->flagfield & MOREVARIANTS) == 0)
374 #ifndef NO_CAPITALIZATION_SUPPORT 384 int ISpellChecker::good (ichar_t *w,
int ignoreflagbits,
int allhits,
int pfxopts,
int sfxopts)
387 int ISpellChecker::good (ichar_t *w,
int ignoreflagbits,
int dummy,
int pfxopts,
int sfxopts)
390 ichar_t nword[INPUTWORDLEN + MAXAFFIXLEN];
399 for (p = w, q = nword; *p; )
400 *q++ = mytoupper (*p++);
406 if ((dp = ispell_lookup (nword, 1)) != NULL)
408 m_hits[0].dictent = dp;
409 m_hits[0].prefix = NULL;
410 m_hits[0].suffix = NULL;
411 #ifndef NO_CAPITALIZATION_SUPPORT 412 if (allhits || cap_ok (w, &m_hits[0], n))
419 if (m_numhits && !allhits)
424 chk_aff (w, nword, n, ignoreflagbits, allhits, pfxopts, sfxopts);