OLD | NEW |
| (Empty) |
1 Index: src/hunspell/affixmgr.cxx | |
2 =================================================================== | |
3 --- src/hunspell/affixmgr.cxx (revision 3811) | |
4 +++ src/hunspell/affixmgr.cxx (working copy) | |
5 @@ -25,7 +27,7 @@ | |
6 #endif | |
7 #endif | |
8 | |
9 -AffixMgr::AffixMgr(const char * affpath, HashMgr* ptr) | |
10 +AffixMgr::AffixMgr(FILE* aff_handle, HashMgr* ptr) | |
11 { | |
12 // register hash manager and load affix data from aff file | |
13 pHMgr = ptr; | |
14 @@ -104,8 +106,8 @@ | |
15 contclasses[j] = 0; | |
16 } | |
17 | |
18 - if (parse_file(affpath)) { | |
19 - HUNSPELL_WARNING(stderr, "Failure loading aff file %s\n",affpath); | |
20 + if (parse_file(aff_handle)) { | |
21 + HUNSPELL_WARNING(stderr, "Failure loading aff file\n"); | |
22 wordchars = mystrdup("qwertzuiopasdfghjklyxcvbnmQWERTZUIOPASDFGHJKLYXCVBNM
"); | |
23 } | |
24 | |
25 @@ -232,7 +234,7 @@ | |
26 | |
27 | |
28 // read in aff file and build up prefix and suffix entry objects | |
29 -int AffixMgr::parse_file(const char * affpath) | |
30 +int AffixMgr::parse_file(FILE* aff_handle) | |
31 { | |
32 | |
33 // io buffers | |
34 @@ -250,11 +252,12 @@ | |
35 | |
36 // open the affix file | |
37 FILE * afflst; | |
38 - afflst = fopen(affpath,"r"); | |
39 + afflst = _fdopen(_dup(_fileno(aff_handle)), "r"); | |
40 if (!afflst) { | |
41 - HUNSPELL_WARNING(stderr, "error: could not open affix description file %s\n
",affpath); | |
42 + HUNSPELL_WARNING(stderr, "error: could not open affix description file\n"); | |
43 return 1; | |
44 } | |
45 + fseek(afflst, 0, SEEK_SET); | |
46 | |
47 // step one is to parse the affix file building up the internal | |
48 // affix data structures | |
49 Index: src/hunspell/affixmgr.hxx | |
50 =================================================================== | |
51 --- src/hunspell/affixmgr.hxx (revision 3811) | |
52 +++ src/hunspell/affixmgr.hxx (working copy) | |
53 @@ -93,7 +93,7 @@ | |
54 | |
55 public: | |
56 | |
57 - AffixMgr(const char * affpath, HashMgr * ptr); | |
58 + AffixMgr(FILE* aff_handle, HashMgr * ptr); | |
59 ~AffixMgr(); | |
60 struct hentry * affix_check(const char * word, int len, | |
61 const unsigned short needflag = (unsigned short) 0, char in_compoun
d = IN_CPD_NOT); | |
62 @@ -179,7 +179,7 @@ | |
63 int get_checksharps(void); | |
64 | |
65 private: | |
66 - int parse_file(const char * affpath); | |
67 + int parse_file(FILE* aff_handle); | |
68 // int parse_string(char * line, char ** out, const char * name); | |
69 int parse_flag(char * line, unsigned short * out, const char * name); | |
70 int parse_num(char * line, int * out, const char * name); | |
71 Index: src/hunspell/hashmgr.cxx | |
72 =================================================================== | |
73 --- src/hunspell/hashmgr.cxx (revision 3811) | |
74 +++ src/hunspell/hashmgr.cxx (working copy) | |
75 @@ -29,7 +31,7 @@ | |
76 | |
77 // build a hash table from a munched word list | |
78 | |
79 -HashMgr::HashMgr(const char * tpath, const char * apath) | |
80 +HashMgr::HashMgr(FILE* dic_handle, FILE* aff_handle) | |
81 { | |
82 tablesize = 0; | |
83 tableptr = NULL; | |
84 @@ -43,8 +45,8 @@ | |
85 aliasf = NULL; | |
86 numaliasm = 0; | |
87 aliasm = NULL; | |
88 - load_config(apath); | |
89 - int ec = load_tables(tpath); | |
90 + load_config(aff_handle); | |
91 + int ec = load_tables(dic_handle); | |
92 if (ec) { | |
93 /* error condition - what should we do here */ | |
94 HUNSPELL_WARNING(stderr, "Hash Manager Error : %d\n",ec); | |
95 @@ -240,7 +242,7 @@ | |
96 } | |
97 | |
98 // load a munched word list and build a hash table on the fly | |
99 -int HashMgr::load_tables(const char * tpath) | |
100 +int HashMgr::load_tables(FILE* t_handle) | |
101 { | |
102 int wl, al; | |
103 char * ap; | |
104 @@ -248,8 +250,9 @@ | |
105 unsigned short * flags; | |
106 | |
107 // raw dictionary - munched file | |
108 - FILE * rawdict = fopen(tpath, "r"); | |
109 + FILE * rawdict = _fdopen(_dup(_fileno(t_handle)), "r"); | |
110 if (rawdict == NULL) return 1; | |
111 + fseek(rawdict, 0, SEEK_SET); | |
112 | |
113 // first read the first line of file to get hash table size */ | |
114 char ts[MAXDELEN]; | |
115 @@ -442,7 +445,7 @@ | |
116 } | |
117 | |
118 // read in aff file and set flag mode | |
119 -int HashMgr::load_config(const char * affpath) | |
120 +int HashMgr::load_config(FILE* aff_handle) | |
121 { | |
122 int firstline = 1; | |
123 | |
124 @@ -451,11 +454,12 @@ | |
125 | |
126 // open the affix file | |
127 FILE * afflst; | |
128 - afflst = fopen(affpath,"r"); | |
129 + afflst = _fdopen(_dup(_fileno(aff_handle)), "r"); | |
130 if (!afflst) { | |
131 - HUNSPELL_WARNING(stderr, "Error - could not open affix description file %s\
n",affpath); | |
132 + HUNSPELL_WARNING(stderr, "Error - could not open affix description file\n")
; | |
133 return 1; | |
134 } | |
135 + fseek(afflst, 0, SEEK_SET); | |
136 | |
137 // read in each line ignoring any that do not | |
138 // start with a known line type indicator | |
139 Index: src/hunspell/hashmgr.hxx | |
140 =================================================================== | |
141 --- src/hunspell/hashmgr.hxx (revision 3811) | |
142 +++ src/hunspell/hashmgr.hxx (working copy) | |
143 @@ -25,7 +25,7 @@ | |
144 | |
145 | |
146 public: | |
147 - HashMgr(const char * tpath, const char * apath); | |
148 + HashMgr(FILE* t_handle, FILE* a_handle); | |
149 ~HashMgr(); | |
150 | |
151 struct hentry * lookup(const char *) const; | |
152 @@ -46,9 +46,9 @@ | |
153 | |
154 | |
155 private: | |
156 - int load_tables(const char * tpath); | |
157 + int load_tables(FILE* t_handle); | |
158 int add_word(const char * word, int wl, unsigned short * ap, int al, const ch
ar * desc); | |
159 - int load_config(const char * affpath); | |
160 + int load_config(FILE* aff_handle); | |
161 int parse_aliasf(char * line, FILE * af); | |
162 #ifdef HUNSPELL_EXPERIMENTAL | |
163 int parse_aliasm(char * line, FILE * af); | |
164 Index: src/hunspell/hunspell.cxx | |
165 =================================================================== | |
166 --- src/hunspell/hunspell.cxx (revision 3811) | |
167 +++ src/hunspell/hunspell.cxx (working copy) | |
168 @@ -20,7 +20,7 @@ | |
169 #endif | |
170 #endif | |
171 | |
172 -Hunspell::Hunspell(const char * affpath, const char * dpath) | |
173 +Hunspell::Hunspell(FILE* aff_handle, FILE* dic_handle) | |
174 { | |
175 encoding = NULL; | |
176 csconv = NULL; | |
177 @@ -28,11 +28,11 @@ | |
178 complexprefixes = 0; | |
179 | |
180 /* first set up the hash manager */ | |
181 - pHMgr = new HashMgr(dpath, affpath); | |
182 + pHMgr = new HashMgr(dic_handle, aff_handle); | |
183 | |
184 /* next set up the affix manager */ | |
185 /* it needs access to the hash manager lookup methods */ | |
186 - pAMgr = new AffixMgr(affpath,pHMgr); | |
187 + pAMgr = new AffixMgr(aff_handle, pHMgr); | |
188 | |
189 /* get the preferred try string and the dictionary */ | |
190 /* encoding from the Affix Manager for that dictionary */ | |
191 @@ -1694,9 +1694,9 @@ | |
192 | |
193 #endif // END OF HUNSPELL_EXPERIMENTAL CODE | |
194 | |
195 -Hunhandle *Hunspell_create(const char * affpath, const char * dpath) | |
196 +Hunhandle *Hunspell_create(FILE* aff_handle, FILE* dic_handle) | |
197 { | |
198 - return (Hunhandle*)(new Hunspell(affpath, dpath)); | |
199 + return (Hunhandle*)(new Hunspell(aff_handle, dic_handle)); | |
200 } | |
201 | |
202 void Hunspell_destroy(Hunhandle *pHunspell) | |
203 Index: src/hunspell/hunspell.hxx | |
204 =================================================================== | |
205 --- src/hunspell/hunspell.hxx (revision 3811) | |
206 +++ src/hunspell/hunspell.hxx (working copy) | |
207 @@ -48,7 +48,7 @@ | |
208 * input: path of affix file and dictionary file | |
209 */ | |
210 | |
211 - Hunspell(const char * affpath, const char * dpath); | |
212 + Hunspell(FILE* aff_handle, FILE* dic_handle); | |
OLD | NEW |