line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::Maketext::Lexicon::Msgcat; |
2
|
|
|
|
|
|
|
$Locale::Maketext::Lexicon::Msgcat::VERSION = '1.00'; |
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
224
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Msgcat catalog parser Maketext |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub parse { |
9
|
4
|
|
|
4
|
0
|
8
|
my $set = 0; |
10
|
4
|
|
|
|
|
8
|
my $msg = undef; |
11
|
4
|
|
|
|
|
34
|
my ( $qr, $qq, $qc ) = ( qr//, '', '' ); |
12
|
4
|
|
|
|
|
14
|
my @out; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Set up the msgcat handler |
15
|
|
|
|
|
|
|
{ |
16
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
66
|
|
|
4
|
|
|
|
|
9
|
|
17
|
2
|
|
|
2
|
|
12
|
no warnings 'once'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1124
|
|
18
|
4
|
|
|
|
|
30
|
*{Locale::Maketext::msgcat} = \&_msgcat; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Parse *.m files; Locale::Msgcat objects and *.cat are not yet supported. |
22
|
4
|
|
|
|
|
11
|
foreach (@_) { |
23
|
44
|
|
|
|
|
253
|
s/[\015\012]*\z//; # fix CRLF issues |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
/^\$set (\d+)/ |
26
|
|
|
|
|
|
|
? do { # set_id |
27
|
4
|
|
|
|
|
14
|
$set = int($1); |
28
|
4
|
|
|
|
|
31
|
push @out, $1, "[msgcat,$1,_1]"; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
/^\$quote (.)/ |
33
|
|
|
|
|
|
|
? do { # quote character |
34
|
4
|
|
|
|
|
10
|
$qc = $1; |
35
|
4
|
|
|
|
|
8
|
$qq = quotemeta($1); |
36
|
4
|
|
|
|
|
74
|
$qr = qr/$qq?/; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
: |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
/^(\d+) ($qr)(.*?)\2(\\?)$/ |
41
|
|
|
|
|
|
|
? do { # msg_id and msg_str |
42
|
16
|
|
|
|
|
46
|
local $^W; |
43
|
16
|
|
|
|
|
53
|
push @out, "$set," . int($1); |
44
|
16
|
100
|
|
|
|
50
|
if ($4) { |
45
|
8
|
|
|
|
|
26
|
$msg = $3; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else { |
48
|
8
|
|
|
|
|
27
|
push @out, unescape( $qq, $qc, $3 ); |
49
|
8
|
|
|
|
|
27
|
undef $msg; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
: |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
( defined $msg and /^($qr)(.*?)\1(\\?)$/ ) |
55
|
44
|
100
|
66
|
|
|
787
|
? do { # continued string |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
56
|
12
|
|
|
|
|
29
|
local $^W; |
57
|
12
|
100
|
|
|
|
29
|
if ($3) { |
58
|
4
|
|
|
|
|
18
|
$msg .= $2; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
8
|
|
|
|
|
30
|
push @out, unescape( $qq, $qc, $msg . $2 ); |
62
|
8
|
|
|
|
|
31
|
undef $msg; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
: (); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
4
|
50
|
|
|
|
13
|
push @out, '' if defined $msg; |
69
|
|
|
|
|
|
|
|
70
|
4
|
|
|
|
|
43
|
return {@out}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _msgcat { |
74
|
10
|
|
|
10
|
|
5798
|
my ( $self, $set_id, $msg_id, @args ) = @_; |
75
|
10
|
|
|
|
|
72
|
return $self->maketext( int($set_id) . ',' . int($msg_id), @args ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub unescape { |
79
|
16
|
|
|
16
|
0
|
41
|
my ( $qq, $qc, $str ) = @_; |
80
|
16
|
0
|
|
|
|
182
|
$str =~ s/(\\([ntvbrf\\$qq]))/($2 eq $qc) ? $qc : eval qq("$1")/e; |
|
0
|
|
|
|
|
0
|
|
81
|
16
|
|
|
|
|
30
|
$str =~ s/([\~\[\]])/~$1/g; |
82
|
16
|
|
|
|
|
40
|
return $str; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |