Locale/Msgfmt/mo.pm

filter: Statementstmt 100% 58 / 58 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 5 totaltotal 91.8% 68 / 74 CC 6 SCAR 11.5
CC
6
Cov
98%
out
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.1
« Locale/Msgfmt/po.pm ↑ Summary Locale/Msgfmt/Utils.pm »
1 package Locale::Msgfmt::mo;
2  
3 4 ▶use 5.008005;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Locale::Msgfmt::Utils ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 our $VERSION = '0.15';
9  
10 15 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
11 15 return bless {}, shift;
12 }
13  
14 15 ▶sub initialize {
Subroutine initialize: called CC=1 SCAR=0.0
Pod undocumented
15 15 my $self = shift;
16 15 $self->{magic} = "0x950412de";
17 15 $self->{format} = 0;
18 15 $self->{strings} = {};
19 }
20  
21 445 ▶sub add_string {
Subroutine add_string: called CC=1 SCAR=0.0
Pod undocumented
22 445 $_[0]->{strings}->{$_[1]} = $_[2];
23 }
24  
25 15 ▶sub prepare {
Subroutine prepare: called CC=1 SCAR=0.0
Pod undocumented
26 15 my $self = shift;
27 15 $self->{count} = scalar keys %{ $self->{strings} };
28 15 $self->{free_mem} = 28 + $self->{count} * 16;
29 15 $self->{sorted} = [ sort keys %{ $self->{strings} } ];
30 $self->{translations} = [
31 15 map { $self->{strings}->{$_} } @{ $self->{sorted} }
32 ];
33 }
34  
35 15 ▶sub out {
Subroutine out: called CC=6 SCAR=17.9
Pod undocumented
36 15 my $self = shift;
37 15 my $file = shift;
38 15 ▶ open my $OUT, ">", $file or die "Could not open ($file) $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $OUT, ">", $file or die "Could not open ($file) $!" 15 0 15
39 15 binmode $OUT;
40 15 print $OUT Locale::Msgfmt::Utils::from_hex( $self->{magic} );
41 15 print $OUT Locale::Msgfmt::Utils::character( $self->{format} );
42 15 print $OUT Locale::Msgfmt::Utils::character( $self->{count} );
43 15 print $OUT Locale::Msgfmt::Utils::character(28);
44 15 print $OUT Locale::Msgfmt::Utils::character( 28 + $self->{count} * 8 );
45 15 print $OUT Locale::Msgfmt::Utils::character(0);
46 15 print $OUT Locale::Msgfmt::Utils::character(0);
47  
48 15 foreach ( @{ $self->{sorted} } ) {
49 445 my $length = length($_);
50 445 print $OUT Locale::Msgfmt::Utils::character($length);
51 445 print $OUT Locale::Msgfmt::Utils::character( $self->{free_mem} );
52 445 $self->{free_mem} += $length + 1;
53 }
54 15 foreach ( @{ $self->{translations} } ) {
55 445 my $length = length($_);
56 445 print $OUT Locale::Msgfmt::Utils::character($length);
57 445 print $OUT Locale::Msgfmt::Utils::character( $self->{free_mem} );
58 445 $self->{free_mem} += $length + 1;
59 }
60 15 foreach ( @{ $self->{sorted} } ) {
61 445 print $OUT Locale::Msgfmt::Utils::null_terminate($_);
62 }
63 15 foreach ( @{ $self->{translations} } ) {
64 445 print $OUT Locale::Msgfmt::Utils::null_terminate($_);
65 }
66 15 close $OUT;
67 }
68  
69 4 1;
70  
71 __END__
« Locale/Msgfmt/po.pm ↑ Summary Locale/Msgfmt/Utils.pm »