| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------- |
|
2
|
|
|
|
|
|
|
# MKDoc::XML::Decode |
|
3
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------- |
|
4
|
|
|
|
|
|
|
# Author : Jean-Michel Hiver |
|
5
|
|
|
|
|
|
|
# Copyright : (c) MKDoc Holdings Ltd, 2003 |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# This modules expands XML entities & > < " and '. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# This module is distributed under the same license as Perl itself. |
|
10
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------- |
|
11
|
|
|
|
|
|
|
package MKDoc::XML::Decode; |
|
12
|
7
|
|
|
7
|
|
109698
|
use warnings; |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
213
|
|
|
13
|
7
|
|
|
7
|
|
35
|
use strict; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
6747
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our %Modules = (); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $WARN = 0; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# import all plugins once |
|
22
|
|
|
|
|
|
|
foreach my $include_dir (@INC) |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
|
|
|
|
|
|
my $dir = "$include_dir/MKDoc/XML/Decode"; |
|
25
|
|
|
|
|
|
|
if (-e $dir and -d $dir) |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
|
|
|
|
|
|
opendir DD, $dir or do { |
|
28
|
|
|
|
|
|
|
warn "Cannot open directory $dir. Reason: $!"; |
|
29
|
|
|
|
|
|
|
next; |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my @modules = map { s/\.pm$//; $_ } |
|
33
|
|
|
|
|
|
|
grep /\.pm$/, |
|
34
|
|
|
|
|
|
|
grep !/^\./, |
|
35
|
|
|
|
|
|
|
readdir (DD); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
closedir DD; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
foreach my $module (@modules) |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
|
|
|
|
|
|
$module =~ /^(\w+)$/; |
|
42
|
|
|
|
|
|
|
$module = $1; |
|
43
|
7
|
|
|
7
|
|
3847
|
eval "use MKDoc::XML::Decode::$module"; |
|
|
7
|
|
|
7
|
|
18
|
|
|
|
7
|
|
|
7
|
|
149
|
|
|
|
7
|
|
|
7
|
|
3992
|
|
|
|
7
|
|
|
7
|
|
52
|
|
|
|
7
|
|
|
7
|
|
147
|
|
|
|
7
|
|
|
7
|
|
3627
|
|
|
|
7
|
|
|
7
|
|
18
|
|
|
|
7
|
|
|
7
|
|
127
|
|
|
|
7
|
|
|
|
|
41
|
|
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
93
|
|
|
|
7
|
|
|
|
|
39
|
|
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
252
|
|
|
|
7
|
|
|
|
|
229
|
|
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
75
|
|
|
|
7
|
|
|
|
|
42
|
|
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
77
|
|
|
|
7
|
|
|
|
|
40
|
|
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
72
|
|
|
|
7
|
|
|
|
|
35
|
|
|
|
7
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
69
|
|
|
44
|
|
|
|
|
|
|
$@ and warn "Cannot import module $module. Reason: $@"; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $name = "MKDoc::XML::Decode::$module"->can ('module_name') ? |
|
47
|
|
|
|
|
|
|
"MKDoc::XML::Decode::$module"->module_name() : |
|
48
|
|
|
|
|
|
|
lc ($module); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$Modules{$name} = "MKDoc::XML::Decode::$module"; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub new |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
96
|
|
|
96
|
1
|
169
|
my $class = shift; |
|
59
|
96
|
50
|
|
|
|
234
|
@_ = sort keys %Modules unless (scalar @_); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $self = bless [ map { |
|
62
|
96
|
50
|
|
|
|
145
|
$Modules{$_} ? $Modules{$_} : do { |
|
|
98
|
|
|
|
|
1816
|
|
|
63
|
0
|
|
|
|
|
0
|
warn "Module $_ not found - Ignoring"; |
|
64
|
0
|
|
|
|
|
0
|
(); |
|
65
|
|
|
|
|
|
|
} } @_ ], $class; |
|
66
|
|
|
|
|
|
|
|
|
67
|
96
|
|
|
|
|
268
|
return $self; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub entity_to_char |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
12
|
|
|
12
|
0
|
18
|
my $self = shift; |
|
74
|
12
|
|
|
|
|
29
|
my $char = shift; |
|
75
|
12
|
|
|
|
|
19
|
for (@{$self}) { |
|
|
12
|
|
|
|
|
573
|
|
|
76
|
12
|
|
|
|
|
61
|
my $res = $_->process ($char); |
|
77
|
12
|
100
|
|
|
|
62
|
return $res if (defined $res); |
|
78
|
|
|
|
|
|
|
}; |
|
79
|
|
|
|
|
|
|
|
|
80
|
5
|
50
|
|
|
|
12
|
warn "Could not expand &$char;" if ($WARN); |
|
81
|
5
|
|
|
|
|
19
|
return "&$char;"; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub process |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
105
|
50
|
|
105
|
0
|
331
|
(@_ == 2) or warn "MKDoc::XML::Encode::process() should be called with two arguments"; |
|
88
|
|
|
|
|
|
|
|
|
89
|
105
|
|
|
|
|
140
|
my $self = shift; |
|
90
|
105
|
50
|
|
|
|
175
|
my $data = join '', map { defined $_ ? $_ : () } @_; |
|
|
105
|
|
|
|
|
456
|
|
|
91
|
105
|
|
|
|
|
283
|
$data =~ s/&(#?[0-9A-Za-z]+);/$self->entity_to_char ($1)/eg; |
|
|
12
|
|
|
|
|
38
|
|
|
92
|
105
|
|
|
|
|
671
|
return $data; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |