diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-11-24 22:03:55 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-11-24 22:03:55 +0100 |
commit | 8b9abab711ccdccceafcbea351b8bef0d23b8ecd (patch) | |
tree | 7c7971c884949f3ca705a22ef848f747e7d6d58c /src/core | |
parent | 082e0251e25060f1b9977412fded5f1dcbe54189 (diff) | |
download | weechat-8b9abab711ccdccceafcbea351b8bef0d23b8ecd.zip |
Fix problem with /set on boolean options with value "toggle"
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-config-file.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index 9658aa640..67f99c94b 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -1064,33 +1064,44 @@ config_file_option_set (struct t_config_option *option, const char *value, switch (option->type) { case CONFIG_OPTION_TYPE_BOOLEAN: - if (config_file_string_boolean_is_valid (value)) + if (!option->value) { - if (!option->value) + option->value = malloc (sizeof (int)); + if (option->value) { - option->value = malloc (sizeof (int)); - if (option->value) + if (string_strcasecmp (value, "toggle") == 0) { - if (string_strcasecmp (value, "toggle") == 0) - CONFIG_BOOLEAN(option) = CONFIG_BOOLEAN_TRUE; - else + CONFIG_BOOLEAN(option) = CONFIG_BOOLEAN_TRUE; + rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED; + } + else + { + if (config_file_string_boolean_is_valid (value)) { value_int = config_file_string_to_boolean (value); CONFIG_BOOLEAN(option) = value_int; + rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED; + } + else + { + free (option->value); + option->value = NULL; } - 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 (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)) { value_int = config_file_string_to_boolean (value); if (value_int == CONFIG_BOOLEAN(option)) |