| Filename | /usr/share/perl/5.28/locale.pm |
| Statements | Executed 11 statements in 474µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 18µs | 33µs | locale::BEGIN@4 |
| 1 | 1 | 1 | 5µs | 5µs | locale::import |
| 0 | 0 | 0 | 0s | 0s | locale::unimport |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package locale; | ||||
| 2 | |||||
| 3 | 1 | 300ns | our $VERSION = '1.09'; | ||
| 4 | 2 | 460µs | 2 | 48µs | # spent 33µs (18+15) within locale::BEGIN@4 which was called:
# once (18µs+15µs) by Template::Filters::BEGIN@24 at line 4 # spent 33µs making 1 call to locale::BEGIN@4
# spent 15µs making 1 call to Config::import |
| 5 | |||||
| 6 | 1 | 1µs | $Carp::Internal{ (__PACKAGE__) } = 1; | ||
| 7 | |||||
| 8 | # A separate bit is used for each of the two forms of the pragma, to save | ||||
| 9 | # having to look at %^H for the normal case of a plain 'use locale' without an | ||||
| 10 | # argument. | ||||
| 11 | |||||
| 12 | 1 | 100ns | $locale::hint_bits = 0x4; | ||
| 13 | 1 | 100ns | $locale::partial_hint_bits = 0x10; # If pragma has an argument | ||
| 14 | |||||
| 15 | # The pseudo-category :characters consists of 2 real ones; but it also is | ||||
| 16 | # given its own number, -1, because in the complement form it also has the | ||||
| 17 | # side effect of "use feature 'unicode_strings'" | ||||
| 18 | |||||
| 19 | # spent 5µs within locale::import which was called:
# once (5µs+0s) by Template::Filters::BEGIN@24 at line 24 of Template/Filters.pm | ||||
| 20 | 1 | 100ns | shift; # should be 'locale'; not checked | ||
| 21 | |||||
| 22 | 1 | 2µs | $^H{locale} = 0 unless defined $^H{locale}; | ||
| 23 | 1 | 5µs | if (! @_) { # If no parameter, use the plain form that changes all categories | ||
| 24 | 1 | 1µs | $^H |= $locale::hint_bits; | ||
| 25 | |||||
| 26 | } | ||||
| 27 | else { | ||||
| 28 | my @categories = ( qw(:ctype :collate :messages | ||||
| 29 | :numeric :monetary :time) ); | ||||
| 30 | for (my $i = 0; $i < @_; $i++) { | ||||
| 31 | my $arg = $_[$i]; | ||||
| 32 | $complement = $arg =~ s/ : ( ! | not_ ) /:/x; | ||||
| 33 | if (! grep { $arg eq $_ } @categories, ":characters") { | ||||
| 34 | require Carp; | ||||
| 35 | Carp::croak("Unknown parameter '$_[$i]' to 'use locale'"); | ||||
| 36 | } | ||||
| 37 | |||||
| 38 | if ($complement) { | ||||
| 39 | if ($i != 0 || $i < @_ - 1) { | ||||
| 40 | require Carp; | ||||
| 41 | Carp::croak("Only one argument to 'use locale' allowed" | ||||
| 42 | . "if is $complement"); | ||||
| 43 | } | ||||
| 44 | |||||
| 45 | if ($arg eq ':characters') { | ||||
| 46 | push @_, grep { $_ ne ':ctype' && $_ ne ':collate' } | ||||
| 47 | @categories; | ||||
| 48 | # We add 1 to the category number; This category number | ||||
| 49 | # is -1 | ||||
| 50 | $^H{locale} |= (1 << 0); | ||||
| 51 | } | ||||
| 52 | else { | ||||
| 53 | push @_, grep { $_ ne $arg } @categories; | ||||
| 54 | } | ||||
| 55 | next; | ||||
| 56 | } | ||||
| 57 | elsif ($arg eq ':characters') { | ||||
| 58 | push @_, ':ctype', ':collate'; | ||||
| 59 | next; | ||||
| 60 | } | ||||
| 61 | |||||
| 62 | $^H |= $locale::partial_hint_bits; | ||||
| 63 | |||||
| 64 | # This form of the pragma overrides the other | ||||
| 65 | $^H &= ~$locale::hint_bits; | ||||
| 66 | |||||
| 67 | $arg =~ s/^://; | ||||
| 68 | |||||
| 69 | eval { require POSIX; import POSIX 'locale_h'; }; | ||||
| 70 | |||||
| 71 | # Map our names to the ones defined by POSIX | ||||
| 72 | my $LC = "LC_" . uc($arg); | ||||
| 73 | |||||
| 74 | my $bit = eval "&POSIX::$LC"; | ||||
| 75 | if (defined $bit) { # XXX Should we warn that this category isn't | ||||
| 76 | # supported on this platform, or make it | ||||
| 77 | # always be the C locale? | ||||
| 78 | |||||
| 79 | # Verify our assumption. | ||||
| 80 | if (! ($bit >= 0 && $bit < 31)) { | ||||
| 81 | require Carp; | ||||
| 82 | Carp::croak("Cannot have ':$arg' parameter to 'use locale'" | ||||
| 83 | . " on this platform. Use the 'perlbug' utility" | ||||
| 84 | . " to report this problem, or send email to" | ||||
| 85 | . " 'perlbug\@perl.org'. $LC=$bit"); | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | # 1 is added so that the pseudo-category :characters, which is | ||||
| 89 | # -1, comes out 0. | ||||
| 90 | $^H{locale} |= 1 << ($bit + 1); | ||||
| 91 | } | ||||
| 92 | } | ||||
| 93 | } | ||||
| 94 | |||||
| 95 | } | ||||
| 96 | |||||
| 97 | sub unimport { | ||||
| 98 | $^H &= ~($locale::hint_bits|$locale::partial_hint_bits); | ||||
| 99 | $^H{locale} = 0; | ||||
| 100 | } | ||||
| 101 | |||||
| 102 | 1 | 4µs | 1; |