diff options
author | sidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-03 20:25:28 +0000 |
---|---|---|
committer | sidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-03 20:25:28 +0000 |
commit | 8f96022103f907be712e24ee75db55d01ce33ed9 (patch) | |
tree | 49a3fcdf904953f43570259d5c4d759a3842c1ac /chrome/third_party | |
parent | 0c8f8d48b98dcb02c01acbf03eb02506c0cc2507 (diff) | |
download | chromium_src-8f96022103f907be712e24ee75db55d01ce33ed9.zip chromium_src-8f96022103f907be712e24ee75db55d01ce33ed9.tar.gz chromium_src-8f96022103f907be712e24ee75db55d01ce33ed9.tar.bz2 |
Fix issue 3039/3040 (Add to dictionary crasher). Earlier, the hentry was being generated manually, and incorrectly, when add to dictionary was trigerred, leading to failures occasionally in hunspell. This patch generates the hentry using existing hunspell method for generating hentry.
Review URL: http://codereview.chromium.org/6430
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2850 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/third_party')
-rw-r--r-- | chrome/third_party/hunspell/src/hunspell/hashmgr.cxx | 28 | ||||
-rw-r--r-- | chrome/third_party/hunspell/src/hunspell/hashmgr.hxx | 2 |
2 files changed, 11 insertions, 19 deletions
diff --git a/chrome/third_party/hunspell/src/hunspell/hashmgr.cxx b/chrome/third_party/hunspell/src/hunspell/hashmgr.cxx index daa4247..8f20dd3 100644 --- a/chrome/third_party/hunspell/src/hunspell/hashmgr.cxx +++ b/chrome/third_party/hunspell/src/hunspell/hashmgr.cxx @@ -119,7 +119,6 @@ HashMgr::~HashMgr() #ifdef HUNSPELL_CHROME_CLIENT
EmptyHentryCache();
- STLDeleteValues(&custom_word_to_hentry_map_);
for (std::vector<std::string*>::iterator it = pointer_to_strings_.begin();
it != pointer_to_strings_.end(); ++it) {
delete *it;
@@ -152,12 +151,12 @@ struct hentry * HashMgr::lookup(const char *word) const int affix_ids[hunspell::BDict::MAX_AFFIXES_PER_WORD];
int affix_count = bdict_reader->FindWord(word, affix_ids);
if (affix_count == 0) { // look for custom added word
- std::map<StringPiece, struct hentry *>::const_iterator iter =
- custom_word_to_hentry_map_.find(word);
- if (iter != custom_word_to_hentry_map_.end())
- return iter->second;
- else
- return NULL;
+ std::map<StringPiece, int>::const_iterator iter =
+ custom_word_to_affix_id_map_.find(word);
+ if (iter != custom_word_to_affix_id_map_.end()) {
+ affix_count = 1;
+ affix_ids[0] = iter->second;
+ }
}
static const int kMaxWordLen = 128;
@@ -243,20 +242,13 @@ int HashMgr::add_word(const char * word, int wl, unsigned short * aff, int al, c dp->next = hp;
}
#endif // HUNSPELL_CHROME_CLIENT
- std::map<StringPiece, struct hentry *>::iterator iter =
- custom_word_to_hentry_map_.find(word);
- if(iter == custom_word_to_hentry_map_.end()) { // word needs to be added
- // Make a custom hentry.
- struct hentry* he = new hentry;
- he->word = (char *)word;
- he->wlen = wl;
- he->next = NULL;
- he->next_homonym = NULL;
-
+ std::map<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);
StringPiece sp(*(new_string_word));
- custom_word_to_hentry_map_[sp] = he;
+ custom_word_to_affix_id_map_[sp] = 0; // no affixes for custom words
return 1;
}
diff --git a/chrome/third_party/hunspell/src/hunspell/hashmgr.hxx b/chrome/third_party/hunspell/src/hunspell/hashmgr.hxx index 4f60646..a334d90 100644 --- a/chrome/third_party/hunspell/src/hunspell/hashmgr.hxx +++ b/chrome/third_party/hunspell/src/hunspell/hashmgr.hxx @@ -19,7 +19,7 @@ class HashMgr #ifdef HUNSPELL_CHROME_CLIENT // Not owned by this class, owned by the Hunspell object. hunspell::BDictReader* bdict_reader; - std::map<StringPiece, struct hentry *> custom_word_to_hentry_map_; + std::map<StringPiece, int> custom_word_to_affix_id_map_; std::vector<std::string*> pointer_to_strings_; #endif int tablesize; |