summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-11-19 14:56:25 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-11-19 14:56:25 +0100
commit5b236c56581771663f1279ad66ec44584d3d7bc4 (patch)
tree0ea77eb93470035a8ed93cc602e4cb9f606433b2 /src/core
parentaec97d2082113d2227460cc9236130773332dcc1 (diff)
downloadweechat-5b236c56581771663f1279ad66ec44584d3d7bc4.zip
Return an error when trying to set boolean option with invalid value
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-config-file.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c
index 4d01748b7..9658aa640 100644
--- a/src/core/wee-config-file.c
+++ b/src/core/wee-config-file.c
@@ -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))