summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schärtl <andreas@schaertl.me>2022-09-01 18:22:29 +0200
committerPatrick <tingping@tingping.se>2022-09-20 18:08:37 -0500
commitbd4290a1a949e444eb1633644f88976e2025b2d8 (patch)
tree410a120531cc1c77323744bb2819eb8ba121cab6 /src
parent46c9df18639ff0ee343d4c8ad48e845795b6ac1c (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/fe-gtk/sexy-spell-entry.c12
1 files changed, 6 insertions, 6 deletions
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)