summaryrefslogtreecommitdiff
path: root/src/core/chat-commands.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-07-15 13:49:57 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-07-15 13:49:57 +0000
commitde5348a084d347ab4d57364700ddf5ca6749c3ea (patch)
tree91042f28d36564f9e180cd00d7a145360740f105 /src/core/chat-commands.c
parent7f9959274ce9cf009ccd3c6d444f1f9f6172ac03 (diff)
downloadirssi-de5348a084d347ab4d57364700ddf5ca6749c3ea.zip
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
Diffstat (limited to 'src/core/chat-commands.c')
-rw-r--r--src/core/chat-commands.c27
1 files changed, 15 insertions, 12 deletions
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 <command> */
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 <command> */
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 <command> */
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);
}
}