line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::Msgfmt::mo; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
72
|
use 5.008005; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
167
|
|
4
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
123
|
|
5
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
98
|
|
6
|
4
|
|
|
4
|
|
2145
|
use Locale::Msgfmt::Utils (); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
2505
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.15'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
15
|
|
|
15
|
0
|
57
|
return bless {}, shift; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub initialize { |
15
|
15
|
|
|
15
|
0
|
24
|
my $self = shift; |
16
|
15
|
|
|
|
|
56
|
$self->{magic} = "0x950412de"; |
17
|
15
|
|
|
|
|
22
|
$self->{format} = 0; |
18
|
15
|
|
|
|
|
48
|
$self->{strings} = {}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub add_string { |
22
|
445
|
|
|
445
|
0
|
2340
|
$_[0]->{strings}->{$_[1]} = $_[2]; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub prepare { |
26
|
15
|
|
|
15
|
0
|
22
|
my $self = shift; |
27
|
15
|
|
|
|
|
18
|
$self->{count} = scalar keys %{ $self->{strings} }; |
|
15
|
|
|
|
|
49
|
|
28
|
15
|
|
|
|
|
43
|
$self->{free_mem} = 28 + $self->{count} * 16; |
29
|
15
|
|
|
|
|
20
|
$self->{sorted} = [ sort keys %{ $self->{strings} } ]; |
|
15
|
|
|
|
|
445
|
|
30
|
445
|
|
|
|
|
1032
|
$self->{translations} = [ |
31
|
15
|
|
|
|
|
41
|
map { $self->{strings}->{$_} } @{ $self->{sorted} } |
|
15
|
|
|
|
|
30
|
|
32
|
|
|
|
|
|
|
]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub out { |
36
|
15
|
|
|
15
|
0
|
21
|
my $self = shift; |
37
|
15
|
|
|
|
|
21
|
my $file = shift; |
38
|
15
|
50
|
|
|
|
1069
|
open my $OUT, ">", $file or die "Could not open ($file) $!"; |
39
|
15
|
|
|
|
|
31
|
binmode $OUT; |
40
|
15
|
|
|
|
|
57
|
print $OUT Locale::Msgfmt::Utils::from_hex( $self->{magic} ); |
41
|
15
|
|
|
|
|
48
|
print $OUT Locale::Msgfmt::Utils::character( $self->{format} ); |
42
|
15
|
|
|
|
|
43
|
print $OUT Locale::Msgfmt::Utils::character( $self->{count} ); |
43
|
15
|
|
|
|
|
37
|
print $OUT Locale::Msgfmt::Utils::character(28); |
44
|
15
|
|
|
|
|
52
|
print $OUT Locale::Msgfmt::Utils::character( 28 + $self->{count} * 8 ); |
45
|
15
|
|
|
|
|
36
|
print $OUT Locale::Msgfmt::Utils::character(0); |
46
|
15
|
|
|
|
|
38
|
print $OUT Locale::Msgfmt::Utils::character(0); |
47
|
|
|
|
|
|
|
|
48
|
15
|
|
|
|
|
19
|
foreach ( @{ $self->{sorted} } ) { |
|
15
|
|
|
|
|
44
|
|
49
|
445
|
|
|
|
|
495
|
my $length = length($_); |
50
|
445
|
|
|
|
|
923
|
print $OUT Locale::Msgfmt::Utils::character($length); |
51
|
445
|
|
|
|
|
1150
|
print $OUT Locale::Msgfmt::Utils::character( $self->{free_mem} ); |
52
|
445
|
|
|
|
|
1009
|
$self->{free_mem} += $length + 1; |
53
|
|
|
|
|
|
|
} |
54
|
15
|
|
|
|
|
27
|
foreach ( @{ $self->{translations} } ) { |
|
15
|
|
|
|
|
64
|
|
55
|
445
|
|
|
|
|
511
|
my $length = length($_); |
56
|
445
|
|
|
|
|
1319
|
print $OUT Locale::Msgfmt::Utils::character($length); |
57
|
445
|
|
|
|
|
1267
|
print $OUT Locale::Msgfmt::Utils::character( $self->{free_mem} ); |
58
|
445
|
|
|
|
|
867
|
$self->{free_mem} += $length + 1; |
59
|
|
|
|
|
|
|
} |
60
|
15
|
|
|
|
|
20
|
foreach ( @{ $self->{sorted} } ) { |
|
15
|
|
|
|
|
31
|
|
61
|
445
|
|
|
|
|
1196
|
print $OUT Locale::Msgfmt::Utils::null_terminate($_); |
62
|
|
|
|
|
|
|
} |
63
|
15
|
|
|
|
|
23
|
foreach ( @{ $self->{translations} } ) { |
|
15
|
|
|
|
|
34
|
|
64
|
445
|
|
|
|
|
1165
|
print $OUT Locale::Msgfmt::Utils::null_terminate($_); |
65
|
|
|
|
|
|
|
} |
66
|
15
|
|
|
|
|
653
|
close $OUT; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |