From bf9d9494db89e7de45653e4797e2977c6e185c13 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 12 Jun 2016 15:26:07 +0200 Subject: [PATCH 1/8] Add a CHOICE type to the settings system. This is useful to let the user choose an option between a finite set of valid alternatives. --- src/core/settings.c | 95 ++++++++++++++++++++++++++++---- src/core/settings.h | 14 ++++- src/fe-common/core/completion.c | 17 +++++- src/fe-common/core/fe-settings.c | 5 ++ 4 files changed, 113 insertions(+), 18 deletions(-) diff --git a/src/core/settings.c b/src/core/settings.c index 8e493124..9c2389bc 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -148,11 +148,34 @@ int settings_get_size(const char *key) return str == NULL ? 0 : bytes; } +int settings_get_choice(const char *key) +{ + SETTINGS_REC *rec; + CONFIG_NODE *node; + char *str; + int idx; + + rec = settings_get(key, SETTING_TYPE_CHOICE); + if (rec == NULL) return -1; + + node = iconfig_node_traverse("settings", FALSE); + node = node == NULL ? NULL : iconfig_node_section(node, rec->module, -1); + + str = node == NULL ? rec->default_value.v_string : + config_node_get_str(node, key, rec->default_value.v_string); + + idx = strarray_find(rec->choices, str); + return (idx < 0) ? rec->default_value.v_int : idx; +} + char *settings_get_print(SETTINGS_REC *rec) { char *value = NULL; switch(rec->type) { + case SETTING_TYPE_CHOICE: + value = g_strdup(rec->choices[settings_get_choice(rec->key)]); + break; case SETTING_TYPE_BOOLEAN: value = g_strdup(settings_get_bool(rec->key) ? "ON" : "OFF"); break; @@ -172,13 +195,31 @@ char *settings_get_print(SETTINGS_REC *rec) static void settings_add(const char *module, const char *section, const char *key, SettingType type, - const SettingValue *default_value) + const SettingValue *default_value, + const char *choices) { SETTINGS_REC *rec; + char **choices_vec = NULL; g_return_if_fail(key != NULL); g_return_if_fail(section != NULL); + if (type == SETTING_TYPE_CHOICE) { + if (choices == NULL) { + g_warning("Trying to add setting '%s' with no choices.", key); + return; + } + + choices_vec = g_strsplit(choices, ",", -1); + + /* validate the default value */ + if (default_value->v_int < 0 || default_value->v_int >= g_strv_length(choices_vec)) { + g_warning("Trying to add setting '%s' with an invalid default value.", key); + g_strfreev(choices_vec); + return; + } + } + rec = g_hash_table_lookup(settings, key); if (rec != NULL) { /* Already exists, make sure it's correct type */ @@ -197,6 +238,7 @@ static void settings_add(const char *module, const char *section, rec->type = type; rec->default_value = *default_value; + rec->choices = choices_vec; g_hash_table_insert(settings, rec->key, rec); } } @@ -208,7 +250,17 @@ void settings_add_str_module(const char *module, const char *section, memset(&default_value, 0, sizeof(default_value)); default_value.v_string = g_strdup(def); - settings_add(module, section, key, SETTING_TYPE_STRING, &default_value); + settings_add(module, section, key, SETTING_TYPE_STRING, &default_value, NULL); +} + +void settings_add_choice_module(const char *module, const char *section, + const char *key, int def, const char *choices) +{ + SettingValue default_value; + + memset(&default_value, 0, sizeof(default_value)); + default_value.v_int = def; + settings_add(module, section, key, SETTING_TYPE_CHOICE, &default_value, choices); } void settings_add_int_module(const char *module, const char *section, @@ -218,7 +270,7 @@ void settings_add_int_module(const char *module, const char *section, memset(&default_value, 0, sizeof(default_value)); default_value.v_int = def; - settings_add(module, section, key, SETTING_TYPE_INT, &default_value); + settings_add(module, section, key, SETTING_TYPE_INT, &default_value, NULL); } void settings_add_bool_module(const char *module, const char *section, @@ -228,8 +280,7 @@ void settings_add_bool_module(const char *module, const char *section, memset(&default_value, 0, sizeof(default_value)); default_value.v_bool = def; - settings_add(module, section, key, SETTING_TYPE_BOOLEAN, - &default_value); + settings_add(module, section, key, SETTING_TYPE_BOOLEAN, &default_value, NULL); } void settings_add_time_module(const char *module, const char *section, @@ -239,7 +290,7 @@ void settings_add_time_module(const char *module, const char *section, memset(&default_value, 0, sizeof(default_value)); default_value.v_string = g_strdup(def); - settings_add(module, section, key, SETTING_TYPE_TIME, &default_value); + settings_add(module, section, key, SETTING_TYPE_TIME, &default_value, NULL); } void settings_add_level_module(const char *module, const char *section, @@ -249,7 +300,7 @@ void settings_add_level_module(const char *module, const char *section, memset(&default_value, 0, sizeof(default_value)); default_value.v_string = g_strdup(def); - settings_add(module, section, key, SETTING_TYPE_LEVEL, &default_value); + settings_add(module, section, key, SETTING_TYPE_LEVEL, &default_value, NULL); } void settings_add_size_module(const char *module, const char *section, @@ -259,14 +310,16 @@ void settings_add_size_module(const char *module, const char *section, memset(&default_value, 0, sizeof(default_value)); default_value.v_string = g_strdup(def); - settings_add(module, section, key, SETTING_TYPE_SIZE, &default_value); + settings_add(module, section, key, SETTING_TYPE_SIZE, &default_value, NULL); } static void settings_destroy(SETTINGS_REC *rec) { if (rec->type != SETTING_TYPE_INT && - rec->type != SETTING_TYPE_BOOLEAN) + rec->type != SETTING_TYPE_BOOLEAN && + rec->type != SETTING_TYPE_CHOICE) g_free(rec->default_value.v_string); + g_strfreev(rec->choices); g_free(rec->module); g_free(rec->section); g_free(rec->key); @@ -328,6 +381,24 @@ static CONFIG_NODE *settings_get_node(const char *key) return iconfig_node_section(node, rec->module, NODE_TYPE_BLOCK); } +gboolean settings_set_choice(const char *key, const char *value) +{ + SETTINGS_REC *rec; + + rec = settings_get_record(key); + /* XXX: The leading/trailing whitespace makes the test fail */ + if (rec != NULL && g_strv_contains((const char **)rec->choices, value) == FALSE) { + char *msg = g_strjoinv(",", rec->choices); + g_warning("Invalid value for '%s', must be one of: %s", key, msg); + g_free(msg); + + return FALSE; + } + + settings_set_str(key, value); + return TRUE; +} + void settings_set_str(const char *key, const char *value) { iconfig_node_set_str(settings_get_node(key), key, value); @@ -343,7 +414,7 @@ void settings_set_bool(const char *key, int value) iconfig_node_set_bool(settings_get_node(key), key, value); } -int settings_set_time(const char *key, const char *value) +gboolean settings_set_time(const char *key, const char *value) { int msecs; @@ -354,7 +425,7 @@ int settings_set_time(const char *key, const char *value) return TRUE; } -int settings_set_level(const char *key, const char *value) +gboolean settings_set_level(const char *key, const char *value) { int iserror; @@ -366,7 +437,7 @@ int settings_set_level(const char *key, const char *value) return TRUE; } -int settings_set_size(const char *key, const char *value) +gboolean settings_set_size(const char *key, const char *value) { int size; diff --git a/src/core/settings.h b/src/core/settings.h index 6f2cf129..d174f250 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -8,6 +8,7 @@ typedef enum { SETTING_TYPE_TIME, SETTING_TYPE_LEVEL, SETTING_TYPE_SIZE, + SETTING_TYPE_CHOICE, SETTING_TYPE_ANY } SettingType; @@ -26,6 +27,7 @@ typedef struct { SettingType type; SettingValue default_value; + char **choices; } SETTINGS_REC; /* macros for handling the default Irssi configuration */ @@ -58,6 +60,7 @@ int settings_get_bool(const char *key); int settings_get_time(const char *key); /* as milliseconds */ int settings_get_level(const char *key); int settings_get_size(const char *key); /* as bytes */ +int settings_get_choice(const char *key); char *settings_get_print(SETTINGS_REC *rec); /* Functions to add/remove settings */ @@ -73,6 +76,8 @@ void settings_add_level_module(const char *module, const char *section, const char *key, const char *def); void settings_add_size_module(const char *module, const char *section, const char *key, const char *def); +void settings_add_choice_module(const char *module, const char *section, + const char *key, int def, const char *choices); void settings_remove(const char *key); void settings_remove_module(const char *module); @@ -88,13 +93,16 @@ void settings_remove_module(const char *module); settings_add_level_module(MODULE_NAME, section, key, def) #define settings_add_size(section, key, def) \ settings_add_size_module(MODULE_NAME, section, key, def) +#define settings_add_choice(section, key, def, choices) \ + settings_add_choice_module(MODULE_NAME, section, key, def, choices) void settings_set_str(const char *key, const char *value); void settings_set_int(const char *key, int value); void settings_set_bool(const char *key, int value); -int settings_set_time(const char *key, const char *value); -int settings_set_level(const char *key, const char *value); -int settings_set_size(const char *key, const char *value); +gboolean settings_set_time(const char *key, const char *value); +gboolean settings_set_level(const char *key, const char *value); +gboolean settings_set_size(const char *key, const char *value); +gboolean settings_set_choice(const char *key, const char *value); /* Get the type (SETTING_TYPE_xxx) of `key' */ SettingType settings_get_type(const char *key); diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index 861054b5..0e9982d5 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -690,9 +690,20 @@ static void sig_complete_set(GList **list, WINDOW_REC *window, else if (*line != '\0' && *word == '\0') { SETTINGS_REC *rec = settings_get_record(line); if (rec != NULL) { - char *value = settings_get_print(rec); - if (value != NULL) - *list = g_list_append(*list, value); + /* show the whole list of valid options */ + if (rec->type == SETTING_TYPE_CHOICE) { + char **tmp = rec->choices; + + while (*tmp) + *list = g_list_append(*list, g_strdup(*tmp++)); + } + /* show the current option */ + else { + char *value = settings_get_print(rec); + + if (value != NULL) + *list = g_list_append(*list, value); + } } } diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c index b689cbf9..e25886ec 100644 --- a/src/fe-common/core/fe-settings.c +++ b/src/fe-common/core/fe-settings.c @@ -142,6 +142,11 @@ static void cmd_set(char *data) else set_int(key, value); break; + case SETTING_TYPE_CHOICE: + settings_set_choice(key, clear ? "" : + set_default ? rec->choices[rec->default_value.v_int] : + value); + break; case SETTING_TYPE_STRING: settings_set_str(key, clear ? "" : set_default ? rec->default_value.v_string : From 86c5e56ef41c70030e43d03b4c01e2df8188c30b Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 12 Jun 2016 16:26:18 +0200 Subject: [PATCH 2/8] Make rejoin_channels_mode of type CHOICE --- src/irc/core/irc-servers.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index 1df95f70..6f5803ed 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -623,39 +623,25 @@ char *irc_server_get_channels(IRC_SERVER_REC *server) GString *chans, *keys; char *ret; int use_keys; - char *rejoin_channels_mode; + int rejoin_channels_mode; g_return_val_if_fail(server != NULL, FALSE); - rejoin_channels_mode = g_strdup(settings_get_str("rejoin_channels_on_reconnect")); + rejoin_channels_mode = settings_get_choice("rejoin_channels_on_reconnect"); - if (rejoin_channels_mode == NULL || - (g_ascii_strcasecmp(rejoin_channels_mode, "on") != 0 && - g_ascii_strcasecmp(rejoin_channels_mode, "off") != 0 && - g_ascii_strcasecmp(rejoin_channels_mode, "auto") != 0)) { - g_warning("Invalid value for 'rejoin_channels_on_reconnect', valid values are 'on', 'off', 'auto', using 'on' as default value."); - g_free(rejoin_channels_mode); - rejoin_channels_mode = g_strdup("on"); - } + /* do we want to rejoin channels in the first place? */ + if(rejoin_channels_mode == 0) + return g_strdup(""); chans = g_string_new(NULL); keys = g_string_new(NULL); use_keys = FALSE; - /* do we want to rejoin channels in the first place? */ - if(g_ascii_strcasecmp(rejoin_channels_mode, "off") == 0) { - g_string_free(chans, TRUE); - g_string_free(keys, TRUE); - g_free(rejoin_channels_mode); - return g_strdup(""); - } - /* get currently joined channels */ for (tmp = server->channels; tmp != NULL; tmp = tmp->next) { CHANNEL_REC *channel = tmp->data; CHANNEL_SETUP_REC *setup = channel_setup_find(channel->name, channel->server->connrec->chatnet); - if ((setup != NULL && setup->autojoin && g_ascii_strcasecmp(rejoin_channels_mode, "auto") == 0) || - g_ascii_strcasecmp(rejoin_channels_mode, "on") == 0) { + if ((setup != NULL && setup->autojoin && rejoin_channels_mode == 2) || rejoin_channels_mode == 1) { g_string_append_printf(chans, "%s,", channel->name); g_string_append_printf(keys, "%s,", channel->key == NULL ? "x" : channel->key); if (channel->key != NULL) @@ -668,8 +654,7 @@ char *irc_server_get_channels(IRC_SERVER_REC *server) REJOIN_REC *rec = tmp->data; CHANNEL_SETUP_REC *setup = channel_setup_find(rec->channel, server->tag); - if ((setup != NULL && setup->autojoin && g_ascii_strcasecmp(rejoin_channels_mode, "auto") == 0) || - g_ascii_strcasecmp(rejoin_channels_mode, "on") == 0) { + if ((setup != NULL && setup->autojoin && rejoin_channels_mode == 2) || rejoin_channels_mode == 1) { g_string_append_printf(chans, "%s,", rec->channel); g_string_append_printf(keys, "%s,", rec->key == NULL ? "x" : rec->key); @@ -687,7 +672,6 @@ char *irc_server_get_channels(IRC_SERVER_REC *server) ret = chans->str; g_string_free(chans, FALSE); g_string_free(keys, TRUE); - g_free(rejoin_channels_mode); return ret; } @@ -1033,7 +1017,7 @@ void irc_server_init_isupport(IRC_SERVER_REC *server) void irc_servers_init(void) { - settings_add_str("servers", "rejoin_channels_on_reconnect", "on"); + settings_add_choice("servers", "rejoin_channels_on_reconnect", 1, "off,on,auto"); settings_add_str("misc", "usermode", DEFAULT_USER_MODE); settings_add_str("misc", "split_line_start", ""); settings_add_str("misc", "split_line_end", ""); From 31f12c10df52e44e7cef0245fc55ae38159ce9e3 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 12 Jun 2016 16:38:34 +0200 Subject: [PATCH 3/8] Use strarray_find instead of g_strv_contains --- src/core/settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/settings.c b/src/core/settings.c index 9c2389bc..9871ad30 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -387,7 +387,7 @@ gboolean settings_set_choice(const char *key, const char *value) rec = settings_get_record(key); /* XXX: The leading/trailing whitespace makes the test fail */ - if (rec != NULL && g_strv_contains((const char **)rec->choices, value) == FALSE) { + if (rec != NULL && strarray_find(rec->choices, value) < 0) { char *msg = g_strjoinv(",", rec->choices); g_warning("Invalid value for '%s', must be one of: %s", key, msg); g_free(msg); From 7307b48bd6928207ded9e186af3f3b97625f00bb Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 12 Jun 2016 22:58:35 +0200 Subject: [PATCH 4/8] Sort the completion results Make sure the current option is shown first. --- src/fe-common/core/completion.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index 0e9982d5..c87fdb50 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -690,19 +690,20 @@ static void sig_complete_set(GList **list, WINDOW_REC *window, else if (*line != '\0' && *word == '\0') { SETTINGS_REC *rec = settings_get_record(line); if (rec != NULL) { + char *value = settings_get_print(rec); + + /* show the current option first */ + if (value != NULL) + *list = g_list_append(*list, value); + /* show the whole list of valid options */ if (rec->type == SETTING_TYPE_CHOICE) { - char **tmp = rec->choices; + char **tmp; - while (*tmp) - *list = g_list_append(*list, g_strdup(*tmp++)); - } - /* show the current option */ - else { - char *value = settings_get_print(rec); - - if (value != NULL) - *list = g_list_append(*list, value); + for (tmp = rec->choices; *tmp; tmp++) { + if (g_ascii_strcasecmp(*tmp, value) != 0) + *list = g_list_append(*list, g_strdup(*tmp)); + } } } } From 6f795f020d5c374023dc9ca647b267aef0a76950 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 12 Jun 2016 23:39:22 +0200 Subject: [PATCH 5/8] Strip the surrounding whitespace. --- src/core/settings.c | 2 +- src/fe-common/core/fe-settings.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/core/settings.c b/src/core/settings.c index 9871ad30..8509a9ff 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -386,7 +386,7 @@ gboolean settings_set_choice(const char *key, const char *value) SETTINGS_REC *rec; rec = settings_get_record(key); - /* XXX: The leading/trailing whitespace makes the test fail */ + if (rec != NULL && strarray_find(rec->choices, value) < 0) { char *msg = g_strjoinv(",", rec->choices); g_warning("Invalid value for '%s', must be one of: %s", key, msg); diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c index e25886ec..ca1f871d 100644 --- a/src/fe-common/core/fe-settings.c +++ b/src/fe-common/core/fe-settings.c @@ -67,6 +67,7 @@ static void set_print_pattern(const char *pattern) static void set_boolean(const char *key, const char *value) { char *stripped_value; + stripped_value = g_strdup(value); g_strstrip(stripped_value); @@ -79,7 +80,7 @@ static void set_boolean(const char *key, const char *value) else printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_NOT_TOGGLE); - g_free(stripped_value); + g_free(stripped_value); } static void set_int(const char *key, const char *value) @@ -99,6 +100,16 @@ static void set_int(const char *key, const char *value) settings_set_int(key, (int)longval); } +static void set_choice(const char *key, const char *value) +{ + char *stripped_value; + + stripped_value = g_strdup(value); + g_strstrip(stripped_value); + settings_set_choice(key, stripped_value); + g_free(stripped_value); +} + /* SYNTAX: SET [-clear | -default] [ []] */ static void cmd_set(char *data) { @@ -143,9 +154,10 @@ static void cmd_set(char *data) set_int(key, value); break; case SETTING_TYPE_CHOICE: - settings_set_choice(key, clear ? "" : - set_default ? rec->choices[rec->default_value.v_int] : - value); + if (clear || set_default) + settings_set_choice(key, rec->choices[rec->default_value.v_int]); + else + set_choice(key, value); break; case SETTING_TYPE_STRING: settings_set_str(key, clear ? "" : From 9a30ab53df226acb4586a2f214f3994a7b8b32ea Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 13 Jun 2016 14:03:00 +0200 Subject: [PATCH 6/8] Move the validation of the CHOICE setting value Also, use a FORMAT to show the error message. --- src/core/settings.c | 8 ++------ src/fe-common/core/fe-settings.c | 10 +++++++++- src/fe-common/core/module-formats.c | 1 + src/fe-common/core/module-formats.h | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/core/settings.c b/src/core/settings.c index 8509a9ff..0716103a 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -387,15 +387,11 @@ gboolean settings_set_choice(const char *key, const char *value) rec = settings_get_record(key); - if (rec != NULL && strarray_find(rec->choices, value) < 0) { - char *msg = g_strjoinv(",", rec->choices); - g_warning("Invalid value for '%s', must be one of: %s", key, msg); - g_free(msg); - + if (rec != NULL && strarray_find(rec->choices, value) < 0) return FALSE; - } settings_set_str(key, value); + return TRUE; } diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c index ca1f871d..6f69d930 100644 --- a/src/fe-common/core/fe-settings.c +++ b/src/fe-common/core/fe-settings.c @@ -106,7 +106,15 @@ static void set_choice(const char *key, const char *value) stripped_value = g_strdup(value); g_strstrip(stripped_value); - settings_set_choice(key, stripped_value); + + if (settings_set_choice(key, stripped_value) == FALSE) { + SETTINGS_REC *rec = settings_get_record(key); + char *msg = g_strjoinv(",", rec->choices); + + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_INVALID_CHOICE, msg); + g_free(msg); + } + g_free(stripped_value); } diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index b897b0c6..5c07f14c 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -221,6 +221,7 @@ FORMAT_REC fecommon_core_formats[] = { { "invalid_level", "Invalid message level", 0 }, { "invalid_size", "Invalid size", 0 }, { "invalid_charset", "Invalid charset: $0", 1, { 0 } }, + { "invalid_choice", "Invalid choice, must be one of $0", 1, { 0 } }, { "eval_max_recurse", "/eval hit maximum recursion limit", 0 }, { "program_not_found", "Could not find file or file is not executable", 0 }, { "no_server_defined", "No servers defined for this network, see /help server for how to add one", 0 }, diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h index de1e13f2..2b45ff6b 100644 --- a/src/fe-common/core/module-formats.h +++ b/src/fe-common/core/module-formats.h @@ -190,6 +190,7 @@ enum { TXT_INVALID_LEVEL, TXT_INVALID_SIZE, TXT_INVALID_CHARSET, + TXT_INVALID_CHOICE, TXT_EVAL_MAX_RECURSE, TXT_PROGRAM_NOT_FOUND, TXT_NO_SERVER_DEFINED, From 439e21f12746519d36e205a3ac053c882d67c024 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 13 Jun 2016 14:07:04 +0200 Subject: [PATCH 7/8] Use ; as separator instead of , --- src/core/settings.c | 2 +- src/irc/core/irc-servers.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/settings.c b/src/core/settings.c index 0716103a..e6b5d16f 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -210,7 +210,7 @@ static void settings_add(const char *module, const char *section, return; } - choices_vec = g_strsplit(choices, ",", -1); + choices_vec = g_strsplit(choices, ";", -1); /* validate the default value */ if (default_value->v_int < 0 || default_value->v_int >= g_strv_length(choices_vec)) { diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index 6f5803ed..c8ba0a48 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -1017,7 +1017,7 @@ void irc_server_init_isupport(IRC_SERVER_REC *server) void irc_servers_init(void) { - settings_add_choice("servers", "rejoin_channels_on_reconnect", 1, "off,on,auto"); + settings_add_choice("servers", "rejoin_channels_on_reconnect", 1, "off;on;auto"); settings_add_str("misc", "usermode", DEFAULT_USER_MODE); settings_add_str("misc", "split_line_start", ""); settings_add_str("misc", "split_line_end", ""); From 5c8423a08cd9ffbe3363f3b0e5722e4a32157914 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 13 Jun 2016 20:27:37 +0200 Subject: [PATCH 8/8] Add a space after the comma when listing the options. --- src/fe-common/core/fe-settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c index 6f69d930..abbd45a8 100644 --- a/src/fe-common/core/fe-settings.c +++ b/src/fe-common/core/fe-settings.c @@ -109,7 +109,7 @@ static void set_choice(const char *key, const char *value) if (settings_set_choice(key, stripped_value) == FALSE) { SETTINGS_REC *rec = settings_get_record(key); - char *msg = g_strjoinv(",", rec->choices); + char *msg = g_strjoinv(", ", rec->choices); printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_INVALID_CHOICE, msg); g_free(msg);