line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Convert::yEnc::RC; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
30678
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
153
|
|
4
|
2
|
|
|
2
|
|
1120
|
use Convert::yEnc::Entry; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
59
|
|
5
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
66
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
9
|
use overload 'eq' => \&_eq; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
12
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
11
|
|
|
|
|
|
|
{ |
12
|
14
|
|
|
14
|
1
|
2998
|
my ($class, $file) = @_; |
13
|
|
|
|
|
|
|
|
14
|
14
|
|
|
|
|
30
|
my $rc = { }; |
15
|
14
|
|
|
|
|
32
|
bless $rc, $class; |
16
|
14
|
100
|
|
|
|
50
|
$rc->load($file) if $file; |
17
|
|
|
|
|
|
|
|
18
|
14
|
|
|
|
|
38
|
$rc |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub load |
23
|
|
|
|
|
|
|
{ |
24
|
11
|
|
|
11
|
1
|
26
|
my($rc, $file) = @_; |
25
|
|
|
|
|
|
|
|
26
|
11
|
|
|
|
|
77
|
$rc->{file } = $file; |
27
|
11
|
|
|
|
|
23
|
$rc->{db } = { }; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
2
|
|
237
|
no warnings qw(uninitialized); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2143
|
|
30
|
11
|
100
|
|
|
|
319
|
open RC, $file or return undef; |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
102
|
while (my $line = ) |
33
|
|
|
|
|
|
|
{ |
34
|
7
|
100
|
|
|
|
40
|
$line =~ /\S/ or next; |
35
|
5
|
|
|
|
|
16
|
my($name, $rest) = split "\t", $line, 2; |
36
|
5
|
|
|
|
|
24
|
my $entry = load Convert::yEnc::Entry $rest; |
37
|
5
|
|
|
|
|
33
|
$rc->{db}{$name} = $entry; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
5
|
|
|
|
|
59
|
close(RC); |
41
|
|
|
|
|
|
|
|
42
|
5
|
|
|
|
|
12
|
1 |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub update |
46
|
|
|
|
|
|
|
{ |
47
|
45
|
|
|
45
|
1
|
4988
|
my($rc, $line) = @_; |
48
|
|
|
|
|
|
|
|
49
|
45
|
|
|
|
|
148
|
my($tag, @fields) = split ' ', $line; |
50
|
|
|
|
|
|
|
|
51
|
45
|
|
|
|
|
60
|
my %field; |
52
|
45
|
|
|
|
|
70
|
for my $field (@fields) |
53
|
|
|
|
|
|
|
{ |
54
|
111
|
|
|
|
|
250
|
my($key, $val) = split /=/, $field; |
55
|
111
|
|
|
|
|
249
|
$field{$key} = $val; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
45
|
|
|
|
|
170
|
$line =~ s(\s+$)(); |
59
|
45
|
|
|
|
|
116
|
my($name) = $line =~ /name=\s*(.*)/; # Die! Die! Die! |
60
|
45
|
100
|
|
|
|
90
|
$field{name} = $name if $name; |
61
|
|
|
|
|
|
|
|
62
|
45
|
|
|
|
|
160
|
$tag =~ s/^=/_/; |
63
|
45
|
50
|
|
|
|
249
|
$rc->can($tag) and $rc->$tag(\%field) |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _ybegin |
67
|
|
|
|
|
|
|
{ |
68
|
19
|
|
|
19
|
|
26
|
my($rc, $fields) = @_; |
69
|
|
|
|
|
|
|
|
70
|
19
|
|
|
|
|
45
|
my $name = $fields->{name}; |
71
|
19
|
50
|
|
|
|
43
|
$name or return 0; |
72
|
|
|
|
|
|
|
|
73
|
19
|
|
|
|
|
67
|
my $entry = $rc->{db}{$name}; |
74
|
|
|
|
|
|
|
|
75
|
19
|
100
|
|
|
|
46
|
if ($entry) |
76
|
|
|
|
|
|
|
{ |
77
|
6
|
|
|
|
|
12
|
$rc->{current} = $entry; |
78
|
6
|
|
|
|
|
33
|
return $entry->ybegin($fields); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
13
|
|
|
|
|
73
|
$rc->{current} = $rc->{db}{$name} = new Convert::yEnc::Entry $fields; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _ypart |
85
|
|
|
|
|
|
|
{ |
86
|
9
|
|
|
9
|
|
13
|
my($rc, $fields) = @_; |
87
|
|
|
|
|
|
|
|
88
|
9
|
|
|
|
|
16
|
my $entry = $rc->{current}; |
89
|
9
|
50
|
|
|
|
77
|
$entry and $entry->ypart($fields); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _yend |
93
|
|
|
|
|
|
|
{ |
94
|
17
|
|
|
17
|
|
26
|
my($rc, $fields) = @_; |
95
|
|
|
|
|
|
|
|
96
|
17
|
|
|
|
|
33
|
my $entry = $rc->{current}; |
97
|
17
|
|
|
|
|
35
|
delete $rc->{current}; |
98
|
|
|
|
|
|
|
|
99
|
17
|
100
|
|
|
|
143
|
$entry and $entry->yend($fields); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub files |
104
|
|
|
|
|
|
|
{ |
105
|
4
|
|
|
4
|
1
|
1850
|
my $rc = shift; |
106
|
4
|
|
|
|
|
6
|
my $db = $rc->{db}; |
107
|
4
|
|
|
|
|
15
|
keys %$db |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub complete |
111
|
|
|
|
|
|
|
{ |
112
|
13
|
|
|
13
|
1
|
3023
|
my($rc, $name) = @_; |
113
|
|
|
|
|
|
|
|
114
|
13
|
100
|
|
|
|
51
|
$name ? $rc->_is_complete($name) : $rc->_complete_files |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub _is_complete |
118
|
|
|
|
|
|
|
{ |
119
|
9
|
|
|
9
|
|
14
|
my($rc, $name) = @_; |
120
|
9
|
|
|
|
|
18
|
my $entry = $rc->{db}{$name}; |
121
|
9
|
50
|
|
|
|
27
|
$entry and $entry->complete; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub _complete_files |
125
|
|
|
|
|
|
|
{ |
126
|
4
|
|
|
4
|
|
5
|
my $rc = shift; |
127
|
4
|
|
|
|
|
7
|
my $db = $rc->{db}; |
128
|
|
|
|
|
|
|
|
129
|
4
|
|
|
|
|
18
|
grep { $db->{$_}->complete($_) } keys %$db |
|
5
|
|
|
|
|
17
|
|
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub entry |
133
|
|
|
|
|
|
|
{ |
134
|
3
|
|
|
3
|
1
|
1418
|
my($rc, $name) = @_; |
135
|
|
|
|
|
|
|
|
136
|
3
|
|
|
|
|
11
|
$rc->{db}{$name} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub drop |
140
|
|
|
|
|
|
|
{ |
141
|
6
|
|
|
6
|
1
|
544
|
my($rc, $name) = @_; |
142
|
|
|
|
|
|
|
|
143
|
6
|
|
|
|
|
40
|
delete $rc->{db}{$name}; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub save |
148
|
|
|
|
|
|
|
{ |
149
|
10
|
|
|
10
|
1
|
548
|
my $rc = shift; |
150
|
10
|
100
|
100
|
|
|
65
|
my $file = shift || $rc->{file} or |
151
|
|
|
|
|
|
|
die ref $rc, "::save: no file\n"; |
152
|
|
|
|
|
|
|
|
153
|
9
|
50
|
|
|
|
779
|
open(RC, "> $file.tmp") or |
154
|
|
|
|
|
|
|
die ref $rc, ": Can't open $file.tmp: $!\n"; |
155
|
|
|
|
|
|
|
|
156
|
9
|
|
|
|
|
19
|
my $db = $rc->{db}; |
157
|
|
|
|
|
|
|
|
158
|
9
|
|
|
|
|
43
|
for my $name (sort keys %$db) |
159
|
|
|
|
|
|
|
{ |
160
|
5
|
|
|
|
|
8
|
my $entry = $db->{$name}; |
161
|
5
|
|
|
|
|
21
|
print RC "$name\t$entry\n"; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
9
|
|
|
|
|
181
|
close RC; |
165
|
|
|
|
|
|
|
|
166
|
9
|
50
|
|
|
|
530
|
rename "$file.tmp", $file or |
167
|
|
|
|
|
|
|
die ref $rc, ": can't rename $file.tmp -> $file: $!\n"; |
168
|
|
|
|
|
|
|
|
169
|
9
|
|
|
|
|
262
|
$rc->{file} = $file; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub _eq |
174
|
|
|
|
|
|
|
{ |
175
|
2
|
|
|
2
|
|
14
|
my($a, $b) = @_; |
176
|
|
|
|
|
|
|
|
177
|
2
|
|
|
|
|
4
|
my $dba = $a->{db}; |
178
|
2
|
|
|
|
|
4
|
my $dbb = $b->{db}; |
179
|
|
|
|
|
|
|
|
180
|
2
|
|
|
|
|
9
|
my @a = keys %$dba; |
181
|
2
|
|
|
|
|
6
|
my @b = keys %$dbb; |
182
|
|
|
|
|
|
|
|
183
|
2
|
50
|
|
|
|
6
|
@a==@b or return 0; |
184
|
|
|
|
|
|
|
|
185
|
2
|
|
|
|
|
4
|
for my $name (@a) |
186
|
|
|
|
|
|
|
{ |
187
|
4
|
50
|
|
|
|
138
|
$a->{db}{$name} eq $b->{db}{$name} or return 0; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
1 |
191
|
2
|
|
|
|
|
10
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
1 |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
__END__ |