summaryrefslogtreecommitdiff
path: root/src/core/chat-commands.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-07-14 23:24:05 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-07-14 23:24:05 +0000
commitbcbb55dd1e0ecf828942dcc91d5661e9a44ab841 (patch)
tree50aa765cfb8208faf58042cf534b814ead24cdbd /src/core/chat-commands.c
parentc930f8f8e6b90a177fc08609d64587b426bd1311 (diff)
downloadirssi-bcbb55dd1e0ecf828942dcc91d5661e9a44ab841.zip
/FOREACH won't crash now if the command removes the item being accessed
(ie. /foreach server disconnect should work) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1625 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core/chat-commands.c')
-rw-r--r--src/core/chat-commands.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c
index 78a05a70..d49d00ee 100644
--- a/src/core/chat-commands.c
+++ b/src/core/chat-commands.c
@@ -320,20 +320,23 @@ 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;
+ GSList *tmp, *next;
- for (tmp = servers; tmp != NULL; tmp = tmp->next)
+ for (tmp = servers; tmp != NULL; tmp = next) {
+ next = tmp->next;
signal_emit("send command", 3, data, tmp->data, NULL);
+ }
}
/* SYNTAX: FOREACH CHANNEL <command> */
static void cmd_foreach_channel(const char *data)
{
- GSList *tmp;
+ GSList *tmp, *next;
- for (tmp = channels; tmp != NULL; tmp = tmp->next) {
+ for (tmp = channels; tmp != NULL; tmp = next) {
CHANNEL_REC *rec = tmp->data;
+ next = tmp->next;
signal_emit("send command", 3, data, rec->server, rec);
}
}
@@ -341,11 +344,12 @@ static void cmd_foreach_channel(const char *data)
/* SYNTAX: FOREACH QUERY <command> */
static void cmd_foreach_query(const char *data)
{
- GSList *tmp;
+ GSList *tmp, *next;
- for (tmp = queries; tmp != NULL; tmp = tmp->next) {
+ for (tmp = queries; tmp != NULL; tmp = next) {
QUERY_REC *rec = tmp->data;
+ next = tmp->next;
signal_emit("send command", 3, data, rec->server, rec);
}
}