From ac61d089765385a9f498d229f53b8e65d832081d Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 9 May 2002 03:01:40 +0000 Subject: fixed /WHO handling git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2762 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/proxy/listen.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/irc/proxy/listen.c b/src/irc/proxy/listen.c index 203551fc..5531720c 100644 --- a/src/irc/proxy/listen.c +++ b/src/irc/proxy/listen.c @@ -74,26 +74,32 @@ static void proxy_redirect_event(CLIENT_REC *client, const char *command, static void grab_who(CLIENT_REC *client, const char *channel) { - char *chlist, *chanevent; + GString *arg; char **list, **tmp; + int count; /* /WHO a,b,c may respond with either one "a,b,c End of WHO" message or three different "a End of WHO", "b End of WHO", .. messages */ - chlist = g_strdup(channel); list = g_strsplit(channel, ",", -1); - for (tmp = list; *tmp != NULL; tmp++) { + arg = g_string_new(channel); + + for (tmp = list, count = 0; *tmp != NULL; tmp++, count++) { if (strcmp(*tmp, "0") == 0) { /* /who 0 displays everyone */ **tmp = '*'; } - chanevent = g_strdup_printf("%s %s", chlist, *tmp); - proxy_redirect_event(client, "who", 1, chanevent, -1); - g_free(chanevent); + g_string_append_c(arg, ' '); + g_string_append(arg, *tmp); } + + proxy_redirect_event(client, "who", + client->server->one_endofwho ? 1 : count, + arg->str, -1); + g_strfreev(list); - g_free(chlist); + g_string_free(arg, TRUE); } static void handle_client_connect_cmd(CLIENT_REC *client, -- cgit v1.2.3