summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-03-14 18:12:29 +0100
committerSébastien Helleu <flashcode@flashtux.org>2020-03-15 07:19:16 +0100
commite3ffe8c785ede4bf8638d6f95307a8f431790d97 (patch)
tree9b8348f85c506e40e609a05169cbb4564d2e561e /src
parent851d1fb00ad93cc3324c85ec6f3dd696d3f8f55a (diff)
downloadweechat-e3ffe8c785ede4bf8638d6f95307a8f431790d97.zip
irc: set channel modes to NULL instead of "+" when no modes are remaining
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-mode.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c
index e79f0deb7..84abfe324 100644
--- a/src/plugins/irc/irc-mode.c
+++ b/src/plugins/irc/irc-mode.c
@@ -162,17 +162,23 @@ irc_mode_channel_update (struct t_irc_server *server,
if (!channel->modes)
return;
+ new_modes = NULL;
+ new_args = NULL;
+ str_modes = NULL;
argc = 0;
argv = NULL;
+
pos_args = strchr (channel->modes, ' ');
if (pos_args)
{
str_modes = weechat_strndup (channel->modes, pos_args - channel->modes);
if (!str_modes)
- return;
+ goto end;
pos_args++;
while (pos_args[0] == ' ')
+ {
pos_args++;
+ }
argv = weechat_string_split (pos_args, " ", NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
@@ -183,7 +189,7 @@ irc_mode_channel_update (struct t_irc_server *server,
{
str_modes = strdup (channel->modes);
if (!str_modes)
- return;
+ goto end;
}
new_modes = malloc (strlen (channel->modes) + 1 + 1);
@@ -279,7 +285,9 @@ irc_mode_channel_update (struct t_irc_server *server,
/* add mode without argument at the beginning of modes */
pos = new_modes;
while (pos[0] == '+')
+ {
pos++;
+ }
memmove (pos + 1, pos, strlen (pos) + 1);
pos[0] = chanmode;
}
@@ -305,6 +313,7 @@ irc_mode_channel_update (struct t_irc_server *server,
}
}
+end:
if (new_modes)
free (new_modes);
if (new_args)
@@ -313,6 +322,11 @@ irc_mode_channel_update (struct t_irc_server *server,
free (str_modes);
if (argv)
weechat_string_free_split (argv);
+ if (channel->modes && (strcmp (channel->modes, "+") == 0))
+ {
+ free (channel->modes);
+ channel->modes = NULL;
+ }
}
/*