mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
Strip the surrounding whitespace.
This commit is contained in:
parent
7307b48bd6
commit
6f795f020d
@ -386,7 +386,7 @@ gboolean settings_set_choice(const char *key, const char *value)
|
|||||||
SETTINGS_REC *rec;
|
SETTINGS_REC *rec;
|
||||||
|
|
||||||
rec = settings_get_record(key);
|
rec = settings_get_record(key);
|
||||||
/* XXX: The leading/trailing whitespace makes the test fail */
|
|
||||||
if (rec != NULL && strarray_find(rec->choices, value) < 0) {
|
if (rec != NULL && strarray_find(rec->choices, value) < 0) {
|
||||||
char *msg = g_strjoinv(",", rec->choices);
|
char *msg = g_strjoinv(",", rec->choices);
|
||||||
g_warning("Invalid value for '%s', must be one of: %s", key, msg);
|
g_warning("Invalid value for '%s', must be one of: %s", key, msg);
|
||||||
|
@ -67,6 +67,7 @@ static void set_print_pattern(const char *pattern)
|
|||||||
static void set_boolean(const char *key, const char *value)
|
static void set_boolean(const char *key, const char *value)
|
||||||
{
|
{
|
||||||
char *stripped_value;
|
char *stripped_value;
|
||||||
|
|
||||||
stripped_value = g_strdup(value);
|
stripped_value = g_strdup(value);
|
||||||
g_strstrip(stripped_value);
|
g_strstrip(stripped_value);
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ static void set_boolean(const char *key, const char *value)
|
|||||||
else
|
else
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_NOT_TOGGLE);
|
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)
|
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);
|
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] [<key> [<value>]] */
|
/* SYNTAX: SET [-clear | -default] [<key> [<value>]] */
|
||||||
static void cmd_set(char *data)
|
static void cmd_set(char *data)
|
||||||
{
|
{
|
||||||
@ -143,9 +154,10 @@ static void cmd_set(char *data)
|
|||||||
set_int(key, value);
|
set_int(key, value);
|
||||||
break;
|
break;
|
||||||
case SETTING_TYPE_CHOICE:
|
case SETTING_TYPE_CHOICE:
|
||||||
settings_set_choice(key, clear ? "" :
|
if (clear || set_default)
|
||||||
set_default ? rec->choices[rec->default_value.v_int] :
|
settings_set_choice(key, rec->choices[rec->default_value.v_int]);
|
||||||
value);
|
else
|
||||||
|
set_choice(key, value);
|
||||||
break;
|
break;
|
||||||
case SETTING_TYPE_STRING:
|
case SETTING_TYPE_STRING:
|
||||||
settings_set_str(key, clear ? "" :
|
settings_set_str(key, clear ? "" :
|
||||||
|
Loading…
Reference in New Issue
Block a user