Filename | /usr/local/lib/perl5/site_perl/Locale/Messages.pm |
Statements | Executed 246077 statements in 402ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
34661 | 1 | 1 | 364ms | 3.16s | gettext | Locale::Messages::
34661 | 1 | 1 | 132ms | 205ms | textdomain | Locale::Messages::
1150 | 1 | 1 | 6.28ms | 119ms | dgettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@119 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@228 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@23 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@235 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@242 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@25 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@253 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@262 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@271 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@282 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@291 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@300 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@311 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@320 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@329 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@338 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@347 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@356 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@363 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@370 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@377 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@384 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@391 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@398 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@405 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@412 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | BEGIN@419 | Locale::Messages::
0 | 0 | 0 | 0s | 0s | CORE:subst (opcode) | Locale::Messages::
0 | 0 | 0 | 0s | 0s | LC_ALL | Locale::Messages::
0 | 0 | 0 | 0s | 0s | LC_COLLATE | Locale::Messages::
0 | 0 | 0 | 0s | 0s | LC_CTYPE | Locale::Messages::
0 | 0 | 0 | 0s | 0s | LC_MESSAGES | Locale::Messages::
0 | 0 | 0 | 0s | 0s | LC_MONETARY | Locale::Messages::
0 | 0 | 0 | 0s | 0s | LC_NUMERIC | Locale::Messages::
0 | 0 | 0 | 0s | 0s | LC_TIME | Locale::Messages::
0 | 0 | 0 | 0s | 0s | bind_textdomain_codeset | Locale::Messages::
0 | 0 | 0 | 0s | 0s | bind_textdomain_filter | Locale::Messages::
0 | 0 | 0 | 0s | 0s | bindtextdomain | Locale::Messages::
0 | 0 | 0 | 0s | 0s | dcgettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | dcngettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | dcnpgettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | dcpgettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | dngettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | dnpgettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | dpgettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | ngettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | nl_putenv | Locale::Messages::
0 | 0 | 0 | 0s | 0s | npgettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | pgettext | Locale::Messages::
0 | 0 | 0 | 0s | 0s | select_package | Locale::Messages::
0 | 0 | 0 | 0s | 0s | setlocale | Locale::Messages::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | #! /bin/false | ||||
2 | |||||
3 | # vim: set autoindent shiftwidth=4 tabstop=4: | ||||
4 | |||||
5 | # Copyright (C) 2002-2017 Guido Flohr <guido.flohr@cantanea.com>, | ||||
6 | # all rights reserved. | ||||
7 | |||||
8 | # This program is free software: you can redistribute it and/or modify | ||||
9 | # it under the terms of the GNU General Public License as published by | ||||
10 | # the Free Software Foundation; either version 3 of the License, or | ||||
11 | # (at your option) any later version. | ||||
12 | |||||
13 | # This program is distributed in the hope that it will be useful, | ||||
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
16 | # GNU General Public License for more details. | ||||
17 | |||||
18 | # You should have received a copy of the GNU General Public License | ||||
19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
20 | |||||
21 | package Locale::Messages; | ||||
22 | |||||
23 | use strict; | ||||
24 | |||||
25 | use vars qw ($package @EXPORT_OK %EXPORT_TAGS @ISA $VERSION); | ||||
26 | |||||
27 | $VERSION = '1.32'; | ||||
28 | |||||
29 | # Try to load the C version first. | ||||
30 | $package = 'gettext_xs'; | ||||
31 | |||||
32 | # Do not load from current working directory. | ||||
33 | local @INC = grep { $_ ne '.' } @INC; | ||||
34 | |||||
35 | eval <<'EOF'; # spent 0s executing statements in string eval | ||||
36 | require Locale::gettext_xs; | ||||
37 | my $version = Locale::gettext_xs::__gettext_xs_version(); | ||||
38 | die "Version: version mismatch ($VERSION vs. $version)" unless $version eq $VERSION; | ||||
39 | EOF | ||||
40 | my $no_xs = $@; | ||||
41 | |||||
42 | # There are systems where setlocale() and the LC_ constants are not | ||||
43 | # defined at all, see https://rt.cpan.org/Ticket/Display.html?id=98109 | ||||
44 | # | ||||
45 | # On such systems, we always fall back to gettext_dumb. | ||||
46 | if ($no_xs) { | ||||
47 | eval { | ||||
48 | require POSIX; | ||||
49 | # void | ||||
50 | POSIX::setlocale(POSIX::LC_ALL()); | ||||
51 | }; | ||||
52 | if ($@) { | ||||
53 | $package = 'gettext_dumb'; | ||||
54 | require Locale::gettext_dumb; | ||||
55 | } else { | ||||
56 | $package = 'gettext_pp'; | ||||
57 | require Locale::gettext_pp; | ||||
58 | } | ||||
59 | } | ||||
60 | |||||
61 | require Exporter; | ||||
62 | @ISA = qw (Exporter); | ||||
63 | %EXPORT_TAGS = (locale_h => [ qw (gettext | ||||
64 | dgettext | ||||
65 | dcgettext | ||||
66 | ngettext | ||||
67 | dngettext | ||||
68 | dcngettext | ||||
69 | pgettext | ||||
70 | dpgettext | ||||
71 | dcpgettext | ||||
72 | npgettext | ||||
73 | dnpgettext | ||||
74 | dcnpgettext | ||||
75 | textdomain | ||||
76 | bindtextdomain | ||||
77 | bind_textdomain_codeset | ||||
78 | ) | ||||
79 | ], | ||||
80 | libintl_h => [ qw (LC_CTYPE | ||||
81 | LC_NUMERIC | ||||
82 | LC_TIME | ||||
83 | LC_COLLATE | ||||
84 | LC_MONETARY | ||||
85 | LC_MESSAGES | ||||
86 | LC_ALL) | ||||
87 | ], | ||||
88 | ); | ||||
89 | |||||
90 | @EXPORT_OK = qw (select_package | ||||
91 | turn_utf_8_on | ||||
92 | turn_utf_8_off | ||||
93 | gettext | ||||
94 | dgettext | ||||
95 | dcgettext | ||||
96 | ngettext | ||||
97 | dngettext | ||||
98 | dcngettext | ||||
99 | pgettext | ||||
100 | dpgettext | ||||
101 | dcpgettext | ||||
102 | npgettext | ||||
103 | dnpgettext | ||||
104 | dcnpgettext | ||||
105 | textdomain | ||||
106 | bindtextdomain | ||||
107 | bind_textdomain_codeset | ||||
108 | bind_textdomain_filter | ||||
109 | nl_putenv | ||||
110 | setlocale | ||||
111 | LC_CTYPE | ||||
112 | LC_NUMERIC | ||||
113 | LC_TIME | ||||
114 | LC_COLLATE | ||||
115 | LC_MONETARY | ||||
116 | LC_MESSAGES | ||||
117 | LC_ALL); | ||||
118 | |||||
119 | BEGIN { | ||||
120 | my ($has_encode, $has_bytes); | ||||
121 | |||||
122 | if ($] >= 5.006) { | ||||
123 | unless (defined $has_encode) { | ||||
124 | eval "require Encode"; # spent 0s executing statements in string eval | ||||
125 | $has_encode = !$@; | ||||
126 | } | ||||
127 | |||||
128 | unless ($has_encode || defined $has_bytes) { | ||||
129 | eval "use bytes"; | ||||
130 | $has_bytes = !$@; | ||||
131 | } | ||||
132 | } | ||||
133 | |||||
134 | # Turn the UTF-8 flag on or off unconditionally. The prototypes | ||||
135 | # allow an optional second parameter, so that you can use the | ||||
136 | # functions as callbacks to bind_textdomain_filter. | ||||
137 | if ($has_encode) { | ||||
138 | eval <<'EOF'; # spent 355ms executing statements in string eval # includes 200ms spent executing 71622 calls to 2 subs defined therein. | ||||
139 | sub turn_utf_8_on($;$) | ||||
140 | { | ||||
141 | Encode::_utf8_on ($_[0]); | ||||
142 | return $_[0]; | ||||
143 | } | ||||
144 | |||||
145 | sub turn_utf_8_off($;$) | ||||
146 | { | ||||
147 | Encode::_utf8_off ($_[0]); | ||||
148 | return $_[0]; | ||||
149 | } | ||||
150 | |||||
151 | EOF | ||||
152 | } elsif ($has_bytes) { | ||||
153 | eval <<'EOF'; | ||||
154 | sub turn_utf_8_on($;$) | ||||
155 | { | ||||
156 | $_[0] = pack "U0C*", unpack "C*", $_[0]; | ||||
157 | } | ||||
158 | |||||
159 | sub turn_utf_8_off($;$) | ||||
160 | { | ||||
161 | use bytes; | ||||
162 | $_[0] = join "", split //, $_[0]; | ||||
163 | } | ||||
164 | |||||
165 | EOF | ||||
166 | } else { | ||||
167 | eval <<'EOF'; | ||||
168 | sub turn_utf_8_on($;$) | ||||
169 | { | ||||
170 | return $_[0]; | ||||
171 | } | ||||
172 | |||||
173 | sub turn_utf_8_off($;$) | ||||
174 | { | ||||
175 | return $_[0]; | ||||
176 | } | ||||
177 | |||||
178 | EOF | ||||
179 | } | ||||
180 | } | ||||
181 | |||||
182 | # The textdomain could be undef. We avoid a warning by specifying | ||||
183 | # a filter for the undefined textdomain. | ||||
184 | my %filters = (undef => \&turn_utf_8_off); | ||||
185 | |||||
186 | sub select_package { | ||||
187 | my ($pkg, $compatibility) = @_; | ||||
188 | |||||
189 | # Compatibility quirk for a bug pre 1.17: | ||||
190 | if (__PACKAGE__ eq $pkg && defined $compatibility) { | ||||
191 | $pkg = $compatibility; | ||||
192 | } | ||||
193 | |||||
194 | if ($no_xs && 'gettext_xs' eq $pkg) { | ||||
195 | $pkg = 'gettext_pp'; | ||||
196 | } | ||||
197 | |||||
198 | if (defined $pkg && 'gettext_pp' eq $pkg) { | ||||
199 | # This branch is not unnecessary. The next (elsif) branch does | ||||
200 | # essentially the same but catches compilation errors. | ||||
201 | require Locale::gettext_pp; | ||||
202 | $package = 'gettext_pp'; | ||||
203 | } elsif (defined $pkg) { | ||||
204 | my $filename = "Locale::$pkg"; | ||||
205 | $filename =~ s{::|\'}{/}; | ||||
206 | $filename .= '.pm'; | ||||
207 | eval { require $filename }; | ||||
208 | $package = $pkg unless $@; | ||||
209 | } else { | ||||
210 | eval "require Locale::gettext_xs"; | ||||
211 | $package = 'gettext_xs' unless $@; | ||||
212 | } | ||||
213 | |||||
214 | return $package; | ||||
215 | } | ||||
216 | |||||
217 | sub bind_textdomain_filter ($;$$) { | ||||
218 | my ($textdomain, $coderef, $data) = @_; | ||||
219 | |||||
220 | $filters{$textdomain} = [ $coderef, $data ]; | ||||
221 | |||||
222 | return 1; | ||||
223 | } | ||||
224 | |||||
225 | # spent 205ms (132+72.6) within Locale::Messages::textdomain which was called 34661 times, avg 6µs/call:
# 34661 times (132ms+72.6ms) by Locale::Messages::gettext at line 247, avg 6µs/call | ||||
226 | 34661 | 8.61ms | my $function = "Locale::${package}::textdomain"; | ||
227 | |||||
228 | no strict 'refs'; | ||||
229 | 34661 | 172ms | 34661 | 72.6ms | &$function; # spent 72.6ms making 34661 calls to Locale::gettext_pp::textdomain, avg 2µs/call |
230 | } | ||||
231 | |||||
232 | sub bindtextdomain ($;$) { | ||||
233 | my $function = "Locale::${package}::bindtextdomain"; | ||||
234 | |||||
235 | no strict 'refs'; | ||||
236 | &$function; | ||||
237 | } | ||||
238 | |||||
239 | sub bind_textdomain_codeset ($;$) { | ||||
240 | my $function = "Locale::${package}::bind_textdomain_codeset"; | ||||
241 | |||||
242 | no strict 'refs'; | ||||
243 | &$function; | ||||
244 | } | ||||
245 | |||||
246 | # spent 3.16s (364ms+2.80) within Locale::Messages::gettext which was called 34661 times, avg 91µs/call:
# 34661 times (364ms+2.80s) by Sympa::Language::_resolve_gettext_locale at line 383 of /usr/local/libexec/sympa/Sympa/Language.pm, avg 91µs/call | ||||
247 | 34661 | 28.5ms | 34661 | 205ms | my $textdomain = textdomain; # spent 205ms making 34661 calls to Locale::Messages::textdomain, avg 6µs/call |
248 | 34661 | 10.3ms | $filters{$textdomain} ||= [ \&turn_utf_8_off ]; | ||
249 | 34661 | 9.30ms | my $cb = $filters{$textdomain}; | ||
250 | |||||
251 | 34661 | 7.49ms | my $function = "Locale::${package}::gettext"; | ||
252 | |||||
253 | no strict 'refs'; | ||||
254 | 34661 | 159ms | 69322 | 2.59s | $cb->[0] (&$function, $cb->[1]); # spent 2.47s making 34661 calls to Locale::gettext_dumb::gettext, avg 71µs/call
# spent 123ms making 34661 calls to Locale::Messages::turn_utf_8_off, avg 4µs/call |
255 | } | ||||
256 | |||||
257 | # spent 119ms (6.28+113) within Locale::Messages::dgettext which was called 1150 times, avg 103µs/call:
# 1150 times (6.28ms+113ms) by Sympa::Language::dgettext at line 593 of /usr/local/libexec/sympa/Sympa/Language.pm, avg 103µs/call | ||||
258 | 1150 | 863µs | my $cb = $filters{$_[0]} ||= [ \&turn_utf_8_off ]; | ||
259 | |||||
260 | 1150 | 417µs | my $function = "Locale::${package}::dgettext"; | ||
261 | |||||
262 | no strict 'refs'; | ||||
263 | 1150 | 5.51ms | 2300 | 113ms | $cb->[0] (&$function, $cb->[1]); # spent 110ms making 1150 calls to Locale::gettext_dumb::dgettext, avg 95µs/call
# spent 2.85ms making 1150 calls to Locale::Messages::turn_utf_8_off, avg 2µs/call |
264 | } | ||||
265 | |||||
266 | sub dcgettext($$$) { | ||||
267 | my $cb = $filters{$_[0]} ||= [ \&turn_utf_8_off ]; | ||||
268 | |||||
269 | my $function = "Locale::${package}::dcgettext"; | ||||
270 | |||||
271 | no strict 'refs'; | ||||
272 | $cb->[0] (&$function, $cb->[1]); | ||||
273 | } | ||||
274 | |||||
275 | sub ngettext($$$) { | ||||
276 | my $textdomain = textdomain; | ||||
277 | $filters{$textdomain} ||= [ \&turn_utf_8_off ]; | ||||
278 | my $cb = $filters{$textdomain}; | ||||
279 | |||||
280 | my $function = "Locale::${package}::ngettext"; | ||||
281 | |||||
282 | no strict 'refs'; | ||||
283 | $cb->[0] (&$function, $cb->[1]); | ||||
284 | } | ||||
285 | |||||
286 | sub dngettext($$$$) { | ||||
287 | my $cb = $filters{$_[0]} ||= [ \&turn_utf_8_off ]; | ||||
288 | |||||
289 | my $function = "Locale::${package}::dngettext"; | ||||
290 | |||||
291 | no strict 'refs'; | ||||
292 | $cb->[0] (&$function, $cb->[1]); | ||||
293 | } | ||||
294 | |||||
295 | sub dcngettext($$$$$) { | ||||
296 | my $cb = $filters{$_[0]} ||= [ \&turn_utf_8_off ]; | ||||
297 | |||||
298 | my $function = "Locale::${package}::dcngettext"; | ||||
299 | |||||
300 | no strict 'refs'; | ||||
301 | $cb->[0] (&$function, $cb->[1]); | ||||
302 | } | ||||
303 | |||||
304 | sub pgettext($$) { | ||||
305 | my $textdomain = textdomain; | ||||
306 | $filters{$textdomain} ||= [ \&turn_utf_8_off ]; | ||||
307 | my $cb = $filters{$textdomain}; | ||||
308 | |||||
309 | my $function = "Locale::${package}::pgettext"; | ||||
310 | |||||
311 | no strict 'refs'; | ||||
312 | $cb->[0] (&$function, $cb->[1]); | ||||
313 | } | ||||
314 | |||||
315 | sub dpgettext($$$) { | ||||
316 | my $cb = $filters{$_[0]} ||= [ \&turn_utf_8_off ]; | ||||
317 | |||||
318 | my $function = "Locale::${package}::dpgettext"; | ||||
319 | |||||
320 | no strict 'refs'; | ||||
321 | $cb->[0] (&$function, $cb->[1]); | ||||
322 | } | ||||
323 | |||||
324 | sub dcpgettext($$$$) { | ||||
325 | my $cb = $filters{$_[0]} ||= [ \&turn_utf_8_off ]; | ||||
326 | |||||
327 | my $function = "Locale::${package}::dcpgettext"; | ||||
328 | |||||
329 | no strict 'refs'; | ||||
330 | $cb->[0] (&$function, $cb->[1]); | ||||
331 | } | ||||
332 | |||||
333 | sub npgettext($$$$) { | ||||
334 | my $cb = $filters{$_[0]} ||= [ \&turn_utf_8_off ]; | ||||
335 | |||||
336 | my $function = "Locale::${package}::npgettext"; | ||||
337 | |||||
338 | no strict 'refs'; | ||||
339 | $cb->[0] (&$function, $cb->[1]); | ||||
340 | } | ||||
341 | |||||
342 | sub dnpgettext($$$$$) { | ||||
343 | my $cb = $filters{$_[0]} ||= [ \&turn_utf_8_off ]; | ||||
344 | |||||
345 | my $function = "Locale::${package}::dnpgettext"; | ||||
346 | |||||
347 | no strict 'refs'; | ||||
348 | $cb->[0] (&$function, $cb->[1]); | ||||
349 | } | ||||
350 | |||||
351 | sub dcnpgettext($$$$$$) { | ||||
352 | my $cb = $filters{$_[0]} ||= [ \&turn_utf_8_off ]; | ||||
353 | |||||
354 | my $function = "Locale::${package}::dcnpgettext"; | ||||
355 | |||||
356 | no strict 'refs'; | ||||
357 | $cb->[0] (&$function, $cb->[1]); | ||||
358 | } | ||||
359 | |||||
360 | sub setlocale($;$) { | ||||
361 | my $function = "Locale::${package}::setlocale"; | ||||
362 | |||||
363 | no strict 'refs'; | ||||
364 | &$function; | ||||
365 | } | ||||
366 | |||||
367 | sub nl_putenv($) { | ||||
368 | my $function = "Locale::${package}::nl_putenv"; | ||||
369 | |||||
370 | no strict 'refs'; | ||||
371 | &$function; | ||||
372 | } | ||||
373 | |||||
374 | sub LC_NUMERIC { | ||||
375 | my $function = "Locale::${package}::LC_NUMERIC"; | ||||
376 | |||||
377 | no strict 'refs'; | ||||
378 | &$function; | ||||
379 | } | ||||
380 | |||||
381 | sub LC_CTYPE { | ||||
382 | my $function = "Locale::${package}::LC_CTYPE"; | ||||
383 | |||||
384 | no strict 'refs'; | ||||
385 | &$function; | ||||
386 | } | ||||
387 | |||||
388 | sub LC_TIME { | ||||
389 | my $function = "Locale::${package}::LC_TIME"; | ||||
390 | |||||
391 | no strict 'refs'; | ||||
392 | &$function; | ||||
393 | } | ||||
394 | |||||
395 | sub LC_COLLATE { | ||||
396 | my $function = "Locale::${package}::LC_COLLATE"; | ||||
397 | |||||
398 | no strict 'refs'; | ||||
399 | &$function; | ||||
400 | } | ||||
401 | |||||
402 | sub LC_MONETARY { | ||||
403 | my $function = "Locale::${package}::LC_MONETARY"; | ||||
404 | |||||
405 | no strict 'refs'; | ||||
406 | &$function; | ||||
407 | } | ||||
408 | |||||
409 | sub LC_MESSAGES { | ||||
410 | my $function = "Locale::${package}::LC_MESSAGES"; | ||||
411 | |||||
412 | no strict 'refs'; | ||||
413 | &$function; | ||||
414 | } | ||||
415 | |||||
416 | sub LC_ALL { | ||||
417 | my $function = "Locale::${package}::LC_ALL"; | ||||
418 | |||||
419 | no strict 'refs'; | ||||
420 | &$function; | ||||
421 | } | ||||
422 | |||||
423 | 1; | ||||
424 | |||||
425 | __END__ |