From 0e187cf9cfb99c19f3dc9cf532fb5bac92dd1145 Mon Sep 17 00:00:00 2001 From: Will Storey Date: Tue, 24 Jul 2018 18:29:31 -0700 Subject: [PATCH 1/4] Fix typo in comment --- src/irc/core/channel-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index 46bbd5fa..6cdfe147 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -126,7 +126,7 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel, chanrec = channel_find(SERVER(server), channel); if (chanrec == NULL) return; - /* the topic may be send out encoded, so we need to + /* the topic may be sent out encoded, so we need to recode it back or /topic will not work properly */ recoded = recode_in(SERVER(server), topic, channel); if (topic != NULL) { From b9e301362db545a4108b5d08c7eda45441a475f5 Mon Sep 17 00:00:00 2001 From: Will Storey Date: Tue, 24 Jul 2018 18:30:51 -0700 Subject: [PATCH 2/4] Ignore vim editor files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 916457f8..1ab7df5f 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ tests/irc/core/test-irc.trs *.la *.lo *.o +*.swp *~ *.tar.bz2 From 15840ac27bd05e710ae13afe1a3c29853d2d6a0b Mon Sep 17 00:00:00 2001 From: Will Storey Date: Tue, 24 Jul 2018 18:31:57 -0700 Subject: [PATCH 3/4] If we receive a 0 length topic, record it as unset Fixes #888. Previously we showed that there was a topic set when using /topic, just an empty one. This was different than how we show such topics when initially joining a channel. Now we say that the topic is unset in both cases. --- src/irc/core/channel-events.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index 6cdfe147..38cc0bdd 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -126,23 +126,25 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel, chanrec = channel_find(SERVER(server), channel); if (chanrec == NULL) return; + + g_free_and_null(chanrec->topic); + g_free_and_null(chanrec->topic_by); + chanrec->topic_time = 0; + /* the topic may be sent out encoded, so we need to recode it back or /topic will not work properly */ recoded = recode_in(SERVER(server), topic, channel); - if (topic != NULL) { - g_free_not_null(chanrec->topic); - chanrec->topic = recoded == NULL ? NULL : g_strdup(recoded); + if (recoded == NULL || strlen(recoded) == 0) { + signal_emit("channel topic changed", 1, chanrec); + g_free(recoded); + return; } - g_free(recoded); - g_free_not_null(chanrec->topic_by); + chanrec->topic = recoded; chanrec->topic_by = g_strdup(setby); - - if (chanrec->topic_by == NULL) { + if (chanrec->topic_by != NULL) { /* ensure invariant topic_time > 0 <=> topic_by != NULL. this could be triggered by a topic command without sender */ - chanrec->topic_time = 0; - } else { chanrec->topic_time = settime; } From b114b11e36598157b7b014cc8d4325fbf04c9b1e Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 30 Jul 2018 23:45:56 -0300 Subject: [PATCH 4/4] channel_change_topic: change one strlen == 0 to *str == '\0' --- src/irc/core/channel-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index 38cc0bdd..4b74b322 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -134,7 +134,7 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel, /* the topic may be sent out encoded, so we need to recode it back or /topic will not work properly */ recoded = recode_in(SERVER(server), topic, channel); - if (recoded == NULL || strlen(recoded) == 0) { + if (recoded == NULL || *recoded == '\0') { signal_emit("channel topic changed", 1, chanrec); g_free(recoded); return;