Gentoo Archives: gentoo-commits

From: "Serkan Kaba (serkan)" <serkan@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-text/gnome-spell/files: gnome-spell-1.0.8-r3-enchant.patch
Date: Sun, 31 May 2009 11:47:32
Message-Id: E1MAjVQ-0002H2-9K@stork.gentoo.org
1 serkan 09/05/31 11:47:12
2
3 Added: gnome-spell-1.0.8-r3-enchant.patch
4 Log:
5 Revbump to fix critical error.
6 (Portage version: 2.2_rc33/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 app-text/gnome-spell/files/gnome-spell-1.0.8-r3-enchant.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-text/gnome-spell/files/gnome-spell-1.0.8-r3-enchant.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-text/gnome-spell/files/gnome-spell-1.0.8-r3-enchant.patch?rev=1.1&content-type=text/plain
13
14 Index: gnome-spell-1.0.8-r3-enchant.patch
15 ===================================================================
16 Index: gnome-spell/dictionary.c
17 ===================================================================
18 --- gnome-spell/dictionary.c (révision 424)
19 +++ gnome-spell/dictionary.c (copie de travail)
20 @@ -30,16 +30,21 @@
21 #include <glib.h>
22 #include <libgnome/gnome-i18n.h>
23 #include <libgnome/gnome-config.h>
24 -#include <gconf/gconf-client.h>
25 #include <bonobo.h>
26
27 #include "Spell.h"
28 #include "dictionary.h"
29
30 +#include <enchant.h>
31 +
32 +typedef struct {
33 + EnchantBroker * config;
34 + EnchantDict * speller;
35 +} SpellEngine;
36 +
37 static BonoboObjectClass *dictionary_parent_class;
38
39 #define DICT_DEBUG(x)
40 -#define GNOME_SPELL_GCONF_DIR "/GNOME/Spell"
41
42 static void release_engines (GNOMESpellDictionary *dict);
43
44 @@ -72,12 +77,24 @@
45 {
46 GNOMESpellDictionary *dict = GNOME_SPELL_DICTIONARY (object);
47
48 - dict->changed = TRUE;
49 dict->engines = NULL;
50 dict->languages = g_hash_table_new (g_str_hash, g_str_equal);
51 dict->engines_ht = g_hash_table_new (NULL, NULL);
52 }
53
54 +static char **
55 +dup_string_list (char ** str_list, size_t list_len)
56 +{
57 + char ** new_str_list;
58 + size_t i;
59 +
60 + new_str_list = g_new0 (char *, list_len + 1);
61 + for (i = 0; i < list_len; i++)
62 + new_str_list [i] = g_strdup (str_list [i]);
63 +
64 + return new_str_list;
65 +}
66 +
67 static void
68 dictionary_finalize (GObject *object)
69 {
70 @@ -93,15 +110,16 @@
71 }
72
73 static SpellEngine *
74 -new_engine (const gchar *language)
75 +new_engine (const gchar *language, CORBA_Environment *ev)
76 {
77 SpellEngine *se;
78
79 se = g_new0 (SpellEngine, 1);
80 - se->config = new_aspell_config ();
81 - aspell_config_replace (se->config, "language-tag", language);
82 - aspell_config_replace (se->config, "encoding", "utf-8");
83 - se->changed = TRUE;
84 + se->config = enchant_broker_init ();
85 + se->speller = enchant_broker_request_dict (se->config, language);
86 +
87 + if(se->speller == NULL)
88 + raise_error (ev, enchant_broker_get_error (se->config));
89
90 return se;
91 }
92 @@ -129,9 +147,9 @@
93 SpellEngine *se = dict->engines->data;
94
95 if (se->speller)
96 - delete_aspell_speller (se->speller);
97 + enchant_broker_free_dict (se->config, se->speller);
98 if (se->config)
99 - delete_aspell_config (se->config);
100 + enchant_broker_free (se->config);
101 g_free (se);
102 dict->engines = g_slist_remove (dict->engines, se);
103 }
104 @@ -140,7 +158,6 @@
105 g_hash_table_foreach_remove (dict->languages, remove_engine_ht, NULL);
106
107 dict->engines = NULL;
108 - dict->changed = TRUE;
109 }
110
111 static LangInfo known_languages [] = {
112 @@ -352,88 +369,31 @@
113 };
114
115 static GSList *
116 -get_languages_real (gint *ln)
117 +get_languages (gint *ln)
118 {
119 GSList *langs;
120 - AspellCanHaveError *err;
121 - AspellConfig *config;
122 - AspellSpeller *speller;
123 - gint i;
124 + EnchantBroker *broker;
125 + gint i, nb_langs;
126
127 - DICT_DEBUG (printf ("get_languages_real\n"));
128 + DICT_DEBUG (printf ("get_languages\n"));
129
130 + /* todo: this could probably be better done by enchant_broker_list_dicts(), but let's keep
131 + the initial code change to a minimum */
132 +
133 + broker = enchant_broker_init ();
134 langs = NULL;
135 - *ln = 0;
136 + nb_langs = 0;
137 for (i=0; i < G_N_ELEMENTS (known_languages); i++) {
138 - config = new_aspell_config ();
139 - aspell_config_replace (config, "language-tag", known_languages [i].abbreviation);
140 - err = new_aspell_speller (config);
141 - if (aspell_error_number (err) == 0) {
142 - speller = to_aspell_speller (err);
143 + if (enchant_broker_dict_exists (broker, known_languages [i].abbreviation)) {
144 DICT_DEBUG (printf ("Language: %s\n", known_languages [i].name));
145 - delete_aspell_speller (speller);
146 langs = g_slist_prepend (langs, GINT_TO_POINTER (i));
147 - (*ln) ++;
148 + nb_langs++;
149 }
150 }
151
152 - return langs;
153 -}
154 -
155 -static GSList *
156 -get_languages_load (GConfClient *gc, gint *ln)
157 -{
158 - GString *str;
159 - GSList *langs = NULL;
160 - gint i, lang_num;
161 -
162 - /* printf ("get_languages_load\n"); */
163 -
164 - str = g_string_new (NULL);
165 - *ln = gconf_client_get_int (gc, GNOME_SPELL_GCONF_DIR "/languages", NULL);
166 - for (i = 0; i < *ln; i++) {
167 - g_string_sprintf (str, GNOME_SPELL_GCONF_DIR "/language%d", i);
168 - lang_num = gconf_client_get_int (gc, str->str, NULL);
169 - langs = g_slist_prepend (langs, GINT_TO_POINTER (lang_num));
170 - }
171 -
172 - return langs;
173 -}
174 -
175 -static GSList *
176 -get_languages (gint *ln)
177 -{
178 - GSList *langs, *l;
179 - GConfClient *gc;
180 - time_t mtime;
181 - struct stat buf;
182 - gint i, kl;
183 -
184 - gc = gconf_client_get_default ();
185 -
186 - mtime = gconf_client_get_int (gc, GNOME_SPELL_GCONF_DIR "/mtime", NULL);
187 - kl = gconf_client_get_int (gc, GNOME_SPELL_GCONF_DIR "/known_languages", NULL);
188 -
189 - if (stat (ASPELL_DICT, &buf) || buf.st_mtime != mtime || kl != G_N_ELEMENTS(known_languages)) {
190 - GString *str;
191 - langs = get_languages_real (ln);
192 -
193 - str = g_string_new (NULL);
194 - gconf_client_set_int (gc, GNOME_SPELL_GCONF_DIR "/languages", *ln, NULL);
195 - for (l = langs, i = 0; i < *ln; i ++) {
196 - g_string_sprintf (str, GNOME_SPELL_GCONF_DIR "/language%d", *ln - i - 1);
197 - gconf_client_set_int (gc, str->str, GPOINTER_TO_INT (l->data), NULL);
198 - l = l->next;
199 - }
200 - gconf_client_set_int (gc, GNOME_SPELL_GCONF_DIR "/mtime", buf.st_mtime, NULL);
201 - gconf_client_set_int (gc, GNOME_SPELL_GCONF_DIR "/known_languages", G_N_ELEMENTS(known_languages), NULL);
202 - g_string_free (str, TRUE);
203 - gnome_config_sync ();
204 - } else
205 - langs = get_languages_load (gc, ln);
206 + *ln = nb_langs;
207
208 - gconf_client_suggest_sync (gc, NULL);
209 - g_object_unref (gc);
210 + enchant_broker_free (broker);
211
212 return langs;
213 }
214 @@ -504,59 +464,19 @@
215 SpellEngine *se;
216
217 one_language = g_strndup (begin, len);
218 - se = new_engine (one_language);
219 + se = new_engine (one_language, ev);
220 dict->engines = g_slist_prepend (dict->engines, se);
221 g_hash_table_insert (dict->languages, one_language, se);
222 g_hash_table_insert (dict->engines_ht, se, g_strdup (one_language));
223 -
224 - dict->changed = TRUE;
225 - }
226 - }
227 -}
228 -
229 -static void
230 -update_engine (SpellEngine *se, CORBA_Environment * ev)
231 -{
232 - AspellCanHaveError *err;
233 -
234 - DICT_DEBUG (printf ("Dictionary: creating new aspell speller\n"));
235 -
236 - if (se->changed) {
237 - if (se->speller)
238 - delete_aspell_speller (se->speller);
239 - err = new_aspell_speller (se->config);
240 - if (aspell_error_number (err) != 0) {
241 - g_warning ("aspell error: %s\n", aspell_error_message (err));
242 - se->speller = NULL;
243 - raise_error (ev, aspell_error_message (err));
244 - } else {
245 - se->speller = to_aspell_speller (err);
246 - se->changed = FALSE;
247 }
248 }
249 }
250
251 -static void
252 -update_engines (GNOMESpellDictionary *dict, CORBA_Environment * ev)
253 -{
254 - g_return_if_fail (IS_GNOME_SPELL_DICTIONARY (dict));
255 -
256 - if (dict->changed) {
257 - GSList *l;
258 -
259 - for (l = dict->engines; l; l = l->next) {
260 - update_engine ((SpellEngine *) l->data, ev);
261 - }
262 -
263 - dict->changed = FALSE;
264 - }
265 -}
266 -
267 static CORBA_boolean
268 engine_check_word (SpellEngine *se, const gchar *word, CORBA_Environment *ev)
269 {
270 - CORBA_boolean result = CORBA_TRUE;
271 - gint aspell_result;
272 + CORBA_boolean result = CORBA_FALSE;
273 + gint enchant_result;
274
275 #ifndef G_DISABLE_CHECKS
276 g_return_val_if_fail (se->speller, CORBA_TRUE);
277 @@ -564,12 +484,12 @@
278 if (!se->speller)
279 return CORBA_TRUE;
280 #endif
281 - aspell_result = aspell_speller_check (se->speller, word, strlen (word));
282 - if (aspell_result == 0)
283 - result = CORBA_FALSE;
284 - if (aspell_result == -1) {
285 - g_warning ("aspell error: %s\n", aspell_speller_error_message (se->speller));
286 - raise_error (ev, aspell_speller_error_message (se->speller));
287 + enchant_result = enchant_dict_check (se->speller, word, strlen (word));
288 + if (enchant_result == 0)
289 + result = CORBA_TRUE;
290 + if (enchant_result == -1) {
291 + g_warning ("enchant error: %s\n", enchant_dict_get_error (se->speller));
292 + raise_error (ev, enchant_dict_get_error (se->speller));
293 }
294
295 return result;
296 @@ -592,7 +512,6 @@
297 if (!strcmp (word, "Ximian"))
298 return CORBA_TRUE;
299
300 - update_engines (dict, ev);
301 for (l = dict->engines; l; l = l->next) {
302 if (((SpellEngine *) l->data)->speller) {
303 valid_speller = TRUE;
304 @@ -621,11 +540,10 @@
305 if (!word)
306 return;
307 #endif
308 - update_engines (dict, ev);
309 DICT_DEBUG (printf ("Dictionary add_word_to_session: %s\n", word));
310 for (l = dict->engines; l; l = l->next) {
311 if (((SpellEngine *) l->data)->speller)
312 - aspell_speller_add_to_session (((SpellEngine *) l->data)->speller, word, strlen (word));
313 + enchant_dict_add_to_session (((SpellEngine *) l->data)->speller, word, strlen (word));
314 }
315 }
316
317 @@ -642,13 +560,11 @@
318 if (!word || !language)
319 return;
320 #endif
321 - update_engines (dict, ev);
322 DICT_DEBUG (printf ("Dictionary add_word_to_personal: %s (%s)\n", word, language));
323 se = (SpellEngine *) g_hash_table_lookup (dict->languages, language);
324
325 if (se && se->speller) {
326 - aspell_speller_add_to_personal (se->speller, word, strlen (word));
327 - aspell_speller_save_all_word_lists (se->speller);
328 + enchant_dict_add_to_pwl (se->speller, word, strlen (word));
329 DICT_DEBUG (printf ("Added and saved.\n"));
330 }
331 }
332 @@ -666,14 +582,12 @@
333 if (!word || !replacement)
334 return;
335 #endif
336 - update_engines (dict, ev);
337 DICT_DEBUG (printf ("Dictionary correction: %s <-- %s\n", word, replacement));
338 se = (SpellEngine *) g_hash_table_lookup (dict->languages, language);
339
340 if (se && se->speller) {
341 - aspell_speller_store_replacement (se->speller, word, strlen (word),
342 - replacement, strlen (replacement));
343 - aspell_speller_save_all_word_lists (se->speller);
344 + enchant_dict_store_replacement (se->speller, word, strlen (word),
345 + replacement, strlen (replacement));
346 DICT_DEBUG (printf ("Set and saved.\n"));
347 }
348 }
349 @@ -683,8 +597,8 @@
350 const CORBA_char *word, CORBA_Environment *ev)
351 {
352 GNOMESpellDictionary *dict = GNOME_SPELL_DICTIONARY (bonobo_object_from_servant (servant));
353 - const AspellWordList *suggestions;
354 - AspellStringEnumeration *elements;
355 + char **suggestions;
356 + size_t number_of_suggestions;
357 GNOME_Spell_StringSeq *seq = NULL;
358 GSList *l, *suggestion_list = NULL;
359 gint i, len, pos;
360 @@ -696,17 +610,19 @@
361 return NULL;
362 #endif
363 DICT_DEBUG (printf ("Dictionary correction: %s\n", word));
364 - update_engines (dict, ev);
365
366 len = 0;
367 for (l = dict->engines; l; l = l->next) {
368 SpellEngine *se = (SpellEngine *) l->data;
369
370 if (se->speller) {
371 - suggestions = aspell_speller_suggest (se->speller, word, strlen (word));
372 - suggestion_list = g_slist_prepend (suggestion_list, (gpointer) suggestions);
373 - len += 2*aspell_word_list_size (suggestions);
374 + suggestions = enchant_dict_suggest (se->speller, word, strlen (word), &number_of_suggestions);
375 + suggestion_list = g_slist_prepend (suggestion_list,
376 + (gpointer) dup_string_list (suggestions, number_of_suggestions));
377 + len += 2*number_of_suggestions;
378 suggestion_list = g_slist_prepend (suggestion_list, engine_to_language (dict, se));
379 + suggestion_list = g_slist_prepend (suggestion_list, GINT_TO_POINTER (number_of_suggestions));
380 + if(suggestions != NULL) enchant_dict_free_string_list (se->speller, suggestions);
381 }
382 }
383
384 @@ -723,17 +639,18 @@
385 gint list_len;
386 gchar *language;
387
388 + list_len = GPOINTER_TO_INT (l->data);
389 + l = l->next;
390 language = (gchar *) l->data;
391 l = l->next;
392 - suggestions = (const AspellWordList *) l->data;
393 - elements = aspell_word_list_elements (suggestions);
394 - list_len = aspell_word_list_size (suggestions);
395 + suggestions = (char **) l->data;
396 for (i = 0; i < list_len; i ++, pos ++) {
397 - seq->_buffer [pos] = CORBA_string_dup (aspell_string_enumeration_next (elements));
398 + seq->_buffer [pos] = CORBA_string_dup (suggestions [i]);
399 pos ++;
400 seq->_buffer [pos] = CORBA_string_dup (language);
401 }
402 - delete_aspell_string_enumeration (elements);
403 +
404 + g_strfreev (suggestions);
405 }
406 CORBA_sequence_set_release (seq, CORBA_TRUE);
407 g_slist_free (suggestion_list);
408 Index: gnome-spell/dictionary.h
409 ===================================================================
410 --- gnome-spell/dictionary.h (révision 424)
411 +++ gnome-spell/dictionary.h (copie de travail)
412 @@ -26,7 +26,6 @@
413 G_BEGIN_DECLS
414
415 #include <bonobo/bonobo-object.h>
416 -#include <aspell.h>
417
418 #define GNOME_SPELL_DICTIONARY_TYPE (gnome_spell_dictionary_get_type ())
419 #define GNOME_SPELL_DICTIONARY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
420 @@ -37,12 +36,6 @@
421 #define IS_GNOME_SPELL_DICTIONARY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNOME_SPELL_DICTIONARY_TYPE))
422
423 typedef struct {
424 - AspellConfig *config;
425 - AspellSpeller *speller;
426 - gboolean changed;
427 -} SpellEngine;
428 -
429 -typedef struct {
430 gchar *abbreviation;
431 gchar *name;
432 } LangInfo;
433 @@ -50,7 +43,6 @@
434 typedef struct {
435 BonoboObject parent;
436
437 - gboolean changed;
438 GSList *engines;
439 GHashTable *languages;
440 GHashTable *engines_ht;
441 Index: gnome-spell/Makefile.am
442 ===================================================================
443 --- gnome-spell/Makefile.am (révision 424)
444 +++ gnome-spell/Makefile.am (copie de travail)
445 @@ -7,13 +7,11 @@
446
447 INCLUDES = \
448 -I$(srcdir) \
449 - $(ASPELL_INC) \
450 -DPREFIX=\""$(prefix)"\" \
451 -DGNOMEDATADIR=\""$(datadir)"\" \
452 -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
453 -DGLADE_DATADIR=\"$(gladedir)\" \
454 -DPLUGIN_DIR=\""$(PLUGIN_DIR)"\" \
455 - -DASPELL_DICT=\""$(ASPELL_DICT)"\" \
456 $(GNOME_SPELL_CFLAGS) \
457 $(END)
458
459 @@ -55,7 +53,6 @@
460 libgnome_spell_component_la_LDFLAGS = -release $(API_VERSION) $(NO_UNDEFINED)
461 libgnome_spell_component_la_LIBADD = \
462 libgnome-spell-idl.la \
463 - $(ASPELL_LIBS) \
464 $(GNOME_SPELL_LIBS) \
465 $(END)
466
467 @@ -69,7 +66,6 @@
468
469 test_gnome_spell_component_LDADD = \
470 libgnome-spell-idl.la \
471 - $(ASPELL_LIBS) \
472 $(GNOME_SPELL_LIBS) \
473 $(END)
474
475 Index: gnome-spell/test-spell.c
476 ===================================================================
477 --- gnome-spell/test-spell.c (révision 424)
478 +++ gnome-spell/test-spell.c (copie de travail)
479 @@ -52,7 +52,6 @@
480 * test dictionary
481 */
482
483 - GNOME_Spell_Dictionary_getLanguages (en, &ev);
484 GNOME_Spell_Dictionary_setLanguage (en, "en", &ev);
485
486 printf ("check: %s --> %d\n",
487 Index: configure.in
488 ===================================================================
489 --- configure.in (révision 424)
490 +++ configure.in (copie de travail)
491 @@ -68,34 +68,6 @@
492 AC_SUBST(API_VERSION)
493
494 dnl
495 -dnl aspell
496 -dnl
497 -
498 -AC_ARG_WITH(aspell-prefix, [ --with-aspell-prefix=DIR
499 - specify under which prefix aspell is installed.], with_aspell_prefix="$withval", )
500 -
501 -if test "x$with_aspell_prefix" != "x"; then
502 - saved_LDFLAGS=$LDFLAGS
503 - LDFLAGS="-L$with_aspell_prefix/lib "$LDFLAGS
504 - ASPELL_INC="-I$with_aspell_prefix/include"
505 - ASPELL_LIBS="-L$with_aspell_prefix/lib -laspell"
506 - ASPELL_DATA="$with_aspell_prefix/lib/aspell"
507 -else
508 - LDFLAGS="-L`aspell config prefix`/lib "$LDFLAGS
509 - ASPELL_INC="-I`aspell config prefix`/include"
510 - ASPELL_LIBS="-L`aspell config prefix`/lib -laspell"
511 - ASPELL_DICT="`aspell config dict-dir`"
512 -fi
513 -AC_CHECK_LIB(aspell,new_aspell_config,,AC_MSG_ERROR([gnome-spell cannot be built without aspell library]),)
514 -if test "x$with_aspell_prefix" != "x"; then
515 - LDFLAGS=$saved_LDFLAGS
516 -fi
517 -
518 -AC_SUBST(ASPELL_DICT)
519 -AC_SUBST(ASPELL_INC)
520 -AC_SUBST(ASPELL_LIBS)
521 -
522 -dnl
523 dnl flags
524 dnl
525
526 @@ -104,7 +76,7 @@
527 AC_SUBST(CPPFLAGS)
528 AC_SUBST(LDFLAGS)
529
530 -GNOME_SPELL_MODULES="libgnomeui-2.0 >= 1.112.1 libbonoboui-2.0 >= 1.112.1 libglade-2.0 >= 1.99.9"
531 +GNOME_SPELL_MODULES="libgnome-2.0 >= 1.112.1 libbonoboui-2.0 >= 1.112.1 libglade-2.0 >= 1.99.9 enchant >= 1.2.5"
532 PKG_CHECK_MODULES(GNOME_SPELL, $GNOME_SPELL_MODULES)
533 AC_SUBST(GNOME_SPELL_CFLAGS)
534 AC_SUBST(GNOME_SPELL_LIBS)