/* ARGSUSED */ int ISpellChecker::good(ichar_t *w, int ignoreflagbits, int dummy, int pfxopts, int sfxopts) #endif { ichar_t nword[INPUTWORDLEN + MAXAFFIXLEN]; register ichar_t *p; register ichar_t *q; register int n; register struct dent *dp; /* ** Make an uppercase copy of the word we are checking. */ for(p = w, q = nword; *p;) *q++ = mytoupper(*p++); *q = 0; n = q - nword; m_numhits = 0; if((dp = ispell_lookup(nword, 1)) != NULL) { m_hits[0].dictent = dp; m_hits[0].prefix = NULL; m_hits[0].suffix = NULL; #ifndef NO_CAPITALIZATION_SUPPORT if(allhits || cap_ok(w, &m_hits[0], n)) m_numhits = 1; #else m_numhits = 1; #endif } if(m_numhits && !allhits) return 1; /* try stripping off affixes */ chk_aff(w, nword, n, ignoreflagbits, allhits, pfxopts, sfxopts); return m_numhits; }
/*! * \param word Word to be checked * \param ucword Upper-case-only word * \param len The length of ucword * \param ind Flag index table * \param optflags Affix option flags * \param pfxent Prefix flag entry if crossonly * \param ignoreflagbits Ignore whether affix is legal * \pram allhits Keep going after first hit */ void ISpellChecker::suf_list_chk (ichar_t *word, ichar_t *ucword, int len, struct flagptr *ind, int optflags, struct flagent *pfxent, int ignoreflagbits, int allhits) { register ichar_t * cp; /* Pointer into end of ucword */ int cond; /* Condition number */ struct dent * dent; /* Dictionary entry we found */ int entcount; /* Number of entries to process */ register struct flagent * flent; /* Current table entry */ int preadd; /* Length added to tword2 as prefix */ register int tlen; /* Length of tword */ ichar_t tword[INPUTWORDLEN + 4 * MAXAFFIXLEN + 4]; /* Tmp cpy */ ichar_t tword2[sizeof tword]; /* 2nd copy for ins_root_cap */ icharcpy (tword, ucword); for (flent = ind->pu.ent, entcount = ind->numents; entcount > 0; flent++, entcount--) { if ((optflags & FF_CROSSPRODUCT) != 0 && (flent->flagflags & FF_CROSSPRODUCT) == 0) continue; /* * If this is a compound-only affix, ignore it unless we're * looking for that specific thing. */ if ((flent->flagflags & FF_COMPOUNDONLY) != 0 && (optflags & FF_COMPOUNDONLY) == 0) continue; /* * See if the suffix matches. */ tlen = len - flent->affl; if (tlen > 0 && (flent->affl == 0 || icharcmp (flent->affix, ucword + tlen) == 0) && tlen + flent->stripl >= flent->numconds) { /* * The suffix matches. Remove it, replace it by the "strip" * string (if any), and check the original conditions. */ icharcpy (tword, ucword); cp = tword + tlen; if (flent->stripl) { icharcpy (cp, flent->strip); tlen += flent->stripl; cp = tword + tlen; } else *cp = '\0'; for (cond = flent->numconds; --cond >= 0; ) { if ((flent->conds[*--cp] & (1 << cond)) == 0) break; } if (cond < 0) { /* * The conditions match. See if the word is in the * dictionary. */ if (ignoreflagbits) { if ((dent = ispell_lookup (tword, 1)) != NULL) { cp = tword2; if ((optflags & FF_CROSSPRODUCT) && pfxent->affl != 0) { icharcpy (cp, pfxent->affix); cp += pfxent->affl; *cp++ = '+'; } preadd = cp - tword2; icharcpy (cp, tword); cp += tlen; if ((optflags & FF_CROSSPRODUCT) && pfxent->stripl != 0) { *cp++ = '-'; icharcpy (cp, pfxent->strip); cp += pfxent->stripl; } if (flent->stripl) { *cp++ = '-'; icharcpy (cp, flent->strip); cp += flent->stripl; } if (flent->affl) { *cp++ = '+'; icharcpy (cp, flent->affix); cp += flent->affl; } } } else if ((dent = ispell_lookup (tword, 1)) != NULL && TSTMASKBIT (dent->mask, flent->flagbit) && ((optflags & FF_CROSSPRODUCT) == 0 || TSTMASKBIT (dent->mask, pfxent->flagbit))) { if (m_numhits < MAX_HITS) { m_hits[m_numhits].dictent = dent; m_hits[m_numhits].prefix = pfxent; m_hits[m_numhits].suffix = flent; m_numhits++; } if (!allhits) { #ifndef NO_CAPITALIZATION_SUPPORT if (cap_ok (word, &m_hits[0], len)) return; m_numhits = 0; #else /* NO_CAPITALIZATION_SUPPORT */ return; #endif /* NO_CAPITALIZATION_SUPPORT */ } } } } } }