Skip to content

Commit c30411f

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 29cc805 commit c30411f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

t/run/locale.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +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];
595+
my $locale = $non_utf8_locales[0] // '';
596596

597597
fresh_perl_is(<<"EOF", "ok\n", {}, "cmp() handles above Latin1 and NUL in non-UTF8 locale");
598598
use locale;
@@ -613,7 +613,7 @@ EOF
613613
SKIP:
614614
{
615615
skip "didn't find a suitable UTF-8 locale", 1 unless $utf8_ref;
616-
my $locale = $utf8_ref->[0];
616+
my $locale = $non_utf8_locales[0] // '';
617617

618618
fresh_perl_is(<<"EOF", "ok\n", {}, "Handles above Unicode in a UTF8 locale");
619619
use locale;
@@ -636,7 +636,7 @@ SKIP:
636636
my $is64bit = length sprintf("%x", ~0) > 8;
637637
skip "32-bit ASCII platforms can't physically have extended UTF-8", 1
638638
if $::IS_ASCII && ! $is64bit;
639-
my $locale = $utf8_ref->[0];
639+
my $locale = $non_utf8_locales[0] // '';
640640

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

688688
my @lc_all_locales = find_locales('LC_ALL');
689-
my $locale = $lc_all_locales[0];
689+
my $locale = $non_utf8_locales[0] // '';
690690
skip "LC_ALL not enabled on this platform", 1 unless $locale;
691691
my $fallback = ($^O eq "MSWin32")
692692
? "system default"

0 commit comments

Comments
 (0)