mirror of
https://github.com/weechat/weechat.git
synced 2026-06-24 20:06:38 +02:00
Return an error when trying to set boolean option with invalid value
This commit is contained in:
+16
-19
@@ -1064,36 +1064,33 @@ config_file_option_set (struct t_config_option *option, const char *value,
|
||||
switch (option->type)
|
||||
{
|
||||
case CONFIG_OPTION_TYPE_BOOLEAN:
|
||||
if (!option->value)
|
||||
if (config_file_string_boolean_is_valid (value))
|
||||
{
|
||||
option->value = malloc (sizeof (int));
|
||||
if (option->value)
|
||||
if (!option->value)
|
||||
{
|
||||
if (string_strcasecmp (value, "toggle") == 0)
|
||||
CONFIG_BOOLEAN(option) = CONFIG_BOOLEAN_TRUE;
|
||||
else
|
||||
option->value = malloc (sizeof (int));
|
||||
if (option->value)
|
||||
{
|
||||
if (config_file_string_boolean_is_valid (value))
|
||||
if (string_strcasecmp (value, "toggle") == 0)
|
||||
CONFIG_BOOLEAN(option) = CONFIG_BOOLEAN_TRUE;
|
||||
else
|
||||
{
|
||||
value_int = config_file_string_to_boolean (value);
|
||||
CONFIG_BOOLEAN(option) = value_int;
|
||||
}
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
|
||||
}
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string_strcasecmp (value, "toggle") == 0)
|
||||
{
|
||||
CONFIG_BOOLEAN(option) =
|
||||
(CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ?
|
||||
CONFIG_BOOLEAN_FALSE : CONFIG_BOOLEAN_TRUE;
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (config_file_string_boolean_is_valid (value))
|
||||
if (string_strcasecmp (value, "toggle") == 0)
|
||||
{
|
||||
CONFIG_BOOLEAN(option) =
|
||||
(CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ?
|
||||
CONFIG_BOOLEAN_FALSE : CONFIG_BOOLEAN_TRUE;
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
|
||||
}
|
||||
else
|
||||
{
|
||||
value_int = config_file_string_to_boolean (value);
|
||||
if (value_int == CONFIG_BOOLEAN(option))
|
||||
|
||||
Reference in New Issue
Block a user