Skip to content

Commit 704caf3

Browse files
committed
Ensure that when variable is used, it has been initialized
There were cases discovered during smoke-testing on OpenBSD since fecfa47 was committed in February 2025 where $locale was undefined and emitting a runtime warning.
1 parent 76d727b commit 704caf3

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

t/run/locale.t

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,7 @@ SKIP:
592592
{
593593
skip "didn't find a suitable non-UTF-8 locale", 1 unless
594594
@non_utf8_locales;
595-
my $locale = $non_utf8_locales[0];
596-
print STDERR "AAA: \$locale: $locale\n";
595+
my $locale = $non_utf8_locales[0] // '';
597596

598597
fresh_perl_is(<<"EOF", "ok\n", {}, "cmp() handles above Latin1 and NUL in non-UTF8 locale");
599598
use locale;
@@ -614,8 +613,7 @@ EOF
614613
SKIP:
615614
{
616615
skip "didn't find a suitable UTF-8 locale", 1 unless $utf8_ref;
617-
my $locale = $utf8_ref->[0];
618-
print STDERR "BBB: \$locale: $locale\n";
616+
my $locale = $non_utf8_locales[0] // '';
619617

620618
fresh_perl_is(<<"EOF", "ok\n", {}, "Handles above Unicode in a UTF8 locale");
621619
use locale;
@@ -638,8 +636,7 @@ SKIP:
638636
my $is64bit = length sprintf("%x", ~0) > 8;
639637
skip "32-bit ASCII platforms can't physically have extended UTF-8", 1
640638
if $::IS_ASCII && ! $is64bit;
641-
my $locale = $utf8_ref->[0];
642-
print STDERR "CCC: \$locale: $locale\n";
639+
my $locale = $non_utf8_locales[0] // '';
643640

644641
fresh_perl_is(<<"EOF", "ok\n", {}, "cmp() handles Perl extended UTF-8");
645642
use locale;
@@ -689,8 +686,7 @@ SKIP: { # GH #20054
689686
&& $Config{d_setlocale_accepts_any_locale_name} eq 'define';
690687

691688
my @lc_all_locales = find_locales('LC_ALL');
692-
my $locale = $lc_all_locales[0];
693-
print STDERR "DDD: \$locale: $locale\n";
689+
my $locale = $non_utf8_locales[0] // '';
694690
skip "LC_ALL not enabled on this platform", 1 unless $locale;
695691
my $fallback = ($^O eq "MSWin32")
696692
? "system default"

0 commit comments

Comments
 (0)