Commit cf90f796 authored by Frédéric Buclin's avatar Frédéric Buclin Committed by Dylan William Hardison

Bug 1260020 - Use Win32::GetConsoleOutputCP() instead of Win32::Console::OutputCP()

parent 1e2027a9
......@@ -24,6 +24,8 @@ use POSIX qw(setlocale LC_CTYPE);
use Scalar::Util qw(tainted);
use Term::ANSIColor qw(colored);
use PerlIO;
use if ON_WINDOWS, 'Win32';
use if ON_WINDOWS, 'Win32::API';
use parent qw(Exporter);
our @EXPORT_OK = qw(
......@@ -73,10 +75,8 @@ sub get_version_and_os {
my @os_details = POSIX::uname;
# 0 is the name of the OS, 2 is the major version,
my $os_name = $os_details[0] . ' ' . $os_details[2];
if (ON_WINDOWS) {
require Win32;
$os_name = Win32::GetOSName();
}
$os_name = Win32::GetOSName() if ON_WINDOWS;
# $os_details[3] is the minor version.
return { bz_ver => BUGZILLA_VERSION,
perl_ver => sprintf('%vd', $^V),
......@@ -582,11 +582,10 @@ sub set_output_encoding {
return if grep(/^encoding/, @stdout_layers);
my $encoding;
if (ON_WINDOWS and eval { require Win32::Console }) {
if (ON_WINDOWS) {
# Although setlocale() works on Windows, it doesn't always return
# the current *console's* encoding. So we use OutputCP here instead,
# when we can.
$encoding = Win32::Console::OutputCP();
# the current *console's* encoding.
$encoding = Win32::GetConsoleOutputCP();
}
else {
my $locale = setlocale(LC_CTYPE);
......@@ -643,9 +642,7 @@ sub prevent_windows_dialog_boxes {
# during checksetup (since loading DBD::Oracle during checksetup when
# Oracle isn't installed causes a scary popup and pauses checksetup).
#
# Win32::API ships with ActiveState by default, though there could
# theoretically be a Windows installation without it, I suppose.
if (ON_WINDOWS and eval { require Win32::API }) {
if (ON_WINDOWS) {
# Call kernel32.SetErrorMode with arguments that mean:
# "The system does not display the critical-error-handler message box.
# Instead, the system sends the error to the calling process." and
......
......@@ -87,8 +87,11 @@ my %all_features = (
# Windows requires some additional modules.
if ( $^O eq 'MSWin32' ) {
$requires{'Win32'} = '0.35';
$requires{'Win32::API'} = '0.55';
# 0.45 implements the GetConsoleOutputCP() method.
# It also supports Windows 7. Set this to 0.52 to support Windows 10.
$requires{'Win32'} = '0.45';
# 0.63 fixes a problem with Strawberry Perl 5.14.1.
$requires{'Win32::API'} = '0.63';
$requires{'DateTime::TimeZone::Local::Win32'} = '1.64';
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment