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» 8 Jan 2013 00:30:25 -0000 | 7 +++ src/hunspell/affixmgr.cxx» 27 Feb 2013 01:10:35 -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» 8 Jan 2013 00:30:25 -0000 | 198 +++ src/hunspell/affixmgr.hxx» 27 Feb 2013 01:10:35 -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» 8 Jan 2013 00:30:25 -0000 | 283 +++ src/hunspell/filemgr.cxx» 27 Feb 2013 01:10:35 -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» 8 Jan 2013 00:30:25 -0000 | 328 +++ src/hunspell/filemgr.hxx» 27 Feb 2013 01:10:35 -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» 8 Jan 2013 00:30:25 -0000 | 371 +++ src/hunspell/hashmgr.cxx» 27 Feb 2013 01:10:35 -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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 + | 731 + |
732 int HashMgr::is_aliasf() { | 732 int HashMgr::is_aliasf() { |
733 return (aliasf != NULL); | 733 return (aliasf != NULL); |
734 } | 734 } |
735 Index: src/hunspell/hashmgr.hxx | 735 Index: src/hunspell/hashmgr.hxx |
736 =================================================================== | 736 =================================================================== |
737 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hashmgr.hxx,v | 737 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hashmgr.hxx,v |
738 retrieving revision 1.3 | 738 retrieving revision 1.3 |
739 diff -u -r1.3 hashmgr.hxx | 739 diff -u -r1.3 hashmgr.hxx |
740 --- 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 |
741 +++ src/hunspell/hashmgr.hxx» 8 Jan 2013 00:30:25 -0000 | 741 +++ src/hunspell/hashmgr.hxx» 27 Feb 2013 01:10:35 -0000 |
742 @@ -8,10 +8,25 @@ | 742 @@ -8,10 +8,25 @@ |
743 #include "htypes.hxx" | 743 #include "htypes.hxx" |
744 #include "filemgr.hxx" | 744 #include "filemgr.hxx" |
745 | 745 |
746 +#ifdef HUNSPELL_CHROME_CLIENT | 746 +#ifdef HUNSPELL_CHROME_CLIENT |
747 +#include <string> | 747 +#include <string> |
748 +#include <map> | 748 +#include <map> |
749 + | 749 + |
750 +#include "base/stl_util.h" | 750 +#include "base/stl_util.h" |
751 +#include "base/string_piece.h" | 751 +#include "base/string_piece.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 + | 829 + |
830 int add_hidden_capitalized_word(char * word, int wbl, int wcl, | 830 int add_hidden_capitalized_word(char * word, int wbl, int wcl, |
831 unsigned short * flags, int al, char * dp, int captype); | 831 unsigned short * flags, int al, char * dp, int captype); |
832 int parse_aliasm(char * line, FileMgr * af); | 832 int parse_aliasm(char * line, FileMgr * af); |
833 Index: src/hunspell/htypes.hxx | 833 Index: src/hunspell/htypes.hxx |
834 =================================================================== | 834 =================================================================== |
835 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/htypes.hxx,v | 835 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/htypes.hxx,v |
836 retrieving revision 1.3 | 836 retrieving revision 1.3 |
837 diff -u -r1.3 htypes.hxx | 837 diff -u -r1.3 htypes.hxx |
838 --- 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 |
839 +++ src/hunspell/htypes.hxx» 8 Jan 2013 00:30:25 -0000 | 839 +++ src/hunspell/htypes.hxx» 27 Feb 2013 01:10:35 -0000 |
840 @@ -1,6 +1,16 @@ | 840 @@ -1,6 +1,16 @@ |
841 #ifndef _HTYPES_HXX_ | 841 #ifndef _HTYPES_HXX_ |
842 #define _HTYPES_HXX_ | 842 #define _HTYPES_HXX_ |
843 | 843 |
844 +#ifdef HUNSPELL_CHROME_CLIENT | 844 +#ifdef HUNSPELL_CHROME_CLIENT |
845 +// 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 |
846 +// contain very long AF lines (~ 12,000 chars). | 846 +// contain very long AF lines (~ 12,000 chars). |
847 +// 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 |
848 +// longer lines than MAXDELEN. | 848 +// longer lines than MAXDELEN. |
849 +#define MAXDELEN (8192 * 2) | 849 +#define MAXDELEN (8192 * 2) |
850 +#else | 850 +#else |
851 +#define MAXDELEN 8192 | 851 +#define MAXDELEN 8192 |
852 +#endif // HUNSPELL_CHROME_CLIENT | 852 +#endif // HUNSPELL_CHROME_CLIENT |
853 + | 853 + |
854 #define ROTATE_LEN 5 | 854 #define ROTATE_LEN 5 |
855 | 855 |
856 #define ROTATE(v,q) \ | 856 #define ROTATE(v,q) \ |
857 Index: src/hunspell/hunspell.cxx | 857 Index: src/hunspell/hunspell.cxx |
858 =================================================================== | 858 =================================================================== |
859 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hunspell.cxx,v | 859 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hunspell.cxx,v |
860 retrieving revision 1.29 | 860 retrieving revision 1.29 |
861 diff -u -r1.29 hunspell.cxx | 861 diff -u -r1.29 hunspell.cxx |
862 --- 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 |
863 +++ src/hunspell/hunspell.cxx» 8 Jan 2013 00:30:25 -0000 | 863 +++ src/hunspell/hunspell.cxx» 27 Feb 2013 01:10:35 -0000 |
864 @@ -7,20 +7,37 @@ | 864 @@ -7,20 +7,37 @@ |
865 | 865 |
866 #include "hunspell.hxx" | 866 #include "hunspell.hxx" |
867 #include "hunspell.h" | 867 #include "hunspell.h" |
868 +#ifndef HUNSPELL_CHROME_CLIENT | 868 +#ifndef HUNSPELL_CHROME_CLIENT |
869 #ifndef MOZILLA_CLIENT | 869 #ifndef MOZILLA_CLIENT |
870 # include "config.h" | 870 # include "config.h" |
871 #endif | 871 #endif |
872 +#endif | 872 +#endif |
873 #include "csutil.hxx" | 873 #include "csutil.hxx" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 +#endif | 999 +#endif |
1000 } | 1000 } |
1001 | 1001 |
1002 void Hunspell_destroy(Hunhandle *pHunspell) | 1002 void Hunspell_destroy(Hunhandle *pHunspell) |
1003 Index: src/hunspell/hunspell.hxx | 1003 Index: src/hunspell/hunspell.hxx |
1004 =================================================================== | 1004 =================================================================== |
1005 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hunspell.hxx,v | 1005 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/hunspell.hxx,v |
1006 retrieving revision 1.6 | 1006 retrieving revision 1.6 |
1007 diff -u -r1.6 hunspell.hxx | 1007 diff -u -r1.6 hunspell.hxx |
1008 --- src/hunspell/hunspell.hxx 21 Jan 2011 17:30:41 -0000 1.6 | 1008 --- src/hunspell/hunspell.hxx 21 Jan 2011 17:30:41 -0000 1.6 |
1009 +++ src/hunspell/hunspell.hxx» 8 Jan 2013 00:30:25 -0000 | 1009 +++ src/hunspell/hunspell.hxx» 27 Feb 2013 01:10:35 -0000 |
1010 @@ -5,6 +5,10 @@ | 1010 @@ -5,6 +5,10 @@ |
1011 #include "suggestmgr.hxx" | 1011 #include "suggestmgr.hxx" |
1012 #include "langnum.hxx" | 1012 #include "langnum.hxx" |
1013 | 1013 |
1014 +#ifdef HUNSPELL_CHROME_CLIENT | 1014 +#ifdef HUNSPELL_CHROME_CLIENT |
1015 +#include "third_party/hunspell/google/bdict_reader.h" | 1015 +#include "third_party/hunspell/google/bdict_reader.h" |
1016 +#endif | 1016 +#endif |
1017 + | 1017 + |
1018 #define SPELL_XML "<?xml?>" | 1018 #define SPELL_XML "<?xml?>" |
1019 | 1019 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 +#endif | 1056 +#endif |
1057 | 1057 |
1058 /* spell(word) - spellcheck word | 1058 /* spell(word) - spellcheck word |
1059 * output: 0 = bad word, not 0 = good word | 1059 * output: 0 = bad word, not 0 = good word |
1060 Index: src/hunspell/replist.hxx | 1060 Index: src/hunspell/replist.hxx |
1061 =================================================================== | 1061 =================================================================== |
1062 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/replist.hxx,v | 1062 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/replist.hxx,v |
1063 retrieving revision 1.2 | 1063 retrieving revision 1.2 |
1064 diff -u -r1.2 replist.hxx | 1064 diff -u -r1.2 replist.hxx |
1065 --- src/hunspell/replist.hxx 15 Apr 2010 11:22:09 -0000 1.2 | 1065 --- src/hunspell/replist.hxx 15 Apr 2010 11:22:09 -0000 1.2 |
1066 +++ src/hunspell/replist.hxx» 8 Jan 2013 00:30:25 -0000 | 1066 +++ src/hunspell/replist.hxx» 27 Feb 2013 01:10:35 -0000 |
1067 @@ -2,6 +2,12 @@ | 1067 @@ -2,6 +2,12 @@ |
1068 #ifndef _REPLIST_HXX_ | 1068 #ifndef _REPLIST_HXX_ |
1069 #define _REPLIST_HXX_ | 1069 #define _REPLIST_HXX_ |
1070 | 1070 |
1071 +#ifdef HUNSPELL_CHROME_CLIENT | 1071 +#ifdef HUNSPELL_CHROME_CLIENT |
1072 +// Compilation issues in spellchecker.cc think near is a macro, therefore | 1072 +// Compilation issues in spellchecker.cc think near is a macro, therefore |
1073 +// removing it here solves that problem. | 1073 +// removing it here solves that problem. |
1074 +#undef near | 1074 +#undef near |
1075 +#endif | 1075 +#endif |
1076 + | 1076 + |
1077 #include "hunvisapi.h" | 1077 #include "hunvisapi.h" |
1078 | 1078 |
1079 #include "w_char.hxx" | 1079 #include "w_char.hxx" |
1080 Index: src/hunspell/suggestmgr.cxx | 1080 Index: src/hunspell/suggestmgr.cxx |
1081 =================================================================== | 1081 =================================================================== |
1082 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/suggestmgr.cxx,v | 1082 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/suggestmgr.cxx,v |
1083 retrieving revision 1.24 | 1083 retrieving revision 1.24 |
1084 diff -u -r1.24 suggestmgr.cxx | 1084 diff -u -r1.24 suggestmgr.cxx |
1085 --- src/hunspell/suggestmgr.cxx 14 Feb 2011 21:47:24 -0000 1.24 | 1085 --- src/hunspell/suggestmgr.cxx 14 Feb 2011 21:47:24 -0000 1.24 |
1086 +++ src/hunspell/suggestmgr.cxx»8 Jan 2013 00:30:26 -0000 | 1086 +++ src/hunspell/suggestmgr.cxx»27 Feb 2013 01:10:36 -0000 |
1087 @@ -12,9 +12,110 @@ | 1087 @@ -12,9 +12,114 @@ |
1088 | 1088 |
1089 const w_char W_VLINE = { '\0', '|' }; | 1089 const w_char W_VLINE = { '\0', '|' }; |
1090 | 1090 |
1091 +#ifdef HUNSPELL_CHROME_CLIENT | 1091 +#ifdef HUNSPELL_CHROME_CLIENT |
1092 +namespace { | 1092 +namespace { |
1093 +// A simple class which creates temporary hentry objects which are available | 1093 +// A simple class which creates temporary hentry objects which are available |
1094 +// only in a scope. To conceal memory operations from SuggestMgr functions, | 1094 +// only in a scope. To conceal memory operations from SuggestMgr functions, |
1095 +// this object automatically deletes all hentry objects created through | 1095 +// this object automatically deletes all hentry objects created through |
1096 +// CreateScopedHashEntry() calls in its destructor. So, the following snippet | 1096 +// CreateScopedHashEntry() calls in its destructor. So, the following snippet |
1097 +// raises a memory error. | 1097 +// raises a memory error. |
(...skipping 25 matching lines...) Expand all Loading... |
1123 + hentry* CreateScopedHashEntry(int index, const hentry* source); | 1123 + hentry* CreateScopedHashEntry(int index, const hentry* source); |
1124 + | 1124 + |
1125 + private: | 1125 + private: |
1126 + // A struct which encapsulates the new hentry struct introduced in hunspell | 1126 + // A struct which encapsulates the new hentry struct introduced in hunspell |
1127 + // 1.2.8. For a pointer to an hentry struct 'h', hunspell 1.2.8 stores a word | 1127 + // 1.2.8. For a pointer to an hentry struct 'h', hunspell 1.2.8 stores a word |
1128 + // (including a NUL character) into 'h->word[0]',...,'h->word[h->blen]' even | 1128 + // (including a NUL character) into 'h->word[0]',...,'h->word[h->blen]' even |
1129 + // though arraysize(h->word[]) is 1. Also, it changed 'astr' to a pointer so | 1129 + // though arraysize(h->word[]) is 1. Also, it changed 'astr' to a pointer so |
1130 + // it can store affix flags into 'h->astr[0]',...,'h->astr[alen-1]'. To handl
e | 1130 + // it can store affix flags into 'h->astr[0]',...,'h->astr[alen-1]'. To handl
e |
1131 + // this new hentry struct, we define a struct which combines three values: an | 1131 + // this new hentry struct, we define a struct which combines three values: an |
1132 + // hentry struct 'hentry'; a char array 'word[kMaxWordLen]', and; an unsigned | 1132 + // hentry struct 'hentry'; a char array 'word[kMaxWordLen]', and; an unsigned |
1133 + // short value 'astr' so a hentry struct 'h' returned from | 1133 + // short array 'astr' so a hentry struct 'h' returned from |
1134 + // CreateScopedHashEntry() satisfies the following equations: | 1134 + // CreateScopedHashEntry() satisfies the following equations: |
1135 + // hentry* h = factory.CreateScopedHashEntry(0, source); | 1135 + // hentry* h = factory.CreateScopedHashEntry(0, source); |
1136 + // h->word[0] == ((HashEntryItem*)h)->entry.word[0]. | 1136 + // h->word[0] == ((HashEntryItem*)h)->entry.word[0]. |
1137 + // h->word[1] == ((HashEntryItem*)h)->word[0]. | 1137 + // h->word[1] == ((HashEntryItem*)h)->word[0]. |
1138 + // ... | 1138 + // ... |
1139 + // h->word[h->blen] == ((HashEntryItem*)h)->word[h->blen-1]. | 1139 + // h->word[h->blen] == ((HashEntryItem*)h)->word[h->blen-1]. |
1140 + // h->astr[0] == ((HashEntryItem*)h)->astr. | 1140 + // h->astr[0] == ((HashEntryItem*)h)->astr[0]. |
1141 + // Our BDICT does not use affix flags longer than one for now since they are | 1141 + // h->astr[1] == ((HashEntryItem*)h)->astr[1]. |
1142 + // discarded by convert_dict, i.e. 'h->astr' is always <= 1. Therefore, this | 1142 + // ... |
1143 + // struct does not use an array for 'astr'. | 1143 + // h->astr[h->alen-1] == ((HashEntryItem*)h)->astr[h->alen-1]. |
1144 + enum { | 1144 + enum { |
1145 + kMaxWordLen = 128, | 1145 + kMaxWordLen = 128, |
| 1146 + kMaxAffixLen = 8, |
1146 + }; | 1147 + }; |
1147 + struct HashEntryItem { | 1148 + struct HashEntryItem { |
1148 + hentry entry; | 1149 + hentry entry; |
1149 + char word[kMaxWordLen]; | 1150 + char word[kMaxWordLen]; |
1150 + unsigned short astr; | 1151 + unsigned short astr[kMaxAffixLen]; |
1151 + }; | 1152 + }; |
1152 + | 1153 + |
1153 + HashEntryItem hash_items_[MAX_ROOTS]; | 1154 + HashEntryItem hash_items_[MAX_ROOTS]; |
1154 +}; | 1155 +}; |
1155 + | 1156 + |
1156 +ScopedHashEntryFactory::ScopedHashEntryFactory() { | 1157 +ScopedHashEntryFactory::ScopedHashEntryFactory() { |
1157 + memset(&hash_items_[0], 0, sizeof(hash_items_)); | 1158 + memset(&hash_items_[0], 0, sizeof(hash_items_)); |
1158 +} | 1159 +} |
1159 + | 1160 + |
1160 +ScopedHashEntryFactory::~ScopedHashEntryFactory() { | 1161 +ScopedHashEntryFactory::~ScopedHashEntryFactory() { |
1161 +} | 1162 +} |
1162 + | 1163 + |
1163 +hentry* ScopedHashEntryFactory::CreateScopedHashEntry(int index, | 1164 +hentry* ScopedHashEntryFactory::CreateScopedHashEntry(int index, |
1164 + const hentry* source) { | 1165 + const hentry* source) { |
1165 + if (index >= MAX_ROOTS || source->blen >= kMaxWordLen || source->alen > 1) | 1166 + if (index >= MAX_ROOTS || source->blen >= kMaxWordLen) |
1166 + return NULL; | 1167 + return NULL; |
1167 + | 1168 + |
1168 + // Retrieve a HashEntryItem struct from our spool, initialize it, and | 1169 + // Retrieve a HashEntryItem struct from our spool, initialize it, and |
1169 + // returns the address of its 'hentry' member. | 1170 + // returns the address of its 'hentry' member. |
1170 + size_t source_size = sizeof(hentry) + source->blen + 1; | 1171 + size_t source_size = sizeof(hentry) + source->blen + 1; |
1171 + HashEntryItem* hash_item = &hash_items_[index]; | 1172 + HashEntryItem* hash_item = &hash_items_[index]; |
1172 + memcpy(&hash_item->entry, source, source_size); | 1173 + memcpy(&hash_item->entry, source, source_size); |
1173 + if (source->astr) { | 1174 + if (source->astr) { |
1174 + hash_item->astr = *source->astr; | 1175 + hash_item->entry.alen = source->alen; |
1175 + hash_item->entry.astr = &hash_item->astr; | 1176 + if (hash_item->entry.alen > kMaxAffixLen) |
| 1177 + hash_item->entry.alen = kMaxAffixLen; |
| 1178 + memcpy(hash_item->astr, source->astr, hash_item->entry.alen * sizeof(hash_i
tem->astr[0])); |
| 1179 + hash_item->entry.astr = &hash_item->astr[0]; |
1176 + } | 1180 + } |
1177 + return &hash_item->entry; | 1181 + return &hash_item->entry; |
1178 +} | 1182 +} |
1179 + | 1183 + |
1180 +} // namespace | 1184 +} // namespace |
1181 +#endif | 1185 +#endif |
1182 + | 1186 + |
1183 + | 1187 + |
1184 +#ifdef HUNSPELL_CHROME_CLIENT | 1188 +#ifdef HUNSPELL_CHROME_CLIENT |
1185 +SuggestMgr::SuggestMgr(hunspell::BDictReader* reader, | 1189 +SuggestMgr::SuggestMgr(hunspell::BDictReader* reader, |
1186 + const char * tryme, int maxn, | 1190 + const char * tryme, int maxn, |
1187 + AffixMgr * aptr) | 1191 + AffixMgr * aptr) |
1188 +{ | 1192 +{ |
1189 + bdict_reader = reader; | 1193 + bdict_reader = reader; |
1190 +#else | 1194 +#else |
1191 SuggestMgr::SuggestMgr(const char * tryme, int maxn, | 1195 SuggestMgr::SuggestMgr(const char * tryme, int maxn, |
1192 AffixMgr * aptr) | 1196 AffixMgr * aptr) |
1193 { | 1197 { |
1194 +#endif | 1198 +#endif |
1195 | 1199 |
1196 // register affix manager and check in string of chars to | 1200 // register affix manager and check in string of chars to |
1197 // try when building candidate suggestions | 1201 // try when building candidate suggestions |
1198 @@ -407,6 +508,49 @@ | 1202 @@ -407,6 +512,49 @@ |
1199 int lenr, lenp; | 1203 int lenr, lenp; |
1200 int wl = strlen(word); | 1204 int wl = strlen(word); |
1201 if (wl < 2 || ! pAMgr) return ns; | 1205 if (wl < 2 || ! pAMgr) return ns; |
1202 + | 1206 + |
1203 +#ifdef HUNSPELL_CHROME_CLIENT | 1207 +#ifdef HUNSPELL_CHROME_CLIENT |
1204 + const char *pattern, *pattern2; | 1208 + const char *pattern, *pattern2; |
1205 + hunspell::ReplacementIterator iterator = bdict_reader->GetReplacementIterator
(); | 1209 + hunspell::ReplacementIterator iterator = bdict_reader->GetReplacementIterator
(); |
1206 + while (iterator.GetNext(&pattern, &pattern2)) { | 1210 + while (iterator.GetNext(&pattern, &pattern2)) { |
1207 + r = word; | 1211 + r = word; |
1208 + lenr = strlen(pattern2); | 1212 + lenr = strlen(pattern2); |
(...skipping 29 matching lines...) Expand all Loading... |
1238 + sp = strchr(prev, ' '); | 1242 + sp = strchr(prev, ' '); |
1239 + } | 1243 + } |
1240 + } | 1244 + } |
1241 + r++; // search for the next letter | 1245 + r++; // search for the next letter |
1242 + } | 1246 + } |
1243 + } | 1247 + } |
1244 +#else | 1248 +#else |
1245 int numrep = pAMgr->get_numrep(); | 1249 int numrep = pAMgr->get_numrep(); |
1246 struct replentry* reptable = pAMgr->get_reptable(); | 1250 struct replentry* reptable = pAMgr->get_reptable(); |
1247 if (reptable==NULL) return ns; | 1251 if (reptable==NULL) return ns; |
1248 @@ -448,6 +592,7 @@ | 1252 @@ -448,6 +596,7 @@ |
1249 r++; // search for the next letter | 1253 r++; // search for the next letter |
1250 } | 1254 } |
1251 } | 1255 } |
1252 +#endif | 1256 +#endif |
1253 return ns; | 1257 return ns; |
1254 } | 1258 } |
1255 | 1259 |
1256 @@ -678,7 +823,9 @@ | 1260 @@ -678,7 +827,9 @@ |
1257 // error is missing a letter it needs | 1261 // error is missing a letter it needs |
1258 int SuggestMgr::forgotchar(char ** wlst, const char * word, int ns, int cpdsugg
est) | 1262 int SuggestMgr::forgotchar(char ** wlst, const char * word, int ns, int cpdsugg
est) |
1259 { | 1263 { |
1260 - char candidate[MAXSWUTF8L]; | 1264 - char candidate[MAXSWUTF8L]; |
1261 + // TODO(rouslan): Remove the interim change below when this patch lands: | 1265 + // TODO(rouslan): Remove the interim change below when this patch lands: |
1262 + // http://sf.net/tracker/?func=detail&aid=3595024&group_id=143754&atid=75639
5 | 1266 + // http://sf.net/tracker/?func=detail&aid=3595024&group_id=143754&atid=75639
5 |
1263 + char candidate[MAXSWUTF8L + 4]; | 1267 + char candidate[MAXSWUTF8L + 4]; |
1264 char * p; | 1268 char * p; |
1265 clock_t timelimit = clock(); | 1269 clock_t timelimit = clock(); |
1266 int timer = MINTIMER; | 1270 int timer = MINTIMER; |
1267 @@ -700,8 +847,10 @@ | 1271 @@ -700,8 +851,10 @@ |
1268 // error is missing a letter it needs | 1272 // error is missing a letter it needs |
1269 int SuggestMgr::forgotchar_utf(char ** wlst, const w_char * word, int wl, int n
s, int cpdsuggest) | 1273 int SuggestMgr::forgotchar_utf(char ** wlst, const w_char * word, int wl, int n
s, int cpdsuggest) |
1270 { | 1274 { |
1271 - w_char candidate_utf[MAXSWL]; | 1275 - w_char candidate_utf[MAXSWL]; |
1272 - char candidate[MAXSWUTF8L]; | 1276 - char candidate[MAXSWUTF8L]; |
1273 + // TODO(rouslan): Remove the interim change below when this patch lands: | 1277 + // TODO(rouslan): Remove the interim change below when this patch lands: |
1274 + // http://sf.net/tracker/?func=detail&aid=3595024&group_id=143754&atid=75639
5 | 1278 + // http://sf.net/tracker/?func=detail&aid=3595024&group_id=143754&atid=75639
5 |
1275 + w_char candidate_utf[MAXSWL + 1]; | 1279 + w_char candidate_utf[MAXSWL + 1]; |
1276 + char candidate[MAXSWUTF8L + 4]; | 1280 + char candidate[MAXSWUTF8L + 4]; |
1277 w_char * p; | 1281 w_char * p; |
1278 clock_t timelimit = clock(); | 1282 clock_t timelimit = clock(); |
1279 int timer = MINTIMER; | 1283 int timer = MINTIMER; |
1280 @@ -1057,6 +1206,9 @@ | 1284 @@ -1057,6 +1210,9 @@ |
1281 | 1285 |
1282 struct hentry* hp = NULL; | 1286 struct hentry* hp = NULL; |
1283 int col = -1; | 1287 int col = -1; |
1284 +#ifdef HUNSPELL_CHROME_CLIENT | 1288 +#ifdef HUNSPELL_CHROME_CLIENT |
1285 + ScopedHashEntryFactory hash_entry_factory; | 1289 + ScopedHashEntryFactory hash_entry_factory; |
1286 +#endif | 1290 +#endif |
1287 phonetable * ph = (pAMgr) ? pAMgr->get_phonetable() : NULL; | 1291 phonetable * ph = (pAMgr) ? pAMgr->get_phonetable() : NULL; |
1288 char target[MAXSWUTF8L]; | 1292 char target[MAXSWUTF8L]; |
1289 char candidate[MAXSWUTF8L]; | 1293 char candidate[MAXSWUTF8L]; |
1290 @@ -1115,7 +1267,11 @@ | 1294 @@ -1115,7 +1271,11 @@ |
1291 | 1295 |
1292 if (sc > scores[lp]) { | 1296 if (sc > scores[lp]) { |
1293 scores[lp] = sc; | 1297 scores[lp] = sc; |
1294 +#ifdef HUNSPELL_CHROME_CLIENT | 1298 +#ifdef HUNSPELL_CHROME_CLIENT |
1295 + roots[lp] = hash_entry_factory.CreateScopedHashEntry(lp, hp); | 1299 + roots[lp] = hash_entry_factory.CreateScopedHashEntry(lp, hp); |
1296 +#else | 1300 +#else |
1297 roots[lp] = hp; | 1301 roots[lp] = hp; |
1298 +#endif | 1302 +#endif |
1299 lval = sc; | 1303 lval = sc; |
1300 for (j=0; j < MAX_ROOTS; j++) | 1304 for (j=0; j < MAX_ROOTS; j++) |
1301 if (scores[j] < lval) { | 1305 if (scores[j] < lval) { |
1302 Index: src/hunspell/suggestmgr.hxx | 1306 Index: src/hunspell/suggestmgr.hxx |
1303 =================================================================== | 1307 =================================================================== |
1304 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/suggestmgr.hxx,v | 1308 RCS file: /cvsroot/hunspell/hunspell/src/hunspell/suggestmgr.hxx,v |
1305 retrieving revision 1.5 | 1309 retrieving revision 1.5 |
1306 diff -u -r1.5 suggestmgr.hxx | 1310 diff -u -r1.5 suggestmgr.hxx |
1307 --- src/hunspell/suggestmgr.hxx 21 Jan 2011 22:10:24 -0000 1.5 | 1311 --- src/hunspell/suggestmgr.hxx 21 Jan 2011 22:10:24 -0000 1.5 |
1308 +++ src/hunspell/suggestmgr.hxx»8 Jan 2013 00:30:26 -0000 | 1312 +++ src/hunspell/suggestmgr.hxx»27 Feb 2013 01:10:36 -0000 |
1309 @@ -52,7 +52,11 @@ | 1313 @@ -52,7 +52,11 @@ |
1310 | 1314 |
1311 | 1315 |
1312 public: | 1316 public: |
1313 +#ifdef HUNSPELL_CHROME_CLIENT | 1317 +#ifdef HUNSPELL_CHROME_CLIENT |
1314 + SuggestMgr(hunspell::BDictReader* reader, const char * tryme, int maxn, Affix
Mgr *aptr); | 1318 + SuggestMgr(hunspell::BDictReader* reader, const char * tryme, int maxn, Affix
Mgr *aptr); |
1315 +#else | 1319 +#else |
1316 SuggestMgr(const char * tryme, int maxn, AffixMgr *aptr); | 1320 SuggestMgr(const char * tryme, int maxn, AffixMgr *aptr); |
1317 +#endif | 1321 +#endif |
1318 ~SuggestMgr(); | 1322 ~SuggestMgr(); |
1319 | 1323 |
1320 int suggest(char*** slst, const char * word, int nsug, int * onlycmpdsug); | 1324 int suggest(char*** slst, const char * word, int nsug, int * onlycmpdsug); |
1321 @@ -66,6 +70,10 @@ | 1325 @@ -66,6 +70,10 @@ |
1322 char * suggest_morph_for_spelling_error(const char * word); | 1326 char * suggest_morph_for_spelling_error(const char * word); |
1323 | 1327 |
1324 private: | 1328 private: |
1325 +#ifdef HUNSPELL_CHROME_CLIENT | 1329 +#ifdef HUNSPELL_CHROME_CLIENT |
1326 + // Not owned by us, owned by the Hunspell object. | 1330 + // Not owned by us, owned by the Hunspell object. |
1327 + hunspell::BDictReader* bdict_reader; | 1331 + hunspell::BDictReader* bdict_reader; |
1328 +#endif | 1332 +#endif |
1329 int testsug(char** wlst, const char * candidate, int wl, int ns, int cpdsugg
est, | 1333 int testsug(char** wlst, const char * candidate, int wl, int ns, int cpdsugg
est, |
1330 int * timer, clock_t * timelimit); | 1334 int * timer, clock_t * timelimit); |
1331 int checkword(const char *, int, int, int *, clock_t *); | 1335 int checkword(const char *, int, int, int *, clock_t *); |
OLD | NEW |