irc: set channel modes to NULL instead of "+" when no modes are remaining
parent
851d1fb00a
commit
e3ffe8c785
|
@ -162,17 +162,23 @@ irc_mode_channel_update (struct t_irc_server *server,
|
||||||
if (!channel->modes)
|
if (!channel->modes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
new_modes = NULL;
|
||||||
|
new_args = NULL;
|
||||||
|
str_modes = NULL;
|
||||||
argc = 0;
|
argc = 0;
|
||||||
argv = NULL;
|
argv = NULL;
|
||||||
|
|
||||||
pos_args = strchr (channel->modes, ' ');
|
pos_args = strchr (channel->modes, ' ');
|
||||||
if (pos_args)
|
if (pos_args)
|
||||||
{
|
{
|
||||||
str_modes = weechat_strndup (channel->modes, pos_args - channel->modes);
|
str_modes = weechat_strndup (channel->modes, pos_args - channel->modes);
|
||||||
if (!str_modes)
|
if (!str_modes)
|
||||||
return;
|
goto end;
|
||||||
pos_args++;
|
pos_args++;
|
||||||
while (pos_args[0] == ' ')
|
while (pos_args[0] == ' ')
|
||||||
|
{
|
||||||
pos_args++;
|
pos_args++;
|
||||||
|
}
|
||||||
argv = weechat_string_split (pos_args, " ", NULL,
|
argv = weechat_string_split (pos_args, " ", NULL,
|
||||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||||
|
@ -183,7 +189,7 @@ irc_mode_channel_update (struct t_irc_server *server,
|
||||||
{
|
{
|
||||||
str_modes = strdup (channel->modes);
|
str_modes = strdup (channel->modes);
|
||||||
if (!str_modes)
|
if (!str_modes)
|
||||||
return;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_modes = malloc (strlen (channel->modes) + 1 + 1);
|
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 */
|
/* add mode without argument at the beginning of modes */
|
||||||
pos = new_modes;
|
pos = new_modes;
|
||||||
while (pos[0] == '+')
|
while (pos[0] == '+')
|
||||||
|
{
|
||||||
pos++;
|
pos++;
|
||||||
|
}
|
||||||
memmove (pos + 1, pos, strlen (pos) + 1);
|
memmove (pos + 1, pos, strlen (pos) + 1);
|
||||||
pos[0] = chanmode;
|
pos[0] = chanmode;
|
||||||
}
|
}
|
||||||
|
@ -305,6 +313,7 @@ irc_mode_channel_update (struct t_irc_server *server,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
if (new_modes)
|
if (new_modes)
|
||||||
free (new_modes);
|
free (new_modes);
|
||||||
if (new_args)
|
if (new_args)
|
||||||
|
@ -313,6 +322,11 @@ irc_mode_channel_update (struct t_irc_server *server,
|
||||||
free (str_modes);
|
free (str_modes);
|
||||||
if (argv)
|
if (argv)
|
||||||
weechat_string_free_split (argv);
|
weechat_string_free_split (argv);
|
||||||
|
if (channel->modes && (strcmp (channel->modes, "+") == 0))
|
||||||
|
{
|
||||||
|
free (channel->modes);
|
||||||
|
channel->modes = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue