1
0
mirror of https://github.com/irssi/irssi.git synced 2024-06-23 06:35:36 +00:00

Merge pull request #1243 from ailin-nemui/config-setup-comments

ignore comments and abort irssi on servers and channels config errors
This commit is contained in:
ailin-nemui 2021-01-08 23:12:31 +01:00 committed by GitHub
commit 24999a066c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 9 deletions

View File

@ -34,6 +34,10 @@ static int compare_channel_setup (CONFIG_NODE *node, CHANNEL_SETUP_REC *channel)
{
char *name, *chatnet;
/* skip comment nodes */
if (node->type == NODE_TYPE_COMMENT)
return -1;
name = config_node_get_str(node, "name", NULL);
chatnet = config_node_get_str(node, "chatnet", NULL);
@ -203,9 +207,18 @@ static void channels_read_config(void)
/* Read channels */
node = iconfig_node_traverse("channels", FALSE);
if (node != NULL) {
int i = 0;
tmp = config_node_first(node->value);
for (; tmp != NULL; tmp = config_node_next(tmp))
channel_setup_read(tmp->data);
for (; tmp != NULL; tmp = config_node_next(tmp), i++) {
node = tmp->data;
if (node->type != NODE_TYPE_BLOCK) {
g_critical("Expected block node at `channels[%d]' was of %s type. "
"Corrupt config?",
i, node->type == NODE_TYPE_LIST ? "list" : "scalar");
} else {
channel_setup_read(node);
}
}
}
}

View File

@ -472,6 +472,10 @@ static int compare_server_setup (CONFIG_NODE *node, SERVER_SETUP_REC *server)
char *address, *chatnet;
int port;
/* skip comment nodes */
if (node->type == NODE_TYPE_COMMENT)
return -1;
address = config_node_get_str(node, "address", NULL);
chatnet = config_node_get_str(node, "chatnet", NULL);
port = config_node_get_int(node, "port", 0);
@ -621,9 +625,18 @@ static void read_servers(void)
/* Read servers */
node = iconfig_node_traverse("servers", FALSE);
if (node != NULL) {
int i = 0;
tmp = config_node_first(node->value);
for (; tmp != NULL; tmp = config_node_next(tmp))
server_setup_read(tmp->data);
for (; tmp != NULL; tmp = config_node_next(tmp), i++) {
node = tmp->data;
if (node->type != NODE_TYPE_BLOCK) {
g_critical("Expected block node at `servers[%d]' was of %s type. "
"Corrupt config?",
i, node->type == NODE_TYPE_LIST ? "list" : "scalar");
} else {
server_setup_read(node);
}
}
}
}

View File

@ -162,6 +162,16 @@ static void textui_init(void)
signal_add_last("gui exit", (SIGNAL_FUNC) sig_exit);
}
static int critical_fatal_section_begin(void)
{
return g_log_set_always_fatal(G_LOG_FATAL_MASK | G_LOG_LEVEL_CRITICAL);
}
static void critical_fatal_section_end(int loglev)
{
g_log_set_always_fatal(loglev);
}
static void textui_finish_init(void)
{
int loglev;
@ -182,10 +192,9 @@ static void textui_finish_init(void)
mainwindows_layout_init();
gui_windows_init();
/* Temporarily raise the fatal level to abort on config errors. */
loglev = g_log_set_always_fatal(G_LOG_FATAL_MASK | G_LOG_LEVEL_CRITICAL);
loglev = critical_fatal_section_begin();
statusbar_init();
g_log_set_always_fatal(loglev);
term_refresh_thaw();
critical_fatal_section_end(loglev);
settings_check();
@ -202,7 +211,12 @@ static void textui_finish_init(void)
dirty_check();
/* Temporarily raise the fatal level to abort on config errors. */
loglev = critical_fatal_section_begin();
fe_common_core_finish_init();
critical_fatal_section_end(loglev);
term_refresh_thaw();
signal_emit("irssi init finished", 0);
statusbar_redraw(NULL, TRUE);
@ -329,7 +343,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
/* Temporarily raise the fatal level to abort on config errors. */
loglev = g_log_set_always_fatal(G_LOG_FATAL_MASK | G_LOG_LEVEL_CRITICAL);
loglev = critical_fatal_section_begin();
textui_init();
if (!term_init()) {
@ -337,7 +351,8 @@ int main(int argc, char **argv)
return 1;
}
g_log_set_always_fatal(loglev);
critical_fatal_section_end(loglev);
textui_finish_init();
main_loop = g_main_loop_new(NULL, TRUE);