From 8b1afbd3557e605f35cf4dab16d49cb4c89ca496 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Sat, 6 Oct 2018 19:26:36 +0200 Subject: [PATCH] revert core changes --- src/core/core.c | 10 ------ src/core/core.h | 3 -- src/irc/core/channel-events.c | 53 +++++++--------------------- tests/irc/core/test-channel-events.c | 6 ++-- 4 files changed, 17 insertions(+), 55 deletions(-) diff --git a/src/core/core.c b/src/core/core.c index d87e86e2..506d6a13 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -73,22 +73,12 @@ const char *get_irssi_dir(void) return irssi_dir; } -void set_irssi_dir(char *const s) -{ - irssi_dir = s; -} - /* return full path for ~/.irssi/config */ const char *get_irssi_config(void) { return irssi_config_file; } -void set_irssi_config(char *const s) -{ - irssi_config_file = s; -} - static void sig_reload_config(int signo) { reload_config = TRUE; diff --git a/src/core/core.h b/src/core/core.h index 395e5c83..982dbaad 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -16,9 +16,6 @@ extern int irssi_init_finished; /* TRUE after "irssi init finished" signal is se extern int reload_config; /* TRUE after received SIGHUP. */ extern time_t client_start_time; -void set_irssi_dir(char *const); -void set_irssi_config(char *const); - void core_preinit(const char *path); void core_register_options(void); diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c index 85d985ea..6ffe7364 100644 --- a/src/irc/core/channel-events.c +++ b/src/irc/core/channel-events.c @@ -29,9 +29,6 @@ #include "irc-servers.h" #include "irc-channels.h" -static void set_topic_info(CHANNEL_REC *const, char const *const, - time_t const); - static void check_join_failure(IRC_SERVER_REC *server, const char *channel) { CHANNEL_REC *chanrec; @@ -130,51 +127,27 @@ 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 + /* the topic may be send 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 || *recoded == '\0') { - signal_emit("channel topic changed", 1, chanrec); - g_free(recoded); - return; + if (topic != NULL) { + g_free_not_null(chanrec->topic); + chanrec->topic = recoded == NULL ? NULL : g_strdup(recoded); } + g_free(recoded); - chanrec->topic = recoded; - set_topic_info(chanrec, setby, settime); - - signal_emit("channel topic changed", 1, chanrec); -} - -static void channel_change_topic_info(IRC_SERVER_REC *server, - const char *channel, const char *setby, time_t settime) -{ - CHANNEL_REC *chanrec; - - chanrec = channel_find(SERVER(server), channel); - if (chanrec == NULL) return; - - g_free_and_null(chanrec->topic_by); - chanrec->topic_time = 0; - - set_topic_info(chanrec, setby, settime); - - signal_emit("channel topic changed", 1, chanrec); -} - -static void set_topic_info(CHANNEL_REC *const chanrec, char const *const setby, - time_t const settime) -{ + g_free_not_null(chanrec->topic_by); 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; } + + signal_emit("channel topic changed", 1, chanrec); } static void event_topic_get(IRC_SERVER_REC *server, const char *data) @@ -214,7 +187,7 @@ static void event_topic_info(IRC_SERVER_REC *server, const char *data) &topicby, &topictime); t = (time_t) atol(topictime); - channel_change_topic_info(server, channel, topicby, t); + channel_change_topic(server, channel, NULL, topicby, t); g_free(params); } diff --git a/tests/irc/core/test-channel-events.c b/tests/irc/core/test-channel-events.c index 98c70ce8..9f52c98d 100644 --- a/tests/irc/core/test-channel-events.c +++ b/tests/irc/core/test-channel-events.c @@ -31,6 +31,7 @@ #include #include #include +#include #define MODULE_NAME "test-channel-events" @@ -87,10 +88,11 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); + core_preinit(*argv); + irssi_gui = IRSSI_GUI_NONE; + modules_init(); signals_init(); - set_irssi_dir("/tmp/irssi"); - set_irssi_config("/tmp/irssi/config"); settings_init(); recode_init(); channel_events_init();