Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

final (?) fix for locale problem (RT #41285) #1

Merged
merged 1 commit into from

2 participants

@eserte

Instead of testing the value of the env variables, use
POSIX::setlocale to get the effective value of the LC_CTYPE
locale (the only one effecting tr operation).

For the workaround on top of the script, add also LC_CTYPE
to the list of env variables explicitely set to C.

Also, setting the env variables must happen in a BEGIN{}
block, otherwise things are too late.

@eserte eserte final (?) fix for locale problem (RT #41285)
Instead of testing the value of the env variables, use
POSIX::setlocale to get the effective value of the LC_CTYPE
locale (the only one effecting tr operation).

For the workaround on top of the script, add also LC_CTYPE
to the list of env variables explicitely set to C.

Also, setting the env variables must happen in a BEGIN{}
block, otherwise things are too late.
b7f034a
@rurban rurban merged commit cb65765 into rurban:master
@rurban
Owner

Uploaded with 1.49. Thanks

@eserte eserte deleted the eserte:RT-41285 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 2, 2013
  1. @eserte

    final (?) fix for locale problem (RT #41285)

    eserte authored
    Instead of testing the value of the env variables, use
    POSIX::setlocale to get the effective value of the LC_CTYPE
    locale (the only one effecting tr operation).
    
    For the workaround on top of the script, add also LC_CTYPE
    to the list of env variables explicitely set to C.
    
    Also, setting the env variables must happen in a BEGIN{}
    block, otherwise things are too late.
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 4 deletions.
  1. +6 −2 t/exec.t
  2. +6 −2 t/sh.t
View
8 t/exec.t
@@ -31,8 +31,12 @@ require "filter-util.pl" ;
use vars qw( $Inc $Perl $script ) ;
$script = '';
-if (exists $ENV{LANG} and $ENV{LANG} !~ /^C|en/) { # CPAN #41285
- $script = q($ENV{LANG}='C'; $ENV{LC_ALL}='C';);
+if (eval {
+ require POSIX;
+ my $val = POSIX::setlocale(&POSIX::LC_CTYPE);
+ $val !~ m{^(C|en)}
+}) { # CPAN #41285
+ $script = q(BEGIN { $ENV{LANG}=$ENV{LC_ALL}=$ENV{LC_CTYPE}='C'; });
}
$script .= <<'EOF' ;
View
8 t/sh.t
@@ -31,8 +31,12 @@ require "filter-util.pl" ;
use vars qw( $Inc $Perl $script ) ;
$script = '';
-if (exists $ENV{LANG} and $ENV{LANG} !~ /^C|en/) { # CPAN #41285
- $script = q($ENV{LANG}='C'; $ENV{LC_ALL}='C';);
+if (eval {
+ require POSIX;
+ my $val = POSIX::setlocale(&POSIX::LC_CTYPE);
+ $val !~ m{^(C|en)}
+}) { # CPAN #41285
+ $script = q(BEGIN { $ENV{LANG}=$ENV{LC_ALL}=$ENV{LC_CTYPE}='C'; });
}
$script .= <<"EOF" ;
Something went wrong with that request. Please try again.