]> jfr.im git - irc/hexchat/hexchat.git/commitdiff
Support whitespace between language codes
authorAndreas Schärtl <redacted>
Thu, 1 Sep 2022 16:22:29 +0000 (18:22 +0200)
committerPatrick <redacted>
Tue, 20 Sep 2022 23:08:37 +0000 (18:08 -0500)
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

index 04ff0f8a913df7bdfb768e8c4fd78c715f55d003..a304278310acc7f062cc071856b27e052fb1e4f3 100644 (file)
@@ -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)