OLD | NEW |
1 diff --git a/third_party/hunspell/src/hunspell/affixmgr.cxx b/third_party/hunspe
ll/src/hunspell/affixmgr.cxx | 1 diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx |
2 index cc9e69b..d31944e 100644 | 2 index 658a8aa..2ece1cd 100644 |
3 --- a/third_party/hunspell/src/hunspell/affixmgr.cxx | 3 --- a/src/hunspell/affixmgr.cxx |
4 +++ b/third_party/hunspell/src/hunspell/affixmgr.cxx | 4 +++ b/src/hunspell/affixmgr.cxx |
5 @@ -87,11 +87,19 @@ | 5 @@ -87,11 +87,19 @@ |
6 | 6 |
7 #include "csutil.hxx" | 7 #include "csutil.hxx" |
8 | 8 |
9 +#ifdef HUNSPELL_CHROME_CLIENT | 9 +#ifdef HUNSPELL_CHROME_CLIENT |
10 +AffixMgr::AffixMgr(hunspell::BDictReader* reader, | 10 +AffixMgr::AffixMgr(hunspell::BDictReader* reader, |
11 + const std::vector<HashMgr*>& ptr) | 11 + const std::vector<HashMgr*>& ptr) |
12 + : alldic(ptr) | 12 + : alldic(ptr) |
13 + , pHMgr(ptr[0]) { | 13 + , pHMgr(ptr[0]) { |
14 + bdict_reader = reader; | 14 + bdict_reader = reader; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 ((at == 'P') && (dupflags[aflag] & dupPFX))) { | 186 ((at == 'P') && (dupflags[aflag] & dupPFX))) { |
187 HUNSPELL_WARNING( | 187 HUNSPELL_WARNING( |
188 @@ -4497,6 +4576,7 @@ bool AffixMgr::parse_affix(const std::string& line, | 188 @@ -4497,6 +4576,7 @@ bool AffixMgr::parse_affix(const std::string& line, |
189 af->getlinenum()); | 189 af->getlinenum()); |
190 } | 190 } |
191 dupflags[aflag] += (char)((at == 'S') ? dupSFX : dupPFX); | 191 dupflags[aflag] += (char)((at == 'S') ? dupSFX : dupPFX); |
192 +#endif | 192 +#endif |
193 break; | 193 break; |
194 } | 194 } |
195 // piece 3 - is cross product indicator | 195 // piece 3 - is cross product indicator |
196 diff --git a/third_party/hunspell/src/hunspell/affixmgr.hxx b/third_party/hunspe
ll/src/hunspell/affixmgr.hxx | 196 diff --git a/src/hunspell/affixmgr.hxx b/src/hunspell/affixmgr.hxx |
197 index c7d5a63..55acd6a 100644 | 197 index 83a4b42..162b475 100644 |
198 --- a/third_party/hunspell/src/hunspell/affixmgr.hxx | 198 --- a/src/hunspell/affixmgr.hxx |
199 +++ b/third_party/hunspell/src/hunspell/affixmgr.hxx | 199 +++ b/src/hunspell/affixmgr.hxx |
200 @@ -92,6 +92,40 @@ | 200 @@ -92,6 +92,40 @@ |
201 class PfxEntry; | 201 class PfxEntry; |
202 class SfxEntry; | 202 class SfxEntry; |
203 | 203 |
204 +#ifdef HUNSPELL_CHROME_CLIENT | 204 +#ifdef HUNSPELL_CHROME_CLIENT |
205 + | 205 + |
206 +#include <vector> | 206 +#include <vector> |
207 + | 207 + |
208 +// This class provides an implementation of the contclasses array in AffixMgr | 208 +// This class provides an implementation of the contclasses array in AffixMgr |
209 +// that is normally a large static array. We should almost never need more than | 209 +// that is normally a large static array. We should almost never need more than |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 int get_fullstrip() const; | 262 int get_fullstrip() const; |
263 | 263 |
264 private: | 264 private: |
265 +#ifdef HUNSPELL_CHROME_CLIENT | 265 +#ifdef HUNSPELL_CHROME_CLIENT |
266 + // Not owned by us, owned by the Hunspell object. | 266 + // Not owned by us, owned by the Hunspell object. |
267 + hunspell::BDictReader* bdict_reader; | 267 + hunspell::BDictReader* bdict_reader; |
268 +#endif | 268 +#endif |
269 int parse_file(const char* affpath, const char* key); | 269 int parse_file(const char* affpath, const char* key); |
270 bool parse_flag(const std::string& line, unsigned short* out, FileMgr* af); | 270 bool parse_flag(const std::string& line, unsigned short* out, FileMgr* af); |
271 bool parse_num(const std::string& line, int* out, FileMgr* af); | 271 bool parse_num(const std::string& line, int* out, FileMgr* af); |
272 diff --git a/third_party/hunspell/src/hunspell/filemgr.cxx b/third_party/hunspel
l/src/hunspell/filemgr.cxx | 272 diff --git a/src/hunspell/filemgr.cxx b/src/hunspell/filemgr.cxx |
273 index b7c89b2..aef6dba 100644 | 273 index b7c89b2..aef6dba 100644 |
274 --- a/third_party/hunspell/src/hunspell/filemgr.cxx | 274 --- a/src/hunspell/filemgr.cxx |
275 +++ b/third_party/hunspell/src/hunspell/filemgr.cxx | 275 +++ b/src/hunspell/filemgr.cxx |
276 @@ -78,6 +78,32 @@ | 276 @@ -78,6 +78,32 @@ |
277 #include "filemgr.hxx" | 277 #include "filemgr.hxx" |
278 #include "csutil.hxx" | 278 #include "csutil.hxx" |
279 | 279 |
280 +#ifdef HUNSPELL_CHROME_CLIENT | 280 +#ifdef HUNSPELL_CHROME_CLIENT |
281 +#include "third_party/hunspell/google/bdict_reader.h" | 281 +#include "third_party/hunspell/google/bdict_reader.h" |
282 + | 282 + |
283 +FileMgr::FileMgr(hunspell::LineIterator* iterator) : iterator_(iterator) { | 283 +FileMgr::FileMgr(hunspell::LineIterator* iterator) : iterator_(iterator) { |
284 +} | 284 +} |
285 + | 285 + |
(...skipping 18 matching lines...) Expand all Loading... |
304 +} | 304 +} |
305 +#else | 305 +#else |
306 int FileMgr::fail(const char* err, const char* par) { | 306 int FileMgr::fail(const char* err, const char* par) { |
307 fprintf(stderr, err, par); | 307 fprintf(stderr, err, par); |
308 return -1; | 308 return -1; |
309 @@ -118,3 +144,4 @@ bool FileMgr::getline(std::string& dest) { | 309 @@ -118,3 +144,4 @@ bool FileMgr::getline(std::string& dest) { |
310 int FileMgr::getlinenum() { | 310 int FileMgr::getlinenum() { |
311 return linenum; | 311 return linenum; |
312 } | 312 } |
313 +#endif | 313 +#endif |
314 diff --git a/third_party/hunspell/src/hunspell/filemgr.hxx b/third_party/hunspel
l/src/hunspell/filemgr.hxx | 314 diff --git a/src/hunspell/filemgr.hxx b/src/hunspell/filemgr.hxx |
315 index ca51faf..daa6d0b 100644 | 315 index 991e924..65fae23 100644 |
316 --- a/third_party/hunspell/src/hunspell/filemgr.hxx | 316 --- a/src/hunspell/filemgr.hxx |
317 +++ b/third_party/hunspell/src/hunspell/filemgr.hxx | 317 +++ b/src/hunspell/filemgr.hxx |
318 @@ -80,6 +80,30 @@ | 318 @@ -80,6 +80,30 @@ |
319 #include <string> | 319 #include <string> |
320 #include <fstream> | 320 #include <fstream> |
321 | 321 |
322 +#ifdef HUNSPELL_CHROME_CLIENT | 322 +#ifdef HUNSPELL_CHROME_CLIENT |
323 +namespace hunspell { | 323 +namespace hunspell { |
324 +class LineIterator; | 324 +class LineIterator; |
325 +} // namespace hunspell | 325 +} // namespace hunspell |
326 + | 326 + |
327 +// A class which encapsulates operations of reading a BDICT file. | 327 +// A class which encapsulates operations of reading a BDICT file. |
(...skipping 16 matching lines...) Expand all Loading... |
344 +}; | 344 +}; |
345 +#else | 345 +#else |
346 class FileMgr { | 346 class FileMgr { |
347 private: | 347 private: |
348 FileMgr(const FileMgr&); | 348 FileMgr(const FileMgr&); |
349 @@ -99,3 +123,4 @@ class FileMgr { | 349 @@ -99,3 +123,4 @@ class FileMgr { |
350 int getlinenum(); | 350 int getlinenum(); |
351 }; | 351 }; |
352 #endif | 352 #endif |
353 +#endif | 353 +#endif |
354 diff --git a/third_party/hunspell/src/hunspell/hashmgr.cxx b/third_party/hunspel
l/src/hunspell/hashmgr.cxx | 354 diff --git a/src/hunspell/hashmgr.cxx b/src/hunspell/hashmgr.cxx |
355 index 072bc1a..b07c585 100644 | 355 index 1de1690..770fac1 100644 |
356 --- a/third_party/hunspell/src/hunspell/hashmgr.cxx | 356 --- a/src/hunspell/hashmgr.cxx |
357 +++ b/third_party/hunspell/src/hunspell/hashmgr.cxx | 357 +++ b/src/hunspell/hashmgr.cxx |
358 @@ -84,8 +84,14 @@ | 358 @@ -84,8 +84,14 @@ |
359 | 359 |
360 // build a hash table from a munched word list | 360 // build a hash table from a munched word list |
361 | 361 |
362 +#ifdef HUNSPELL_CHROME_CLIENT | 362 +#ifdef HUNSPELL_CHROME_CLIENT |
363 +HashMgr::HashMgr(hunspell::BDictReader* reader) | 363 +HashMgr::HashMgr(hunspell::BDictReader* reader) |
364 + : bdict_reader(reader), | 364 + : bdict_reader(reader), |
365 +#else | 365 +#else |
366 HashMgr::HashMgr(const char* tpath, const char* apath, const char* key) | 366 HashMgr::HashMgr(const char* tpath, const char* apath, const char* key) |
367 - : tablesize(0), | 367 - : tablesize(0), |
(...skipping 11 matching lines...) Expand all Loading... |
379 + // No tables to load, just the AF lines. | 379 + // No tables to load, just the AF lines. |
380 + load_config(NULL, NULL); | 380 + load_config(NULL, NULL); |
381 + int ec = LoadAFLines(); | 381 + int ec = LoadAFLines(); |
382 +#else | 382 +#else |
383 load_config(apath, key); | 383 load_config(apath, key); |
384 int ec = load_tables(tpath, key); | 384 int ec = load_tables(tpath, key); |
385 +#endif | 385 +#endif |
386 if (ec) { | 386 if (ec) { |
387 /* error condition - what should we do here */ | 387 /* error condition - what should we do here */ |
388 HUNSPELL_WARNING(stderr, "Hash Manager Error : %d\n", ec); | 388 HUNSPELL_WARNING(stderr, "Hash Manager Error : %d\n", ec); |
389 @@ -156,14 +168,57 @@ HashMgr::~HashMgr() { | 389 @@ -158,14 +170,57 @@ HashMgr::~HashMgr() { |
390 #endif | 390 #endif |
391 #endif | 391 #endif |
392 | 392 |
393 +#ifdef HUNSPELL_CHROME_CLIENT | 393 +#ifdef HUNSPELL_CHROME_CLIENT |
394 + EmptyHentryCache(); | 394 + EmptyHentryCache(); |
395 + for (std::vector<std::string*>::iterator it = pointer_to_strings_.begin(); | 395 + for (std::vector<std::string*>::iterator it = pointer_to_strings_.begin(); |
396 + it != pointer_to_strings_.end(); ++it) { | 396 + it != pointer_to_strings_.end(); ++it) { |
397 + delete *it; | 397 + delete *it; |
398 + } | 398 + } |
399 +#endif | 399 +#endif |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 + static const int kMaxWordLen = 128; | 437 + static const int kMaxWordLen = 128; |
438 + static char word_buf[kMaxWordLen]; | 438 + static char word_buf[kMaxWordLen]; |
439 + // To take account of null-termination, we use upto 127. | 439 + // To take account of null-termination, we use upto 127. |
440 + strncpy(word_buf, word, kMaxWordLen - 1); | 440 + strncpy(word_buf, word, kMaxWordLen - 1); |
441 + | 441 + |
442 + return AffixIDsToHentry(word_buf, affix_ids, affix_count); | 442 + return AffixIDsToHentry(word_buf, affix_ids, affix_count); |
443 +#else | 443 +#else |
444 struct hentry* dp; | 444 struct hentry* dp; |
445 if (tableptr) { | 445 if (tableptr) { |
446 dp = tableptr[hash(word)]; | 446 dp = tableptr[hash(word)]; |
447 @@ -175,6 +230,7 @@ struct hentry* HashMgr::lookup(const char* word) const { | 447 @@ -177,6 +232,7 @@ struct hentry* HashMgr::lookup(const char* word) const { |
448 } | 448 } |
449 } | 449 } |
450 return NULL; | 450 return NULL; |
451 +#endif | 451 +#endif |
452 } | 452 } |
453 | 453 |
454 // add a word to the hash table (private) | 454 // add a word to the hash table (private) |
455 @@ -184,6 +240,8 @@ int HashMgr::add_word(const std::string& in_word, | 455 @@ -186,6 +242,8 @@ int HashMgr::add_word(const std::string& in_word, |
456 int al, | 456 int al, |
457 const std::string* in_desc, | 457 const std::string* in_desc, |
458 bool onlyupcase) { | 458 bool onlyupcase) { |
459 +// TODO: The following 40 lines or so are actually new. Should they be included
? | 459 +// TODO: The following 40 lines or so are actually new. Should they be included
? |
460 +#ifndef HUNSPELL_CHROME_CLIENT | 460 +#ifndef HUNSPELL_CHROME_CLIENT |
461 const std::string* word = &in_word; | 461 const std::string* word = &in_word; |
462 const std::string* desc = in_desc; | 462 const std::string* desc = in_desc; |
463 | 463 |
464 @@ -316,6 +374,17 @@ int HashMgr::add_word(const std::string& in_word, | 464 @@ -318,6 +376,17 @@ int HashMgr::add_word(const std::string& in_word, |
465 | 465 |
466 delete desc_copy; | 466 delete desc_copy; |
467 delete word_copy; | 467 delete word_copy; |
468 +#else | 468 +#else |
469 + std::map<base::StringPiece, int>::iterator iter = | 469 + std::map<base::StringPiece, int>::iterator iter = |
470 + custom_word_to_affix_id_map_.find(in_word); | 470 + custom_word_to_affix_id_map_.find(in_word); |
471 + if (iter == custom_word_to_affix_id_map_.end()) { // word needs to be added | 471 + if (iter == custom_word_to_affix_id_map_.end()) { // word needs to be added |
472 + std::string* new_string_word = new std::string(in_word); | 472 + std::string* new_string_word = new std::string(in_word); |
473 + pointer_to_strings_.push_back(new_string_word); | 473 + pointer_to_strings_.push_back(new_string_word); |
474 + base::StringPiece sp(*(new_string_word)); | 474 + base::StringPiece sp(*(new_string_word)); |
475 + custom_word_to_affix_id_map_[sp] = 0; // no affixes for custom words | 475 + custom_word_to_affix_id_map_[sp] = 0; // no affixes for custom words |
476 + return 1; | 476 + return 1; |
477 + } | 477 + } |
478 +#endif | 478 +#endif |
479 return 0; | 479 return 0; |
480 } | 480 } |
481 | 481 |
482 @@ -376,6 +445,12 @@ int HashMgr::get_clen_and_captype(const std::string& word,
int* captype) { | 482 @@ -378,6 +447,12 @@ int HashMgr::get_clen_and_captype(const std::string& word,
int* captype) { |
483 | 483 |
484 // remove word (personal dictionary function for standalone applications) | 484 // remove word (personal dictionary function for standalone applications) |
485 int HashMgr::remove(const std::string& word) { | 485 int HashMgr::remove(const std::string& word) { |
486 +#ifdef HUNSPELL_CHROME_CLIENT | 486 +#ifdef HUNSPELL_CHROME_CLIENT |
487 + std::map<base::StringPiece, int>::iterator iter = | 487 + std::map<base::StringPiece, int>::iterator iter = |
488 + custom_word_to_affix_id_map_.find(word); | 488 + custom_word_to_affix_id_map_.find(word); |
489 + if (iter != custom_word_to_affix_id_map_.end()) | 489 + if (iter != custom_word_to_affix_id_map_.end()) |
490 + custom_word_to_affix_id_map_.erase(iter); | 490 + custom_word_to_affix_id_map_.erase(iter); |
491 +#else | 491 +#else |
492 struct hentry* dp = lookup(word.c_str()); | 492 struct hentry* dp = lookup(word.c_str()); |
493 while (dp) { | 493 while (dp) { |
494 if (dp->alen == 0 || !TESTAFF(dp->astr, forbiddenword, dp->alen)) { | 494 if (dp->alen == 0 || !TESTAFF(dp->astr, forbiddenword, dp->alen)) { |
495 @@ -392,6 +467,7 @@ int HashMgr::remove(const std::string& word) { | 495 @@ -395,6 +470,7 @@ int HashMgr::remove(const std::string& word) { |
496 } | 496 } |
497 dp = dp->next_homonym; | 497 dp = dp->next_homonym; |
498 } | 498 } |
499 +#endif | 499 +#endif |
500 return 0; | 500 return 0; |
501 } | 501 } |
502 | 502 |
503 @@ -465,6 +541,44 @@ int HashMgr::add_with_affix(const std::string& word, const
std::string& example) | 503 @@ -469,6 +545,44 @@ int HashMgr::add_with_affix(const std::string& word, const
std::string& example) |
504 // walk the hash table entry by entry - null at end | 504 // walk the hash table entry by entry - null at end |
505 // initialize: col=-1; hp = NULL; hp = walk_hashtable(&col, hp); | 505 // initialize: col=-1; hp = NULL; hp = walk_hashtable(&col, hp); |
506 struct hentry* HashMgr::walk_hashtable(int& col, struct hentry* hp) const { | 506 struct hentry* HashMgr::walk_hashtable(int& col, struct hentry* hp) const { |
507 +#ifdef HUNSPELL_CHROME_CLIENT | 507 +#ifdef HUNSPELL_CHROME_CLIENT |
508 + // Return NULL if dictionary is not valid. | 508 + // Return NULL if dictionary is not valid. |
509 + if (!bdict_reader->IsValid()) | 509 + if (!bdict_reader->IsValid()) |
510 + return NULL; | 510 + return NULL; |
511 + | 511 + |
512 + // This function is only ever called by one place and not nested. We can | 512 + // This function is only ever called by one place and not nested. We can |
513 + // therefore keep static state between calls and use |col| as a "reset" flag | 513 + // therefore keep static state between calls and use |col| as a "reset" flag |
(...skipping 24 matching lines...) Expand all Loading... |
538 + hentry entry; | 538 + hentry entry; |
539 + char word[kMaxWordLen]; | 539 + char word[kMaxWordLen]; |
540 + } hash_entry; | 540 + } hash_entry; |
541 + | 541 + |
542 + return InitHashEntry(&hash_entry.entry, sizeof(hash_entry), | 542 + return InitHashEntry(&hash_entry.entry, sizeof(hash_entry), |
543 + &word[0], word_len, affix_ids[0]); | 543 + &word[0], word_len, affix_ids[0]); |
544 +#else | 544 +#else |
545 if (hp && hp->next != NULL) | 545 if (hp && hp->next != NULL) |
546 return hp->next; | 546 return hp->next; |
547 for (col++; col < tablesize; col++) { | 547 for (col++; col < tablesize; col++) { |
548 @@ -474,10 +588,12 @@ struct hentry* HashMgr::walk_hashtable(int& col, struct he
ntry* hp) const { | 548 @@ -478,10 +592,12 @@ struct hentry* HashMgr::walk_hashtable(int& col, struct he
ntry* hp) const { |
549 // null at end and reset to start | 549 // null at end and reset to start |
550 col = -1; | 550 col = -1; |
551 return NULL; | 551 return NULL; |
552 +#endif | 552 +#endif |
553 } | 553 } |
554 | 554 |
555 // load a munched word list and build a hash table on the fly | 555 // load a munched word list and build a hash table on the fly |
556 int HashMgr::load_tables(const char* tpath, const char* key) { | 556 int HashMgr::load_tables(const char* tpath, const char* key) { |
557 +#ifndef HUNSPELL_CHROME_CLIENT | 557 +#ifndef HUNSPELL_CHROME_CLIENT |
558 // open dictionary file | 558 // open dictionary file |
559 FileMgr* dict = new FileMgr(tpath, key); | 559 FileMgr* dict = new FileMgr(tpath, key); |
560 if (dict == NULL) | 560 if (dict == NULL) |
561 @@ -606,12 +722,16 @@ int HashMgr::load_tables(const char* tpath, const char* ke
y) { | 561 @@ -610,12 +726,16 @@ int HashMgr::load_tables(const char* tpath, const char* ke
y) { |
562 } | 562 } |
563 | 563 |
564 delete dict; | 564 delete dict; |
565 +#endif | 565 +#endif |
566 return 0; | 566 return 0; |
567 } | 567 } |
568 | 568 |
569 // the hash function is a simple load and rotate | 569 // the hash function is a simple load and rotate |
570 // algorithm borrowed | 570 // algorithm borrowed |
571 int HashMgr::hash(const char* word) const { | 571 int HashMgr::hash(const char* word) const { |
572 +#ifdef HUNSPELL_CHROME_CLIENT | 572 +#ifdef HUNSPELL_CHROME_CLIENT |
573 + return 0; | 573 + return 0; |
574 +#else | 574 +#else |
575 unsigned long hv = 0; | 575 unsigned long hv = 0; |
576 for (int i = 0; i < 4 && *word != 0; i++) | 576 for (int i = 0; i < 4 && *word != 0; i++) |
577 hv = (hv << 8) | (*word++); | 577 hv = (hv << 8) | (*word++); |
578 @@ -620,6 +740,7 @@ int HashMgr::hash(const char* word) const { | 578 @@ -624,6 +744,7 @@ int HashMgr::hash(const char* word) const { |
579 hv ^= (*word++); | 579 hv ^= (*word++); |
580 } | 580 } |
581 return (unsigned long)hv % tablesize; | 581 return (unsigned long)hv % tablesize; |
582 +#endif | 582 +#endif |
583 } | 583 } |
584 | 584 |
585 int HashMgr::decode_flags(unsigned short** result, const std::string& flags, Fi
leMgr* af) const { | 585 int HashMgr::decode_flags(unsigned short** result, const std::string& flags, Fi
leMgr* af) const { |
586 @@ -829,7 +950,12 @@ int HashMgr::load_config(const char* affpath, const char* k
ey) { | 586 @@ -833,7 +954,12 @@ int HashMgr::load_config(const char* affpath, const char* k
ey) { |
587 int firstline = 1; | 587 int firstline = 1; |
588 | 588 |
589 // open the affix file | 589 // open the affix file |
590 +#ifdef HUNSPELL_CHROME_CLIENT | 590 +#ifdef HUNSPELL_CHROME_CLIENT |
591 + hunspell::LineIterator iterator = bdict_reader->GetOtherLineIterator(); | 591 + hunspell::LineIterator iterator = bdict_reader->GetOtherLineIterator(); |
592 + FileMgr * afflst = new FileMgr(&iterator); | 592 + FileMgr * afflst = new FileMgr(&iterator); |
593 +#else | 593 +#else |
594 FileMgr* afflst = new FileMgr(affpath, key); | 594 FileMgr* afflst = new FileMgr(affpath, key); |
595 +#endif | 595 +#endif |
596 if (!afflst) { | 596 if (!afflst) { |
597 HUNSPELL_WARNING( | 597 HUNSPELL_WARNING( |
598 stderr, "Error - could not open affix description file %s\n", affpath); | 598 stderr, "Error - could not open affix description file %s\n", affpath); |
599 @@ -1058,6 +1184,122 @@ bool HashMgr::parse_aliasf(const std::string& line, File
Mgr* af) { | 599 @@ -1062,6 +1188,122 @@ bool HashMgr::parse_aliasf(const std::string& line, File
Mgr* af) { |
600 return true; | 600 return true; |
601 } | 601 } |
602 | 602 |
603 +#ifdef HUNSPELL_CHROME_CLIENT | 603 +#ifdef HUNSPELL_CHROME_CLIENT |
604 +int HashMgr::LoadAFLines() | 604 +int HashMgr::LoadAFLines() |
605 +{ | 605 +{ |
606 + utf8 = 1; // We always use UTF-8. | 606 + utf8 = 1; // We always use UTF-8. |
607 + | 607 + |
608 + // Read in all the AF lines which tell us the rules for each affix group ID. | 608 + // Read in all the AF lines which tell us the rules for each affix group ID. |
609 + hunspell::LineIterator iterator = bdict_reader->GetAfLineIterator(); | 609 + hunspell::LineIterator iterator = bdict_reader->GetAfLineIterator(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 + if (found != cache.end()) | 712 + if (found != cache.end()) |
713 + return found->second; | 713 + return found->second; |
714 + else | 714 + else |
715 + return NULL; | 715 + return NULL; |
716 +} | 716 +} |
717 +#endif | 717 +#endif |
718 + | 718 + |
719 int HashMgr::is_aliasf() const { | 719 int HashMgr::is_aliasf() const { |
720 return (aliasf != NULL); | 720 return (aliasf != NULL); |
721 } | 721 } |
722 diff --git a/third_party/hunspell/src/hunspell/hashmgr.hxx b/third_party/hunspel
l/src/hunspell/hashmgr.hxx | 722 diff --git a/src/hunspell/hashmgr.hxx b/src/hunspell/hashmgr.hxx |
723 index a158a16..9714a90 100644 | 723 index 812171a..af27d6c 100644 |
724 --- a/third_party/hunspell/src/hunspell/hashmgr.hxx | 724 --- a/src/hunspell/hashmgr.hxx |
725 +++ b/third_party/hunspell/src/hunspell/hashmgr.hxx | 725 +++ b/src/hunspell/hashmgr.hxx |
726 @@ -82,9 +82,23 @@ | 726 @@ -82,9 +82,23 @@ |
727 #include "filemgr.hxx" | 727 #include "filemgr.hxx" |
728 #include "w_char.hxx" | 728 #include "w_char.hxx" |
729 | 729 |
730 +#ifdef HUNSPELL_CHROME_CLIENT | 730 +#ifdef HUNSPELL_CHROME_CLIENT |
731 +#include <map> | 731 +#include <map> |
732 + | 732 + |
733 +#include "base/stl_util.h" | 733 +#include "base/stl_util.h" |
734 +#include "base/strings/string_piece.h" | 734 +#include "base/strings/string_piece.h" |
735 +#include "third_party/hunspell/google/bdict_reader.h" | 735 +#include "third_party/hunspell/google/bdict_reader.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 + | 805 + |
806 + // See EmptyHentryCache above. Note that each one is actually a linked list | 806 + // See EmptyHentryCache above. Note that each one is actually a linked list |
807 + // followed by the homonym pointer. | 807 + // followed by the homonym pointer. |
808 + typedef std::map<std::string, hentry*> HEntryCache; | 808 + typedef std::map<std::string, hentry*> HEntryCache; |
809 + HEntryCache hentry_cache; | 809 + HEntryCache hentry_cache; |
810 +#endif | 810 +#endif |
811 + | 811 + |
812 int add_hidden_capitalized_word(const std::string& word, | 812 int add_hidden_capitalized_word(const std::string& word, |
813 int wcl, | 813 int wcl, |
814 unsigned short* flags, | 814 unsigned short* flags, |
815 diff --git a/third_party/hunspell/src/hunspell/htypes.hxx b/third_party/hunspell
/src/hunspell/htypes.hxx | 815 diff --git a/src/hunspell/htypes.hxx b/src/hunspell/htypes.hxx |
816 index d244394..05ef6af 100644 | 816 index 1e6c118..c3aa2be 100644 |
817 --- a/third_party/hunspell/src/hunspell/htypes.hxx | 817 --- a/src/hunspell/htypes.hxx |
818 +++ b/third_party/hunspell/src/hunspell/htypes.hxx | 818 +++ b/src/hunspell/htypes.hxx |
819 @@ -41,6 +41,16 @@ | 819 @@ -41,6 +41,16 @@ |
820 #ifndef _HTYPES_HXX_ | 820 #ifndef HTYPES_HXX_ |
821 #define _HTYPES_HXX_ | 821 #define HTYPES_HXX_ |
822 | 822 |
823 +#ifdef HUNSPELL_CHROME_CLIENT | 823 +#ifdef HUNSPELL_CHROME_CLIENT |
824 +// This is a workaround for preventing errors in parsing Turkish BDICs, which | 824 +// This is a workaround for preventing errors in parsing Turkish BDICs, which |
825 +// contain very long AF lines (~ 12,000 chars). | 825 +// contain very long AF lines (~ 12,000 chars). |
826 +// TODO(hbono) change the HashMgr::parse_aliasf() function to be able to parse | 826 +// TODO(hbono) change the HashMgr::parse_aliasf() function to be able to parse |
827 +// longer lines than MAXDELEN. | 827 +// longer lines than MAXDELEN. |
828 +#define MAXDELEN (8192 * 2) | 828 +#define MAXDELEN (8192 * 2) |
829 +#else | 829 +#else |
830 +#define MAXDELEN 8192 | 830 +#define MAXDELEN 8192 |
831 +#endif // HUNSPELL_CHROME_CLIENT | 831 +#endif // HUNSPELL_CHROME_CLIENT |
832 + | 832 + |
833 #define ROTATE_LEN 5 | 833 #define ROTATE_LEN 5 |
834 | 834 |
835 #define ROTATE(v, q) \ | 835 #define ROTATE(v, q) \ |
836 diff --git a/third_party/hunspell/src/hunspell/hunspell.cxx b/third_party/hunspe
ll/src/hunspell/hunspell.cxx | 836 diff --git a/src/hunspell/hunspell.cxx b/src/hunspell/hunspell.cxx |
837 index 114570f..1110ee0 100644 | 837 index abcdb8f..c8c5cf4 100644 |
838 --- a/third_party/hunspell/src/hunspell/hunspell.cxx | 838 --- a/src/hunspell/hunspell.cxx |
839 +++ b/third_party/hunspell/src/hunspell/hunspell.cxx | 839 +++ b/src/hunspell/hunspell.cxx |
840 @@ -79,6 +79,9 @@ | 840 @@ -79,6 +79,9 @@ |
841 #include "hunspell.hxx" | 841 #include "hunspell.hxx" |
842 #include "suggestmgr.hxx" | 842 #include "suggestmgr.hxx" |
843 #include "hunspell.h" | 843 #include "hunspell.h" |
844 +#ifndef HUNSPELL_CHROME_CLIENT | 844 +#ifndef HUNSPELL_CHROME_CLIENT |
845 +# include "config.h" | 845 +# include "config.h" |
846 +#endif | 846 +#endif |
847 #include "csutil.hxx" | 847 #include "csutil.hxx" |
848 | 848 |
849 #include <limits> | 849 #include <limits> |
850 @@ -89,9 +92,15 @@ | 850 @@ -89,9 +92,15 @@ |
851 class HunspellImpl | 851 class HunspellImpl |
852 { | 852 { |
853 public: | 853 public: |
854 +#ifdef HUNSPELL_CHROME_CLIENT | 854 +#ifdef HUNSPELL_CHROME_CLIENT |
855 + HunspellImpl(const unsigned char* bdict_data, size_t bdict_length); | 855 + HunspellImpl(const unsigned char* bdict_data, size_t bdict_length); |
856 +#else | 856 +#else |
857 HunspellImpl(const char* affpath, const char* dpath, const char* key); | 857 HunspellImpl(const char* affpath, const char* dpath, const char* key); |
858 +#endif | 858 +#endif |
859 ~HunspellImpl(); | 859 ~HunspellImpl(); |
860 +#ifndef HUNSPELL_CHROME_CLIENT | 860 +#ifndef HUNSPELL_CHROME_CLIENT |
861 int add_dic(const char* dpath, const char* key); | 861 int add_dic(const char* dpath, const char* key); |
862 +#endif | 862 +#endif |
863 std::vector<std::string> suffix_suggest(const std::string& root_word); | 863 std::vector<std::string> suffix_suggest(const std::string& root_word); |
864 std::vector<std::string> generate(const std::string& word, const std::vector<
std::string>& pl); | 864 std::vector<std::string> generate(const std::string& word, const std::vector<
std::string>& pl); |
865 std::vector<std::string> generate(const std::string& word, const std::string&
pattern); | 865 std::vector<std::string> generate(const std::string& word, const std::string&
pattern); |
866 @@ -115,7 +124,9 @@ private: | 866 @@ -116,7 +125,9 @@ private: |
867 AffixMgr* pAMgr; | 867 AffixMgr* pAMgr; |
868 std::vector<HashMgr*> m_HMgrs; | 868 std::vector<HashMgr*> m_HMgrs; |
869 SuggestMgr* pSMgr; | 869 SuggestMgr* pSMgr; |
870 +#ifndef HUNSPELL_CHROME_CLIENT // We are using BDict instead. | 870 +#ifndef HUNSPELL_CHROME_CLIENT // We are using BDict instead. |
871 char* affixpath; | 871 char* affixpath; |
872 +#endif | 872 +#endif |
873 std::string encoding; | 873 std::string encoding; |
874 struct cs_info* csconv; | 874 struct cs_info* csconv; |
875 int langnum; | 875 int langnum; |
876 @@ -123,6 +134,11 @@ private: | 876 @@ -124,6 +135,11 @@ private: |
877 int complexprefixes; | 877 int complexprefixes; |
878 std::vector<std::string> wordbreak; | 878 std::vector<std::string> wordbreak; |
879 | 879 |
880 +#ifdef HUNSPELL_CHROME_CLIENT | 880 +#ifdef HUNSPELL_CHROME_CLIENT |
881 + // Not owned by us, owned by the Hunspell object. | 881 + // Not owned by us, owned by the Hunspell object. |
882 + hunspell::BDictReader* bdict_reader; | 882 + hunspell::BDictReader* bdict_reader; |
883 +#endif | 883 +#endif |
884 + | 884 + |
885 private: | 885 private: |
886 void cleanword(std::string& dest, const std::string&, int* pcaptype, int* pab
brev); | 886 void cleanword(std::string& dest, const std::string&, int* pcaptype, int* pab
brev); |
887 size_t cleanword2(std::string& dest, | 887 size_t cleanword2(std::string& dest, |
888 @@ -152,22 +168,43 @@ private: | 888 @@ -153,22 +169,43 @@ private: |
889 HunspellImpl& operator=(const HunspellImpl&); | 889 HunspellImpl& operator=(const HunspellImpl&); |
890 }; | 890 }; |
891 | 891 |
892 +#ifdef HUNSPELL_CHROME_CLIENT | 892 +#ifdef HUNSPELL_CHROME_CLIENT |
893 +Hunspell::Hunspell(const unsigned char* bdict_data, size_t bdict_length) | 893 +Hunspell::Hunspell(const unsigned char* bdict_data, size_t bdict_length) |
894 + : m_Impl(new HunspellImpl(bdict_data, bdict_length)) { | 894 + : m_Impl(new HunspellImpl(bdict_data, bdict_length)) { |
895 +#else | 895 +#else |
896 Hunspell::Hunspell(const char* affpath, const char* dpath, const char* key) | 896 Hunspell::Hunspell(const char* affpath, const char* dpath, const char* key) |
897 : m_Impl(new HunspellImpl(affpath, dpath, key)) { | 897 : m_Impl(new HunspellImpl(affpath, dpath, key)) { |
898 +#endif | 898 +#endif |
(...skipping 23 matching lines...) Expand all Loading... |
922 + /* first set up the hash manager */ | 922 + /* first set up the hash manager */ |
923 m_HMgrs.push_back(new HashMgr(dpath, affpath, key)); | 923 m_HMgrs.push_back(new HashMgr(dpath, affpath, key)); |
924 | 924 |
925 /* next set up the affix manager */ | 925 /* next set up the affix manager */ |
926 /* it needs access to the hash manager lookup methods */ | 926 /* it needs access to the hash manager lookup methods */ |
927 pAMgr = new AffixMgr(affpath, m_HMgrs, key); | 927 pAMgr = new AffixMgr(affpath, m_HMgrs, key); |
928 +#endif | 928 +#endif |
929 | 929 |
930 /* get the preferred try string and the dictionary */ | 930 /* get the preferred try string and the dictionary */ |
931 /* encoding from the Affix Manager for that dictionary */ | 931 /* encoding from the Affix Manager for that dictionary */ |
932 @@ -181,7 +218,11 @@ HunspellImpl::HunspellImpl(const char* affpath, const char*
dpath, const char* k | 932 @@ -185,7 +222,11 @@ HunspellImpl::HunspellImpl(const char* affpath, const char*
dpath, const char* k |
933 wordbreak = pAMgr->get_breaktable(); | 933 strcpy(&dic_encoding_vec[0], encoding.c_str()); |
934 | 934 |
935 /* and finally set up the suggestion manager */ | 935 /* and finally set up the suggestion manager */ |
936 +#ifdef HUNSPELL_CHROME_CLIENT | 936 +#ifdef HUNSPELL_CHROME_CLIENT |
937 + pSMgr = new SuggestMgr(bdict_reader, try_string, MAXSUGGESTION, pAMgr); | 937 + pSMgr = new SuggestMgr(bdict_reader, try_string, MAXSUGGESTION, pAMgr); |
938 +#else | 938 +#else |
939 pSMgr = new SuggestMgr(try_string, MAXSUGGESTION, pAMgr); | 939 pSMgr = new SuggestMgr(try_string, MAXSUGGESTION, pAMgr); |
940 +#endif | 940 +#endif |
941 if (try_string) | 941 if (try_string) |
942 free(try_string); | 942 free(try_string); |
943 } | 943 } |
944 @@ -201,11 +242,17 @@ HunspellImpl::~HunspellImpl() { | 944 @@ -205,11 +246,17 @@ HunspellImpl::~HunspellImpl() { |
945 delete[] csconv; | 945 delete[] csconv; |
946 #endif | 946 #endif |
947 csconv = NULL; | 947 csconv = NULL; |
948 +#ifdef HUNSPELL_CHROME_CLIENT | 948 +#ifdef HUNSPELL_CHROME_CLIENT |
949 + if (bdict_reader) delete bdict_reader; | 949 + if (bdict_reader) delete bdict_reader; |
950 + bdict_reader = NULL; | 950 + bdict_reader = NULL; |
951 +#else | 951 +#else |
952 if (affixpath) | 952 if (affixpath) |
953 free(affixpath); | 953 free(affixpath); |
954 affixpath = NULL; | 954 affixpath = NULL; |
955 +#endif | 955 +#endif |
956 } | 956 } |
957 | 957 |
958 +#ifndef HUNSPELL_CHROME_CLIENT | 958 +#ifndef HUNSPELL_CHROME_CLIENT |
959 // load extra dictionaries | 959 // load extra dictionaries |
960 int Hunspell::add_dic(const char* dpath, const char* key) { | 960 int Hunspell::add_dic(const char* dpath, const char* key) { |
961 return m_Impl->add_dic(dpath, key); | 961 return m_Impl->add_dic(dpath, key); |
962 @@ -218,6 +265,7 @@ int HunspellImpl::add_dic(const char* dpath, const char* key
) { | 962 @@ -222,6 +269,7 @@ int HunspellImpl::add_dic(const char* dpath, const char* key
) { |
963 m_HMgrs.push_back(new HashMgr(dpath, affixpath, key)); | 963 m_HMgrs.push_back(new HashMgr(dpath, affixpath, key)); |
964 return 0; | 964 return 0; |
965 } | 965 } |
966 +#endif | 966 +#endif |
967 | 967 |
968 // make a copy of src at destination while removing all leading | 968 // make a copy of src at destination while removing all leading |
969 // blanks and removing any trailing periods after recording | 969 // blanks and removing any trailing periods after recording |
970 @@ -411,6 +459,9 @@ bool Hunspell::spell(const std::string& word, int* info, std
::string* root) { | 970 @@ -415,6 +463,9 @@ bool Hunspell::spell(const std::string& word, int* info, std
::string* root) { |
971 } | 971 } |
972 | 972 |
973 bool HunspellImpl::spell(const std::string& word, int* info, std::string* root)
{ | 973 bool HunspellImpl::spell(const std::string& word, int* info, std::string* root)
{ |
974 +#ifdef HUNSPELL_CHROME_CLIENT | 974 +#ifdef HUNSPELL_CHROME_CLIENT |
975 + if (m_HMgrs[0]) m_HMgrs[0]->EmptyHentryCache(); | 975 + if (m_HMgrs[0]) m_HMgrs[0]->EmptyHentryCache(); |
976 +#endif | 976 +#endif |
977 struct hentry* rv = NULL; | 977 struct hentry* rv = NULL; |
978 | 978 |
979 int info2 = 0; | 979 int info2 = 0; |
980 @@ -717,6 +768,13 @@ struct hentry* HunspellImpl::checkword(const std::string& w
, int* info, std::str | 980 @@ -721,6 +772,13 @@ struct hentry* HunspellImpl::checkword(const std::string& w
, int* info, std::str |
981 if (!len) | 981 if (!len) |
982 return NULL; | 982 return NULL; |
983 | 983 |
984 +#ifdef HUNSPELL_CHROME_CLIENT | 984 +#ifdef HUNSPELL_CHROME_CLIENT |
985 + // We need to check if the word length is valid to make coverity (Event | 985 + // We need to check if the word length is valid to make coverity (Event |
986 + // fixed_size_dest: Possible overrun of N byte fixed size buffer) happy. | 986 + // fixed_size_dest: Possible overrun of N byte fixed size buffer) happy. |
987 + if ((utf8 && strlen(word) >= MAXWORDUTF8LEN) || (!utf8 && strlen(word) >= MAX
WORDLEN)) | 987 + if ((utf8 && strlen(word) >= MAXWORDUTF8LEN) || (!utf8 && strlen(word) >= MAX
WORDLEN)) |
988 + return NULL; | 988 + return NULL; |
989 +#endif | 989 +#endif |
990 + | 990 + |
991 // word reversing wrapper for complex prefixes | 991 // word reversing wrapper for complex prefixes |
992 if (complexprefixes) { | 992 if (complexprefixes) { |
993 if (!usebuffer) { | 993 if (!usebuffer) { |
994 @@ -829,6 +887,9 @@ std::vector<std::string> Hunspell::suggest(const std::string
& word) { | 994 @@ -833,6 +891,9 @@ std::vector<std::string> Hunspell::suggest(const std::string
& word) { |
995 } | 995 } |
996 | 996 |
997 std::vector<std::string> HunspellImpl::suggest(const std::string& word) { | 997 std::vector<std::string> HunspellImpl::suggest(const std::string& word) { |
998 +#ifdef HUNSPELL_CHROME_CLIENT | 998 +#ifdef HUNSPELL_CHROME_CLIENT |
999 + if (m_HMgrs[0]) m_HMgrs[0]->EmptyHentryCache(); | 999 + if (m_HMgrs[0]) m_HMgrs[0]->EmptyHentryCache(); |
1000 +#endif | 1000 +#endif |
1001 std::vector<std::string> slst; | 1001 std::vector<std::string> slst; |
1002 | 1002 |
1003 int onlycmpdsug = 0; | 1003 int onlycmpdsug = 0; |
1004 @@ -992,9 +1053,9 @@ std::vector<std::string> HunspellImpl::suggest(const std::s
tring& word) { | 1004 @@ -1875,22 +1936,32 @@ int Hunspell::generate(char*** slst, const char* word, c
onst char* pattern) { |
1005 w.append(slst[j].substr(pos + 1)); | |
1006 (void)spell(w, &info, NULL); | |
1007 if ((info & SPELL_COMPOUND) && (info & SPELL_FORBIDDEN)) { | |
1008 - slst[pos] = ' '; | |
1009 + slst[j][pos] = ' '; | |
1010 } else | |
1011 - slst[pos] = '-'; | |
1012 + slst[j][pos] = '-'; | |
1013 } | |
1014 } | |
1015 } | |
1016 @@ -1845,22 +1906,32 @@ int Hunspell::generate(char*** slst, const char* word, c
onst char* pattern) { | |
1017 } | 1005 } |
1018 | 1006 |
1019 Hunhandle* Hunspell_create(const char* affpath, const char* dpath) { | 1007 Hunhandle* Hunspell_create(const char* affpath, const char* dpath) { |
1020 +#ifdef HUNSPELL_CHROME_CLIENT | 1008 +#ifdef HUNSPELL_CHROME_CLIENT |
1021 + return NULL; | 1009 + return NULL; |
1022 +#else | 1010 +#else |
1023 return (Hunhandle*)(new Hunspell(affpath, dpath)); | 1011 return (Hunhandle*)(new Hunspell(affpath, dpath)); |
1024 +#endif | 1012 +#endif |
1025 } | 1013 } |
1026 | 1014 |
(...skipping 12 matching lines...) Expand all Loading... |
1039 } | 1027 } |
1040 | 1028 |
1041 +#ifndef HUNSPELL_CHROME_CLIENT | 1029 +#ifndef HUNSPELL_CHROME_CLIENT |
1042 int Hunspell_add_dic(Hunhandle* pHunspell, const char* dpath) { | 1030 int Hunspell_add_dic(Hunhandle* pHunspell, const char* dpath) { |
1043 return reinterpret_cast<Hunspell*>(pHunspell)->add_dic(dpath); | 1031 return reinterpret_cast<Hunspell*>(pHunspell)->add_dic(dpath); |
1044 } | 1032 } |
1045 +#endif | 1033 +#endif |
1046 | 1034 |
1047 int Hunspell_spell(Hunhandle* pHunspell, const char* word) { | 1035 int Hunspell_spell(Hunhandle* pHunspell, const char* word) { |
1048 return reinterpret_cast<Hunspell*>(pHunspell)->spell(std::string(word)); | 1036 return reinterpret_cast<Hunspell*>(pHunspell)->spell(std::string(word)); |
1049 diff --git a/third_party/hunspell/src/hunspell/hunspell.hxx b/third_party/hunspe
ll/src/hunspell/hunspell.hxx | 1037 diff --git a/src/hunspell/hunspell.hxx b/src/hunspell/hunspell.hxx |
1050 index db25bae..251d58e 100644 | 1038 index 43af66b..a35df83 100644 |
1051 --- a/third_party/hunspell/src/hunspell/hunspell.hxx | 1039 --- a/src/hunspell/hunspell.hxx |
1052 +++ b/third_party/hunspell/src/hunspell/hunspell.hxx | 1040 +++ b/src/hunspell/hunspell.hxx |
1053 @@ -78,6 +78,10 @@ | 1041 @@ -79,6 +79,10 @@ |
1054 #include <string> | 1042 #include <string> |
1055 #include <vector> | 1043 #include <vector> |
1056 | 1044 |
1057 +#ifdef HUNSPELL_CHROME_CLIENT | 1045 +#ifdef HUNSPELL_CHROME_CLIENT |
1058 +#include "third_party/hunspell/google/bdict_reader.h" | 1046 +#include "third_party/hunspell/google/bdict_reader.h" |
1059 +#endif | 1047 +#endif |
1060 + | 1048 + |
1061 #define SPELL_XML "<?xml?>" | 1049 #define SPELL_XML "<?xml?>" |
1062 | 1050 |
1063 #define MAXSUGGESTION 15 | 1051 #define MAXSUGGESTION 15 |
1064 @@ -111,11 +115,17 @@ class LIBHUNSPELL_DLL_EXPORTED Hunspell { | 1052 @@ -115,11 +119,17 @@ class LIBHUNSPELL_DLL_EXPORTED Hunspell { |
1065 * long path names (without the long path prefix Hunspell will use fopen() | 1053 * long path names (without the long path prefix Hunspell will use fopen() |
1066 * with system-dependent character encoding instead of _wfopen()). | 1054 * with system-dependent character encoding instead of _wfopen()). |
1067 */ | 1055 */ |
1068 +#ifdef HUNSPELL_CHROME_CLIENT | 1056 +#ifdef HUNSPELL_CHROME_CLIENT |
1069 + Hunspell(const unsigned char* bdict_data, size_t bdict_length); | 1057 + Hunspell(const unsigned char* bdict_data, size_t bdict_length); |
1070 +#else | 1058 +#else |
1071 Hunspell(const char* affpath, const char* dpath, const char* key = NULL); | 1059 Hunspell(const char* affpath, const char* dpath, const char* key = NULL); |
1072 +#endif | 1060 +#endif |
1073 ~Hunspell(); | 1061 ~Hunspell(); |
1074 | 1062 |
1075 +#ifndef HUNSPELL_CHROME_CLIENT | 1063 +#ifndef HUNSPELL_CHROME_CLIENT |
1076 /* load extra dictionaries (only dic files) */ | 1064 /* load extra dictionaries (only dic files) */ |
1077 int add_dic(const char* dpath, const char* key = NULL); | 1065 int add_dic(const char* dpath, const char* key = NULL); |
1078 +#endif | 1066 +#endif |
1079 | 1067 |
1080 /* spell(word) - spellcheck word | 1068 /* spell(word) - spellcheck word |
1081 * output: false = bad word, true = good word | 1069 * output: false = bad word, true = good word |
1082 diff --git a/third_party/hunspell/src/hunspell/replist.cxx b/third_party/hunspel
l/src/hunspell/replist.cxx | 1070 diff --git a/src/hunspell/replist.cxx b/src/hunspell/replist.cxx |
1083 index 8404947..3128420 100644 | 1071 index 89d4caa..756dc03 100644 |
1084 --- a/third_party/hunspell/src/hunspell/replist.cxx | 1072 --- a/src/hunspell/replist.cxx |
1085 +++ b/third_party/hunspell/src/hunspell/replist.cxx | 1073 +++ b/src/hunspell/replist.cxx |
1086 @@ -167,6 +167,7 @@ int RepList::add(const std::string& in_pat1, const std::stri
ng& pat2) { | 1074 @@ -167,6 +167,7 @@ int RepList::add(const std::string& in_pat1, const std::stri
ng& pat2) { |
1087 mystrrep(r->outstrings[type], "_", " "); | 1075 mystrrep(r->outstrings[type], "_", " "); |
1088 dat[pos++] = r; | 1076 dat[pos++] = r; |
1089 // sort to the right place in the list | 1077 // sort to the right place in the list |
1090 +#if 0 | 1078 +#if 0 |
1091 int i; | 1079 int i; |
1092 for (i = pos - 1; i > 0; i--) { | 1080 for (i = pos - 1; i > 0; i--) { |
1093 int c = strncmp(r->pattern.c_str(), dat[i-1]->pattern.c_str(), dat[i-1]->pa
ttern.size()); | 1081 int c = strncmp(r->pattern.c_str(), dat[i-1]->pattern.c_str(), dat[i-1]->pa
ttern.size()); |
1094 @@ -184,6 +185,15 @@ int RepList::add(const std::string& in_pat1, const std::str
ing& pat2) { | 1082 @@ -184,6 +185,15 @@ int RepList::add(const std::string& in_pat1, const std::str
ing& pat2) { |
1095 } | 1083 } |
1096 memmove(dat + i + 1, dat + i, (pos - i - 1) * sizeof(replentry *)); | 1084 memmove(dat + i + 1, dat + i, (pos - i - 1) * sizeof(replentry *)); |
1097 dat[i] = r; | 1085 dat[i] = r; |
1098 +#else | 1086 +#else |
1099 + for (int i = pos - 1; i > 0; i--) { | 1087 + for (int i = pos - 1; i > 0; i--) { |
1100 + r = dat[i]; | 1088 + r = dat[i]; |
1101 + if (r->pattern < dat[i - 1]->pattern) { | 1089 + if (r->pattern < dat[i - 1]->pattern) { |
1102 + dat[i] = dat[i - 1]; | 1090 + dat[i] = dat[i - 1]; |
1103 + dat[i - 1] = r; | 1091 + dat[i - 1] = r; |
1104 + } else break; | 1092 + } else break; |
1105 + } | 1093 + } |
1106 +#endif | 1094 +#endif |
1107 return 0; | 1095 return 0; |
1108 } | 1096 } |
1109 | 1097 |
1110 diff --git a/third_party/hunspell/src/hunspell/replist.hxx b/third_party/hunspel
l/src/hunspell/replist.hxx | 1098 diff --git a/src/hunspell/replist.hxx b/src/hunspell/replist.hxx |
1111 index ccf29b5c..176ccec 100644 | 1099 index 2f9d350..3afe005 100644 |
1112 --- a/third_party/hunspell/src/hunspell/replist.hxx | 1100 --- a/src/hunspell/replist.hxx |
1113 +++ b/third_party/hunspell/src/hunspell/replist.hxx | 1101 +++ b/src/hunspell/replist.hxx |
1114 @@ -75,6 +75,12 @@ | 1102 @@ -75,6 +75,12 @@ |
1115 #ifndef _REPLIST_HXX_ | 1103 #ifndef REPLIST_HXX_ |
1116 #define _REPLIST_HXX_ | 1104 #define REPLIST_HXX_ |
1117 | 1105 |
1118 +#ifdef HUNSPELL_CHROME_CLIENT | 1106 +#ifdef HUNSPELL_CHROME_CLIENT |
1119 +// Compilation issues in spellchecker.cc think near is a macro, therefore | 1107 +// Compilation issues in spellchecker.cc think near is a macro, therefore |
1120 +// removing it here solves that problem. | 1108 +// removing it here solves that problem. |
1121 +#undef near | 1109 +#undef near |
1122 +#endif | 1110 +#endif |
1123 + | 1111 + |
1124 #include "w_char.hxx" | 1112 #include "w_char.hxx" |
1125 | 1113 |
1126 #include <string> | 1114 #include <string> |
1127 diff --git a/third_party/hunspell/src/hunspell/suggestmgr.cxx b/third_party/huns
pell/src/hunspell/suggestmgr.cxx | 1115 diff --git a/src/hunspell/suggestmgr.cxx b/src/hunspell/suggestmgr.cxx |
1128 index 7a9dafa..55f99b6 100644 | 1116 index b998341..4e122da 100644 |
1129 --- a/third_party/hunspell/src/hunspell/suggestmgr.cxx | 1117 --- a/src/hunspell/suggestmgr.cxx |
1130 +++ b/third_party/hunspell/src/hunspell/suggestmgr.cxx | 1118 +++ b/src/hunspell/suggestmgr.cxx |
1131 @@ -82,7 +82,112 @@ | 1119 @@ -82,7 +82,112 @@ |
1132 | 1120 |
1133 const w_char W_VLINE = {'\0', '|'}; | 1121 const w_char W_VLINE = {'\0', '|'}; |
1134 | 1122 |
1135 +#ifdef HUNSPELL_CHROME_CLIENT | 1123 +#ifdef HUNSPELL_CHROME_CLIENT |
1136 +namespace { | 1124 +namespace { |
1137 +// A simple class which creates temporary hentry objects which are available | 1125 +// A simple class which creates temporary hentry objects which are available |
1138 +// only in a scope. To conceal memory operations from SuggestMgr functions, | 1126 +// only in a scope. To conceal memory operations from SuggestMgr functions, |
1139 +// this object automatically deletes all hentry objects created through | 1127 +// this object automatically deletes all hentry objects created through |
1140 +// CreateScopedHashEntry() calls in its destructor. So, the following snippet | 1128 +// CreateScopedHashEntry() calls in its destructor. So, the following snippet |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 @@ -1047,6 +1168,9 @@ void SuggestMgr::ngsuggest(std::vector<std::string>& wlst, | 1262 @@ -1047,6 +1168,9 @@ void SuggestMgr::ngsuggest(std::vector<std::string>& wlst, |
1275 | 1263 |
1276 struct hentry* hp = NULL; | 1264 struct hentry* hp = NULL; |
1277 int col = -1; | 1265 int col = -1; |
1278 +#ifdef HUNSPELL_CHROME_CLIENT | 1266 +#ifdef HUNSPELL_CHROME_CLIENT |
1279 + ScopedHashEntryFactory hash_entry_factory; | 1267 + ScopedHashEntryFactory hash_entry_factory; |
1280 +#endif | 1268 +#endif |
1281 phonetable* ph = (pAMgr) ? pAMgr->get_phonetable() : NULL; | 1269 phonetable* ph = (pAMgr) ? pAMgr->get_phonetable() : NULL; |
1282 std::string target; | 1270 std::string target; |
1283 std::string candidate; | 1271 std::string candidate; |
1284 @@ -1109,7 +1233,11 @@ void SuggestMgr::ngsuggest(std::vector<std::string>& wlst
, | 1272 @@ -1074,12 +1198,12 @@ void SuggestMgr::ngsuggest(std::vector<std::string>& wls
t, |
| 1273 u8_u16(w_word, word); |
| 1274 u8_u16(w_target, target); |
| 1275 } |
| 1276 - |
| 1277 + |
| 1278 std::vector<w_char> w_entry; |
| 1279 std::string f; |
| 1280 std::vector<w_char> w_f; |
| 1281 std::vector<w_char> w_target2; |
| 1282 - |
| 1283 + |
| 1284 for (size_t i = 0; i < rHMgr.size(); ++i) { |
| 1285 while (0 != (hp = rHMgr[i]->walk_hashtable(col, hp))) { |
| 1286 if ((hp->astr) && (pAMgr) && |
| 1287 @@ -1143,7 +1267,11 @@ void SuggestMgr::ngsuggest(std::vector<std::string>& wlst
, |
1285 | 1288 |
1286 if (sc > scores[lp]) { | 1289 if (sc > scores[lp]) { |
1287 scores[lp] = sc; | 1290 scores[lp] = sc; |
1288 +#ifdef HUNSPELL_CHROME_CLIENT | 1291 +#ifdef HUNSPELL_CHROME_CLIENT |
1289 + roots[lp] = hash_entry_factory.CreateScopedHashEntry(lp, hp); | 1292 + roots[lp] = hash_entry_factory.CreateScopedHashEntry(lp, hp); |
1290 +#else | 1293 +#else |
1291 roots[lp] = hp; | 1294 roots[lp] = hp; |
1292 +#endif | 1295 +#endif |
1293 lval = sc; | 1296 lval = sc; |
1294 for (int j = 0; j < MAX_ROOTS; j++) | 1297 for (int j = 0; j < MAX_ROOTS; j++) |
1295 if (scores[j] < lval) { | 1298 if (scores[j] < lval) { |
1296 @@ -1137,6 +1265,7 @@ void SuggestMgr::ngsuggest(std::vector<std::string>& wlst, | 1299 @@ -2058,8 +2186,8 @@ void SuggestMgr::lcs(const char* s, |
1297 int thresh = 0; | |
1298 for (int sp = 1; sp < 4; sp++) { | |
1299 if (utf8) { | |
1300 + u8_u16(u8, word); | |
1301 for (int k = sp; k < n; k += 4) { | |
1302 u8[k].l = '*'; | |
1303 u8[k].h = 0; | |
1304 @@ -1968,8 +2097,8 @@ void SuggestMgr::lcs(const char* s, | |
1305 m = strlen(s); | 1300 m = strlen(s); |
1306 n = strlen(s2); | 1301 n = strlen(s2); |
1307 } | 1302 } |
1308 - c = (char*)malloc((m + 1) * (n + 1)); | 1303 - c = (char*)malloc((m + 1) * (n + 1)); |
1309 - b = (char*)malloc((m + 1) * (n + 1)); | 1304 - b = (char*)malloc((m + 1) * (n + 1)); |
1310 + c = (char *) calloc(m + 1, n + 1); | 1305 + c = (char *) calloc(m + 1, n + 1); |
1311 + b = (char *) calloc(m + 1, n + 1); | 1306 + b = (char *) calloc(m + 1, n + 1); |
1312 if (!c || !b) { | 1307 if (!c || !b) { |
1313 if (c) | 1308 if (c) |
1314 free(c); | 1309 free(c); |
1315 @@ -1978,10 +2107,6 @@ void SuggestMgr::lcs(const char* s, | 1310 @@ -2068,10 +2196,6 @@ void SuggestMgr::lcs(const char* s, |
1316 *result = NULL; | 1311 *result = NULL; |
1317 return; | 1312 return; |
1318 } | 1313 } |
1319 - for (i = 1; i <= m; i++) | 1314 - for (i = 1; i <= m; i++) |
1320 - c[i * (n + 1)] = 0; | 1315 - c[i * (n + 1)] = 0; |
1321 - for (j = 0; j <= n; j++) | 1316 - for (j = 0; j <= n; j++) |
1322 - c[j] = 0; | 1317 - c[j] = 0; |
1323 for (i = 1; i <= m; i++) { | 1318 for (i = 1; i <= m; i++) { |
1324 for (j = 1; j <= n; j++) { | 1319 for (j = 1; j <= n; j++) { |
1325 if (((utf8) && (su[i - 1] == su2[j - 1])) || | 1320 if (((utf8) && (su[i - 1] == su2[j - 1])) || |
1326 diff --git a/third_party/hunspell/src/hunspell/suggestmgr.hxx b/third_party/huns
pell/src/hunspell/suggestmgr.hxx | 1321 diff --git a/src/hunspell/suggestmgr.hxx b/src/hunspell/suggestmgr.hxx |
1327 index ee0322c..f940431 100644 | 1322 index 6ba9dc8..0b80fac 100644 |
1328 --- a/third_party/hunspell/src/hunspell/suggestmgr.hxx | 1323 --- a/src/hunspell/suggestmgr.hxx |
1329 +++ b/third_party/hunspell/src/hunspell/suggestmgr.hxx | 1324 +++ b/src/hunspell/suggestmgr.hxx |
1330 @@ -124,7 +124,11 @@ class SuggestMgr { | 1325 @@ -124,7 +124,11 @@ class SuggestMgr { |
1331 int complexprefixes; | 1326 int complexprefixes; |
1332 | 1327 |
1333 public: | 1328 public: |
1334 +#ifdef HUNSPELL_CHROME_CLIENT | 1329 +#ifdef HUNSPELL_CHROME_CLIENT |
1335 + SuggestMgr(hunspell::BDictReader* reader, const char * tryme, int maxn, Affix
Mgr *aptr); | 1330 + SuggestMgr(hunspell::BDictReader* reader, const char * tryme, int maxn, Affix
Mgr *aptr); |
1336 +#else | 1331 +#else |
1337 SuggestMgr(const char* tryme, unsigned int maxn, AffixMgr* aptr); | 1332 SuggestMgr(const char* tryme, unsigned int maxn, AffixMgr* aptr); |
1338 +#endif | 1333 +#endif |
1339 ~SuggestMgr(); | 1334 ~SuggestMgr(); |
1340 | 1335 |
1341 void suggest(std::vector<std::string>& slst, const char* word, int* onlycmpds
ug); | 1336 void suggest(std::vector<std::string>& slst, const char* word, int* onlycmpds
ug); |
1342 @@ -134,6 +138,10 @@ class SuggestMgr { | 1337 @@ -134,6 +138,10 @@ class SuggestMgr { |
1343 std::string suggest_gen(const std::vector<std::string>& pl, const std::string
& pattern); | 1338 std::string suggest_gen(const std::vector<std::string>& pl, const std::string
& pattern); |
1344 | 1339 |
1345 private: | 1340 private: |
1346 +#ifdef HUNSPELL_CHROME_CLIENT | 1341 +#ifdef HUNSPELL_CHROME_CLIENT |
1347 + // Not owned by us, owned by the Hunspell object. | 1342 + // Not owned by us, owned by the Hunspell object. |
1348 + hunspell::BDictReader* bdict_reader; | 1343 + hunspell::BDictReader* bdict_reader; |
1349 +#endif | 1344 +#endif |
1350 void testsug(std::vector<std::string>& wlst, | 1345 void testsug(std::vector<std::string>& wlst, |
1351 const std::string& candidate, | 1346 const std::string& candidate, |
1352 int cpdsuggest, | 1347 int cpdsuggest, |
1353 diff --git a/third_party/hunspell/src/parsers/testparser.cxx b/third_party/hunsp
ell/src/parsers/testparser.cxx | |
1354 index 69f2cbc3..81db53a 100644 | |
1355 --- a/third_party/hunspell/src/parsers/testparser.cxx | |
1356 +++ b/third_party/hunspell/src/parsers/testparser.cxx | |
1357 @@ -14,15 +14,15 @@ | |
1358 * The Original Code is Hunspell, based on MySpell. | |
1359 * | |
1360 * The Initial Developers of the Original Code are | |
1361 - * Kevin Hendricks (MySpell) and Németh László (Hunspell). | |
1362 + * Kevin Hendricks (MySpell) and Németh László (Hunspell). | |
1363 * Portions created by the Initial Developers are Copyright (C) 2002-2005 | |
1364 * the Initial Developers. All Rights Reserved. | |
1365 * | |
1366 * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, | |
1367 - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, | |
1368 - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, | |
1369 - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, | |
1370 - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen | |
1371 + * Gianluca Turconi, Simon Brouwer, Noll János, BÃró Ãrpád, | |
1372 + * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, | |
1373 + * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, | |
1374 + * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen | |
1375 * | |
1376 * Alternatively, the contents of this file may be used under the terms of | |
1377 * either the GNU General Public License Version 2 or later (the "GPL"), or | |
OLD | NEW |