Chromium Code Reviews| Index: src/hunspell/suggestmgr.cxx |
| diff --git a/src/hunspell/suggestmgr.cxx b/src/hunspell/suggestmgr.cxx |
| index cfec5251e99481fef956260e656d9b9f6bd56fee..2e72ef7a974b1ea868c1ad39af555b4d0426d22b 100644 |
| --- a/src/hunspell/suggestmgr.cxx |
| +++ b/src/hunspell/suggestmgr.cxx |
| @@ -54,24 +54,25 @@ class ScopedHashEntryFactory { |
| // it can store affix flags into 'h->astr[0]',...,'h->astr[alen-1]'. To handle |
| // this new hentry struct, we define a struct which combines three values: an |
| // hentry struct 'hentry'; a char array 'word[kMaxWordLen]', and; an unsigned |
| - // short value 'astr' so a hentry struct 'h' returned from |
| + // short array 'astr' so a hentry struct 'h' returned from |
| // CreateScopedHashEntry() satisfies the following equations: |
| // hentry* h = factory.CreateScopedHashEntry(0, source); |
| // h->word[0] == ((HashEntryItem*)h)->entry.word[0]. |
| // h->word[1] == ((HashEntryItem*)h)->word[0]. |
| // ... |
| // h->word[h->blen] == ((HashEntryItem*)h)->word[h->blen-1]. |
| - // h->astr[0] == ((HashEntryItem*)h)->astr. |
| - // Our BDICT does not use affix flags longer than one for now since they are |
| - // discarded by convert_dict, i.e. 'h->astr' is always <= 1. Therefore, this |
|
groby-ooo-7-16
2013/02/27 00:45:46
Do we support this in convert_dict, then?
please use gerrit instead
2013/02/27 01:18:07
Yes, convert_dict supports multiple affixes.
|
| - // struct does not use an array for 'astr'. |
| + // h->astr[0] == ((HashEntryItem*)h)->astr[0]. |
| + // h->astr[1] == ((HashEntryItem*)h)->astr[1]. |
| + // ... |
| + // h->astr[h->alen-1] == ((HashEntryItem*)h)->astr[h->alen-1]. |
| enum { |
| kMaxWordLen = 128, |
| + kMaxAffixLen = 8, |
| }; |
| struct HashEntryItem { |
| hentry entry; |
| char word[kMaxWordLen]; |
| - unsigned short astr; |
| + unsigned short astr[kMaxAffixLen]; |
| }; |
| HashEntryItem hash_items_[MAX_ROOTS]; |
| @@ -86,7 +87,7 @@ ScopedHashEntryFactory::~ScopedHashEntryFactory() { |
| hentry* ScopedHashEntryFactory::CreateScopedHashEntry(int index, |
| const hentry* source) { |
| - if (index >= MAX_ROOTS || source->blen >= kMaxWordLen || source->alen > 1) |
| + if (index >= MAX_ROOTS || source->blen >= kMaxWordLen) |
| return NULL; |
| // Retrieve a HashEntryItem struct from our spool, initialize it, and |
| @@ -95,8 +96,11 @@ hentry* ScopedHashEntryFactory::CreateScopedHashEntry(int index, |
| HashEntryItem* hash_item = &hash_items_[index]; |
| memcpy(&hash_item->entry, source, source_size); |
| if (source->astr) { |
| - hash_item->astr = *source->astr; |
| - hash_item->entry.astr = &hash_item->astr; |
| + hash_item->entry.alen = source->alen; |
| + if (source->alen > kMaxAffixLen) |
| + hash_item->entry.alen = kMaxAffixLen; |
| + memcpy(hash_item->astr, source->astr, hash_item->entry.alen * sizeof(unsigned short)); |
|
groby-ooo-7-16
2013/02/27 00:45:46
Please make this sizeof(hash_item->astr[0]) - just
please use gerrit instead
2013/02/27 01:18:07
Done.
|
| + hash_item->entry.astr = &hash_item->astr[0]; |
| } |
| return &hash_item->entry; |
| } |