From 514f1cdcf6e0c8c6d09d47481e7583eed0d11393 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Fri, 22 Dec 2023 13:03:28 +0100 Subject: [PATCH 1/2] Revert "Merge pull request #1498 from ailin-nemui/perl5380locale" This reverts commit 48bc90eb17ec3c6549afd69c5d6f16d07fd57db0, reversing changes made to 2a1291f26f6dc47b1d3169d18faba8f995bd3ea6. --- src/perl/irssi-core.pl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/perl/irssi-core.pl b/src/perl/irssi-core.pl index 880bd6a3..cf987b31 100644 --- a/src/perl/irssi-core.pl +++ b/src/perl/irssi-core.pl @@ -50,10 +50,3 @@ sub eval_file { die "cap_sasl has been unloaded from Irssi ".Irssi::version()." because it conflicts with the built-in SASL support. See /help network for configuring SASL or read the ChangeLog for more information."; } } - -if ( $] >= 5.037005 && $] <= 5.038000 ) { - # https://github.com/Perl/perl5/issues/21366 - print STDERR "\e7 \e[A Irssi: applying locale workaround for Perl 5.38.0 \e8"; - require POSIX; - POSIX::setlocale(&POSIX::LC_ALL, ""); -} From a0caf5e5e64fff9c7f0274800d1fca34b63fcc7a Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Fri, 22 Dec 2023 13:03:24 +0100 Subject: [PATCH 2/2] restore locale if perl breaks it --- src/perl/perl-core.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/perl/perl-core.c b/src/perl/perl-core.c index 79d5c13c..fe52874a 100644 --- a/src/perl/perl-core.c +++ b/src/perl/perl-core.c @@ -90,24 +90,41 @@ static void xs_init(pTHX) void perl_scripts_init(void) { char *code, *use_code; + int broken_perl; perl_scripts = NULL; perl_sources_start(); perl_signals_start(); my_perl = perl_alloc(); + broken_perl = wcwidth(160); perl_construct(my_perl); + broken_perl = broken_perl != wcwidth(160); - perl_parse(my_perl, xs_init, G_N_ELEMENTS(perl_args)-1, perl_args, NULL); + perl_parse(my_perl, xs_init, G_N_ELEMENTS(perl_args) - 1, perl_args, NULL); - perl_common_start(); + perl_common_start(); use_code = perl_get_use_list(); code = g_strdup_printf(irssi_core_code, use_code); perl_eval_pv(code, TRUE); + if (broken_perl) { + g_warning("applying locale workaround for Perl %d.%d, see " + "https://github.com/Perl/perl5/issues/21366", + PERL_REVISION, PERL_VERSION); + perl_eval_pv("package Irssi::Core;" + /* https://github.com/Perl/perl5/issues/21746 */ + "if ( $] == $] )" + "{" + "require POSIX;" + "POSIX::setlocale(&POSIX::LC_ALL, \"\");" + "}" + "1;", + TRUE); + } g_free(code); - g_free(use_code); + g_free(use_code); } /* Destroy all perl scripts and deinitialize perl interpreter */ @@ -441,7 +458,7 @@ void perl_core_init(void) char **argv = perl_args; PERL_SYS_INIT3(&argc, &argv, &environ); - print_script_errors = 1; + print_script_errors = 1; settings_add_str("perl", "perl_use_lib", PERL_USE_LIB); /*PL_perl_destruct_level = 1; - this crashes with some people.. */