gtkhtml r8826 - trunk/components/editor
- From: mbarnes svn gnome org
- To: svn-commits-list gnome org
- Subject: gtkhtml r8826 - trunk/components/editor
- Date: Thu, 17 Apr 2008 17:18:59 +0100 (BST)
Author: mbarnes
Date: Thu Apr 17 17:18:59 2008
New Revision: 8826
URL: http://svn.gnome.org/viewvc/gtkhtml?rev=8826&view=rev
Log:
2008-04-17 Matthew Barnes <mbarnes redhat com>
** Fixes bug #528401
* components/editor/gtkhtml-spell-language.c (spell_language_lookup):
Split gtkhtml_spell_language_lookup() into a public and private
function to eliminate the chance of any more infinite loops. Now
spell_language_pick_default() calls the private function, but the
private function does not call spell_language_pick_default() as a
fallback.
Modified:
trunk/components/editor/ChangeLog
trunk/components/editor/gtkhtml-spell-language.c
Modified: trunk/components/editor/gtkhtml-spell-language.c
==============================================================================
--- trunk/components/editor/gtkhtml-spell-language.c (original)
+++ trunk/components/editor/gtkhtml-spell-language.c Thu Apr 17 17:18:59 2008
@@ -225,6 +225,31 @@
/* do nothing */
}
+static const GtkhtmlSpellLanguage *
+spell_language_lookup (const gchar *language_code)
+{
+ const GtkhtmlSpellLanguage *closest_match = NULL;
+ const GList *available_languages;
+
+ available_languages = gtkhtml_spell_language_get_available ();
+
+ while (available_languages != NULL && language_code != NULL) {
+ GtkhtmlSpellLanguage *language = available_languages->data;
+ const gchar *code = language->code;
+ gsize length = strlen (code);
+
+ if (g_ascii_strcasecmp (language_code, code) == 0)
+ return language;
+
+ if (g_ascii_strncasecmp (language_code, code, length) == 0)
+ closest_match = language;
+
+ available_languages = g_list_next (available_languages);
+ }
+
+ return closest_match;
+}
+
static gboolean
spell_language_traverse_cb (const gchar *code,
const gchar *name,
@@ -327,10 +352,10 @@
available_languages = gtkhtml_spell_language_get_available ();
for (ii = 0; language == NULL && language_names[ii] != NULL; ii++)
- language = gtkhtml_spell_language_lookup (language_names[ii]);
+ language = spell_language_lookup (language_names[ii]);
if (language == NULL)
- language = gtkhtml_spell_language_lookup ("en_US");
+ language = spell_language_lookup ("en_US");
if (language == NULL && available_languages != NULL)
language = available_languages->data;
@@ -341,33 +366,14 @@
const GtkhtmlSpellLanguage *
gtkhtml_spell_language_lookup (const gchar *language_code)
{
- const GtkhtmlSpellLanguage *closest_match = NULL;
- const GList *available_languages;
-
- available_languages = gtkhtml_spell_language_get_available ();
-
- /* No dictionaries available? */
- if (available_languages == NULL)
- return NULL;
-
- while (available_languages != NULL && language_code != NULL) {
- GtkhtmlSpellLanguage *language = available_languages->data;
- const gchar *code = language->code;
- gsize length = strlen (code);
-
- if (g_ascii_strcasecmp (language_code, code) == 0)
- return language;
+ const GtkhtmlSpellLanguage *language = NULL;
- if (g_ascii_strncasecmp (language_code, code, length) == 0)
- closest_match = language;
+ language = spell_language_lookup (language_code);
- available_languages = g_list_next (available_languages);
- }
-
- if (closest_match == NULL)
- closest_match = spell_language_pick_default ();
+ if (language == NULL)
+ language = spell_language_pick_default ();
- return closest_match;
+ return language;
}
const gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]