@@ -0,0 +1,35058 @@
+diff -uprN --exclude=CVS spellcheck.old/hunspell/hunspell/affentry.cpp spellcheck/hunspell/hunspell/affentry.cpp
+--- spellcheck.old/hunspell/hunspell/affentry.cpp 1970-01-01 01:00:00.000000000 +0100
++++ spellcheck/hunspell/hunspell/affentry.cpp 2008-04-23 16:42:09.000000000 +0200
+@@ -0,0 +1,924 @@
++/******* BEGIN LICENSE BLOCK *******
++ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
++ *
++ * The contents of this file are subject to the Mozilla Public License Version
++ * 1.1 (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ * http://www.mozilla.org/MPL/
++ *
++ * Software distributed under the License is distributed on an "AS IS" basis,
++ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
++ * for the specific language governing rights and limitations under the
++ * License.
++ *
++ * The Initial Developers of the Original Code are Kevin Hendricks (MySpell)
++ * and László Németh (Hunspell). Portions created by the Initial Developers
++ * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved.
++ *
++ * Contributor(s): Kevin Hendricks (kevin.hendricks@sympatico.ca)
++ * David Einstein (deinst@world.std.com)
++ * László Németh (nemethl@gyorsposta.hu)
++ * Davide Prina
++ * Giuseppe Modugno
++ * Gianluca Turconi
++ * Simon Brouwer
++ * Noll Janos
++ * Biro Arpad
++ * Goldman Eleonora
++ * Sarlos Tamas
++ * Bencsath Boldizsar
++ * Halacsy Peter
++ * Dvornik Laszlo
++ * Gefferth Andras
++ * Nagy Viktor
++ * Varga Daniel
++ * Chris Halls
++ * Rene Engelhard
++ * Bram Moolenaar
++ * Dafydd Jones
++ * Harri Pitkanen
++ * Andras Timar
++ * Tor Lillqvist
++ *
++ * Alternatively, the contents of this file may be used under the terms of
++ * either the GNU General Public License Version 2 or later (the "GPL"), or
++ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
++ * in which case the provisions of the GPL or the LGPL are applicable instead
++ * of those above. If you wish to allow use of your version of this file only
++ * under the terms of either the GPL or the LGPL, and not to allow others to
++ * use your version of this file under the terms of the MPL, indicate your
++ * decision by deleting the provisions above and replace them with the notice
++ * and other provisions required by the GPL or the LGPL. If you do not delete
++ * the provisions above, a recipient may use your version of this file under
++ * the terms of any one of the MPL, the GPL or the LGPL.
++ *
++ ******* END LICENSE BLOCK *******/
++
++#ifndef MOZILLA_CLIENT
++#include <cstdlib>
++#include <cstring>
++#include <cctype>
++#include <cstdio>
++#else
++#include <stdlib.h>
++#include <string.h>
++#include <stdio.h>
++#include <ctype.h>
++#endif
++
++#include "affentry.hxx"
++#include "csutil.hxx"
++
++#ifndef MOZILLA_CLIENT
++#ifndef W32
++using namespace std;
++#endif
++#endif
++
++
++PfxEntry::PfxEntry(AffixMgr* pmgr, affentry* dp)
++{
++ // register affix manager
++ pmyMgr = pmgr;
++
++ // set up its intial values
++
++ aflag = dp->aflag; // flag
++ strip = dp->strip; // string to strip
++ appnd = dp->appnd; // string to append
++ stripl = dp->stripl; // length of strip string
++ appndl = dp->appndl; // length of append string
++ numconds = dp->numconds; // number of conditions to match
++ opts = dp->opts; // cross product flag
++ // then copy over all of the conditions
++ memcpy(&conds.base[0],&dp->conds.base[0],SETSIZE*sizeof(conds.base[0]));
++ next = NULL;
++ nextne = NULL;
++ nexteq = NULL;
++#ifdef HUNSPELL_EXPERIMENTAL
++ morphcode = dp->morphcode;
++#endif
++ contclass = dp->contclass;
++ contclasslen = dp->contclasslen;
++}
++
++
++PfxEntry::~PfxEntry()
++{
++ aflag = 0;
++ if (appnd) free(appnd);
++ if (strip) free(strip);
++ pmyMgr = NULL;
++ appnd = NULL;
++ strip = NULL;
++ if (opts & aeUTF8) {
++ for (int i = 0; i < numconds; i++) {
++ if (conds.utf8.wchars[i]) free(conds.utf8.wchars[i]);
++ }
++ }
++#ifdef HUNSPELL_EXPERIMENTAL
++ if (morphcode && !(opts & aeALIASM)) free(morphcode);
++#endif
++ if (contclass && !(opts & aeALIASF)) free(contclass);
++}
++
++// add prefix to this word assuming conditions hold
++char * PfxEntry::add(const char * word, int len)
++{
++ char tword[MAXWORDUTF8LEN + 4];
++
++ if ((len > stripl) && (len >= numconds) && test_condition(word) &&
++ (!stripl || (strncmp(word, strip, stripl) == 0)) &&
++ ((MAXWORDUTF8LEN + 4) > (len + appndl - stripl))) {
++ /* we have a match so add prefix */
++ char * pp = tword;
++ if (appndl) {
++ strcpy(tword,appnd);
++ pp += appndl;
++ }
++ strcpy(pp, (word + stripl));
++ return mystrdup(tword);
++ }
++ return NULL;
++}
++
++
++inline int PfxEntry::test_condition(const char * st)
++{
++ int cond;
++ unsigned char * cp = (unsigned char *)st;
++ if (!(opts & aeUTF8)) { // 256-character codepage
++ for (cond = 0; cond < numconds; cond++) {
++ if ((conds.base[*cp++] & (1 << cond)) == 0) return 0;
++ }
++ } else { // UTF-8 encoding
++ unsigned short wc;
++ for (cond = 0; cond < numconds; cond++) {
++ // a simple 7-bit ASCII character in UTF-8
++ if ((*cp >> 7) == 0) {
++ // also check limit (end of word)
++ if ((!*cp) || ((conds.utf8.ascii[*cp++] & (1 << cond)) == 0)) return 0;
++ // UTF-8 multibyte character
++ } else {
++ // not dot wildcard in rule
++ if (!conds.utf8.all[cond]) {
++ if (conds.utf8.neg[cond]) {
++ u8_u16((w_char *) &wc, 1, (char *) cp);
++ if (conds.utf8.wchars[cond] &&
++ flag_bsearch((unsigned short *)conds.utf8.wchars[cond],
++ wc, (short) conds.utf8.wlen[cond])) return 0;
++ } else {
++ if (!conds.utf8.wchars[cond]) return 0;
++ u8_u16((w_char *) &wc, 1, (char *) cp);
++ if (!flag_bsearch((unsigned short *)conds.utf8.wchars[cond],
++ wc, (short)conds.utf8.wlen[cond])) return 0;
++ }
++ }
++ // jump to next UTF-8 character
++ for(cp++; (*cp & 0xc0) == 0x80; cp++);
++ }
++ }
++ }
++ return 1;
++}
++
++
++// check if this prefix entry matches
++struct hentry * PfxEntry::checkword(const char * word, int len, char in_compound, const FLAG needflag)
++{
++ int tmpl; // length of tmpword
++ struct hentry * he; // hash entry of root word or NULL
++ char tmpword[MAXWORDUTF8LEN + 4];
++
++ // on entry prefix is 0 length or already matches the beginning of the word.
++ // So if the remaining root word has positive length
++ // and if there are enough chars in root word and added back strip chars
|