From de5348a084d347ab4d57364700ddf5ca6749c3ea Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 15 Jul 2001 13:49:57 +0000 Subject: Another /FOREACH update - it only goes through the current servers/channels/queries, if the command creates new ones it skips them (ie. /FOREACH CHANNEL /CYCLE works now). git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1628 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/chat-commands.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c index d49d00ee..2303a701 100644 --- a/src/core/chat-commands.c +++ b/src/core/chat-commands.c @@ -320,37 +320,40 @@ static void cmd_foreach(const char *data, SERVER_REC *server, /* SYNTAX: FOREACH SERVER */ static void cmd_foreach_server(const char *data, SERVER_REC *server) { - GSList *tmp, *next; + GSList *list; - for (tmp = servers; tmp != NULL; tmp = next) { - next = tmp->next; - signal_emit("send command", 3, data, tmp->data, NULL); + list = g_slist_copy(servers); + while (list != NULL) { + signal_emit("send command", 3, data, list->data, NULL); + list = g_slist_remove(list, list->data); } } /* SYNTAX: FOREACH CHANNEL */ static void cmd_foreach_channel(const char *data) { - GSList *tmp, *next; + GSList *list; - for (tmp = channels; tmp != NULL; tmp = next) { - CHANNEL_REC *rec = tmp->data; + list = g_slist_copy(channels); + while (list != NULL) { + CHANNEL_REC *rec = list->data; - next = tmp->next; signal_emit("send command", 3, data, rec->server, rec); + list = g_slist_remove(list, list->data); } } /* SYNTAX: FOREACH QUERY */ static void cmd_foreach_query(const char *data) { - GSList *tmp, *next; + GSList *list; - for (tmp = queries; tmp != NULL; tmp = next) { - QUERY_REC *rec = tmp->data; + list = g_slist_copy(channels); + while (list != NULL) { + QUERY_REC *rec = list->data; - next = tmp->next; signal_emit("send command", 3, data, rec->server, rec); + list = g_slist_remove(list, list->data); } } -- cgit v1.2.3