| Index: third_party/hunspell/google.patch
|
| diff --git a/third_party/hunspell/google.patch b/third_party/hunspell/google.patch
|
| index 47d561dd4c123999fcc745b8bfb6fd290232567f..a01020284dfd319d81aa34094f5bed5c8bacfde2 100644
|
| --- a/third_party/hunspell/google.patch
|
| +++ b/third_party/hunspell/google.patch
|
| @@ -1,27 +1,29 @@
|
| -Index: src/hunspell/affixmgr.cxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/affixmgr.cxx,v
|
| -retrieving revision 1.41
|
| -diff -u -r1.41 affixmgr.cxx
|
| ---- src/hunspell/affixmgr.cxx 16 Dec 2011 09:15:34 -0000 1.41
|
| -+++ src/hunspell/affixmgr.cxx 29 May 2014 01:05:07 -0000
|
| -@@ -14,8 +14,14 @@
|
| +diff --git a/third_party/hunspell/src/hunspell/affixmgr.cxx b/third_party/hunspell/src/hunspell/affixmgr.cxx
|
| +index cc9e69b..d31944e 100644
|
| +--- a/third_party/hunspell/src/hunspell/affixmgr.cxx
|
| ++++ b/third_party/hunspell/src/hunspell/affixmgr.cxx
|
| +@@ -87,11 +87,19 @@
|
|
|
| #include "csutil.hxx"
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+AffixMgr::AffixMgr(hunspell::BDictReader* reader, HashMgr** ptr, int * md)
|
| -+{
|
| ++AffixMgr::AffixMgr(hunspell::BDictReader* reader,
|
| ++ const std::vector<HashMgr*>& ptr)
|
| ++ : alldic(ptr)
|
| ++ , pHMgr(ptr[0]) {
|
| + bdict_reader = reader;
|
| +#else
|
| - AffixMgr::AffixMgr(const char * affpath, HashMgr** ptr, int * md, const char * key)
|
| - {
|
| + AffixMgr::AffixMgr(const char* affpath,
|
| + const std::vector<HashMgr*>& ptr,
|
| + const char* key)
|
| + : alldic(ptr)
|
| + , pHMgr(ptr[0]) {
|
| +#endif
|
| +
|
| // register hash manager and load affix data from aff file
|
| - pHMgr = ptr[0];
|
| - alldic = ptr;
|
| -@@ -107,9 +113,17 @@
|
| - sFlag[i] = NULL;
|
| + csconv = NULL;
|
| +@@ -166,9 +174,17 @@ AffixMgr::AffixMgr(const char* affpath,
|
| + sFlag[i] = NULL;
|
| }
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| @@ -31,17 +33,18 @@ diff -u -r1.41 affixmgr.cxx
|
| + const char* affpath = NULL;
|
| + const char* key = NULL;
|
| +#else
|
| - for (int j=0; j < CONTSIZE; j++) {
|
| + for (int j = 0; j < CONTSIZE; j++) {
|
| contclasses[j] = 0;
|
| }
|
| +#endif
|
|
|
| if (parse_file(affpath, key)) {
|
| - HUNSPELL_WARNING(stderr, "Failure loading aff file %s\n",affpath);
|
| -@@ -269,6 +283,43 @@
|
| - char * line; // io buffers
|
| - char ft; // affix type
|
| -
|
| + HUNSPELL_WARNING(stderr, "Failure loading aff file %s\n", affpath);
|
| +@@ -246,7 +262,44 @@ void AffixMgr::finishFileMgr(FileMgr* afflst) {
|
| +
|
| + // read in aff file and build up prefix and suffix entry objects
|
| + int AffixMgr::parse_file(const char* affpath, const char* key) {
|
| ++ std::string line;
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + // open the affix file
|
| + // We're always UTF-8
|
| @@ -59,15 +62,15 @@ diff -u -r1.41 affixmgr.cxx
|
| + return 1;
|
| + }
|
| +
|
| -+ while ((line = iterator->getline())) {
|
| -+ ft = ' ';
|
| -+ if (strncmp(line,"PFX",3) == 0) ft = complexprefixes ? 'S' : 'P';
|
| -+ if (strncmp(line,"SFX",3) == 0) ft = complexprefixes ? 'P' : 'S';
|
| ++ while (iterator->getline(line)) {
|
| ++ char ft = ' ';
|
| ++ if (line.compare(0, 3, "PFX") == 0) ft = complexprefixes ? 'S' : 'P';
|
| ++ if (line.compare(0, 3, "SFX") == 0) ft = complexprefixes ? 'P' : 'S';
|
| + if (ft != ' ')
|
| + parse_affix(line, ft, iterator, NULL);
|
| + }
|
| + delete iterator;
|
| -+
|
| +
|
| + // Create a FileMgr object for reading lines except PFX and SFX lines.
|
| + // We don't need to change the loop below since our FileMgr emulates the
|
| + // original one.
|
| @@ -82,121 +85,119 @@ diff -u -r1.41 affixmgr.cxx
|
| // checking flag duplication
|
| char dupflags[CONTSIZE];
|
| char dupflags_ini = 1;
|
| -@@ -282,6 +333,7 @@
|
| - HUNSPELL_WARNING(stderr, "error: could not open affix description file %s\n",affpath);
|
| +@@ -261,16 +314,17 @@ int AffixMgr::parse_file(const char* affpath, const char* key) {
|
| + stderr, "error: could not open affix description file %s\n", affpath);
|
| return 1;
|
| }
|
| +#endif
|
|
|
| // step one is to parse the affix file building up the internal
|
| // affix data structures
|
| -@@ -291,6 +343,7 @@
|
| - while ((line = afflst->getline()) != NULL) {
|
| - mychomp(line);
|
| +
|
| + // read in each line ignoring any that do not
|
| + // start with a known line type indicator
|
| +- std::string line;
|
| + while (afflst->getline(line)) {
|
| + mychomp(line);
|
|
|
| +#ifndef HUNSPELL_CHROME_CLIENT
|
| - /* remove byte order mark */
|
| - if (firstline) {
|
| - firstline = 0;
|
| -@@ -299,6 +352,7 @@
|
| - memmove(line, line+3, strlen(line+3)+1);
|
| - }
|
| - }
|
| + /* remove byte order mark */
|
| + if (firstline) {
|
| + firstline = 0;
|
| +@@ -280,6 +334,7 @@ int AffixMgr::parse_file(const char* affpath, const char* key) {
|
| + line.erase(0, 3);
|
| + }
|
| + }
|
| +#endif
|
|
|
| - /* parse in the keyboard string */
|
| - if (strncmp(line,"KEY",3) == 0) {
|
| -@@ -545,6 +599,7 @@
|
| - }
|
| - }
|
| + /* parse in the keyboard string */
|
| + if (line.compare(0, 3, "KEY", 3) == 0) {
|
| +@@ -532,6 +587,7 @@ int AffixMgr::parse_file(const char* affpath, const char* key) {
|
| + }
|
| + }
|
|
|
| +#ifndef HUNSPELL_CHROME_CLIENT
|
| - /* parse in the typical fault correcting table */
|
| - if (strncmp(line,"REP",3) == 0) {
|
| - if (parse_reptable(line, afflst)) {
|
| -@@ -552,6 +607,7 @@
|
| - return 1;
|
| - }
|
| - }
|
| + /* parse in the typical fault correcting table */
|
| + if (line.compare(0, 3, "REP", 3) == 0) {
|
| + if (!parse_reptable(line, afflst)) {
|
| +@@ -539,6 +595,7 @@ int AffixMgr::parse_file(const char* affpath, const char* key) {
|
| + return 1;
|
| + }
|
| + }
|
| +#endif
|
|
|
| - /* parse in the input conversion table */
|
| - if (strncmp(line,"ICONV",5) == 0) {
|
| -@@ -699,6 +755,7 @@
|
| - checksharps=1;
|
| - }
|
| + /* parse in the input conversion table */
|
| + if (line.compare(0, 5, "ICONV", 5) == 0) {
|
| +@@ -688,6 +745,7 @@ int AffixMgr::parse_file(const char* affpath, const char* key) {
|
| + checksharps = 1;
|
| + }
|
|
|
| +#ifndef HUNSPELL_CHROME_CLIENT
|
| - /* parse this affix: P - prefix, S - suffix */
|
| - ft = ' ';
|
| - if (strncmp(line,"PFX",3) == 0) ft = complexprefixes ? 'S' : 'P';
|
| -@@ -713,6 +770,7 @@
|
| - return 1;
|
| - }
|
| - }
|
| -+#endif
|
| + /* parse this affix: P - prefix, S - suffix */
|
| + // affix type
|
| + char ft = ' ';
|
| +@@ -705,6 +763,7 @@ int AffixMgr::parse_file(const char* affpath, const char* key) {
|
| + return 1;
|
| + }
|
| }
|
| ++#endif
|
| + }
|
|
|
| - finishFileMgr(afflst);
|
| -@@ -1307,6 +1365,26 @@
|
| - const char * r;
|
| - int lenr, lenp;
|
| + finishFileMgr(afflst);
|
| +@@ -1281,6 +1340,24 @@ std::string AffixMgr::prefix_check_twosfx_morph(const char* word,
|
| + // Is word a non compound with a REP substitution (see checkcompoundrep)?
|
| + int AffixMgr::cpdrep_check(const char* word, int wl) {
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + const char *pattern, *pattern2;
|
| + hunspell::ReplacementIterator iterator = bdict_reader->GetReplacementIterator();
|
| + while (iterator.GetNext(&pattern, &pattern2)) {
|
| -+ r = word;
|
| -+ lenr = strlen(pattern2);
|
| -+ lenp = strlen(pattern);
|
| ++ const char* r = word;
|
| ++ const size_t lenr = strlen(pattern2);
|
| ++ const size_t lenp = strlen(pattern);
|
| +
|
| + // search every occurence of the pattern in the word
|
| + while ((r=strstr(r, pattern)) != NULL) {
|
| -+ strcpy(candidate, word);
|
| -+ if (r-word + lenr + strlen(r+lenp) >= MAXLNLEN) break;
|
| -+ strcpy(candidate+(r-word), pattern2);
|
| -+ strcpy(candidate+(r-word)+lenr, r+lenp);
|
| -+ if (candidate_check(candidate,strlen(candidate))) return 1;
|
| ++ std::string candidate(word);
|
| ++ candidate.replace(r-word, lenp, pattern2);
|
| ++ if (candidate_check(candidate.c_str(), candidate.size())) return 1;
|
| + r++; // search for the next letter
|
| + }
|
| + }
|
| +
|
| +#else
|
| - if ((wl < 2) || !numrep) return 0;
|
| + if ((wl < 2) || reptable.empty())
|
| + return 0;
|
|
|
| - for (int i=0; i < numrep; i++ ) {
|
| -@@ -1323,6 +1401,7 @@
|
| - r++; // search for the next letter
|
| - }
|
| - }
|
| +@@ -1299,6 +1376,7 @@ int AffixMgr::cpdrep_check(const char* word, int wl) {
|
| + ++r; // search for the next letter
|
| + }
|
| + }
|
| +#endif
|
| - return 0;
|
| - }
|
|
|
| -@@ -4219,6 +4298,7 @@
|
| - case 1: {
|
| - np++;
|
| - aflag = pHMgr->decode_flag(piece);
|
| + return 0;
|
| + }
|
| +@@ -4489,6 +4567,7 @@ bool AffixMgr::parse_affix(const std::string& line,
|
| + case 1: {
|
| + np++;
|
| + aflag = pHMgr->decode_flag(std::string(start_piece, iter).c_str());
|
| +#ifndef HUNSPELL_CHROME_CLIENT // We don't check for duplicates.
|
| - if (((at == 'S') && (dupflags[aflag] & dupSFX)) ||
|
| - ((at == 'P') && (dupflags[aflag] & dupPFX))) {
|
| - HUNSPELL_WARNING(stderr, "error: line %d: multiple definitions of an affix flag\n",
|
| -@@ -4226,6 +4306,7 @@
|
| - // return 1; XXX permissive mode for bad dictionaries
|
| - }
|
| - dupflags[aflag] += (char) ((at == 'S') ? dupSFX : dupPFX);
|
| + if (((at == 'S') && (dupflags[aflag] & dupSFX)) ||
|
| + ((at == 'P') && (dupflags[aflag] & dupPFX))) {
|
| + HUNSPELL_WARNING(
|
| +@@ -4497,6 +4576,7 @@ bool AffixMgr::parse_affix(const std::string& line,
|
| + af->getlinenum());
|
| + }
|
| + dupflags[aflag] += (char)((at == 'S') ? dupSFX : dupPFX);
|
| +#endif
|
| - break;
|
| - }
|
| - // piece 3 - is cross product indicator
|
| -Index: src/hunspell/affixmgr.hxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/affixmgr.hxx,v
|
| -retrieving revision 1.15
|
| -diff -u -r1.15 affixmgr.hxx
|
| ---- src/hunspell/affixmgr.hxx 13 Oct 2011 13:41:54 -0000 1.15
|
| -+++ src/hunspell/affixmgr.hxx 29 May 2014 01:05:07 -0000
|
| -@@ -18,6 +18,40 @@
|
| + break;
|
| + }
|
| + // piece 3 - is cross product indicator
|
| +diff --git a/third_party/hunspell/src/hunspell/affixmgr.hxx b/third_party/hunspell/src/hunspell/affixmgr.hxx
|
| +index c7d5a63..55acd6a 100644
|
| +--- a/third_party/hunspell/src/hunspell/affixmgr.hxx
|
| ++++ b/third_party/hunspell/src/hunspell/affixmgr.hxx
|
| +@@ -92,6 +92,40 @@
|
| class PfxEntry;
|
| class SfxEntry;
|
|
|
| @@ -234,56 +235,47 @@ diff -u -r1.15 affixmgr.hxx
|
| +
|
| +#endif // HUNSPELL_CHROME_CLIENT
|
| +
|
| - class LIBHUNSPELL_DLL_EXPORTED AffixMgr
|
| - {
|
| -
|
| -@@ -106,12 +140,20 @@
|
| - int fullstrip;
|
| + class AffixMgr {
|
| + PfxEntry* pStart[SETSIZE];
|
| + SfxEntry* sStart[SETSIZE];
|
| +@@ -175,11 +209,19 @@ class AffixMgr {
|
| + int fullstrip;
|
|
|
| - int havecontclass; // boolean variable
|
| + int havecontclass; // boolean variable
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + ContClasses contclasses;
|
| +#else
|
| - char contclasses[CONTSIZE]; // flags of possible continuing classes (twofold affix)
|
| + char contclasses[CONTSIZE]; // flags of possible continuing classes (twofold
|
| + // affix)
|
| +#endif
|
|
|
| - public:
|
| -
|
| + public:
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+ AffixMgr(hunspell::BDictReader* reader, HashMgr** ptr, int * md);
|
| ++ AffixMgr(hunspell::BDictReader* reader, const std::vector<HashMgr*>& ptr);
|
| +#else
|
| - AffixMgr(const char * affpath, HashMgr** ptr, int * md,
|
| - const char * key = NULL);
|
| + AffixMgr(const char* affpath, const std::vector<HashMgr*>& ptr, const char* key = NULL);
|
| +#endif
|
| ~AffixMgr();
|
| - struct hentry * affix_check(const char * word, int len,
|
| - const unsigned short needflag = (unsigned short) 0,
|
| -@@ -218,6 +260,10 @@
|
| - int get_fullstrip() const;
|
| + struct hentry* affix_check(const char* word,
|
| + int len,
|
| +@@ -337,6 +379,10 @@ class AffixMgr {
|
| + int get_fullstrip() const;
|
|
|
| - private:
|
| + private:
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + // Not owned by us, owned by the Hunspell object.
|
| + hunspell::BDictReader* bdict_reader;
|
| +#endif
|
| - int parse_file(const char * affpath, const char * key);
|
| - int parse_flag(char * line, unsigned short * out, FileMgr * af);
|
| - int parse_num(char * line, int * out, FileMgr * af);
|
| -@@ -249,4 +295,3 @@
|
| - };
|
| -
|
| - #endif
|
| --
|
| -Index: src/hunspell/filemgr.cxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/filemgr.cxx,v
|
| -retrieving revision 1.5
|
| -diff -u -r1.5 filemgr.cxx
|
| ---- src/hunspell/filemgr.cxx 23 Jun 2011 09:21:50 -0000 1.5
|
| -+++ src/hunspell/filemgr.cxx 29 May 2014 01:05:07 -0000
|
| -@@ -7,6 +7,32 @@
|
| -
|
| + int parse_file(const char* affpath, const char* key);
|
| + bool parse_flag(const std::string& line, unsigned short* out, FileMgr* af);
|
| + bool parse_num(const std::string& line, int* out, FileMgr* af);
|
| +diff --git a/third_party/hunspell/src/hunspell/filemgr.cxx b/third_party/hunspell/src/hunspell/filemgr.cxx
|
| +index b7c89b2..aef6dba 100644
|
| +--- a/third_party/hunspell/src/hunspell/filemgr.cxx
|
| ++++ b/third_party/hunspell/src/hunspell/filemgr.cxx
|
| +@@ -78,6 +78,32 @@
|
| #include "filemgr.hxx"
|
| + #include "csutil.hxx"
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| +#include "third_party/hunspell/google/bdict_reader.h"
|
| @@ -294,13 +286,13 @@ diff -u -r1.5 filemgr.cxx
|
| +FileMgr::~FileMgr() {
|
| +}
|
| +
|
| -+char * FileMgr::getline() {
|
| -+ // Read one line from a BDICT file and store the line to our line buffer.
|
| -+ // To emulate the original FileMgr::getline(), this function returns
|
| -+ // the pointer to our line buffer if we can read a line without errors.
|
| -+ // Otherwise, this function returns NULL.
|
| ++bool FileMgr::getline(std::string& line) {
|
| ++ // Read one line from a BDICT file and return it, if we can read a line
|
| ++ // without errors.
|
| + bool result = iterator_->AdvanceAndCopy(line_, BUFSIZE - 1);
|
| -+ return result ? line_ : NULL;
|
| ++ if (result)
|
| ++ line = line_;
|
| ++ return result;
|
| +}
|
| +
|
| +int FileMgr::getlinenum() {
|
| @@ -311,24 +303,21 @@ diff -u -r1.5 filemgr.cxx
|
| + return 0;
|
| +}
|
| +#else
|
| - int FileMgr::fail(const char * err, const char * par) {
|
| - fprintf(stderr, err, par);
|
| - return -1;
|
| -@@ -47,3 +73,4 @@
|
| + int FileMgr::fail(const char* err, const char* par) {
|
| + fprintf(stderr, err, par);
|
| + return -1;
|
| +@@ -118,3 +144,4 @@ bool FileMgr::getline(std::string& dest) {
|
| int FileMgr::getlinenum() {
|
| - return linenum;
|
| + return linenum;
|
| }
|
| +#endif
|
| -Index: src/hunspell/filemgr.hxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/filemgr.hxx,v
|
| -retrieving revision 1.3
|
| -diff -u -r1.3 filemgr.hxx
|
| ---- src/hunspell/filemgr.hxx 15 Apr 2010 11:22:08 -0000 1.3
|
| -+++ src/hunspell/filemgr.hxx 29 May 2014 01:05:07 -0000
|
| -@@ -7,6 +7,30 @@
|
| - #include "hunzip.hxx"
|
| - #include <stdio.h>
|
| +diff --git a/third_party/hunspell/src/hunspell/filemgr.hxx b/third_party/hunspell/src/hunspell/filemgr.hxx
|
| +index ca51faf..daa6d0b 100644
|
| +--- a/third_party/hunspell/src/hunspell/filemgr.hxx
|
| ++++ b/third_party/hunspell/src/hunspell/filemgr.hxx
|
| +@@ -80,6 +80,30 @@
|
| + #include <string>
|
| + #include <fstream>
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| +namespace hunspell {
|
| @@ -346,7 +335,7 @@ diff -u -r1.3 filemgr.hxx
|
| + public:
|
| + FileMgr(hunspell::LineIterator* iterator);
|
| + ~FileMgr();
|
| -+ char* getline();
|
| ++ bool getline(std::string& line);
|
| + int getlinenum();
|
| +
|
| + protected:
|
| @@ -354,40 +343,38 @@ diff -u -r1.3 filemgr.hxx
|
| + char line_[BUFSIZE + 50]; // input buffer
|
| +};
|
| +#else
|
| - class LIBHUNSPELL_DLL_EXPORTED FileMgr
|
| - {
|
| - protected:
|
| -@@ -23,3 +47,4 @@
|
| - int getlinenum();
|
| + class FileMgr {
|
| + private:
|
| + FileMgr(const FileMgr&);
|
| +@@ -99,3 +123,4 @@ class FileMgr {
|
| + int getlinenum();
|
| };
|
| #endif
|
| +#endif
|
| -Index: src/hunspell/hashmgr.cxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hashmgr.cxx,v
|
| -retrieving revision 1.12
|
| -diff -u -r1.12 hashmgr.cxx
|
| ---- src/hunspell/hashmgr.cxx 23 Jun 2011 09:21:50 -0000 1.12
|
| -+++ src/hunspell/hashmgr.cxx 29 May 2014 01:05:07 -0000
|
| -@@ -12,8 +12,14 @@
|
| +diff --git a/third_party/hunspell/src/hunspell/hashmgr.cxx b/third_party/hunspell/src/hunspell/hashmgr.cxx
|
| +index 072bc1a..b07c585 100644
|
| +--- a/third_party/hunspell/src/hunspell/hashmgr.cxx
|
| ++++ b/third_party/hunspell/src/hunspell/hashmgr.cxx
|
| +@@ -84,8 +84,14 @@
|
|
|
| // build a hash table from a munched word list
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| +HashMgr::HashMgr(hunspell::BDictReader* reader)
|
| -+{
|
| -+ bdict_reader = reader;
|
| ++ : bdict_reader(reader),
|
| +#else
|
| - HashMgr::HashMgr(const char * tpath, const char * apath, const char * key)
|
| - {
|
| + HashMgr::HashMgr(const char* tpath, const char* apath, const char* key)
|
| +- : tablesize(0),
|
| ++ :
|
| +#endif
|
| - tablesize = 0;
|
| - tableptr = NULL;
|
| - flag_mode = FLAG_CHAR;
|
| -@@ -31,8 +37,14 @@
|
| - numaliasm = 0;
|
| - aliasm = NULL;
|
| - forbiddenword = FORBIDDENWORD; // forbidden word signing flag
|
| ++ tablesize(0),
|
| + tableptr(NULL),
|
| + flag_mode(FLAG_CHAR),
|
| + complexprefixes(0),
|
| +@@ -99,8 +105,14 @@ HashMgr::HashMgr(const char* tpath, const char* apath, const char* key)
|
| + aliasm(NULL) {
|
| + langnum = 0;
|
| + csconv = 0;
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + // No tables to load, just the AF lines.
|
| + load_config(NULL, NULL);
|
| @@ -398,10 +385,10 @@ diff -u -r1.12 hashmgr.cxx
|
| +#endif
|
| if (ec) {
|
| /* error condition - what should we do here */
|
| - HUNSPELL_WARNING(stderr, "Hash Manager Error : %d\n",ec);
|
| -@@ -91,15 +103,58 @@
|
| - if (ignorechars) free(ignorechars);
|
| - if (ignorechars_utf16) free(ignorechars_utf16);
|
| + HUNSPELL_WARNING(stderr, "Hash Manager Error : %d\n", ec);
|
| +@@ -156,14 +168,57 @@ HashMgr::~HashMgr() {
|
| + #endif
|
| + #endif
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + EmptyHentryCache();
|
| @@ -411,7 +398,7 @@ diff -u -r1.12 hashmgr.cxx
|
| + }
|
| +#endif
|
| #ifdef MOZILLA_CLIENT
|
| - delete [] csconv;
|
| + delete[] csconv;
|
| #endif
|
| }
|
|
|
| @@ -434,8 +421,7 @@ diff -u -r1.12 hashmgr.cxx
|
| +
|
| // lookup a root word in the hashtable
|
|
|
| - struct hentry * HashMgr::lookup(const char *word) const
|
| - {
|
| + struct hentry* HashMgr::lookup(const char* word) const {
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + int affix_ids[hunspell::BDict::MAX_AFFIXES_PER_WORD];
|
| + int affix_count = bdict_reader->FindWord(word, affix_ids);
|
| @@ -455,67 +441,69 @@ diff -u -r1.12 hashmgr.cxx
|
| +
|
| + return AffixIDsToHentry(word_buf, affix_ids, affix_count);
|
| +#else
|
| - struct hentry * dp;
|
| - if (tableptr) {
|
| - dp = tableptr[hash(word)];
|
| -@@ -109,12 +164,14 @@
|
| - }
|
| + struct hentry* dp;
|
| + if (tableptr) {
|
| + dp = tableptr[hash(word)];
|
| +@@ -175,6 +230,7 @@ struct hentry* HashMgr::lookup(const char* word) const {
|
| }
|
| - return NULL;
|
| + }
|
| + return NULL;
|
| +#endif
|
| }
|
|
|
| // add a word to the hash table (private)
|
| - int HashMgr::add_word(const char * word, int wbl, int wcl, unsigned short * aff,
|
| - int al, const char * desc, bool onlyupcase)
|
| - {
|
| +@@ -184,6 +240,8 @@ int HashMgr::add_word(const std::string& in_word,
|
| + int al,
|
| + const std::string* in_desc,
|
| + bool onlyupcase) {
|
| ++// TODO: The following 40 lines or so are actually new. Should they be included?
|
| +#ifndef HUNSPELL_CHROME_CLIENT
|
| - bool upcasehomonym = false;
|
| - int descl = desc ? (aliasm ? sizeof(short) : strlen(desc) + 1) : 0;
|
| - // variable-length hash record with word and optional fields
|
| -@@ -206,6 +263,17 @@
|
| - if (hp->astr) free(hp->astr);
|
| - free(hp);
|
| - }
|
| + const std::string* word = &in_word;
|
| + const std::string* desc = in_desc;
|
| +
|
| +@@ -316,6 +374,17 @@ int HashMgr::add_word(const std::string& in_word,
|
| +
|
| + delete desc_copy;
|
| + delete word_copy;
|
| +#else
|
| -+ std::map<base::StringPiece, int>::iterator iter =
|
| -+ custom_word_to_affix_id_map_.find(word);
|
| -+ if(iter == custom_word_to_affix_id_map_.end()) { // word needs to be added
|
| -+ std::string* new_string_word = new std::string(word);
|
| -+ pointer_to_strings_.push_back(new_string_word);
|
| -+ base::StringPiece sp(*(new_string_word));
|
| -+ custom_word_to_affix_id_map_[sp] = 0; // no affixes for custom words
|
| -+ return 1;
|
| -+ }
|
| ++ std::map<base::StringPiece, int>::iterator iter =
|
| ++ custom_word_to_affix_id_map_.find(in_word);
|
| ++ if (iter == custom_word_to_affix_id_map_.end()) { // word needs to be added
|
| ++ std::string* new_string_word = new std::string(in_word);
|
| ++ pointer_to_strings_.push_back(new_string_word);
|
| ++ base::StringPiece sp(*(new_string_word));
|
| ++ custom_word_to_affix_id_map_[sp] = 0; // no affixes for custom words
|
| ++ return 1;
|
| ++ }
|
| +#endif
|
| - return 0;
|
| - }
|
| + return 0;
|
| + }
|
| +
|
| +@@ -376,6 +445,12 @@ int HashMgr::get_clen_and_captype(const std::string& word, int* captype) {
|
|
|
| -@@ -256,6 +324,12 @@
|
| // remove word (personal dictionary function for standalone applications)
|
| - int HashMgr::remove(const char * word)
|
| - {
|
| + int HashMgr::remove(const std::string& word) {
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+ std::map<base::StringPiece, int>::iterator iter =
|
| -+ custom_word_to_affix_id_map_.find(word);
|
| -+ if (iter != custom_word_to_affix_id_map_.end())
|
| -+ custom_word_to_affix_id_map_.erase(iter);
|
| ++ std::map<base::StringPiece, int>::iterator iter =
|
| ++ custom_word_to_affix_id_map_.find(word);
|
| ++ if (iter != custom_word_to_affix_id_map_.end())
|
| ++ custom_word_to_affix_id_map_.erase(iter);
|
| +#else
|
| - struct hentry * dp = lookup(word);
|
| - while (dp) {
|
| - if (dp->alen == 0 || !TESTAFF(dp->astr, forbiddenword, dp->alen)) {
|
| -@@ -270,6 +344,7 @@
|
| - }
|
| - dp = dp->next_homonym;
|
| + struct hentry* dp = lookup(word.c_str());
|
| + while (dp) {
|
| + if (dp->alen == 0 || !TESTAFF(dp->astr, forbiddenword, dp->alen)) {
|
| +@@ -392,6 +467,7 @@ int HashMgr::remove(const std::string& word) {
|
| }
|
| + dp = dp->next_homonym;
|
| + }
|
| +#endif
|
| - return 0;
|
| + return 0;
|
| }
|
|
|
| -@@ -339,6 +414,44 @@
|
| +@@ -465,6 +541,44 @@ int HashMgr::add_with_affix(const std::string& word, const std::string& example)
|
| + // walk the hash table entry by entry - null at end
|
| // initialize: col=-1; hp = NULL; hp = walk_hashtable(&col, hp);
|
| - struct hentry * HashMgr::walk_hashtable(int &col, struct hentry * hp) const
|
| - {
|
| + struct hentry* HashMgr::walk_hashtable(int& col, struct hentry* hp) const {
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + // Return NULL if dictionary is not valid.
|
| + if (!bdict_reader->IsValid())
|
| @@ -554,10 +542,10 @@ diff -u -r1.12 hashmgr.cxx
|
| + return InitHashEntry(&hash_entry.entry, sizeof(hash_entry),
|
| + &word[0], word_len, affix_ids[0]);
|
| +#else
|
| - if (hp && hp->next != NULL) return hp->next;
|
| + if (hp && hp->next != NULL)
|
| + return hp->next;
|
| for (col++; col < tablesize; col++) {
|
| - if (tableptr[col]) return tableptr[col];
|
| -@@ -346,11 +459,13 @@
|
| +@@ -474,10 +588,12 @@ struct hentry* HashMgr::walk_hashtable(int& col, struct hentry* hp) const {
|
| // null at end and reset to start
|
| col = -1;
|
| return NULL;
|
| @@ -565,13 +553,12 @@ diff -u -r1.12 hashmgr.cxx
|
| }
|
|
|
| // load a munched word list and build a hash table on the fly
|
| - int HashMgr::load_tables(const char * tpath, const char * key)
|
| - {
|
| + int HashMgr::load_tables(const char* tpath, const char* key) {
|
| +#ifndef HUNSPELL_CHROME_CLIENT
|
| - int al;
|
| - char * ap;
|
| - char * dp;
|
| -@@ -471,6 +586,7 @@
|
| + // open dictionary file
|
| + FileMgr* dict = new FileMgr(tpath, key);
|
| + if (dict == NULL)
|
| +@@ -606,12 +722,16 @@ int HashMgr::load_tables(const char* tpath, const char* key) {
|
| }
|
|
|
| delete dict;
|
| @@ -579,39 +566,38 @@ diff -u -r1.12 hashmgr.cxx
|
| return 0;
|
| }
|
|
|
| -@@ -479,6 +595,9 @@
|
| -
|
| - int HashMgr::hash(const char * word) const
|
| - {
|
| + // the hash function is a simple load and rotate
|
| + // algorithm borrowed
|
| + int HashMgr::hash(const char* word) const {
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + return 0;
|
| +#else
|
| - long hv = 0;
|
| - for (int i=0; i < 4 && *word != 0; i++)
|
| - hv = (hv << 8) | (*word++);
|
| -@@ -487,6 +606,7 @@
|
| - hv ^= (*word++);
|
| - }
|
| - return (unsigned long) hv % tablesize;
|
| + unsigned long hv = 0;
|
| + for (int i = 0; i < 4 && *word != 0; i++)
|
| + hv = (hv << 8) | (*word++);
|
| +@@ -620,6 +740,7 @@ int HashMgr::hash(const char* word) const {
|
| + hv ^= (*word++);
|
| + }
|
| + return (unsigned long)hv % tablesize;
|
| +#endif
|
| }
|
|
|
| - int HashMgr::decode_flags(unsigned short ** result, char * flags, FileMgr * af) {
|
| -@@ -607,7 +727,12 @@
|
| + int HashMgr::decode_flags(unsigned short** result, const std::string& flags, FileMgr* af) const {
|
| +@@ -829,7 +950,12 @@ int HashMgr::load_config(const char* affpath, const char* key) {
|
| int firstline = 1;
|
| -
|
| +
|
| // open the affix file
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + hunspell::LineIterator iterator = bdict_reader->GetOtherLineIterator();
|
| + FileMgr * afflst = new FileMgr(&iterator);
|
| +#else
|
| - FileMgr * afflst = new FileMgr(affpath, key);
|
| + FileMgr* afflst = new FileMgr(affpath, key);
|
| +#endif
|
| if (!afflst) {
|
| - HUNSPELL_WARNING(stderr, "Error - could not open affix description file %s\n",affpath);
|
| - return 1;
|
| -@@ -802,6 +927,121 @@
|
| - return 0;
|
| + HUNSPELL_WARNING(
|
| + stderr, "Error - could not open affix description file %s\n", affpath);
|
| +@@ -1058,6 +1184,122 @@ bool HashMgr::parse_aliasf(const std::string& line, FileMgr* af) {
|
| + return true;
|
| }
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| @@ -622,7 +608,8 @@ diff -u -r1.12 hashmgr.cxx
|
| + // Read in all the AF lines which tell us the rules for each affix group ID.
|
| + hunspell::LineIterator iterator = bdict_reader->GetAfLineIterator();
|
| + FileMgr afflst(&iterator);
|
| -+ while (char* line = afflst.getline()) {
|
| ++ std::string line;
|
| ++ while (afflst.getline(line)) {
|
| + int rv = parse_aliasf(line, &afflst);
|
| + if (rv)
|
| + return rv;
|
| @@ -729,22 +716,18 @@ diff -u -r1.12 hashmgr.cxx
|
| +}
|
| +#endif
|
| +
|
| - int HashMgr::is_aliasf() {
|
| - return (aliasf != NULL);
|
| + int HashMgr::is_aliasf() const {
|
| + return (aliasf != NULL);
|
| }
|
| -Index: src/hunspell/hashmgr.hxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hashmgr.hxx,v
|
| -retrieving revision 1.3
|
| -diff -u -r1.3 hashmgr.hxx
|
| ---- src/hunspell/hashmgr.hxx 15 Apr 2010 11:22:08 -0000 1.3
|
| -+++ src/hunspell/hashmgr.hxx 29 May 2014 01:05:07 -0000
|
| -@@ -8,10 +8,25 @@
|
| - #include "htypes.hxx"
|
| +diff --git a/third_party/hunspell/src/hunspell/hashmgr.hxx b/third_party/hunspell/src/hunspell/hashmgr.hxx
|
| +index a158a16..9714a90 100644
|
| +--- a/third_party/hunspell/src/hunspell/hashmgr.hxx
|
| ++++ b/third_party/hunspell/src/hunspell/hashmgr.hxx
|
| +@@ -82,9 +82,23 @@
|
| #include "filemgr.hxx"
|
| + #include "w_char.hxx"
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+#include <string>
|
| +#include <map>
|
| +
|
| +#include "base/stl_util.h"
|
| @@ -754,21 +737,20 @@ diff -u -r1.3 hashmgr.hxx
|
| +
|
| enum flag { FLAG_CHAR, FLAG_LONG, FLAG_NUM, FLAG_UNI };
|
|
|
| - class LIBHUNSPELL_DLL_EXPORTED HashMgr
|
| - {
|
| + class HashMgr {
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + // Not owned by this class, owned by the Hunspell object.
|
| + hunspell::BDictReader* bdict_reader;
|
| + std::map<base::StringPiece, int> custom_word_to_affix_id_map_;
|
| + std::vector<std::string*> pointer_to_strings_;
|
| +#endif
|
| - int tablesize;
|
| - struct hentry ** tableptr;
|
| - int userword;
|
| -@@ -34,7 +49,23 @@
|
| -
|
| + int tablesize;
|
| + struct hentry** tableptr;
|
| + flag flag_mode;
|
| +@@ -104,7 +118,23 @@ class HashMgr {
|
| + char** aliasm;
|
|
|
| - public:
|
| + public:
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + HashMgr(hunspell::BDictReader* reader);
|
| +
|
| @@ -784,15 +766,15 @@ diff -u -r1.3 hashmgr.hxx
|
| + // This function allows that cache to be emptied and not grow infinitely.
|
| + void EmptyHentryCache();
|
| +#else
|
| - HashMgr(const char * tpath, const char * apath, const char * key = NULL);
|
| + HashMgr(const char* tpath, const char* apath, const char* key = NULL);
|
| +#endif
|
| ~HashMgr();
|
|
|
| - struct hentry * lookup(const char *) const;
|
| -@@ -59,6 +90,40 @@
|
| - int al, const char * desc, bool onlyupcase);
|
| - int load_config(const char * affpath, const char * key);
|
| - int parse_aliasf(char * line, FileMgr * af);
|
| + struct hentry* lookup(const char*) const;
|
| +@@ -134,6 +164,40 @@ class HashMgr {
|
| + bool onlyupcase);
|
| + int load_config(const char* affpath, const char* key);
|
| + bool parse_aliasf(const std::string& line, FileMgr* af);
|
| +
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + // Loads the AF lines from a BDICT.
|
| @@ -827,17 +809,14 @@ diff -u -r1.3 hashmgr.hxx
|
| + HEntryCache hentry_cache;
|
| +#endif
|
| +
|
| - int add_hidden_capitalized_word(char * word, int wbl, int wcl,
|
| - unsigned short * flags, int al, char * dp, int captype);
|
| - int parse_aliasm(char * line, FileMgr * af);
|
| -Index: src/hunspell/htypes.hxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/htypes.hxx,v
|
| -retrieving revision 1.3
|
| -diff -u -r1.3 htypes.hxx
|
| ---- src/hunspell/htypes.hxx 6 Sep 2010 07:58:53 -0000 1.3
|
| -+++ src/hunspell/htypes.hxx 29 May 2014 01:05:07 -0000
|
| -@@ -1,6 +1,16 @@
|
| + int add_hidden_capitalized_word(const std::string& word,
|
| + int wcl,
|
| + unsigned short* flags,
|
| +diff --git a/third_party/hunspell/src/hunspell/htypes.hxx b/third_party/hunspell/src/hunspell/htypes.hxx
|
| +index d244394..05ef6af 100644
|
| +--- a/third_party/hunspell/src/hunspell/htypes.hxx
|
| ++++ b/third_party/hunspell/src/hunspell/htypes.hxx
|
| +@@ -41,6 +41,16 @@
|
| #ifndef _HTYPES_HXX_
|
| #define _HTYPES_HXX_
|
|
|
| @@ -851,112 +830,156 @@ diff -u -r1.3 htypes.hxx
|
| +#define MAXDELEN 8192
|
| +#endif // HUNSPELL_CHROME_CLIENT
|
| +
|
| - #define ROTATE_LEN 5
|
| -
|
| - #define ROTATE(v,q) \
|
| -Index: src/hunspell/hunspell.cxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hunspell.cxx,v
|
| -retrieving revision 1.29
|
| -diff -u -r1.29 hunspell.cxx
|
| ---- src/hunspell/hunspell.cxx 23 Jun 2011 09:21:50 -0000 1.29
|
| -+++ src/hunspell/hunspell.cxx 29 May 2014 01:05:07 -0000
|
| -@@ -7,20 +7,37 @@
|
| + #define ROTATE_LEN 5
|
|
|
| + #define ROTATE(v, q) \
|
| +diff --git a/third_party/hunspell/src/hunspell/hunspell.cxx b/third_party/hunspell/src/hunspell/hunspell.cxx
|
| +index 114570f..1110ee0 100644
|
| +--- a/third_party/hunspell/src/hunspell/hunspell.cxx
|
| ++++ b/third_party/hunspell/src/hunspell/hunspell.cxx
|
| +@@ -79,6 +79,9 @@
|
| #include "hunspell.hxx"
|
| + #include "suggestmgr.hxx"
|
| #include "hunspell.h"
|
| +#ifndef HUNSPELL_CHROME_CLIENT
|
| - #ifndef MOZILLA_CLIENT
|
| - # include "config.h"
|
| - #endif
|
| ++# include "config.h"
|
| +#endif
|
| #include "csutil.hxx"
|
|
|
| + #include <limits>
|
| +@@ -89,9 +92,15 @@
|
| + class HunspellImpl
|
| + {
|
| + public:
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+Hunspell::Hunspell(const unsigned char* bdict_data, size_t bdict_length)
|
| ++ HunspellImpl(const unsigned char* bdict_data, size_t bdict_length);
|
| +#else
|
| - Hunspell::Hunspell(const char * affpath, const char * dpath, const char * key)
|
| + HunspellImpl(const char* affpath, const char* dpath, const char* key);
|
| +#endif
|
| - {
|
| - encoding = NULL;
|
| - csconv = NULL;
|
| - utf8 = 0;
|
| - complexprefixes = 0;
|
| + ~HunspellImpl();
|
| +#ifndef HUNSPELL_CHROME_CLIENT
|
| - affixpath = mystrdup(affpath);
|
| + int add_dic(const char* dpath, const char* key);
|
| +#endif
|
| - maxdic = 0;
|
| + std::vector<std::string> suffix_suggest(const std::string& root_word);
|
| + std::vector<std::string> generate(const std::string& word, const std::vector<std::string>& pl);
|
| + std::vector<std::string> generate(const std::string& word, const std::string& pattern);
|
| +@@ -115,7 +124,9 @@ private:
|
| + AffixMgr* pAMgr;
|
| + std::vector<HashMgr*> m_HMgrs;
|
| + SuggestMgr* pSMgr;
|
| ++#ifndef HUNSPELL_CHROME_CLIENT // We are using BDict instead.
|
| + char* affixpath;
|
| ++#endif
|
| + std::string encoding;
|
| + struct cs_info* csconv;
|
| + int langnum;
|
| +@@ -123,6 +134,11 @@ private:
|
| + int complexprefixes;
|
| + std::vector<std::string> wordbreak;
|
| +
|
| ++#ifdef HUNSPELL_CHROME_CLIENT
|
| ++ // Not owned by us, owned by the Hunspell object.
|
| ++ hunspell::BDictReader* bdict_reader;
|
| ++#endif
|
| ++
|
| + private:
|
| + void cleanword(std::string& dest, const std::string&, int* pcaptype, int* pabbrev);
|
| + size_t cleanword2(std::string& dest,
|
| +@@ -152,22 +168,43 @@ private:
|
| + HunspellImpl& operator=(const HunspellImpl&);
|
| + };
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+ bdict_reader = new hunspell::BDictReader;
|
| -+ bdict_reader->Init(bdict_data, bdict_length);
|
| ++Hunspell::Hunspell(const unsigned char* bdict_data, size_t bdict_length)
|
| ++ : m_Impl(new HunspellImpl(bdict_data, bdict_length)) {
|
| ++#else
|
| + Hunspell::Hunspell(const char* affpath, const char* dpath, const char* key)
|
| + : m_Impl(new HunspellImpl(affpath, dpath, key)) {
|
| ++#endif
|
| + }
|
| +
|
| ++#ifdef HUNSPELL_CHROME_CLIENT
|
| ++HunspellImpl::HunspellImpl(const unsigned char* bdict_data, size_t bdict_length) {
|
| ++#else
|
| + HunspellImpl::HunspellImpl(const char* affpath, const char* dpath, const char* key) {
|
| ++#endif
|
| + csconv = NULL;
|
| + utf8 = 0;
|
| + complexprefixes = 0;
|
| ++#ifndef HUNSPELL_CHROME_CLIENT
|
| + affixpath = mystrdup(affpath);
|
| ++#endif
|
| +
|
| -+ pHMgr[0] = new HashMgr(bdict_reader);
|
| -+ if (pHMgr[0]) maxdic = 1;
|
| ++#ifdef HUNSPELL_CHROME_CLIENT
|
| ++ bdict_reader = new hunspell::BDictReader;
|
| ++ bdict_reader->Init(bdict_data, bdict_length);
|
| +
|
| + /* first set up the hash manager */
|
| ++ m_HMgrs.push_back(new HashMgr(bdict_reader));
|
| +
|
| -+ pAMgr = new AffixMgr(bdict_reader, pHMgr, &maxdic);
|
| ++ pAMgr = new AffixMgr(bdict_reader, m_HMgrs); // TODO: 'key' ?
|
| +#else
|
| - /* first set up the hash manager */
|
| - pHMgr[0] = new HashMgr(dpath, affpath, key);
|
| - if (pHMgr[0]) maxdic = 1;
|
| -@@ -28,6 +45,7 @@
|
| - /* next set up the affix manager */
|
| - /* it needs access to the hash manager lookup methods */
|
| - pAMgr = new AffixMgr(affpath, pHMgr, &maxdic, key);
|
| ++ /* first set up the hash manager */
|
| + m_HMgrs.push_back(new HashMgr(dpath, affpath, key));
|
| +
|
| + /* next set up the affix manager */
|
| + /* it needs access to the hash manager lookup methods */
|
| + pAMgr = new AffixMgr(affpath, m_HMgrs, key);
|
| +#endif
|
|
|
| - /* get the preferred try string and the dictionary */
|
| - /* encoding from the Affix Manager for that dictionary */
|
| -@@ -41,7 +59,11 @@
|
| - wordbreak = pAMgr->get_breaktable();
|
| + /* get the preferred try string and the dictionary */
|
| + /* encoding from the Affix Manager for that dictionary */
|
| +@@ -181,7 +218,11 @@ HunspellImpl::HunspellImpl(const char* affpath, const char* dpath, const char* k
|
| + wordbreak = pAMgr->get_breaktable();
|
|
|
| - /* and finally set up the suggestion manager */
|
| + /* and finally set up the suggestion manager */
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+ pSMgr = new SuggestMgr(bdict_reader, try_string, MAXSUGGESTION, pAMgr);
|
| ++ pSMgr = new SuggestMgr(bdict_reader, try_string, MAXSUGGESTION, pAMgr);
|
| +#else
|
| - pSMgr = new SuggestMgr(try_string, MAXSUGGESTION, pAMgr);
|
| + pSMgr = new SuggestMgr(try_string, MAXSUGGESTION, pAMgr);
|
| +#endif
|
| - if (try_string) free(try_string);
|
| + if (try_string)
|
| + free(try_string);
|
| }
|
| -
|
| -@@ -59,10 +81,16 @@
|
| - csconv= NULL;
|
| - if (encoding) free(encoding);
|
| - encoding = NULL;
|
| +@@ -201,11 +242,17 @@ HunspellImpl::~HunspellImpl() {
|
| + delete[] csconv;
|
| + #endif
|
| + csconv = NULL;
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + if (bdict_reader) delete bdict_reader;
|
| + bdict_reader = NULL;
|
| +#else
|
| - if (affixpath) free(affixpath);
|
| - affixpath = NULL;
|
| + if (affixpath)
|
| + free(affixpath);
|
| + affixpath = NULL;
|
| +#endif
|
| }
|
|
|
| +#ifndef HUNSPELL_CHROME_CLIENT
|
| // load extra dictionaries
|
| - int Hunspell::add_dic(const char * dpath, const char * key) {
|
| - if (maxdic == MAXDIC || !affixpath) return 1;
|
| -@@ -70,6 +98,7 @@
|
| - if (pHMgr[maxdic]) maxdic++; else return 1;
|
| - return 0;
|
| + int Hunspell::add_dic(const char* dpath, const char* key) {
|
| + return m_Impl->add_dic(dpath, key);
|
| +@@ -218,6 +265,7 @@ int HunspellImpl::add_dic(const char* dpath, const char* key) {
|
| + m_HMgrs.push_back(new HashMgr(dpath, affixpath, key));
|
| + return 0;
|
| }
|
| +#endif
|
|
|
| // make a copy of src at destination while removing all leading
|
| // blanks and removing any trailing periods after recording
|
| -@@ -322,6 +351,9 @@
|
| +@@ -411,6 +459,9 @@ bool Hunspell::spell(const std::string& word, int* info, std::string* root) {
|
| + }
|
|
|
| - int Hunspell::spell(const char * word, int * info, char ** root)
|
| - {
|
| + bool HunspellImpl::spell(const std::string& word, int* info, std::string* root) {
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+ if (pHMgr[0]) pHMgr[0]->EmptyHentryCache();
|
| ++ if (m_HMgrs[0]) m_HMgrs[0]->EmptyHentryCache();
|
| +#endif
|
| - struct hentry * rv=NULL;
|
| - // need larger vector. For example, Turkish capital letter I converted a
|
| - // 2-byte UTF-8 character (dotless i) by mkallsmall.
|
| -@@ -586,6 +618,13 @@
|
| + struct hentry* rv = NULL;
|
| +
|
| + int info2 = 0;
|
| +@@ -717,6 +768,13 @@ struct hentry* HunspellImpl::checkword(const std::string& w, int* info, std::str
|
| if (!len)
|
| - return NULL;
|
| + return NULL;
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + // We need to check if the word length is valid to make coverity (Event
|
| @@ -967,104 +990,128 @@ diff -u -r1.29 hunspell.cxx
|
| +
|
| // word reversing wrapper for complex prefixes
|
| if (complexprefixes) {
|
| - if (word != w2) {
|
| -@@ -675,6 +714,9 @@
|
| + if (!usebuffer) {
|
| +@@ -829,6 +887,9 @@ std::vector<std::string> Hunspell::suggest(const std::string& word) {
|
| + }
|
|
|
| - int Hunspell::suggest(char*** slst, const char * word)
|
| - {
|
| + std::vector<std::string> HunspellImpl::suggest(const std::string& word) {
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+ if (pHMgr[0]) pHMgr[0]->EmptyHentryCache();
|
| ++ if (m_HMgrs[0]) m_HMgrs[0]->EmptyHentryCache();
|
| +#endif
|
| + std::vector<std::string> slst;
|
| +
|
| int onlycmpdsug = 0;
|
| - char cw[MAXWORDUTF8LEN];
|
| - char wspace[MAXWORDUTF8LEN];
|
| -@@ -1921,13 +1963,21 @@
|
| +@@ -992,9 +1053,9 @@ std::vector<std::string> HunspellImpl::suggest(const std::string& word) {
|
| + w.append(slst[j].substr(pos + 1));
|
| + (void)spell(w, &info, NULL);
|
| + if ((info & SPELL_COMPOUND) && (info & SPELL_FORBIDDEN)) {
|
| +- slst[pos] = ' ';
|
| ++ slst[j][pos] = ' ';
|
| + } else
|
| +- slst[pos] = '-';
|
| ++ slst[j][pos] = '-';
|
| + }
|
| + }
|
| + }
|
| +@@ -1845,22 +1906,32 @@ int Hunspell::generate(char*** slst, const char* word, const char* pattern) {
|
| + }
|
|
|
| - Hunhandle *Hunspell_create(const char * affpath, const char * dpath)
|
| - {
|
| + Hunhandle* Hunspell_create(const char* affpath, const char* dpath) {
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + return NULL;
|
| +#else
|
| - return (Hunhandle*)(new Hunspell(affpath, dpath));
|
| + return (Hunhandle*)(new Hunspell(affpath, dpath));
|
| +#endif
|
| }
|
|
|
| - Hunhandle *Hunspell_create_key(const char * affpath, const char * dpath,
|
| - const char * key)
|
| - {
|
| + Hunhandle* Hunspell_create_key(const char* affpath,
|
| + const char* dpath,
|
| + const char* key) {
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + return NULL;
|
| +#else
|
| - return (Hunhandle*)(new Hunspell(affpath, dpath, key));
|
| + return reinterpret_cast<Hunhandle*>(new Hunspell(affpath, dpath, key));
|
| +#endif
|
| }
|
|
|
| - void Hunspell_destroy(Hunhandle *pHunspell)
|
| -Index: src/hunspell/hunspell.hxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hunspell.hxx,v
|
| -retrieving revision 1.6
|
| -diff -u -r1.6 hunspell.hxx
|
| ---- src/hunspell/hunspell.hxx 21 Jan 2011 17:30:41 -0000 1.6
|
| -+++ src/hunspell/hunspell.hxx 29 May 2014 01:05:07 -0000
|
| -@@ -5,6 +5,10 @@
|
| - #include "suggestmgr.hxx"
|
| - #include "langnum.hxx"
|
| + void Hunspell_destroy(Hunhandle* pHunspell) {
|
| + delete reinterpret_cast<Hunspell*>(pHunspell);
|
| + }
|
|
|
| -+#ifdef HUNSPELL_CHROME_CLIENT
|
| -+#include "third_party/hunspell/google/bdict_reader.h"
|
| ++#ifndef HUNSPELL_CHROME_CLIENT
|
| + int Hunspell_add_dic(Hunhandle* pHunspell, const char* dpath) {
|
| + return reinterpret_cast<Hunspell*>(pHunspell)->add_dic(dpath);
|
| + }
|
| +#endif
|
| -+
|
| - #define SPELL_XML "<?xml?>"
|
|
|
| - #define MAXDIC 20
|
| -@@ -23,7 +27,9 @@
|
| - HashMgr* pHMgr[MAXDIC];
|
| - int maxdic;
|
| - SuggestMgr* pSMgr;
|
| -+#ifndef HUNSPELL_CHROME_CLIENT // We are using BDict instead.
|
| - char * affixpath;
|
| -+#endif
|
| - char * encoding;
|
| - struct cs_info * csconv;
|
| - int langnum;
|
| -@@ -31,17 +37,28 @@
|
| - int complexprefixes;
|
| - char** wordbreak;
|
| + int Hunspell_spell(Hunhandle* pHunspell, const char* word) {
|
| + return reinterpret_cast<Hunspell*>(pHunspell)->spell(std::string(word));
|
| +diff --git a/third_party/hunspell/src/hunspell/hunspell.hxx b/third_party/hunspell/src/hunspell/hunspell.hxx
|
| +index db25bae..251d58e 100644
|
| +--- a/third_party/hunspell/src/hunspell/hunspell.hxx
|
| ++++ b/third_party/hunspell/src/hunspell/hunspell.hxx
|
| +@@ -78,6 +78,10 @@
|
| + #include <string>
|
| + #include <vector>
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+ // Not owned by us, owned by the Hunspell object.
|
| -+ hunspell::BDictReader* bdict_reader;
|
| ++#include "third_party/hunspell/google/bdict_reader.h"
|
| +#endif
|
| +
|
| - public:
|
| + #define SPELL_XML "<?xml?>"
|
|
|
| - /* Hunspell(aff, dic) - constructor of Hunspell class
|
| - * input: path of affix file and dictionary file
|
| + #define MAXSUGGESTION 15
|
| +@@ -111,11 +115,17 @@ class LIBHUNSPELL_DLL_EXPORTED Hunspell {
|
| + * long path names (without the long path prefix Hunspell will use fopen()
|
| + * with system-dependent character encoding instead of _wfopen()).
|
| */
|
| -
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + Hunspell(const unsigned char* bdict_data, size_t bdict_length);
|
| +#else
|
| - Hunspell(const char * affpath, const char * dpath, const char * key = NULL);
|
| + Hunspell(const char* affpath, const char* dpath, const char* key = NULL);
|
| +#endif
|
| ~Hunspell();
|
|
|
| +#ifndef HUNSPELL_CHROME_CLIENT
|
| /* load extra dictionaries (only dic files) */
|
| - int add_dic(const char * dpath, const char * key = NULL);
|
| + int add_dic(const char* dpath, const char* key = NULL);
|
| +#endif
|
|
|
| /* spell(word) - spellcheck word
|
| - * output: 0 = bad word, not 0 = good word
|
| -Index: src/hunspell/replist.hxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/replist.hxx,v
|
| -retrieving revision 1.2
|
| -diff -u -r1.2 replist.hxx
|
| ---- src/hunspell/replist.hxx 15 Apr 2010 11:22:09 -0000 1.2
|
| -+++ src/hunspell/replist.hxx 29 May 2014 01:05:07 -0000
|
| -@@ -2,6 +2,12 @@
|
| + * output: false = bad word, true = good word
|
| +diff --git a/third_party/hunspell/src/hunspell/replist.cxx b/third_party/hunspell/src/hunspell/replist.cxx
|
| +index 8404947..3128420 100644
|
| +--- a/third_party/hunspell/src/hunspell/replist.cxx
|
| ++++ b/third_party/hunspell/src/hunspell/replist.cxx
|
| +@@ -167,6 +167,7 @@ int RepList::add(const std::string& in_pat1, const std::string& pat2) {
|
| + mystrrep(r->outstrings[type], "_", " ");
|
| + dat[pos++] = r;
|
| + // sort to the right place in the list
|
| ++#if 0
|
| + int i;
|
| + for (i = pos - 1; i > 0; i--) {
|
| + int c = strncmp(r->pattern.c_str(), dat[i-1]->pattern.c_str(), dat[i-1]->pattern.size());
|
| +@@ -184,6 +185,15 @@ int RepList::add(const std::string& in_pat1, const std::string& pat2) {
|
| + }
|
| + memmove(dat + i + 1, dat + i, (pos - i - 1) * sizeof(replentry *));
|
| + dat[i] = r;
|
| ++#else
|
| ++ for (int i = pos - 1; i > 0; i--) {
|
| ++ r = dat[i];
|
| ++ if (r->pattern < dat[i - 1]->pattern) {
|
| ++ dat[i] = dat[i - 1];
|
| ++ dat[i - 1] = r;
|
| ++ } else break;
|
| ++ }
|
| ++#endif
|
| + return 0;
|
| + }
|
| +
|
| +diff --git a/third_party/hunspell/src/hunspell/replist.hxx b/third_party/hunspell/src/hunspell/replist.hxx
|
| +index ccf29b5c..176ccec 100644
|
| +--- a/third_party/hunspell/src/hunspell/replist.hxx
|
| ++++ b/third_party/hunspell/src/hunspell/replist.hxx
|
| +@@ -75,6 +75,12 @@
|
| #ifndef _REPLIST_HXX_
|
| #define _REPLIST_HXX_
|
|
|
| @@ -1074,19 +1121,16 @@ diff -u -r1.2 replist.hxx
|
| +#undef near
|
| +#endif
|
| +
|
| - #include "hunvisapi.h"
|
| -
|
| #include "w_char.hxx"
|
| -Index: src/hunspell/suggestmgr.cxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/suggestmgr.cxx,v
|
| -retrieving revision 1.24
|
| -diff -u -r1.24 suggestmgr.cxx
|
| ---- src/hunspell/suggestmgr.cxx 14 Feb 2011 21:47:24 -0000 1.24
|
| -+++ src/hunspell/suggestmgr.cxx 29 May 2014 01:05:07 -0000
|
| -@@ -12,9 +12,114 @@
|
|
|
| - const w_char W_VLINE = { '\0', '|' };
|
| + #include <string>
|
| +diff --git a/third_party/hunspell/src/hunspell/suggestmgr.cxx b/third_party/hunspell/src/hunspell/suggestmgr.cxx
|
| +index 7a9dafa..55f99b6 100644
|
| +--- a/third_party/hunspell/src/hunspell/suggestmgr.cxx
|
| ++++ b/third_party/hunspell/src/hunspell/suggestmgr.cxx
|
| +@@ -82,7 +82,112 @@
|
| +
|
| + const w_char W_VLINE = {'\0', '|'};
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| +namespace {
|
| @@ -1192,213 +1236,142 @@ diff -u -r1.24 suggestmgr.cxx
|
| +{
|
| + bdict_reader = reader;
|
| +#else
|
| - SuggestMgr::SuggestMgr(const char * tryme, int maxn,
|
| - AffixMgr * aptr)
|
| - {
|
| + SuggestMgr::SuggestMgr(const char* tryme, unsigned int maxn, AffixMgr* aptr) {
|
| +#endif
|
| -
|
| - // register affix manager and check in string of chars to
|
| + // register affix manager and check in string of chars to
|
| // try when building candidate suggestions
|
| -@@ -407,6 +512,49 @@
|
| - int lenr, lenp;
|
| + pAMgr = aptr;
|
| +@@ -409,6 +514,21 @@ int SuggestMgr::replchars(std::vector<std::string>& wlst,
|
| int wl = strlen(word);
|
| - if (wl < 2 || ! pAMgr) return ns;
|
| -+
|
| + if (wl < 2 || !pAMgr)
|
| + return wlst.size();
|
| ++
|
| ++// TODO: wrong, 'ns' doesn't exist any more
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + const char *pattern, *pattern2;
|
| + hunspell::ReplacementIterator iterator = bdict_reader->GetReplacementIterator();
|
| + while (iterator.GetNext(&pattern, &pattern2)) {
|
| -+ r = word;
|
| -+ lenr = strlen(pattern2);
|
| -+ lenp = strlen(pattern);
|
| -+
|
| -+ // search every occurence of the pattern in the word
|
| -+ while ((r=strstr(r, pattern)) != NULL) {
|
| -+ strcpy(candidate, word);
|
| -+ if (r-word + lenr + strlen(r+lenp) >= MAXLNLEN) break;
|
| -+ strcpy(candidate+(r-word), pattern2);
|
| -+ strcpy(candidate+(r-word)+lenr, r+lenp);
|
| -+ ns = testsug(wlst, candidate, wl-lenp+lenr, ns, cpdsuggest, NULL, NULL);
|
| -+ if (ns == -1) return -1;
|
| -+ // check REP suggestions with space
|
| -+ char * sp = strchr(candidate, ' ');
|
| -+ if (sp) {
|
| -+ char * prev = candidate;
|
| -+ while (sp) {
|
| -+ *sp = '\0';
|
| -+ if (checkword(prev, strlen(prev), 0, NULL, NULL)) {
|
| -+ int oldns = ns;
|
| -+ *sp = ' ';
|
| -+ ns = testsug(wlst, sp + 1, strlen(sp + 1), ns, cpdsuggest, NULL, NULL);
|
| -+ if (ns == -1) return -1;
|
| -+ if (oldns < ns) {
|
| -+ free(wlst[ns - 1]);
|
| -+ wlst[ns - 1] = mystrdup(candidate);
|
| -+ if (!wlst[ns - 1]) return -1;
|
| -+ }
|
| -+ }
|
| -+ *sp = ' ';
|
| -+ prev = sp + 1;
|
| -+ sp = strchr(prev, ' ');
|
| -+ }
|
| -+ }
|
| -+ r++; // search for the next letter
|
| -+ }
|
| -+ }
|
| ++ const char* r = word;
|
| ++ size_t lenr = strlen(pattern2);
|
| ++ size_t lenp = strlen(pattern);
|
| ++
|
| ++ // search every occurence of the pattern in the word
|
| ++ while ((r=strstr(r, pattern)) != NULL) {
|
| ++ candidate = word;
|
| ++ candidate.replace(r-word, lenp, pattern2);
|
| +#else
|
| - int numrep = pAMgr->get_numrep();
|
| - struct replentry* reptable = pAMgr->get_reptable();
|
| - if (reptable==NULL) return ns;
|
| -@@ -448,6 +596,7 @@
|
| - r++; // search for the next letter
|
| - }
|
| - }
|
| + const std::vector<replentry>& reptable = pAMgr->get_reptable();
|
| + for (size_t i = 0; i < reptable.size(); ++i) {
|
| + const char* r = word;
|
| +@@ -428,6 +548,7 @@ int SuggestMgr::replchars(std::vector<std::string>& wlst,
|
| + candidate.resize(r - word);
|
| + candidate.append(reptable[i].outstrings[type]);
|
| + candidate.append(r + reptable[i].pattern.size());
|
| +#endif
|
| - return ns;
|
| - }
|
| -
|
| -@@ -678,7 +827,9 @@
|
| - // error is missing a letter it needs
|
| - int SuggestMgr::forgotchar(char ** wlst, const char * word, int ns, int cpdsuggest)
|
| - {
|
| -- char candidate[MAXSWUTF8L];
|
| -+ // TODO(rouslan): Remove the interim change below when this patch lands:
|
| -+ // http://sf.net/tracker/?func=detail&aid=3595024&group_id=143754&atid=756395
|
| -+ char candidate[MAXSWUTF8L + 4];
|
| - char * p;
|
| - clock_t timelimit = clock();
|
| - int timer = MINTIMER;
|
| -@@ -700,8 +851,10 @@
|
| - // error is missing a letter it needs
|
| - int SuggestMgr::forgotchar_utf(char ** wlst, const w_char * word, int wl, int ns, int cpdsuggest)
|
| - {
|
| -- w_char candidate_utf[MAXSWL];
|
| -- char candidate[MAXSWUTF8L];
|
| -+ // TODO(rouslan): Remove the interim change below when this patch lands:
|
| -+ // http://sf.net/tracker/?func=detail&aid=3595024&group_id=143754&atid=756395
|
| -+ w_char candidate_utf[MAXSWL + 1];
|
| -+ char candidate[MAXSWUTF8L + 4];
|
| - w_char * p;
|
| - clock_t timelimit = clock();
|
| - int timer = MINTIMER;
|
| -@@ -1057,6 +1210,9 @@
|
| + testsug(wlst, candidate, cpdsuggest, NULL, NULL);
|
| + // check REP suggestions with space
|
| + size_t sp = candidate.find(' ');
|
| +@@ -1047,6 +1168,9 @@ void SuggestMgr::ngsuggest(std::vector<std::string>& wlst,
|
|
|
| struct hentry* hp = NULL;
|
| int col = -1;
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + ScopedHashEntryFactory hash_entry_factory;
|
| +#endif
|
| - phonetable * ph = (pAMgr) ? pAMgr->get_phonetable() : NULL;
|
| - char target[MAXSWUTF8L];
|
| - char candidate[MAXSWUTF8L];
|
| -@@ -1115,7 +1271,11 @@
|
| + phonetable* ph = (pAMgr) ? pAMgr->get_phonetable() : NULL;
|
| + std::string target;
|
| + std::string candidate;
|
| +@@ -1109,7 +1233,11 @@ void SuggestMgr::ngsuggest(std::vector<std::string>& wlst,
|
|
|
| - if (sc > scores[lp]) {
|
| - scores[lp] = sc;
|
| + if (sc > scores[lp]) {
|
| + scores[lp] = sc;
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| -+ roots[lp] = hash_entry_factory.CreateScopedHashEntry(lp, hp);
|
| ++ roots[lp] = hash_entry_factory.CreateScopedHashEntry(lp, hp);
|
| +#else
|
| - roots[lp] = hp;
|
| + roots[lp] = hp;
|
| +#endif
|
| - lval = sc;
|
| - for (j=0; j < MAX_ROOTS; j++)
|
| - if (scores[j] < lval) {
|
| -@@ -1948,16 +2108,14 @@
|
| + lval = sc;
|
| + for (int j = 0; j < MAX_ROOTS; j++)
|
| + if (scores[j] < lval) {
|
| +@@ -1137,6 +1265,7 @@ void SuggestMgr::ngsuggest(std::vector<std::string>& wlst,
|
| + int thresh = 0;
|
| + for (int sp = 1; sp < 4; sp++) {
|
| + if (utf8) {
|
| ++ u8_u16(u8, word);
|
| + for (int k = sp; k < n; k += 4) {
|
| + u8[k].l = '*';
|
| + u8[k].h = 0;
|
| +@@ -1968,8 +2097,8 @@ void SuggestMgr::lcs(const char* s,
|
| m = strlen(s);
|
| n = strlen(s2);
|
| }
|
| -- c = (char *) malloc((m + 1) * (n + 1));
|
| -- b = (char *) malloc((m + 1) * (n + 1));
|
| +- c = (char*)malloc((m + 1) * (n + 1));
|
| +- b = (char*)malloc((m + 1) * (n + 1));
|
| + c = (char *) calloc(m + 1, n + 1);
|
| + b = (char *) calloc(m + 1, n + 1);
|
| if (!c || !b) {
|
| - if (c) free(c);
|
| - if (b) free(b);
|
| + if (c)
|
| + free(c);
|
| +@@ -1978,10 +2107,6 @@ void SuggestMgr::lcs(const char* s,
|
| *result = NULL;
|
| return;
|
| }
|
| -- for (i = 1; i <= m; i++) c[i*(n+1)] = 0;
|
| -- for (j = 0; j <= n; j++) c[j] = 0;
|
| +- for (i = 1; i <= m; i++)
|
| +- c[i * (n + 1)] = 0;
|
| +- for (j = 0; j <= n; j++)
|
| +- c[j] = 0;
|
| for (i = 1; i <= m; i++) {
|
| for (j = 1; j <= n; j++) {
|
| - if ( ((utf8) && (*((short *) su+i-1) == *((short *)su2+j-1)))
|
| -Index: src/hunspell/suggestmgr.hxx
|
| -===================================================================
|
| -RCS file: /cvsroot/hunspell/hunspell/src/hunspell/suggestmgr.hxx,v
|
| -retrieving revision 1.5
|
| -diff -u -r1.5 suggestmgr.hxx
|
| ---- src/hunspell/suggestmgr.hxx 21 Jan 2011 22:10:24 -0000 1.5
|
| -+++ src/hunspell/suggestmgr.hxx 29 May 2014 01:05:07 -0000
|
| -@@ -52,7 +52,11 @@
|
| -
|
| -
|
| - public:
|
| + if (((utf8) && (su[i - 1] == su2[j - 1])) ||
|
| +diff --git a/third_party/hunspell/src/hunspell/suggestmgr.hxx b/third_party/hunspell/src/hunspell/suggestmgr.hxx
|
| +index ee0322c..f940431 100644
|
| +--- a/third_party/hunspell/src/hunspell/suggestmgr.hxx
|
| ++++ b/third_party/hunspell/src/hunspell/suggestmgr.hxx
|
| +@@ -124,7 +124,11 @@ class SuggestMgr {
|
| + int complexprefixes;
|
| +
|
| + public:
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + SuggestMgr(hunspell::BDictReader* reader, const char * tryme, int maxn, AffixMgr *aptr);
|
| +#else
|
| - SuggestMgr(const char * tryme, int maxn, AffixMgr *aptr);
|
| + SuggestMgr(const char* tryme, unsigned int maxn, AffixMgr* aptr);
|
| +#endif
|
| ~SuggestMgr();
|
|
|
| - int suggest(char*** slst, const char * word, int nsug, int * onlycmpdsug);
|
| -@@ -66,6 +70,10 @@
|
| - char * suggest_morph_for_spelling_error(const char * word);
|
| + void suggest(std::vector<std::string>& slst, const char* word, int* onlycmpdsug);
|
| +@@ -134,6 +138,10 @@ class SuggestMgr {
|
| + std::string suggest_gen(const std::vector<std::string>& pl, const std::string& pattern);
|
|
|
| - private:
|
| + private:
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + // Not owned by us, owned by the Hunspell object.
|
| + hunspell::BDictReader* bdict_reader;
|
| +#endif
|
| - int testsug(char** wlst, const char * candidate, int wl, int ns, int cpdsuggest,
|
| - int * timer, clock_t * timelimit);
|
| - int checkword(const char *, int, int, int *, clock_t *);
|
| -diff --git a/third_party/hunspell/src/hunspell/csutil.cxx b/third_party/hunspell/src/hunspell/csutil.cxx
|
| -index 2be9027..0f2267f 100644
|
| ---- a/third_party/hunspell/src/hunspell/csutil.cxx
|
| -+++ b/third_party/hunspell/src/hunspell/csutil.cxx
|
| -@@ -96,10 +96,10 @@ char * u16_u8(char * dest, int size, const w_char * src, int srclen) {
|
| -
|
| - /* only UTF-16 (BMP) implementation */
|
| - int u8_u16(w_char * dest, int size, const char * src) {
|
| -- const signed char * u8 = (const signed char *)src;
|
| -+ const unsigned char * u8 = (const unsigned char*)src;
|
| - w_char * u2 = dest;
|
| - w_char * u2_max = u2 + size;
|
| --
|
| -+
|
| - while ((u2 < u2_max) && *u8) {
|
| - switch ((*u8) & 0xf0) {
|
| - case 0x00:
|
| -@@ -118,7 +118,7 @@ int u8_u16(w_char * dest, int size, const char * src) {
|
| - case 0x90:
|
| - case 0xa0:
|
| - case 0xb0: {
|
| -- HUNSPELL_WARNING(stderr, "UTF-8 encoding error. Unexpected continuation bytes in %ld. character position\n%s\n", static_cast<long>(u8 - (signed char *)src), src);
|
| -+ HUNSPELL_WARNING(stderr, "UTF-8 encoding error. Unexpected continuation bytes in %ld. character position\n%s\n", static_cast<long>(u8 - (const unsigned char*)src), src);
|
| - u2->h = 0xff;
|
| - u2->l = 0xfd;
|
| - break;
|
| -@@ -130,7 +130,7 @@ int u8_u16(w_char * dest, int size, const char * src) {
|
| - u2->l = (*u8 << 6) + (*(u8+1) & 0x3f);
|
| - u8++;
|
| - } else {
|
| -- HUNSPELL_WARNING(stderr, "UTF-8 encoding error. Missing continuation byte in %ld. character position:\n%s\n", static_cast<long>(u8 - (signed char *)src), src);
|
| -+ HUNSPELL_WARNING(stderr, "UTF-8 encoding error. Missing continuation byte in %ld. character position:\n%s\n", static_cast<long>(u8 - (const unsigned char*)src), src);
|
| - u2->h = 0xff;
|
| - u2->l = 0xfd;
|
| - }
|
| -@@ -144,12 +144,12 @@ int u8_u16(w_char * dest, int size, const char * src) {
|
| - u2->l = (*u8 << 6) + (*(u8+1) & 0x3f);
|
| - u8++;
|
| - } else {
|
| -- HUNSPELL_WARNING(stderr, "UTF-8 encoding error. Missing continuation byte in %ld. character position:\n%s\n", static_cast<long>(u8 - (signed char *)src), src);
|
| -+ HUNSPELL_WARNING(stderr, "UTF-8 encoding error. Missing continuation byte in %ld. character position:\n%s\n", static_cast<long>(u8 - (const unsigned char*)src), src);
|
| - u2->h = 0xff;
|
| - u2->l = 0xfd;
|
| - }
|
| - } else {
|
| -- HUNSPELL_WARNING(stderr, "UTF-8 encoding error. Missing continuation byte in %ld. character position:\n%s\n", static_cast<long>(u8 - (signed char *)src), src);
|
| -+ HUNSPELL_WARNING(stderr, "UTF-8 encoding error. Missing continuation byte in %ld. character position:\n%s\n", static_cast<long>(u8 - (const unsigned char*)src), src);
|
| - u2->h = 0xff;
|
| - u2->l = 0xfd;
|
| - }
|
| + void testsug(std::vector<std::string>& wlst,
|
| + const std::string& candidate,
|
| + int cpdsuggest,
|
| +diff --git a/third_party/hunspell/src/parsers/testparser.cxx b/third_party/hunspell/src/parsers/testparser.cxx
|
| +index 69f2cbc3..81db53a 100644
|
| +--- a/third_party/hunspell/src/parsers/testparser.cxx
|
| ++++ b/third_party/hunspell/src/parsers/testparser.cxx
|
| +@@ -14,15 +14,15 @@
|
| + * The Original Code is Hunspell, based on MySpell.
|
| + *
|
| + * The Initial Developers of the Original Code are
|
| +- * Kevin Hendricks (MySpell) and Németh László (Hunspell).
|
| ++ * Kevin Hendricks (MySpell) and Németh László (Hunspell).
|
| + * Portions created by the Initial Developers are Copyright (C) 2002-2005
|
| + * the Initial Developers. All Rights Reserved.
|
| + *
|
| + * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno,
|
| +- * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád,
|
| +- * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter,
|
| +- * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls,
|
| +- * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen
|
| ++ * Gianluca Turconi, Simon Brouwer, Noll János, BÃró Ãrpád,
|
| ++ * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter,
|
| ++ * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls,
|
| ++ * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen
|
| + *
|
| + * 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
|
|
|