diff --git a/lib/Syntax/Construct.pm b/lib/Syntax/Construct.pm index 4b449a0..933c7f5 100644 --- a/lib/Syntax/Construct.pm +++ b/lib/Syntax/Construct.pm @@ -201,8 +201,12 @@ sub _hook { eval { use locale; require POSIX; - POSIX::setlocale(POSIX::LC_ALL(), 'tr_TR.UTF-8'); - lc 'I' ne 'i' + my $orig_locale = POSIX::setlocale(POSIX::LC_CTYPE()); + POSIX::setlocale(POSIX::LC_CTYPE(), 'tr_TR.UTF-8') + eq 'tr_TR.UTF-8' or die; + my $cmp = lc 'I' ne 'i'; + POSIX::setlocale(POSIX::LC_CTYPE(), $orig_locale); + $cmp } or die 'Turkic locale casing not working at ' . _position(1) . "\.\n"; }, diff --git a/t/02-constructs.t b/t/02-constructs.t index 3d79a3c..7161f0b 100755 --- a/t/02-constructs.t +++ b/t/02-constructs.t @@ -115,8 +115,12 @@ my %tests = ( q("\N{ORIYA DIGIT FOUR}" =~ m'\N{ORIYA DIGIT FOUR}'), 1 ], [ 'turkic-casing', 'use locale; use POSIX "locale_h";' . skippable( - 'eval{setlocale(LC_ALL, "tr_TR.UTF-8") eq "tr_TR.UTF-8" or die;' - . ' lc "I" eq "\N{LATIN SMALL LETTER DOTLESS I}"}', + 'my $o = setlocale(LC_CTYPE);' + . 'eval {' + . 'setlocale(LC_CTYPE, "tr_TR.UTF-8") eq "tr_TR.UTF-8" or die;' + . 'my $r = lc "I" eq "\N{LATIN SMALL LETTER DOTLESS I}";' + . 'setlocale(LC_CTYPE, $o);' + . '$r }', '": testing locale not supported"', "", '1'), 1 ],