line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2007-2017 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
5
|
|
|
5
|
|
477
|
use warnings; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
190
|
|
6
|
5
|
|
|
5
|
|
35
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
194
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Log::Report::Lexicon::POTcompact; |
9
|
5
|
|
|
5
|
|
36
|
use vars '$VERSION'; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
300
|
|
10
|
|
|
|
|
|
|
$VERSION = '1.08'; |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
35
|
use base 'Log::Report::Lexicon::Table'; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
1468
|
|
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
43
|
use Log::Report 'log-report-lexicon'; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
36
|
|
15
|
5
|
|
|
5
|
|
1444
|
use Log::Report::Util qw/escape_chars unescape_chars/; |
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
5280
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _unescape($$); |
18
|
|
|
|
|
|
|
sub _escape($$); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub read($@) |
22
|
1
|
|
|
1
|
1
|
740
|
{ my ($class, $fn, %args) = @_; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
4
|
my $self = bless {}, $class; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $charset = $args{charset} |
27
|
1
|
50
|
|
|
|
8
|
or error __x"charset parameter required for {fn}", fn => $fn; |
28
|
|
|
|
|
|
|
|
29
|
1
|
50
|
|
1
|
|
45
|
open my $fh, "<:encoding($charset):crlf", $fn |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
30
|
|
|
|
|
|
|
or fault __x"cannot read in {cs} from file {fn}" |
31
|
|
|
|
|
|
|
, cs => $charset, fn => $fn; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Speed! |
34
|
1
|
|
|
|
|
1612
|
my $msgctxt = ''; |
35
|
1
|
|
|
|
|
3
|
my ($last, $msgid, @msgstr); |
36
|
1
|
|
50
|
|
|
17
|
my $index = $self->{index} ||= {}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
LINE: |
39
|
1
|
|
|
|
|
40
|
while(my $line = $fh->getline) |
40
|
50
|
100
|
|
|
|
2944
|
{ next if substr($line, 0, 1) eq '#'; |
41
|
|
|
|
|
|
|
|
42
|
34
|
100
|
|
|
|
189
|
if($line =~ m/^\s*$/) # blank line starts new |
43
|
7
|
100
|
|
|
|
25
|
{ if(@msgstr) |
44
|
5
|
100
|
|
|
|
34
|
{ $index->{"$msgid#$msgctxt"} |
45
|
|
|
|
|
|
|
= @msgstr > 1 ? [@msgstr] : $msgstr[0]; |
46
|
5
|
|
|
|
|
17
|
($msgctxt, $msgid, @msgstr) = (''); |
47
|
|
|
|
|
|
|
} |
48
|
7
|
|
|
|
|
210
|
next LINE; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
27
|
50
|
66
|
|
|
323
|
if($line =~ s/^msgctxt\s+//) |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
{ $msgctxt = _unescape $line, $fn; |
53
|
0
|
|
|
|
|
0
|
$last = \$msgctxt; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif($line =~ s/^msgid\s+//) |
56
|
5
|
|
|
|
|
20
|
{ $msgid = _unescape $line, $fn; |
57
|
5
|
|
|
|
|
190
|
$last = \$msgid; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
elsif($line =~ s/^msgstr\[(\d+)\]\s*//) |
60
|
4
|
|
|
|
|
18
|
{ $last = \($msgstr[$1] = _unescape $line, $fn); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif($line =~ s/^msgstr\s+//) |
63
|
4
|
|
|
|
|
13
|
{ $msgstr[0] = _unescape $line, $fn; |
64
|
4
|
|
|
|
|
142
|
$last = \$msgstr[0]; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
elsif($last && $line =~ m/^\s*\"/) |
67
|
13
|
|
|
|
|
45
|
{ $$last .= _unescape $line, $fn; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
1
|
0
|
|
|
|
46
|
$index->{"$msgid#$msgctxt"} = (@msgstr > 1 ? \@msgstr : $msgstr[0]) |
|
|
50
|
|
|
|
|
|
72
|
|
|
|
|
|
|
if @msgstr; # don't forget the last |
73
|
|
|
|
|
|
|
|
74
|
1
|
50
|
|
|
|
23
|
close $fh |
75
|
|
|
|
|
|
|
or failure __x"failed reading from file {fn}", fn => $fn; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
5
|
$self->{filename} = $fn; |
78
|
1
|
|
|
|
|
12
|
$self->setupPluralAlgorithm; |
79
|
1
|
|
|
|
|
9
|
$self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
0
|
1
|
0
|
sub filename() {shift->{filename}} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
0
|
0
|
0
|
sub index() {shift->{index}} |
87
|
|
|
|
|
|
|
# The index is a HASH with "$msg#$msgctxt" keys. If there is no |
88
|
|
|
|
|
|
|
# $msgctxt, then there still is the # |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
4
|
|
50
|
4
|
1
|
43
|
sub msgid($) { $_[0]->{index}{$_[1].'#'.($_[2]//'')} } |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# speed!!! |
95
|
|
|
|
|
|
|
sub msgstr($;$$) |
96
|
12
|
|
|
12
|
1
|
1753
|
{ my ($self, $msgid, $count, $ctxt) = @_; |
97
|
|
|
|
|
|
|
|
98
|
12
|
|
50
|
|
|
86
|
$ctxt //= ''; |
99
|
12
|
50
|
|
|
|
58
|
my $po = $self->{index}{"$msgid#$ctxt"} |
100
|
|
|
|
|
|
|
or return undef; |
101
|
|
|
|
|
|
|
|
102
|
12
|
100
|
|
|
|
55
|
ref $po # no plurals defined |
103
|
|
|
|
|
|
|
or return $po; |
104
|
|
|
|
|
|
|
|
105
|
9
|
50
|
50
|
|
|
248
|
$po->[$self->{algo}->($count // 1)] || $po->[$self->{algo}->(1)]; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# |
109
|
|
|
|
|
|
|
### internal helper routines, shared with ::PO.pm and ::POT.pm |
110
|
|
|
|
|
|
|
# |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _unescape($$) |
113
|
91
|
50
|
|
91
|
|
483
|
{ unless( $_[0] =~ m/^\s*\"(.*)\"\s*$/ ) |
114
|
0
|
|
|
|
|
0
|
{ warning __x"string '{text}' not between quotes at {location}" |
115
|
|
|
|
|
|
|
, text => $_[0], location => $_[1]; |
116
|
0
|
|
|
|
|
0
|
return $_[0]; |
117
|
|
|
|
|
|
|
} |
118
|
91
|
|
|
|
|
335
|
unescape_chars $1; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _escape($$) |
122
|
64
|
100
|
100
|
64
|
|
569
|
{ my @escaped = map { '"' . escape_chars($_) . '"' } |
|
100
|
|
|
|
|
771
|
|
123
|
|
|
|
|
|
|
defined $_[0] && length $_[0] ? split(/(?<=\n)/, $_[0]) : ''; |
124
|
|
|
|
|
|
|
|
125
|
64
|
100
|
|
|
|
868
|
unshift @escaped, '""' if @escaped > 1; |
126
|
64
|
|
|
|
|
354
|
join $_[1], @escaped; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |