[PATCH 64/65] Merge 2015-2016 patches in

From: FRIGN <dev_AT_frign.de>
Date: Mon, 9 May 2016 16:59:23 +0200

---
 ii.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/ii.c b/ii.c
index bb2372f..b290292 100644
--- a/ii.c
+++ b/ii.c
_AT_@ -42,6 +42,7 @@ static time_t   last_response = 0;
 static Channel *channels = NULL;
 static Channel *channelmaster = NULL;
 static char     nick[32];          /* might change while running */
+static char     _nick[32];         /* might change while running */
 static char     ircpath[PATH_MAX]; /* irc dir (-i) */
 static char     msg[IRC_MSG_MAX];  /* message buf used for communication */
 
_AT_@ -447,7 +448,7 @@ proc_channels_input(int ircfd, Channel *c, char *buf)
 			break;
 		case 'n': /* change nick */
 			if(buflen >= 3) {
-				strlcpy(nick, &buf[3], sizeof(nick));
+				strlcpy(_nick, &buf[3], sizeof(nick));
 				snprintf(msg, sizeof(msg), "NICK %s\r\n", &buf[3]);
 			}
 			break;
_AT_@ -545,12 +546,12 @@ proc_server_cmd(int fd, char *buf)
 	} else if(!strcmp("ERROR", argv[TOK_CMD]))
 		snprintf(msg, sizeof(msg), "-!- error %s",
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "unknown");
-	else if(!strcmp("JOIN", argv[TOK_CMD])) {
+	else if(!strcmp("JOIN", argv[TOK_CMD]) && (argv[TOK_CHAN] || argv[TOK_TEXT])) {
 		if (argv[TOK_TEXT] != NULL)
 			argv[TOK_CHAN] = argv[TOK_TEXT];
 		snprintf(msg, sizeof(msg), "-!- %s(%s) has joined %s",
 				argv[TOK_NICKSRV],argv[TOK_USER], argv[TOK_CHAN]);
-	} else if(!strcmp("PART", argv[TOK_CMD])) {
+	} else if(!strcmp("PART", argv[TOK_CMD]) && argv[TOK_CHAN]) {
 		snprintf(msg, sizeof(msg), "-!- %s(%s) has left %s",
 				argv[TOK_NICKSRV], argv[TOK_USER], argv[TOK_CHAN]);
 		/* if user itself leaves, don't write to channel (don't reopen channel). */
_AT_@ -566,14 +567,16 @@ proc_server_cmd(int fd, char *buf)
 		snprintf(msg, sizeof(msg), "-!- %s(%s) has quit \"%s\"",
 				argv[TOK_NICKSRV], argv[TOK_USER],
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
-	} else if(!strcmp("NICK", argv[TOK_CMD])) {
+	} else if(!strcmp("NICK", argv[TOK_CMD]) && argv[TOK_TEXT] &&
+	          !strcmp(_nick, argv[TOK_TEXT])) {
+		strlcpy(nick, _nick, sizeof(nick));
 		snprintf(msg, sizeof(msg), "-!- %s changed nick to %s",
 				argv[TOK_NICKSRV], argv[TOK_TEXT]);
 	} else if(!strcmp("TOPIC", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "-!- %s changed topic to \"%s\"",
 				argv[TOK_NICKSRV],
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
-	} else if(!strcmp("KICK", argv[TOK_CMD])) {
+	} else if(!strcmp("KICK", argv[TOK_CMD]) && argv[TOK_ARG]) {
 		snprintf(msg, sizeof(msg), "-!- %s kicked %s (\"%s\")",
 				argv[TOK_NICKSRV], argv[TOK_ARG],
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
_AT_@ -583,6 +586,8 @@ proc_server_cmd(int fd, char *buf)
 	} else if(!strcmp("PRIVMSG", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "<%s> %s", argv[TOK_NICKSRV],
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
+	} else {
+		return; /* can't read this message */
 	}
 	if(!argv[TOK_CHAN] || !strcmp(argv[TOK_CHAN], nick))
 		channel = argv[TOK_NICKSRV];
_AT_@ -658,7 +663,7 @@ setup(void)
 static void
 run(int ircfd, const char *host)
 {
-	Channel *c;
+	Channel *c, *n;
 	fd_set rdset;
 	struct timeval tv;
 	char ping_msg[IRC_MSG_MAX];
_AT_@ -692,7 +697,8 @@ run(int ircfd, const char *host)
 			handle_server_output(ircfd);
 			last_response = time(NULL);
 		}
-		for(c = channels; c; c = c->next) {
+		for(c = channels; c; c = n) {
+			n = c->next;
 			if(FD_ISSET(c->fdin, &rdset))
 				handle_channels_input(ircfd, c);
 		}
-- 
2.4.10
--Multipart=_Mon__9_May_2016_17_21_10_+0200_I.6cpFVydhq75aaE
Content-Type: text/x-diff;
 name="0065-Whitespace-changes.patch"
Content-Disposition: attachment;
 filename="0065-Whitespace-changes.patch"
Content-Transfer-Encoding: 7bit
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Mon May 09 2016 - 17:24:22 CEST