| Filename | C:/tmp64ng/perl/lib/ExtUtils/MakeMaker/Locale.pm | 
| Statements | Executed 50 statements in 15.6ms | 
| Calls | P | F | Exclusive Time  | 
        Inclusive Time  | 
        Subroutine | 
|---|---|---|---|---|---|
| 1 | 1 | 1 | 15.6ms | 31.2ms | ExtUtils::MakeMaker::Locale::_init | 
| 1 | 1 | 1 | 0s | 0s | ExtUtils::MakeMaker::Locale::BEGIN@104 | 
| 1 | 1 | 1 | 0s | 0s | ExtUtils::MakeMaker::Locale::BEGIN@105 | 
| 1 | 1 | 1 | 0s | 0s | ExtUtils::MakeMaker::Locale::BEGIN@110 | 
| 1 | 1 | 1 | 0s | 15.6ms | ExtUtils::MakeMaker::Locale::BEGIN@13 | 
| 1 | 1 | 1 | 0s | 0s | ExtUtils::MakeMaker::Locale::BEGIN@14 | 
| 1 | 1 | 1 | 0s | 0s | ExtUtils::MakeMaker::Locale::BEGIN@3 | 
| 1 | 1 | 1 | 0s | 0s | ExtUtils::MakeMaker::Locale::BEGIN@6 | 
| 1 | 1 | 1 | 0s | 0s | ExtUtils::MakeMaker::Locale::GetACP (xsub) | 
| 3 | 2 | 1 | 0s | 0s | ExtUtils::MakeMaker::Locale::__ANON__[:107] | 
| 0 | 0 | 0 | 0s | 0s | ExtUtils::MakeMaker::Locale::_flush_aliases | 
| 0 | 0 | 0 | 0s | 0s | ExtUtils::MakeMaker::Locale::decode_argv | 
| 0 | 0 | 0 | 0s | 0s | ExtUtils::MakeMaker::Locale::env | 
| 0 | 0 | 0 | 0s | 0s | ExtUtils::MakeMaker::Locale::reinit | 
| Line | State ments  | 
      Time on line  | 
      Calls | Time in subs  | 
      Code | 
|---|---|---|---|---|---|
| 1 | package ExtUtils::MakeMaker::Locale; | ||||
| 2 | |||||
| 3 | 2 | 0s | 2 | 0s | # spent 0s within ExtUtils::MakeMaker::Locale::BEGIN@3 which was called:
#    once (0s+0s) by main::BEGIN@1 at line 3 # spent     0s making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@3
# spent     0s making 1 call to strict::import  | 
| 4 | 1 | 0s | our $VERSION = "7.04"; | ||
| 5 | |||||
| 6 | 2 | 0s | 2 | 0s | # spent 0s within ExtUtils::MakeMaker::Locale::BEGIN@6 which was called:
#    once (0s+0s) by main::BEGIN@1 at line 6 # spent     0s making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@6
# spent     0s making 1 call to base::import  | 
| 7 | 1 | 0s | our @EXPORT_OK = qw( | ||
| 8 | decode_argv env | ||||
| 9 | $ENCODING_LOCALE $ENCODING_LOCALE_FS | ||||
| 10 | $ENCODING_CONSOLE_IN $ENCODING_CONSOLE_OUT | ||||
| 11 | ); | ||||
| 12 | |||||
| 13 | 2 | 0s | 1 | 15.6ms | # spent 15.6ms (0s+15.6) within ExtUtils::MakeMaker::Locale::BEGIN@13 which was called:
#    once (0s+15.6ms) by main::BEGIN@1 at line 13 # spent  15.6ms making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@13  | 
| 14 | 2 | 0s | 1 | 0s | # spent 0s within ExtUtils::MakeMaker::Locale::BEGIN@14 which was called:
#    once (0s+0s) by main::BEGIN@1 at line 14 # spent     0s making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@14  | 
| 15 | |||||
| 16 | 1 | 0s | our $ENCODING_LOCALE; | ||
| 17 | 1 | 0s | our $ENCODING_LOCALE_FS; | ||
| 18 | 1 | 0s | our $ENCODING_CONSOLE_IN; | ||
| 19 | 1 | 0s | our $ENCODING_CONSOLE_OUT; | ||
| 20 | |||||
| 21 | sub DEBUG () { 0 } | ||||
| 22 | |||||
| 23 | # spent 31.2ms (15.6+15.6) within ExtUtils::MakeMaker::Locale::_init which was called:
#    once (15.6ms+15.6ms) by main::BEGIN@1 at line 102  | ||||
| 24 | 1 | 0s | if ($^O eq "MSWin32") { | ||
| 25 | 1 | 0s | unless ($ENCODING_LOCALE) { | ||
| 26 | # Try to obtain what the Windows ANSI code page is | ||||
| 27 | 1 | 0s | eval { | ||
| 28 | 1 | 0s | unless (defined &GetACP) { | ||
| 29 | 1 | 0s | require Win32::API; | ||
| 30 | 1 | 0s | 1 | 0s |                     Win32::API->Import('kernel32', 'int GetACP()');                     # spent     0s making 1 call to Win32::API::Import  | 
| 31 | }; | ||||
| 32 | 1 | 0s | if (defined &GetACP) { | ||
| 33 | 1 | 0s | 1 | 0s |                     my $cp = GetACP();                     # spent     0s making 1 call to ExtUtils::MakeMaker::Locale::GetACP  | 
| 34 | 1 | 0s | $ENCODING_LOCALE = "cp$cp" if $cp; | ||
| 35 | } | ||||
| 36 | }; | ||||
| 37 | } | ||||
| 38 | |||||
| 39 | 1 | 0s | unless ($ENCODING_CONSOLE_IN) { | ||
| 40 | # If we have the Win32::Console module installed we can ask | ||||
| 41 | # it for the code set to use | ||||
| 42 | 1 | 0s | eval { | ||
| 43 | 1 | 15.6ms | require Win32::Console; | ||
| 44 | 1 | 0s | 1 | 0s |                 my $cp = Win32::Console::InputCP();                 # spent     0s making 1 call to Win32::Console::InputCP  | 
| 45 | 1 | 0s | $ENCODING_CONSOLE_IN = "cp$cp" if $cp; | ||
| 46 | 1 | 0s | 1 | 0s |                 $cp = Win32::Console::OutputCP();                 # spent     0s making 1 call to Win32::Console::OutputCP  | 
| 47 | 1 | 0s | $ENCODING_CONSOLE_OUT = "cp$cp" if $cp; | ||
| 48 | }; | ||||
| 49 | # Invoking the 'chcp' program might also work | ||||
| 50 | 1 | 0s | if (!$ENCODING_CONSOLE_IN && (qx(chcp) || '') =~ /^Active code page: (\d+)/) { | ||
| 51 | $ENCODING_CONSOLE_IN = "cp$1"; | ||||
| 52 | } | ||||
| 53 | } | ||||
| 54 | } | ||||
| 55 | |||||
| 56 | 1 | 0s | unless ($ENCODING_LOCALE) { | ||
| 57 | eval { | ||||
| 58 | require I18N::Langinfo; | ||||
| 59 | $ENCODING_LOCALE = I18N::Langinfo::langinfo(I18N::Langinfo::CODESET()); | ||||
| 60 | |||||
| 61 | # Workaround of Encode < v2.25. The "646" encoding alias was | ||||
| 62 | # introduced in Encode-2.25, but we don't want to require that version | ||||
| 63 | # quite yet. Should avoid the CPAN testers failure reported from | ||||
| 64 | # openbsd-4.7/perl-5.10.0 combo. | ||||
| 65 | $ENCODING_LOCALE = "ascii" if $ENCODING_LOCALE eq "646"; | ||||
| 66 | |||||
| 67 | # https://rt.cpan.org/Ticket/Display.html?id=66373 | ||||
| 68 | $ENCODING_LOCALE = "hp-roman8" if $^O eq "hpux" && $ENCODING_LOCALE eq "roman8"; | ||||
| 69 | }; | ||||
| 70 | $ENCODING_LOCALE ||= $ENCODING_CONSOLE_IN; | ||||
| 71 | } | ||||
| 72 | |||||
| 73 | 1 | 0s | if ($^O eq "darwin") { | ||
| 74 | $ENCODING_LOCALE_FS ||= "UTF-8"; | ||||
| 75 | } | ||||
| 76 | |||||
| 77 | # final fallback | ||||
| 78 | 1 | 0s | $ENCODING_LOCALE ||= $^O eq "MSWin32" ? "cp1252" : "UTF-8"; | ||
| 79 | 1 | 0s | $ENCODING_LOCALE_FS ||= $ENCODING_LOCALE; | ||
| 80 | 1 | 0s | $ENCODING_CONSOLE_IN ||= $ENCODING_LOCALE; | ||
| 81 | 1 | 0s | $ENCODING_CONSOLE_OUT ||= $ENCODING_CONSOLE_IN; | ||
| 82 | |||||
| 83 | 1 | 0s | 1 | 0s |     unless (Encode::find_encoding($ENCODING_LOCALE)) {     # spent     0s making 1 call to Encode::find_encoding  | 
| 84 | my $foundit; | ||||
| 85 | if (lc($ENCODING_LOCALE) eq "gb18030") { | ||||
| 86 | eval { | ||||
| 87 | require Encode::HanExtra; | ||||
| 88 | }; | ||||
| 89 | if ($@) { | ||||
| 90 | die "Need Encode::HanExtra to be installed to support locale codeset ($ENCODING_LOCALE), stopped"; | ||||
| 91 | } | ||||
| 92 | $foundit++ if Encode::find_encoding($ENCODING_LOCALE); | ||||
| 93 | } | ||||
| 94 | die "The locale codeset ($ENCODING_LOCALE) isn't one that perl can decode, stopped" | ||||
| 95 | unless $foundit; | ||||
| 96 | |||||
| 97 | } | ||||
| 98 | |||||
| 99 | # use Data::Dump; ddx $ENCODING_LOCALE, $ENCODING_LOCALE_FS, $ENCODING_CONSOLE_IN, $ENCODING_CONSOLE_OUT; | ||||
| 100 | } | ||||
| 101 | |||||
| 102 | 1 | 0s | 1 | 31.2ms | _init(); # spent  31.2ms making 1 call to ExtUtils::MakeMaker::Locale::_init  | 
| 103 | # spent 0s within ExtUtils::MakeMaker::Locale::__ANON__[C:/tmp64ng/perl/lib/ExtUtils/MakeMaker/Locale.pm:107] which was called 3 times, avg 0s/call:
# 2 times (0s+0s) by Encode::Alias::find_alias at line 38 of Encode/Alias.pm, avg 0s/call
#    once (0s+0s) by Encode::Alias::define_alias at line 89 of Encode/Alias.pm  | ||||
| 104 | 2 | 0s | 2 | 0s | # spent 0s within ExtUtils::MakeMaker::Locale::BEGIN@104 which was called:
#    once (0s+0s) by main::BEGIN@1 at line 104     # spent     0s making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@104
    # spent     0s making 1 call to strict::unimport  | 
| 105 | 2 | 0s | 2 | 0s | # spent 0s within ExtUtils::MakeMaker::Locale::BEGIN@105 which was called:
#    once (0s+0s) by main::BEGIN@1 at line 105     # spent     0s making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@105
    # spent     0s making 1 call to warnings::unimport  | 
| 106 | 3 | 0s | return ${"ENCODING_" . uc(shift)}; | ||
| 107 | 1 | 0s | 1 | 0s | }, "locale"); # spent     0s making 1 call to Encode::Alias::define_alias  | 
| 108 | |||||
| 109 | sub _flush_aliases { | ||||
| 110 | 2 | 0s | 2 | 0s | # spent 0s within ExtUtils::MakeMaker::Locale::BEGIN@110 which was called:
#    once (0s+0s) by main::BEGIN@1 at line 110     # spent     0s making 1 call to ExtUtils::MakeMaker::Locale::BEGIN@110
    # spent     0s making 1 call to strict::unimport  | 
| 111 | for my $a (keys %Encode::Alias::Alias) { | ||||
| 112 | if (defined ${"ENCODING_" . uc($a)}) { | ||||
| 113 | delete $Encode::Alias::Alias{$a}; | ||||
| 114 | warn "Flushed alias cache for $a" if DEBUG; | ||||
| 115 | } | ||||
| 116 | } | ||||
| 117 | } | ||||
| 118 | |||||
| 119 | sub reinit { | ||||
| 120 | $ENCODING_LOCALE = shift; | ||||
| 121 | $ENCODING_LOCALE_FS = shift; | ||||
| 122 | $ENCODING_CONSOLE_IN = $ENCODING_LOCALE; | ||||
| 123 | $ENCODING_CONSOLE_OUT = $ENCODING_LOCALE; | ||||
| 124 | _init(); | ||||
| 125 | _flush_aliases(); | ||||
| 126 | } | ||||
| 127 | |||||
| 128 | sub decode_argv { | ||||
| 129 | die if defined wantarray; | ||||
| 130 | for (@ARGV) { | ||||
| 131 | $_ = Encode::decode(locale => $_, @_); | ||||
| 132 | } | ||||
| 133 | } | ||||
| 134 | |||||
| 135 | sub env { | ||||
| 136 | my $k = Encode::encode(locale => shift); | ||||
| 137 | my $old = $ENV{$k}; | ||||
| 138 | if (@_) { | ||||
| 139 | my $v = shift; | ||||
| 140 | if (defined $v) { | ||||
| 141 | $ENV{$k} = Encode::encode(locale => $v); | ||||
| 142 | } | ||||
| 143 | else { | ||||
| 144 | delete $ENV{$k}; | ||||
| 145 | } | ||||
| 146 | } | ||||
| 147 | return Encode::decode(locale => $old) if defined wantarray; | ||||
| 148 | } | ||||
| 149 | |||||
| 150 | 1 | 0s | 1; | ||
| 151 | |||||
| 152 | __END__ | ||||
# spent 0s within ExtUtils::MakeMaker::Locale::GetACP which was called:
#    once (0s+0s) by ExtUtils::MakeMaker::Locale::_init at line 33  |