mirror of
https://github.com/weechat/weechat.git
synced 2026-07-02 15:53:12 +02:00
irc: fix warning on creation of irc.msgbuffer option when the server name contains upper case letters (closes #2281)
Now the following command is OK without warning: /set irc.msgbuffer.TEST.notice current And the following command returns an error instead of a warning (that means the option is NOT created): /set irc.msgbuffer.TEST.NOTICE current
This commit is contained in:
@@ -1580,7 +1580,7 @@ irc_config_msgbuffer_create_option_cb (const void *pointer, void *data,
|
||||
const char *option_name, const char *value)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
char *name_lower;
|
||||
char *pos, *name_lower;
|
||||
int rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -1607,29 +1607,37 @@ irc_config_msgbuffer_create_option_cb (const void *pointer, void *data,
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
name_lower = weechat_string_tolower (option_name);
|
||||
if (name_lower && (strcmp (option_name, name_lower) != 0))
|
||||
pos = strrchr (option_name, '.');
|
||||
if (pos)
|
||||
{
|
||||
weechat_printf (
|
||||
NULL,
|
||||
_("%s%s: warning: the command name \"%s\" must be "
|
||||
"lower case, the option \"irc.msgbuffer.%s\" will "
|
||||
"not work"),
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
option_name, option_name);
|
||||
pos++;
|
||||
name_lower = weechat_string_tolower (pos);
|
||||
if (name_lower && (strcmp (pos, name_lower) == 0))
|
||||
{
|
||||
ptr_option = weechat_config_new_option (
|
||||
config_file, section,
|
||||
option_name, "enum",
|
||||
_("buffer used to display message received from IRC "
|
||||
"server"),
|
||||
"weechat|server|current|private", 0, 0, value, value, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
rc = (ptr_option) ?
|
||||
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE :
|
||||
WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (
|
||||
NULL,
|
||||
_("%s%s: error: invalid option \"%s.%s\", the command "
|
||||
"name or alias \"%s\" must be lower case"),
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
"irc.msgbuffer", option_name, pos);
|
||||
free (name_lower);
|
||||
return rc;
|
||||
}
|
||||
free (name_lower);
|
||||
}
|
||||
free (name_lower);
|
||||
|
||||
ptr_option = weechat_config_new_option (
|
||||
config_file, section,
|
||||
option_name, "enum",
|
||||
_("buffer used to display message received from IRC "
|
||||
"server"),
|
||||
"weechat|server|current|private", 0, 0, value, value, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
rc = (ptr_option) ?
|
||||
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE :
|
||||
WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
else
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
@@ -1640,8 +1648,9 @@ irc_config_msgbuffer_create_option_cb (const void *pointer, void *data,
|
||||
{
|
||||
weechat_printf (
|
||||
NULL,
|
||||
_("%s%s: error creating \"%s\" => \"%s\""),
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME, option_name, value);
|
||||
_("%s%s: error creating \"%s.%s\" => \"%s\""),
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
"irc.msgbuffer", option_name, value);
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
Reference in New Issue
Block a user