Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 Index: src/hunspell/affixmgr.cxx | 1 Index: src/hunspell/affixmgr.cxx |
| 2 =================================================================== | 2 =================================================================== |
| 3 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/affixmgr.cxx,v | 3 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/affixmgr.cxx,v |
| 4 retrieving revision 1.41 | 4 retrieving revision 1.41 |
| 5 diff -u -r1.41 affixmgr.cxx | 5 diff -u -r1.41 affixmgr.cxx |
| 6 --- src/hunspell/affixmgr.cxx 16 Dec 2011 09:15:34 -0000 1.41 | 6 --- src/hunspell/affixmgr.cxx 16 Dec 2011 09:15:34 -0000 1.41 |
| 7 +++ src/hunspell/affixmgr.cxx» 23 Mar 2012 05:56:23 -0000 | 7 +++ src/hunspell/affixmgr.cxx» 20 Dec 2012 17:39:19 -0000 |
| 8 @@ -14,8 +14,14 @@ | 8 @@ -14,8 +14,14 @@ |
| 9 | 9 |
| 10 #include "csutil.hxx" | 10 #include "csutil.hxx" |
| 11 | 11 |
| 12 +#ifdef HUNSPELL_CHROME_CLIENT | 12 +#ifdef HUNSPELL_CHROME_CLIENT |
| 13 +AffixMgr::AffixMgr(hunspell::BDictReader* reader, HashMgr** ptr, int * md) | 13 +AffixMgr::AffixMgr(hunspell::BDictReader* reader, HashMgr** ptr, int * md) |
| 14 +{ | 14 +{ |
| 15 + bdict_reader = reader; | 15 + bdict_reader = reader; |
| 16 +#else | 16 +#else |
| 17 AffixMgr::AffixMgr(const char * affpath, HashMgr** ptr, int * md, const char * key) | 17 AffixMgr::AffixMgr(const char * affpath, HashMgr** ptr, int * md, const char * key) |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 +#endif | 188 +#endif |
| 189 break; | 189 break; |
| 190 } | 190 } |
| 191 // piece 3 - is cross product indicator | 191 // piece 3 - is cross product indicator |
| 192 Index: src/hunspell/affixmgr.hxx | 192 Index: src/hunspell/affixmgr.hxx |
| 193 =================================================================== | 193 =================================================================== |
| 194 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/affixmgr.hxx,v | 194 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/affixmgr.hxx,v |
| 195 retrieving revision 1.15 | 195 retrieving revision 1.15 |
| 196 diff -u -r1.15 affixmgr.hxx | 196 diff -u -r1.15 affixmgr.hxx |
| 197 --- src/hunspell/affixmgr.hxx 13 Oct 2011 13:41:54 -0000 1.15 | 197 --- src/hunspell/affixmgr.hxx 13 Oct 2011 13:41:54 -0000 1.15 |
| 198 +++ src/hunspell/affixmgr.hxx» 23 Mar 2012 05:56:23 -0000 | 198 +++ src/hunspell/affixmgr.hxx» 20 Dec 2012 17:39:19 -0000 |
| 199 @@ -18,6 +18,40 @@ | 199 @@ -18,6 +18,40 @@ |
| 200 class PfxEntry; | 200 class PfxEntry; |
| 201 class SfxEntry; | 201 class SfxEntry; |
| 202 | 202 |
| 203 +#ifdef HUNSPELL_CHROME_CLIENT | 203 +#ifdef HUNSPELL_CHROME_CLIENT |
| 204 + | 204 + |
| 205 +#include <vector> | 205 +#include <vector> |
| 206 + | 206 + |
| 207 +// This class provides an implementation of the contclasses array in AffixMgr | 207 +// This class provides an implementation of the contclasses array in AffixMgr |
| 208 +// that is normally a large static array. We should almost never need more than | 208 +// that is normally a large static array. We should almost never need more than |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 #endif | 275 #endif |
| 276 - | 276 - |
| 277 Index: src/hunspell/filemgr.cxx | 277 Index: src/hunspell/filemgr.cxx |
| 278 =================================================================== | 278 =================================================================== |
| 279 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/filemgr.cxx,v | 279 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/filemgr.cxx,v |
| 280 retrieving revision 1.5 | 280 retrieving revision 1.5 |
| 281 diff -u -r1.5 filemgr.cxx | 281 diff -u -r1.5 filemgr.cxx |
| 282 --- src/hunspell/filemgr.cxx 23 Jun 2011 09:21:50 -0000 1.5 | 282 --- src/hunspell/filemgr.cxx 23 Jun 2011 09:21:50 -0000 1.5 |
| 283 +++ src/hunspell/filemgr.cxx» 23 Mar 2012 05:56:23 -0000 | 283 +++ src/hunspell/filemgr.cxx» 20 Dec 2012 17:39:19 -0000 |
| 284 @@ -7,6 +7,32 @@ | 284 @@ -7,6 +7,32 @@ |
| 285 | 285 |
| 286 #include "filemgr.hxx" | 286 #include "filemgr.hxx" |
| 287 | 287 |
| 288 +#ifdef HUNSPELL_CHROME_CLIENT | 288 +#ifdef HUNSPELL_CHROME_CLIENT |
| 289 +#include "third_party/hunspell/google/bdict_reader.h" | 289 +#include "third_party/hunspell/google/bdict_reader.h" |
| 290 + | 290 + |
| 291 +FileMgr::FileMgr(hunspell::LineIterator* iterator) : iterator_(iterator) { | 291 +FileMgr::FileMgr(hunspell::LineIterator* iterator) : iterator_(iterator) { |
| 292 +} | 292 +} |
| 293 + | 293 + |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 318 int FileMgr::getlinenum() { | 318 int FileMgr::getlinenum() { |
| 319 return linenum; | 319 return linenum; |
| 320 } | 320 } |
| 321 +#endif | 321 +#endif |
| 322 Index: src/hunspell/filemgr.hxx | 322 Index: src/hunspell/filemgr.hxx |
| 323 =================================================================== | 323 =================================================================== |
| 324 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/filemgr.hxx,v | 324 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/filemgr.hxx,v |
| 325 retrieving revision 1.3 | 325 retrieving revision 1.3 |
| 326 diff -u -r1.3 filemgr.hxx | 326 diff -u -r1.3 filemgr.hxx |
| 327 --- src/hunspell/filemgr.hxx 15 Apr 2010 11:22:08 -0000 1.3 | 327 --- src/hunspell/filemgr.hxx 15 Apr 2010 11:22:08 -0000 1.3 |
| 328 +++ src/hunspell/filemgr.hxx» 23 Mar 2012 05:56:23 -0000 | 328 +++ src/hunspell/filemgr.hxx» 20 Dec 2012 17:39:19 -0000 |
| 329 @@ -7,6 +7,30 @@ | 329 @@ -7,6 +7,30 @@ |
| 330 #include "hunzip.hxx" | 330 #include "hunzip.hxx" |
| 331 #include <stdio.h> | 331 #include <stdio.h> |
| 332 | 332 |
| 333 +#ifdef HUNSPELL_CHROME_CLIENT | 333 +#ifdef HUNSPELL_CHROME_CLIENT |
| 334 +namespace hunspell { | 334 +namespace hunspell { |
| 335 +class LineIterator; | 335 +class LineIterator; |
| 336 +} // namespace hunspell | 336 +} // namespace hunspell |
| 337 + | 337 + |
| 338 +// A class which encapsulates operations of reading a BDICT file. | 338 +// A class which encapsulates operations of reading a BDICT file. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 361 int getlinenum(); | 361 int getlinenum(); |
| 362 }; | 362 }; |
| 363 #endif | 363 #endif |
| 364 +#endif | 364 +#endif |
| 365 Index: src/hunspell/hashmgr.cxx | 365 Index: src/hunspell/hashmgr.cxx |
| 366 =================================================================== | 366 =================================================================== |
| 367 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hashmgr.cxx,v | 367 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hashmgr.cxx,v |
| 368 retrieving revision 1.12 | 368 retrieving revision 1.12 |
| 369 diff -u -r1.12 hashmgr.cxx | 369 diff -u -r1.12 hashmgr.cxx |
| 370 --- src/hunspell/hashmgr.cxx 23 Jun 2011 09:21:50 -0000 1.12 | 370 --- src/hunspell/hashmgr.cxx 23 Jun 2011 09:21:50 -0000 1.12 |
| 371 +++ src/hunspell/hashmgr.cxx» 23 Mar 2012 05:56:23 -0000 | 371 +++ src/hunspell/hashmgr.cxx» 20 Dec 2012 17:39:19 -0000 |
| 372 @@ -12,8 +12,14 @@ | 372 @@ -12,8 +12,14 @@ |
| 373 | 373 |
| 374 // build a hash table from a munched word list | 374 // build a hash table from a munched word list |
| 375 | 375 |
| 376 +#ifdef HUNSPELL_CHROME_CLIENT | 376 +#ifdef HUNSPELL_CHROME_CLIENT |
| 377 +HashMgr::HashMgr(hunspell::BDictReader* reader) | 377 +HashMgr::HashMgr(hunspell::BDictReader* reader) |
| 378 +{ | 378 +{ |
| 379 + bdict_reader = reader; | 379 + bdict_reader = reader; |
| 380 +#else | 380 +#else |
| 381 HashMgr::HashMgr(const char * tpath, const char * apath, const char * key) | 381 HashMgr::HashMgr(const char * tpath, const char * apath, const char * key) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 + std::string* new_string_word = new std::string(word); | 484 + std::string* new_string_word = new std::string(word); |
| 485 + pointer_to_strings_.push_back(new_string_word); | 485 + pointer_to_strings_.push_back(new_string_word); |
| 486 + base::StringPiece sp(*(new_string_word)); | 486 + base::StringPiece sp(*(new_string_word)); |
| 487 + custom_word_to_affix_id_map_[sp] = 0; // no affixes for custom words | 487 + custom_word_to_affix_id_map_[sp] = 0; // no affixes for custom words |
| 488 + return 1; | 488 + return 1; |
| 489 + } | 489 + } |
| 490 +#endif | 490 +#endif |
| 491 return 0; | 491 return 0; |
| 492 } | 492 } |
| 493 | 493 |
| 494 @@ -339,6 +407,44 @@ | 494 @@ -256,6 +324,12 @@ |
| 495 // remove word (personal dictionary function for standalone applications) | |
| 496 int HashMgr::remove(const char * word) | |
| 497 { | |
| 498 +#ifdef HUNSPELL_CHROME_CLIENT | |
| 499 + std::map<base::StringPiece, int>::iterator iter = | |
| 500 + custom_word_to_affix_id_map_.find(word); | |
| 501 + if (iter != custom_word_to_affix_id_map_.end()) | |
| 502 + custom_word_to_affix_id_map_.erase(iter); | |
| 503 +#else | |
| 504 struct hentry * dp = lookup(word); | |
| 505 while (dp) { | |
| 506 if (dp->alen == 0 || !TESTAFF(dp->astr, forbiddenword, dp->alen)) { | |
| 507 @@ -270,6 +344,7 @@ | |
| 508 } | |
| 509 dp = dp->next_homonym; | |
| 510 } | |
| 511 +#endif | |
| 512 return 0; | |
| 513 } | |
| 514 | |
| 515 @@ -339,6 +414,44 @@ | |
| 495 // initialize: col=-1; hp = NULL; hp = walk_hashtable(&col, hp); | 516 // initialize: col=-1; hp = NULL; hp = walk_hashtable(&col, hp); |
| 496 struct hentry * HashMgr::walk_hashtable(int &col, struct hentry * hp) const | 517 struct hentry * HashMgr::walk_hashtable(int &col, struct hentry * hp) const |
| 497 { | 518 { |
| 498 +#ifdef HUNSPELL_CHROME_CLIENT | 519 +#ifdef HUNSPELL_CHROME_CLIENT |
| 499 + // Return NULL if dictionary is not valid. | 520 + // Return NULL if dictionary is not valid. |
| 500 + if (!bdict_reader->IsValid()) | 521 + if (!bdict_reader->IsValid()) |
| 501 + return NULL; | 522 + return NULL; |
| 502 + | 523 + |
| 503 + // This function is only ever called by one place and not nested. We can | 524 + // This function is only ever called by one place and not nested. We can |
| 504 + // therefore keep static state between calls and use |col| as a "reset" flag | 525 + // therefore keep static state between calls and use |col| as a "reset" flag |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 529 + hentry entry; | 550 + hentry entry; |
| 530 + char word[kMaxWordLen]; | 551 + char word[kMaxWordLen]; |
| 531 + } hash_entry; | 552 + } hash_entry; |
| 532 + | 553 + |
| 533 + return InitHashEntry(&hash_entry.entry, sizeof(hash_entry), | 554 + return InitHashEntry(&hash_entry.entry, sizeof(hash_entry), |
| 534 + &word[0], word_len, affix_ids[0]); | 555 + &word[0], word_len, affix_ids[0]); |
| 535 +#else | 556 +#else |
| 536 if (hp && hp->next != NULL) return hp->next; | 557 if (hp && hp->next != NULL) return hp->next; |
| 537 for (col++; col < tablesize; col++) { | 558 for (col++; col < tablesize; col++) { |
| 538 if (tableptr[col]) return tableptr[col]; | 559 if (tableptr[col]) return tableptr[col]; |
| 539 @@ -346,11 +452,13 @@ | 560 @@ -346,11 +459,13 @@ |
| 540 // null at end and reset to start | 561 // null at end and reset to start |
| 541 col = -1; | 562 col = -1; |
| 542 return NULL; | 563 return NULL; |
| 543 +#endif | 564 +#endif |
| 544 } | 565 } |
| 545 | 566 |
| 546 // load a munched word list and build a hash table on the fly | 567 // load a munched word list and build a hash table on the fly |
| 547 int HashMgr::load_tables(const char * tpath, const char * key) | 568 int HashMgr::load_tables(const char * tpath, const char * key) |
| 548 { | 569 { |
| 549 +#ifndef HUNSPELL_CHROME_CLIENT | 570 +#ifndef HUNSPELL_CHROME_CLIENT |
| 550 int al; | 571 int al; |
| 551 char * ap; | 572 char * ap; |
| 552 char * dp; | 573 char * dp; |
| 553 @@ -471,6 +579,7 @@ | 574 @@ -471,6 +586,7 @@ |
| 554 } | 575 } |
| 555 | 576 |
| 556 delete dict; | 577 delete dict; |
| 557 +#endif | 578 +#endif |
| 558 return 0; | 579 return 0; |
| 559 } | 580 } |
| 560 | 581 |
| 561 @@ -479,6 +588,9 @@ | 582 @@ -479,6 +595,9 @@ |
| 562 | 583 |
| 563 int HashMgr::hash(const char * word) const | 584 int HashMgr::hash(const char * word) const |
| 564 { | 585 { |
| 565 +#ifdef HUNSPELL_CHROME_CLIENT | 586 +#ifdef HUNSPELL_CHROME_CLIENT |
| 566 + return 0; | 587 + return 0; |
| 567 +#else | 588 +#else |
| 568 long hv = 0; | 589 long hv = 0; |
| 569 for (int i=0; i < 4 && *word != 0; i++) | 590 for (int i=0; i < 4 && *word != 0; i++) |
| 570 hv = (hv << 8) | (*word++); | 591 hv = (hv << 8) | (*word++); |
| 571 @@ -487,6 +599,7 @@ | 592 @@ -487,6 +606,7 @@ |
| 572 hv ^= (*word++); | 593 hv ^= (*word++); |
| 573 } | 594 } |
| 574 return (unsigned long) hv % tablesize; | 595 return (unsigned long) hv % tablesize; |
| 575 +#endif | 596 +#endif |
| 576 } | 597 } |
| 577 | 598 |
| 578 int HashMgr::decode_flags(unsigned short ** result, char * flags, FileMgr * af) { | 599 int HashMgr::decode_flags(unsigned short ** result, char * flags, FileMgr * af) { |
| 579 @@ -607,7 +720,12 @@ | 600 @@ -607,7 +727,12 @@ |
| 580 int firstline = 1; | 601 int firstline = 1; |
| 581 | 602 |
| 582 // open the affix file | 603 // open the affix file |
| 583 +#ifdef HUNSPELL_CHROME_CLIENT | 604 +#ifdef HUNSPELL_CHROME_CLIENT |
| 584 + hunspell::LineIterator iterator = bdict_reader->GetOtherLineIterator(); | 605 + hunspell::LineIterator iterator = bdict_reader->GetOtherLineIterator(); |
| 585 + FileMgr * afflst = new FileMgr(&iterator); | 606 + FileMgr * afflst = new FileMgr(&iterator); |
| 586 +#else | 607 +#else |
| 587 FileMgr * afflst = new FileMgr(affpath, key); | 608 FileMgr * afflst = new FileMgr(affpath, key); |
| 588 +#endif | 609 +#endif |
| 589 if (!afflst) { | 610 if (!afflst) { |
| 590 HUNSPELL_WARNING(stderr, "Error - could not open affix description file %s\ n",affpath); | 611 HUNSPELL_WARNING(stderr, "Error - could not open affix description file %s\ n",affpath); |
| 591 return 1; | 612 return 1; |
| 592 @@ -802,6 +920,121 @@ | 613 @@ -802,6 +927,121 @@ |
| 593 return 0; | 614 return 0; |
| 594 } | 615 } |
| 595 | 616 |
| 596 +#ifdef HUNSPELL_CHROME_CLIENT | 617 +#ifdef HUNSPELL_CHROME_CLIENT |
| 597 +int HashMgr::LoadAFLines() | 618 +int HashMgr::LoadAFLines() |
| 598 +{ | 619 +{ |
| 599 + utf8 = 1; // We always use UTF-8. | 620 + utf8 = 1; // We always use UTF-8. |
| 600 + | 621 + |
| 601 + // Read in all the AF lines which tell us the rules for each affix group ID. | 622 + // Read in all the AF lines which tell us the rules for each affix group ID. |
| 602 + hunspell::LineIterator iterator = bdict_reader->GetAfLineIterator(); | 623 + hunspell::LineIterator iterator = bdict_reader->GetAfLineIterator(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 + | 731 + |
| 711 int HashMgr::is_aliasf() { | 732 int HashMgr::is_aliasf() { |
| 712 return (aliasf != NULL); | 733 return (aliasf != NULL); |
| 713 } | 734 } |
| 714 Index: src/hunspell/hashmgr.hxx | 735 Index: src/hunspell/hashmgr.hxx |
| 715 =================================================================== | 736 =================================================================== |
| 716 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hashmgr.hxx,v | 737 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hashmgr.hxx,v |
| 717 retrieving revision 1.3 | 738 retrieving revision 1.3 |
| 718 diff -u -r1.3 hashmgr.hxx | 739 diff -u -r1.3 hashmgr.hxx |
| 719 --- src/hunspell/hashmgr.hxx 15 Apr 2010 11:22:08 -0000 1.3 | 740 --- src/hunspell/hashmgr.hxx 15 Apr 2010 11:22:08 -0000 1.3 |
| 720 +++ src/hunspell/hashmgr.hxx» 23 Mar 2012 05:56:23 -0000 | 741 +++ src/hunspell/hashmgr.hxx» 20 Dec 2012 17:39:19 -0000 |
| 721 @@ -8,10 +8,25 @@ | 742 @@ -8,10 +8,25 @@ |
| 722 #include "htypes.hxx" | 743 #include "htypes.hxx" |
| 723 #include "filemgr.hxx" | 744 #include "filemgr.hxx" |
| 724 | 745 |
| 725 +#ifdef HUNSPELL_CHROME_CLIENT | 746 +#ifdef HUNSPELL_CHROME_CLIENT |
| 726 +#include <string> | 747 +#include <string> |
| 727 +#include <map> | 748 +#include <map> |
| 728 + | 749 + |
| 729 +#include "base/stl_util.h" | 750 +#include "base/stl_util.h" |
| 730 +#include "base/string_piece.h" | 751 +#include "base/string_piece.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 808 + | 829 + |
| 809 int add_hidden_capitalized_word(char * word, int wbl, int wcl, | 830 int add_hidden_capitalized_word(char * word, int wbl, int wcl, |
| 810 unsigned short * flags, int al, char * dp, int captype); | 831 unsigned short * flags, int al, char * dp, int captype); |
| 811 int parse_aliasm(char * line, FileMgr * af); | 832 int parse_aliasm(char * line, FileMgr * af); |
| 812 Index: src/hunspell/htypes.hxx | 833 Index: src/hunspell/htypes.hxx |
| 813 =================================================================== | 834 =================================================================== |
| 814 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/htypes.hxx,v | 835 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/htypes.hxx,v |
| 815 retrieving revision 1.3 | 836 retrieving revision 1.3 |
| 816 diff -u -r1.3 htypes.hxx | 837 diff -u -r1.3 htypes.hxx |
| 817 --- src/hunspell/htypes.hxx 6 Sep 2010 07:58:53 -0000 1.3 | 838 --- src/hunspell/htypes.hxx 6 Sep 2010 07:58:53 -0000 1.3 |
| 818 +++ src/hunspell/htypes.hxx» 23 Mar 2012 05:56:23 -0000 | 839 +++ src/hunspell/htypes.hxx» 20 Dec 2012 17:39:19 -0000 |
| 819 @@ -1,6 +1,16 @@ | 840 @@ -1,6 +1,16 @@ |
| 820 #ifndef _HTYPES_HXX_ | 841 #ifndef _HTYPES_HXX_ |
| 821 #define _HTYPES_HXX_ | 842 #define _HTYPES_HXX_ |
| 822 | 843 |
| 823 +#ifdef HUNSPELL_CHROME_CLIENT | 844 +#ifdef HUNSPELL_CHROME_CLIENT |
| 824 +// This is a workaround for preventing errors in parsing Turkish BDICs, which | 845 +// This is a workaround for preventing errors in parsing Turkish BDICs, which |
| 825 +// contain very long AF lines (~ 12,000 chars). | 846 +// contain very long AF lines (~ 12,000 chars). |
| 826 +// TODO(hbono) change the HashMgr::parse_aliasf() function to be able to parse | 847 +// TODO(hbono) change the HashMgr::parse_aliasf() function to be able to parse |
| 827 +// longer lines than MAXDELEN. | 848 +// longer lines than MAXDELEN. |
| 828 +#define MAXDELEN (8192 * 2) | 849 +#define MAXDELEN (8192 * 2) |
| 829 +#else | 850 +#else |
| 830 +#define MAXDELEN 8192 | 851 +#define MAXDELEN 8192 |
| 831 +#endif // HUNSPELL_CHROME_CLIENT | 852 +#endif // HUNSPELL_CHROME_CLIENT |
| 832 + | 853 + |
| 833 #define ROTATE_LEN 5 | 854 #define ROTATE_LEN 5 |
| 834 | 855 |
| 835 #define ROTATE(v,q) \ | 856 #define ROTATE(v,q) \ |
| 836 Index: src/hunspell/hunspell.cxx | 857 Index: src/hunspell/hunspell.cxx |
| 837 =================================================================== | 858 =================================================================== |
| 838 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hunspell.cxx,v | 859 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hunspell.cxx,v |
| 839 retrieving revision 1.29 | 860 retrieving revision 1.29 |
| 840 diff -u -r1.29 hunspell.cxx | 861 diff -u -r1.29 hunspell.cxx |
| 841 --- src/hunspell/hunspell.cxx 23 Jun 2011 09:21:50 -0000 1.29 | 862 --- src/hunspell/hunspell.cxx 23 Jun 2011 09:21:50 -0000 1.29 |
| 842 +++ src/hunspell/hunspell.cxx» 23 Mar 2012 05:56:24 -0000 | 863 +++ src/hunspell/hunspell.cxx» 20 Dec 2012 17:39:19 -0000 |
| 843 @@ -12,15 +12,30 @@ | 864 @@ -7,20 +7,37 @@ |
| 865 | |
| 866 #include "hunspell.hxx" | |
| 867 #include "hunspell.h" | |
| 868 +#ifndef HUNSPELL_CHROME_CLIENT | |
| 869 #ifndef MOZILLA_CLIENT | |
| 870 # include "config.h" | |
| 844 #endif | 871 #endif |
| 872 +#endif | |
| 845 #include "csutil.hxx" | 873 #include "csutil.hxx" |
| 846 | 874 |
| 847 +#ifdef HUNSPELL_CHROME_CLIENT | 875 +#ifdef HUNSPELL_CHROME_CLIENT |
| 848 +Hunspell::Hunspell(const unsigned char* bdict_data, size_t bdict_length) | 876 +Hunspell::Hunspell(const unsigned char* bdict_data, size_t bdict_length) |
| 849 +#else | 877 +#else |
| 850 Hunspell::Hunspell(const char * affpath, const char * dpath, const char * key) | 878 Hunspell::Hunspell(const char * affpath, const char * dpath, const char * key) |
| 851 +#endif | 879 +#endif |
| 852 { | 880 { |
| 853 encoding = NULL; | 881 encoding = NULL; |
| 854 csconv = NULL; | 882 csconv = NULL; |
| 855 utf8 = 0; | 883 utf8 = 0; |
| 856 complexprefixes = 0; | 884 complexprefixes = 0; |
| 857 +#ifndef HUNSPELL_CHROME_CLIENT | 885 +#ifndef HUNSPELL_CHROME_CLIENT |
| 858 affixpath = mystrdup(affpath); | 886 affixpath = mystrdup(affpath); |
| 859 +#endif | 887 +#endif |
| 860 maxdic = 0; | 888 maxdic = 0; |
| 861 | 889 |
| 862 +#ifdef HUNSPELL_CHROME_CLIENT | 890 +#ifdef HUNSPELL_CHROME_CLIENT |
| 863 + bdict_reader = new hunspell::BDictReader; | 891 + bdict_reader = new hunspell::BDictReader; |
| 864 + bdict_reader->Init(bdict_data, bdict_length); | 892 + bdict_reader->Init(bdict_data, bdict_length); |
| 865 + | 893 + |
| 866 + pHMgr[0] = new HashMgr(bdict_reader); | 894 + pHMgr[0] = new HashMgr(bdict_reader); |
| 867 + if (pHMgr[0]) maxdic = 1; | 895 + if (pHMgr[0]) maxdic = 1; |
| 868 + | 896 + |
| 869 + pAMgr = new AffixMgr(bdict_reader, pHMgr, &maxdic); | 897 + pAMgr = new AffixMgr(bdict_reader, pHMgr, &maxdic); |
| 870 +#else | 898 +#else |
| 871 /* first set up the hash manager */ | 899 /* first set up the hash manager */ |
| 872 pHMgr[0] = new HashMgr(dpath, affpath, key); | 900 pHMgr[0] = new HashMgr(dpath, affpath, key); |
| 873 if (pHMgr[0]) maxdic = 1; | 901 if (pHMgr[0]) maxdic = 1; |
| 874 @@ -28,6 +43,7 @@ | 902 @@ -28,6 +45,7 @@ |
| 875 /* next set up the affix manager */ | 903 /* next set up the affix manager */ |
| 876 /* it needs access to the hash manager lookup methods */ | 904 /* it needs access to the hash manager lookup methods */ |
| 877 pAMgr = new AffixMgr(affpath, pHMgr, &maxdic, key); | 905 pAMgr = new AffixMgr(affpath, pHMgr, &maxdic, key); |
| 878 +#endif | 906 +#endif |
| 879 | 907 |
| 880 /* get the preferred try string and the dictionary */ | 908 /* get the preferred try string and the dictionary */ |
| 881 /* encoding from the Affix Manager for that dictionary */ | 909 /* encoding from the Affix Manager for that dictionary */ |
| 882 @@ -59,10 +75,16 @@ | 910 @@ -41,7 +59,11 @@ |
| 911 wordbreak = pAMgr->get_breaktable(); | |
|
groby-ooo-7-16
2012/12/20 22:56:28
This one and the free statement a bit later are od
please use gerrit instead
2012/12/21 02:24:39
"wordbreak = pAMgr->get_breaktable()" itself is no
| |
| 912 | |
| 913 /* and finally set up the suggestion manager */ | |
| 914 +#ifdef HUNSPELL_CHROME_CLIENT | |
| 915 + pSMgr = new SuggestMgr(bdict_reader, try_string, MAXSUGGESTION, pAMgr); | |
| 916 +#else | |
| 917 pSMgr = new SuggestMgr(try_string, MAXSUGGESTION, pAMgr); | |
| 918 +#endif | |
| 919 if (try_string) free(try_string); | |
| 920 } | |
| 921 | |
| 922 @@ -59,10 +81,16 @@ | |
| 883 csconv= NULL; | 923 csconv= NULL; |
| 884 if (encoding) free(encoding); | 924 if (encoding) free(encoding); |
| 885 encoding = NULL; | 925 encoding = NULL; |
| 886 +#ifdef HUNSPELL_CHROME_CLIENT | 926 +#ifdef HUNSPELL_CHROME_CLIENT |
| 887 + if (bdict_reader) delete bdict_reader; | 927 + if (bdict_reader) delete bdict_reader; |
| 888 + bdict_reader = NULL; | 928 + bdict_reader = NULL; |
| 889 +#else | 929 +#else |
| 890 if (affixpath) free(affixpath); | 930 if (affixpath) free(affixpath); |
| 891 affixpath = NULL; | 931 affixpath = NULL; |
| 892 +#endif | 932 +#endif |
| 893 } | 933 } |
| 894 | 934 |
| 895 +#ifndef HUNSPELL_CHROME_CLIENT | 935 +#ifndef HUNSPELL_CHROME_CLIENT |
| 896 // load extra dictionaries | 936 // load extra dictionaries |
| 897 int Hunspell::add_dic(const char * dpath, const char * key) { | 937 int Hunspell::add_dic(const char * dpath, const char * key) { |
| 898 if (maxdic == MAXDIC || !affixpath) return 1; | 938 if (maxdic == MAXDIC || !affixpath) return 1; |
| 899 @@ -70,6 +92,7 @@ | 939 @@ -70,6 +98,7 @@ |
| 900 if (pHMgr[maxdic]) maxdic++; else return 1; | 940 if (pHMgr[maxdic]) maxdic++; else return 1; |
| 901 return 0; | 941 return 0; |
| 902 } | 942 } |
| 903 +#endif | 943 +#endif |
| 904 | 944 |
| 905 // make a copy of src at destination while removing all leading | 945 // make a copy of src at destination while removing all leading |
| 906 // blanks and removing any trailing periods after recording | 946 // blanks and removing any trailing periods after recording |
| 907 @@ -322,6 +345,9 @@ | 947 @@ -108,7 +137,9 @@ |
| 948 if (utf8) { | |
| 949 *nc = u8_u16(dest_utf, MAXWORDLEN, dest); | |
| 950 // don't check too long words | |
| 951 - if (*nc >= MAXWORDLEN) return 0; | |
| 952 + // TODO(rouslan): Remove the interim change below when this patch lands: | |
| 953 + // http://sf.net/tracker/?func=detail&aid=3595024&group_id=143754&atid=75 6395. | |
| 954 + if (*nc >= MAXWORDLEN - 1) return 0; | |
| 955 if (*nc == -1) { // big Unicode character (non BMP area) | |
| 956 *pcaptype = NOCAP; | |
| 957 return nl; | |
| 958 @@ -322,6 +353,9 @@ | |
| 908 | 959 |
| 909 int Hunspell::spell(const char * word, int * info, char ** root) | 960 int Hunspell::spell(const char * word, int * info, char ** root) |
| 910 { | 961 { |
| 911 +#ifdef HUNSPELL_CHROME_CLIENT | 962 +#ifdef HUNSPELL_CHROME_CLIENT |
| 912 + if (pHMgr) pHMgr[0]->EmptyHentryCache(); | 963 + if (pHMgr) pHMgr[0]->EmptyHentryCache(); |
| 913 +#endif | 964 +#endif |
| 914 struct hentry * rv=NULL; | 965 struct hentry * rv=NULL; |
| 915 // need larger vector. For example, Turkish capital letter I converted a | 966 // need larger vector. For example, Turkish capital letter I converted a |
| 916 // 2-byte UTF-8 character (dotless i) by mkallsmall. | 967 // 2-byte UTF-8 character (dotless i) by mkallsmall. |
| 917 @@ -586,6 +612,13 @@ | 968 @@ -586,6 +620,13 @@ |
| 918 if (!len) | 969 if (!len) |
| 919 return NULL; | 970 return NULL; |
| 920 | 971 |
| 921 +#ifdef HUNSPELL_CHROME_CLIENT | 972 +#ifdef HUNSPELL_CHROME_CLIENT |
| 922 + // We need to check if the word length is valid to make coverity (Event | 973 + // We need to check if the word length is valid to make coverity (Event |
| 923 + // fixed_size_dest: Possible overrun of N byte fixed size buffer) happy. | 974 + // fixed_size_dest: Possible overrun of N byte fixed size buffer) happy. |
| 924 + if ((utf8 && strlen(word) >= MAXWORDUTF8LEN) || (!utf8 && strlen(word) >= MAX WORDLEN)) | 975 + if ((utf8 && strlen(word) >= MAXWORDUTF8LEN) || (!utf8 && strlen(word) >= MAX WORDLEN)) |
| 925 + return NULL; | 976 + return NULL; |
| 926 +#endif | 977 +#endif |
| 927 + | 978 + |
| 928 // word reversing wrapper for complex prefixes | 979 // word reversing wrapper for complex prefixes |
| 929 if (complexprefixes) { | 980 if (complexprefixes) { |
| 930 if (word != w2) { | 981 if (word != w2) { |
| 931 @@ -675,6 +708,9 @@ | 982 @@ -675,6 +716,9 @@ |
| 932 | 983 |
| 933 int Hunspell::suggest(char*** slst, const char * word) | 984 int Hunspell::suggest(char*** slst, const char * word) |
| 934 { | 985 { |
| 935 +#ifdef HUNSPELL_CHROME_CLIENT | 986 +#ifdef HUNSPELL_CHROME_CLIENT |
| 936 + if (pHMgr) pHMgr[0]->EmptyHentryCache(); | 987 + if (pHMgr) pHMgr[0]->EmptyHentryCache(); |
| 937 +#endif | 988 +#endif |
| 938 int onlycmpdsug = 0; | 989 int onlycmpdsug = 0; |
| 939 char cw[MAXWORDUTF8LEN]; | 990 char cw[MAXWORDUTF8LEN]; |
| 940 char wspace[MAXWORDUTF8LEN]; | 991 char wspace[MAXWORDUTF8LEN]; |
| 941 @@ -1921,13 +1957,21 @@ | 992 @@ -1921,13 +1965,21 @@ |
| 942 | 993 |
| 943 Hunhandle *Hunspell_create(const char * affpath, const char * dpath) | 994 Hunhandle *Hunspell_create(const char * affpath, const char * dpath) |
| 944 { | 995 { |
| 945 +#ifdef HUNSPELL_CHROME_CLIENT | 996 +#ifdef HUNSPELL_CHROME_CLIENT |
| 946 + return NULL; | 997 + return NULL; |
| 947 +#else | 998 +#else |
| 948 return (Hunhandle*)(new Hunspell(affpath, dpath)); | 999 return (Hunhandle*)(new Hunspell(affpath, dpath)); |
| 949 +#endif | 1000 +#endif |
| 950 } | 1001 } |
| 951 | 1002 |
| 952 Hunhandle *Hunspell_create_key(const char * affpath, const char * dpath, | 1003 Hunhandle *Hunspell_create_key(const char * affpath, const char * dpath, |
| 953 const char * key) | 1004 const char * key) |
| 954 { | 1005 { |
| 955 +#ifdef HUNSPELL_CHROME_CLIENT | 1006 +#ifdef HUNSPELL_CHROME_CLIENT |
| 956 + return NULL; | 1007 + return NULL; |
| 957 +#else | 1008 +#else |
| 958 return (Hunhandle*)(new Hunspell(affpath, dpath, key)); | 1009 return (Hunhandle*)(new Hunspell(affpath, dpath, key)); |
| 959 +#endif | 1010 +#endif |
| 960 } | 1011 } |
| 961 | 1012 |
| 962 void Hunspell_destroy(Hunhandle *pHunspell) | 1013 void Hunspell_destroy(Hunhandle *pHunspell) |
| 963 Index: src/hunspell/hunspell.hxx | 1014 Index: src/hunspell/hunspell.hxx |
| 964 =================================================================== | 1015 =================================================================== |
| 965 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hunspell.hxx,v | 1016 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hunspell.hxx,v |
| 966 retrieving revision 1.6 | 1017 retrieving revision 1.6 |
| 967 diff -u -r1.6 hunspell.hxx | 1018 diff -u -r1.6 hunspell.hxx |
| 968 --- src/hunspell/hunspell.hxx 21 Jan 2011 17:30:41 -0000 1.6 | 1019 --- src/hunspell/hunspell.hxx 21 Jan 2011 17:30:41 -0000 1.6 |
| 969 +++ src/hunspell/hunspell.hxx» 23 Mar 2012 05:56:24 -0000 | 1020 +++ src/hunspell/hunspell.hxx» 20 Dec 2012 17:39:19 -0000 |
| 970 @@ -5,6 +5,10 @@ | 1021 @@ -5,6 +5,10 @@ |
| 971 #include "suggestmgr.hxx" | 1022 #include "suggestmgr.hxx" |
| 972 #include "langnum.hxx" | 1023 #include "langnum.hxx" |
| 973 | 1024 |
| 974 +#ifdef HUNSPELL_CHROME_CLIENT | 1025 +#ifdef HUNSPELL_CHROME_CLIENT |
| 975 +#include "third_party/hunspell/google/bdict_reader.h" | 1026 +#include "third_party/hunspell/google/bdict_reader.h" |
| 976 +#endif | 1027 +#endif |
| 977 + | 1028 + |
| 978 #define SPELL_XML "<?xml?>" | 1029 #define SPELL_XML "<?xml?>" |
| 979 | 1030 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1010 +#endif | 1061 +#endif |
| 1011 ~Hunspell(); | 1062 ~Hunspell(); |
| 1012 | 1063 |
| 1013 +#ifndef HUNSPELL_CHROME_CLIENT | 1064 +#ifndef HUNSPELL_CHROME_CLIENT |
| 1014 /* load extra dictionaries (only dic files) */ | 1065 /* load extra dictionaries (only dic files) */ |
| 1015 int add_dic(const char * dpath, const char * key = NULL); | 1066 int add_dic(const char * dpath, const char * key = NULL); |
| 1016 +#endif | 1067 +#endif |
| 1017 | 1068 |
| 1018 /* spell(word) - spellcheck word | 1069 /* spell(word) - spellcheck word |
| 1019 * output: 0 = bad word, not 0 = good word | 1070 * output: 0 = bad word, not 0 = good word |
| 1071 Index: src/hunspell/license.hunspell | |
| 1072 =================================================================== | |
| 1073 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/license.hunspell,v | |
| 1074 retrieving revision 1.1.1.1 | |
| 1075 diff -u -r1.1.1.1 license.hunspell | |
| 1076 --- src/hunspell/license.hunspell 23 Feb 2010 09:08:56 -0000 1.1.1.1 | |
| 1077 +++ src/hunspell/license.hunspell 20 Dec 2012 17:39:19 -0000 | |
| 1078 @@ -56,4 +56,6 @@ | |
| 1079 * | |
| 1080 * ***** END LICENSE BLOCK ***** */ | |
| 1081 | |
| 1082 +#ifndef HUNSPELL_CHROME_CLIENT | |
| 1083 #include "config.h" | |
| 1084 +#endif | |
| 1020 Index: src/hunspell/replist.hxx | 1085 Index: src/hunspell/replist.hxx |
| 1021 =================================================================== | 1086 =================================================================== |
| 1022 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/replist.hxx,v | 1087 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/replist.hxx,v |
| 1023 retrieving revision 1.2 | 1088 retrieving revision 1.2 |
| 1024 diff -u -r1.2 replist.hxx | 1089 diff -u -r1.2 replist.hxx |
| 1025 --- src/hunspell/replist.hxx 15 Apr 2010 11:22:09 -0000 1.2 | 1090 --- src/hunspell/replist.hxx 15 Apr 2010 11:22:09 -0000 1.2 |
| 1026 +++ src/hunspell/replist.hxx» 23 Mar 2012 05:56:24 -0000 | 1091 +++ src/hunspell/replist.hxx» 20 Dec 2012 17:39:19 -0000 |
| 1027 @@ -2,6 +2,12 @@ | 1092 @@ -2,6 +2,12 @@ |
| 1028 #ifndef _REPLIST_HXX_ | 1093 #ifndef _REPLIST_HXX_ |
| 1029 #define _REPLIST_HXX_ | 1094 #define _REPLIST_HXX_ |
| 1030 | 1095 |
| 1031 +#ifdef HUNSPELL_CHROME_CLIENT | 1096 +#ifdef HUNSPELL_CHROME_CLIENT |
| 1032 +// Compilation issues in spellchecker.cc think near is a macro, therefore | 1097 +// Compilation issues in spellchecker.cc think near is a macro, therefore |
| 1033 +// removing it here solves that problem. | 1098 +// removing it here solves that problem. |
| 1034 +#undef near | 1099 +#undef near |
| 1035 +#endif | 1100 +#endif |
| 1036 + | 1101 + |
| 1037 #include "hunvisapi.h" | 1102 #include "hunvisapi.h" |
| 1038 | 1103 |
| 1039 #include "w_char.hxx" | 1104 #include "w_char.hxx" |
| 1040 Index: src/hunspell/suggestmgr.cxx | 1105 Index: src/hunspell/suggestmgr.cxx |
| 1041 =================================================================== | 1106 =================================================================== |
| 1042 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/suggestmgr.cxx,v | 1107 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/suggestmgr.cxx,v |
| 1043 retrieving revision 1.24 | 1108 retrieving revision 1.24 |
| 1044 diff -u -r1.24 suggestmgr.cxx | 1109 diff -u -r1.24 suggestmgr.cxx |
| 1045 --- src/hunspell/suggestmgr.cxx 14 Feb 2011 21:47:24 -0000 1.24 | 1110 --- src/hunspell/suggestmgr.cxx 14 Feb 2011 21:47:24 -0000 1.24 |
| 1046 +++ src/hunspell/suggestmgr.cxx»23 Mar 2012 05:56:24 -0000 | 1111 +++ src/hunspell/suggestmgr.cxx»20 Dec 2012 17:39:19 -0000 |
| 1047 @@ -12,6 +12,98 @@ | 1112 @@ -12,9 +12,110 @@ |
| 1048 | 1113 |
| 1049 const w_char W_VLINE = { '\0', '|' }; | 1114 const w_char W_VLINE = { '\0', '|' }; |
| 1050 | 1115 |
| 1051 +#ifdef HUNSPELL_CHROME_CLIENT | 1116 +#ifdef HUNSPELL_CHROME_CLIENT |
| 1052 +namespace { | 1117 +namespace { |
| 1053 +// A simple class which creates temporary hentry objects which are available | 1118 +// A simple class which creates temporary hentry objects which are available |
| 1054 +// only in a scope. To conceal memory operations from SuggestMgr functions, | 1119 +// only in a scope. To conceal memory operations from SuggestMgr functions, |
| 1055 +// this object automatically deletes all hentry objects created through | 1120 +// this object automatically deletes all hentry objects created through |
| 1056 +// CreateScopedHashEntry() calls in its destructor. So, the following snippet | 1121 +// CreateScopedHashEntry() calls in its destructor. So, the following snippet |
| 1057 +// raises a memory error. | 1122 +// raises a memory error. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1133 + if (source->astr) { | 1198 + if (source->astr) { |
| 1134 + hash_item->astr = *source->astr; | 1199 + hash_item->astr = *source->astr; |
| 1135 + hash_item->entry.astr = &hash_item->astr; | 1200 + hash_item->entry.astr = &hash_item->astr; |
| 1136 + } | 1201 + } |
| 1137 + return &hash_item->entry; | 1202 + return &hash_item->entry; |
| 1138 +} | 1203 +} |
| 1139 + | 1204 + |
| 1140 +} // namespace | 1205 +} // namespace |
| 1141 +#endif | 1206 +#endif |
| 1142 + | 1207 + |
| 1208 + | |
| 1209 +#ifdef HUNSPELL_CHROME_CLIENT | |
| 1210 +SuggestMgr::SuggestMgr(hunspell::BDictReader* reader, | |
| 1211 + const char * tryme, int maxn, | |
| 1212 + AffixMgr * aptr) | |
| 1213 +{ | |
| 1214 + bdict_reader = reader; | |
|
groby-ooo-7-16
2012/12/20 22:56:28
This shouldn't be part of the patch either. The pu
please use gerrit instead
2012/12/20 22:58:00
SGTM, let me do that first.
please use gerrit instead
2012/12/20 23:48:02
CL to bring google.patch file up to date: https://
| |
| 1215 +#else | |
| 1143 SuggestMgr::SuggestMgr(const char * tryme, int maxn, | 1216 SuggestMgr::SuggestMgr(const char * tryme, int maxn, |
| 1144 AffixMgr * aptr) | 1217 AffixMgr * aptr) |
| 1145 { | 1218 { |
| 1146 @@ -1057,6 +1149,9 @@ | 1219 +#endif |
| 1220 | |
| 1221 // register affix manager and check in string of chars to | |
| 1222 // try when building candidate suggestions | |
| 1223 @@ -407,6 +508,49 @@ | |
| 1224 int lenr, lenp; | |
| 1225 int wl = strlen(word); | |
| 1226 if (wl < 2 || ! pAMgr) return ns; | |
| 1227 + | |
| 1228 +#ifdef HUNSPELL_CHROME_CLIENT | |
| 1229 + const char *pattern, *pattern2; | |
| 1230 + hunspell::ReplacementIterator iterator = bdict_reader->GetReplacementIterator (); | |
| 1231 + while (iterator.GetNext(&pattern, &pattern2)) { | |
| 1232 + r = word; | |
| 1233 + lenr = strlen(pattern2); | |
| 1234 + lenp = strlen(pattern); | |
| 1235 + | |
| 1236 + // search every occurence of the pattern in the word | |
| 1237 + while ((r=strstr(r, pattern)) != NULL) { | |
| 1238 + strcpy(candidate, word); | |
| 1239 + if (r-word + lenr + strlen(r+lenp) >= MAXLNLEN) break; | |
| 1240 + strcpy(candidate+(r-word), pattern2); | |
| 1241 + strcpy(candidate+(r-word)+lenr, r+lenp); | |
| 1242 + ns = testsug(wlst, candidate, wl-lenp+lenr, ns, cpdsuggest, NULL, NUL L); | |
| 1243 + if (ns == -1) return -1; | |
| 1244 + // check REP suggestions with space | |
| 1245 + char * sp = strchr(candidate, ' '); | |
| 1246 + if (sp) { | |
| 1247 + char * prev = candidate; | |
| 1248 + while (sp) { | |
| 1249 + *sp = '\0'; | |
| 1250 + if (checkword(prev, strlen(prev), 0, NULL, NULL)) { | |
| 1251 + int oldns = ns; | |
| 1252 + *sp = ' '; | |
| 1253 + ns = testsug(wlst, sp + 1, strlen(sp + 1), ns, cpdsuggest, NULL , NULL); | |
| 1254 + if (ns == -1) return -1; | |
| 1255 + if (oldns < ns) { | |
| 1256 + free(wlst[ns - 1]); | |
| 1257 + wlst[ns - 1] = mystrdup(candidate); | |
| 1258 + if (!wlst[ns - 1]) return -1; | |
| 1259 + } | |
| 1260 + } | |
| 1261 + *sp = ' '; | |
| 1262 + prev = sp + 1; | |
| 1263 + sp = strchr(prev, ' '); | |
| 1264 + } | |
| 1265 + } | |
| 1266 + r++; // search for the next letter | |
| 1267 + } | |
| 1268 + } | |
| 1269 +#else | |
| 1270 int numrep = pAMgr->get_numrep(); | |
| 1271 struct replentry* reptable = pAMgr->get_reptable(); | |
| 1272 if (reptable==NULL) return ns; | |
| 1273 @@ -448,6 +592,7 @@ | |
| 1274 r++; // search for the next letter | |
| 1275 } | |
| 1276 } | |
| 1277 +#endif | |
| 1278 return ns; | |
| 1279 } | |
| 1280 | |
| 1281 @@ -1057,6 +1202,9 @@ | |
| 1147 | 1282 |
| 1148 struct hentry* hp = NULL; | 1283 struct hentry* hp = NULL; |
| 1149 int col = -1; | 1284 int col = -1; |
| 1150 +#ifdef HUNSPELL_CHROME_CLIENT | 1285 +#ifdef HUNSPELL_CHROME_CLIENT |
| 1151 + ScopedHashEntryFactory hash_entry_factory; | 1286 + ScopedHashEntryFactory hash_entry_factory; |
| 1152 +#endif | 1287 +#endif |
| 1153 phonetable * ph = (pAMgr) ? pAMgr->get_phonetable() : NULL; | 1288 phonetable * ph = (pAMgr) ? pAMgr->get_phonetable() : NULL; |
| 1154 char target[MAXSWUTF8L]; | 1289 char target[MAXSWUTF8L]; |
| 1155 char candidate[MAXSWUTF8L]; | 1290 char candidate[MAXSWUTF8L]; |
| 1156 @@ -1115,7 +1210,11 @@ | 1291 @@ -1115,7 +1263,11 @@ |
| 1157 | 1292 |
| 1158 if (sc > scores[lp]) { | 1293 if (sc > scores[lp]) { |
| 1159 scores[lp] = sc; | 1294 scores[lp] = sc; |
| 1160 +#ifdef HUNSPELL_CHROME_CLIENT | 1295 +#ifdef HUNSPELL_CHROME_CLIENT |
| 1161 + roots[lp] = hash_entry_factory.CreateScopedHashEntry(lp, hp); | 1296 + roots[lp] = hash_entry_factory.CreateScopedHashEntry(lp, hp); |
| 1162 +#else | 1297 +#else |
| 1163 roots[lp] = hp; | 1298 roots[lp] = hp; |
| 1164 +#endif | 1299 +#endif |
| 1165 lval = sc; | 1300 lval = sc; |
| 1166 for (j=0; j < MAX_ROOTS; j++) | 1301 for (j=0; j < MAX_ROOTS; j++) |
| 1167 if (scores[j] < lval) { | 1302 if (scores[j] < lval) { |
| 1303 Index: src/hunspell/suggestmgr.hxx | |
| 1304 =================================================================== | |
| 1305 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/suggestmgr.hxx,v | |
| 1306 retrieving revision 1.5 | |
| 1307 diff -u -r1.5 suggestmgr.hxx | |
| 1308 --- src/hunspell/suggestmgr.hxx 21 Jan 2011 22:10:24 -0000 1.5 | |
| 1309 +++ src/hunspell/suggestmgr.hxx 20 Dec 2012 17:39:19 -0000 | |
| 1310 @@ -52,7 +52,11 @@ | |
| 1311 | |
| 1312 | |
| 1313 public: | |
| 1314 +#ifdef HUNSPELL_CHROME_CLIENT | |
| 1315 + SuggestMgr(hunspell::BDictReader* reader, const char * tryme, int maxn, Affix Mgr *aptr); | |
| 1316 +#else | |
| 1317 SuggestMgr(const char * tryme, int maxn, AffixMgr *aptr); | |
| 1318 +#endif | |
| 1319 ~SuggestMgr(); | |
| 1320 | |
| 1321 int suggest(char*** slst, const char * word, int nsug, int * onlycmpdsug); | |
| 1322 @@ -66,6 +70,10 @@ | |
| 1323 char * suggest_morph_for_spelling_error(const char * word); | |
| 1324 | |
| 1325 private: | |
| 1326 +#ifdef HUNSPELL_CHROME_CLIENT | |
| 1327 + // Not owned by us, owned by the Hunspell object. | |
| 1328 + hunspell::BDictReader* bdict_reader; | |
| 1329 +#endif | |
| 1330 int testsug(char** wlst, const char * candidate, int wl, int ns, int cpdsugg est, | |
| 1331 int * timer, clock_t * timelimit); | |
| 1332 int checkword(const char *, int, int, int *, clock_t *); | |
| OLD | NEW |