summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2015-05-13 10:28:22 +1000
committerTony Cook <tony@develop-help.com>2015-05-15 11:47:23 +1000
commit18fe62667c7b9e1cc19201a7075e74e31b6ae16b (patch)
treed5bd556c723d5e349837ae083fefe04ac504531e
parent30aa8e3f58555e9f59c77b031038678310f01473 (diff)
downloadperl-18fe62667c7b9e1cc19201a7075e74e31b6ae16b.tar.gz
backport 1e2f0871 from the EUMM repository
-rwxr-xr-xPorting/Maintainers.pl2
-rw-r--r--cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker/Locale.pm72
-rw-r--r--t/porting/customized.dat1
3 files changed, 52 insertions, 23 deletions
diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl
index d31e190073..9baab5f4e1 100755
--- a/Porting/Maintainers.pl
+++ b/Porting/Maintainers.pl
@@ -474,7 +474,7 @@ use File::Glob qw(:case);
'README.packaging',
],
# Applied upstream remove customisation when updating EUMM
- 'CUSTOMIZED' => [ qw[ t/pm_to_blib.t ] ],
+ 'CUSTOMIZED' => [ qw[ t/pm_to_blib.t lib/ExtUtils/MakeMaker/Locale.pm ] ],
},
'ExtUtils::Manifest' => {
diff --git a/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker/Locale.pm b/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker/Locale.pm
index f6edcf2d1f..23d0c6ecfe 100644
--- a/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker/Locale.pm
+++ b/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker/Locale.pm
@@ -1,7 +1,7 @@
package ExtUtils::MakeMaker::Locale;
use strict;
-our $VERSION = "7.04";
+our $VERSION = "7.04_01";
use base 'Exporter';
our @EXPORT_OK = qw(
@@ -25,31 +25,60 @@ sub _init {
unless ($ENCODING_LOCALE) {
# Try to obtain what the Windows ANSI code page is
eval {
- unless (defined &GetACP) {
+ unless (defined &GetConsoleCP) {
+ require Win32;
+ # no point falling back to Win32::GetConsoleCP from this
+ # as added same time, 0.45
+ eval { Win32::GetConsoleCP() };
+ # manually "import" it since Win32->import refuses
+ *GetConsoleCP = sub { &Win32::GetConsoleCP } unless $@;
+ }
+ unless (defined &GetConsoleCP) {
require Win32::API;
- Win32::API->Import('kernel32', 'int GetACP()');
- };
- if (defined &GetACP) {
- my $cp = GetACP();
+ Win32::API->Import('kernel32', 'int GetConsoleCP()');
+ }
+ if (defined &GetConsoleCP) {
+ my $cp = GetConsoleCP();
$ENCODING_LOCALE = "cp$cp" if $cp;
}
};
}
unless ($ENCODING_CONSOLE_IN) {
- # If we have the Win32::Console module installed we can ask
- # it for the code set to use
- eval {
- require Win32::Console;
- my $cp = Win32::Console::InputCP();
- $ENCODING_CONSOLE_IN = "cp$cp" if $cp;
- $cp = Win32::Console::OutputCP();
- $ENCODING_CONSOLE_OUT = "cp$cp" if $cp;
- };
- # Invoking the 'chcp' program might also work
- if (!$ENCODING_CONSOLE_IN && (qx(chcp) || '') =~ /^Active code page: (\d+)/) {
- $ENCODING_CONSOLE_IN = "cp$1";
+ # only test one since set together
+ unless (defined &GetInputCP) {
+ eval {
+ require Win32;
+ eval { Win32::GetConsoleCP() };
+ # manually "import" it since Win32->import refuses
+ *GetInputCP = sub { &Win32::GetConsoleCP } unless $@;
+ *GetOutputCP = sub { &Win32::GetConsoleOutputCP } unless $@;
+ };
+ unless (defined &GetInputCP) {
+ eval {
+ # try Win32::Console module for codepage to use
+ require Win32::Console;
+ eval { Win32::Console::InputCP() };
+ *GetInputCP = sub { &Win32::Console::InputCP }
+ unless $@;
+ *GetOutputCP = sub { &Win32::Console::OutputCP }
+ unless $@;
+ };
+ }
+ unless (defined &GetInputCP) {
+ # final fallback
+ *GetInputCP = *GetOutputCP = sub {
+ # another fallback that could work is:
+ # reg query HKLM\System\CurrentControlSet\Control\Nls\CodePage /v ACP
+ ((qx(chcp) || '') =~ /^Active code page: (\d+)/)
+ ? $1 : ();
+ };
+ }
}
+ my $cp = GetInputCP();
+ $ENCODING_CONSOLE_IN = "cp$cp" if $cp;
+ $cp = GetOutputCP();
+ $ENCODING_CONSOLE_OUT = "cp$cp" if $cp;
}
}
@@ -206,8 +235,7 @@ C<Encode::Locale> will do that if available and make these encodings known
under the C<Encode> aliases "console_in" and "console_out". For systems where
we can't determine the terminal encoding these will be aliased as the same
encoding as "locale". The advice is to use "console_in" for input known to
-come from the terminal and "console_out" for output known to go from the
-terminal.
+come from the terminal and "console_out" for output to the terminal.
In addition to arranging for various Encode aliases the following functions and
variables are provided:
@@ -266,7 +294,7 @@ L<Encode> know this encoding as "locale".
=item $ENCODING_LOCALE_FS
-The encoding name determined to be suiteable for file system interfaces
+The encoding name determined to be suitable for file system interfaces
involving file names.
L<Encode> know this encoding as "locale_fs".
@@ -336,7 +364,7 @@ Users are advised to always specify UTF-8 as the locale charset.
=head1 SEE ALSO
-L<I18N::Langinfo>, L<Encode>
+L<I18N::Langinfo>, L<Encode>, L<Term::Encoding>
=head1 AUTHOR
diff --git a/t/porting/customized.dat b/t/porting/customized.dat
index fa37838db4..50652eb67d 100644
--- a/t/porting/customized.dat
+++ b/t/porting/customized.dat
@@ -1,3 +1,4 @@
+ExtUtils::MakeMaker cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker/Locale.pm 82be06851deb84c6419ad003ce9b6d1957f395f3
ExtUtils::MakeMaker cpan/ExtUtils-MakeMaker/t/pm_to_blib.t 71ebcee355691ce374fcad251b12d8b2412462b3
PerlIO::via::QuotedPrint cpan/PerlIO-via-QuotedPrint/t/QuotedPrint.t ca39f0146e89de02c746e199c45dcb3e5edad691
Text::ParseWords cpan/Text-ParseWords/t/ParseWords.t 9bae51c9b944cd5c0bbabe9d397e573976a2be8e