From bd4290a1a949e444eb1633644f88976e2025b2d8 Mon Sep 17 00:00:00 2001 From: Andreas Schärtl Date: Thu, 1 Sep 2022 18:22:29 +0200 Subject: Support whitespace between language codes So far, when configuring multiple spell check languages, Hexchat requires the user to separate multiple entries with commas and only commas. This patch allows users to also enter whitespace, e.g. de_DE, en_US as is common in many applications. --- src/fe-gtk/sexy-spell-entry.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/fe-gtk/sexy-spell-entry.c') diff --git a/src/fe-gtk/sexy-spell-entry.c b/src/fe-gtk/sexy-spell-entry.c index 04ff0f8a..a3042783 100644 --- a/src/fe-gtk/sexy-spell-entry.c +++ b/src/fe-gtk/sexy-spell-entry.c @@ -1255,7 +1255,7 @@ void sexy_spell_entry_activate_default_languages(SexySpellEntry *entry) { GSList *enchant_langs; - char *lang, *langs; + char *lang, **i, **langs; if (!have_enchant) return; @@ -1265,21 +1265,21 @@ sexy_spell_entry_activate_default_languages(SexySpellEntry *entry) enchant_langs = sexy_spell_entry_get_languages(entry); - langs = g_strdup (prefs.hex_text_spell_langs); + langs = g_strsplit_set (prefs.hex_text_spell_langs, ", \t", 0); - lang = strtok (langs, ","); - while (lang != NULL) + for (i = langs; *i; i++) { + lang = *i; + if (enchant_has_lang (lang, enchant_langs)) { sexy_spell_entry_activate_language_internal (entry, lang, NULL); } - lang = strtok (NULL, ","); } g_slist_foreach(enchant_langs, (GFunc) g_free, NULL); g_slist_free(enchant_langs); - g_free (langs); + g_strfreev (langs); /* If we don't have any languages activated, use "en" */ if (entry->priv->dict_list == NULL) -- cgit 1.4.1