From c32047a4b4583e745b663a03ca89587a59c2059f Mon Sep 17 00:00:00 2001 From: lingsheng Date: Wed, 22 Sep 2021 14:36:39 +0800 Subject: [PATCH] Execute setlocale before printing --- src/fe-none/irssi.c | 13 +++++++++++++ src/fe-text/irssi.c | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/fe-none/irssi.c b/src/fe-none/irssi.c index 6c60162..3c5e4df 100644 --- a/src/fe-none/irssi.c +++ b/src/fe-none/irssi.c @@ -25,6 +25,8 @@ #include "signals.h" #include "core.h" +#include + #ifdef HAVE_STATIC_PERL void perl_core_init(void); void perl_core_deinit(void); @@ -86,6 +88,17 @@ int main(int argc, char **argv) { NULL } }; + /* setlocale() must be called at the beginning before any calls that + affect it, especially regexps seem to break if they're generated + before this call. + + locales aren't actually used for anything else than autodetection + of UTF-8 currently.. + + furthermore to get the users's charset with g_get_charset() properly + you have to call setlocale(LC_ALL, "") */ + setlocale(LC_ALL, ""); + autoload_module = NULL; core_register_options(); args_register(options); diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c index 0288e4f..58ce661 100644 --- a/src/fe-text/irssi.c +++ b/src/fe-text/irssi.c @@ -271,6 +271,17 @@ int main(int argc, char **argv) }; int loglev; + /* setlocale() must be called at the beginning before any calls that + affect it, especially regexps seem to break if they're generated + before this call. + + locales aren't actually used for anything else than autodetection + of UTF-8 currently.. + + furthermore to get the users's charset with g_get_charset() properly + you have to call setlocale(LC_ALL, "") */ + setlocale(LC_ALL, ""); + core_register_options(); fe_common_core_register_options(); args_register(options); @@ -293,17 +304,6 @@ int main(int argc, char **argv) SOCKSinit(argv[0]); #endif - /* setlocale() must be called at the beginning before any calls that - affect it, especially regexps seem to break if they're generated - before this call. - - locales aren't actually used for anything else than autodetection - of UTF-8 currently.. - - furthermore to get the users's charset with g_get_charset() properly - you have to call setlocale(LC_ALL, "") */ - setlocale(LC_ALL, ""); - loglev = g_log_set_always_fatal(G_LOG_FATAL_MASK | G_LOG_LEVEL_CRITICAL); textui_init(); -- 2.23.0