line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
require 5; |
3
|
|
|
|
|
|
|
package Pod::Simple::XMLOutStream; |
4
|
29
|
|
|
29
|
|
35231
|
use strict; |
|
29
|
|
|
|
|
92
|
|
|
29
|
|
|
|
|
778
|
|
5
|
29
|
|
|
29
|
|
144
|
use Carp (); |
|
29
|
|
|
|
|
51
|
|
|
29
|
|
|
|
|
445
|
|
6
|
29
|
|
|
29
|
|
2267
|
use Pod::Simple (); |
|
29
|
|
|
|
|
57
|
|
|
29
|
|
|
|
|
572
|
|
7
|
29
|
|
|
29
|
|
124
|
use vars qw( $ATTR_PAD @ISA $VERSION $SORT_ATTRS); |
|
29
|
|
|
|
|
53
|
|
|
29
|
|
|
|
|
2628
|
|
8
|
|
|
|
|
|
|
$VERSION = '3.42'; |
9
|
|
|
|
|
|
|
BEGIN { |
10
|
29
|
|
|
29
|
|
536
|
@ISA = ('Pod::Simple'); |
11
|
29
|
50
|
|
|
|
18269
|
*DEBUG = \&Pod::Simple::DEBUG unless defined &DEBUG; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$ATTR_PAD = "\n" unless defined $ATTR_PAD; |
15
|
|
|
|
|
|
|
# Don't mess with this unless you know what you're doing. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$SORT_ATTRS = 0 unless defined $SORT_ATTRS; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
469
|
|
|
469
|
1
|
6082
|
my $self = shift; |
21
|
469
|
|
|
|
|
1456
|
my $new = $self->SUPER::new(@_); |
22
|
469
|
|
50
|
|
|
2203
|
$new->{'output_fh'} ||= *STDOUT{IO}; |
23
|
469
|
|
|
|
|
1408
|
$new->keep_encoding_directive(1); |
24
|
|
|
|
|
|
|
#$new->accept_codes('VerbatimFormatted'); |
25
|
469
|
|
|
|
|
942
|
return $new; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _handle_element_start { |
31
|
|
|
|
|
|
|
# ($self, $element_name, $attr_hash_r) |
32
|
1870
|
|
|
1870
|
|
2896
|
my $fh = $_[0]{'output_fh'}; |
33
|
1870
|
|
|
|
|
2721
|
my($key, $value); |
34
|
1870
|
|
|
|
|
2144
|
DEBUG and print STDERR "++ $_[1]\n"; |
35
|
1870
|
|
|
|
|
5431
|
print $fh "<", $_[1]; |
36
|
1870
|
100
|
|
|
|
3367
|
if($SORT_ATTRS) { |
37
|
1160
|
|
|
|
|
1400
|
foreach my $key (sort keys %{$_[2]}) { |
|
1160
|
|
|
|
|
4036
|
|
38
|
2043
|
100
|
|
|
|
4531
|
unless($key =~ m/^~/s) { |
39
|
1602
|
50
|
66
|
|
|
4656
|
next if $key eq 'start_line' and $_[0]{'hide_line_numbers'}; |
40
|
695
|
|
|
|
|
1772
|
_xml_escape($value = $_[2]{$key}); |
41
|
695
|
|
|
|
|
1637
|
print $fh $ATTR_PAD, $key, '="', $value, '"'; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} else { # faster |
45
|
710
|
|
|
|
|
957
|
while(($key,$value) = each %{$_[2]}) { |
|
1544
|
|
|
|
|
4551
|
|
46
|
834
|
100
|
|
|
|
1926
|
unless($key =~ m/^~/s) { |
47
|
764
|
100
|
100
|
|
|
2518
|
next if $key eq 'start_line' and $_[0]{'hide_line_numbers'}; |
48
|
197
|
|
|
|
|
469
|
_xml_escape($value); |
49
|
197
|
|
|
|
|
492
|
print $fh $ATTR_PAD, $key, '="', $value, '"'; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
1870
|
|
|
|
|
4409
|
print $fh ">"; |
54
|
1870
|
|
|
|
|
3574
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _handle_text { |
58
|
1278
|
|
|
1278
|
|
1861
|
DEBUG and print STDERR "== \"$_[1]\"\n"; |
59
|
1278
|
100
|
|
|
|
2307
|
if(length $_[1]) { |
60
|
1267
|
|
|
|
|
1764
|
my $text = $_[1]; |
61
|
1267
|
|
|
|
|
2516
|
_xml_escape($text); |
62
|
1267
|
|
|
|
|
1491
|
print {$_[0]{'output_fh'}} $text; |
|
1267
|
|
|
|
|
3125
|
|
63
|
|
|
|
|
|
|
} |
64
|
1278
|
|
|
|
|
3079
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _handle_element_end { |
68
|
1870
|
|
|
1870
|
|
2196
|
DEBUG and print STDERR "-- $_[1]\n"; |
69
|
1870
|
|
|
|
|
2376
|
print {$_[0]{'output_fh'}} "", $_[1], ">"; |
|
1870
|
|
|
|
|
4191
|
|
70
|
1870
|
|
|
|
|
3164
|
return; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
74
|
|
|
|
|
|
|
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _xml_escape { |
77
|
2159
|
|
|
2159
|
|
3195
|
foreach my $x (@_) { |
78
|
|
|
|
|
|
|
# Escape things very cautiously: |
79
|
2159
|
50
|
|
|
|
7706
|
if ($] ge 5.007_003) { |
80
|
2159
|
|
|
|
|
5652
|
$x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/''.(utf8::native_to_unicode(ord($1))).';'/eg; |
|
862
|
|
|
|
|
2860
|
|
81
|
|
|
|
|
|
|
} else { # Is broken for non-ASCII platforms on early perls |
82
|
0
|
|
|
|
|
0
|
$x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/''.(ord($1)).';'/eg; |
|
0
|
|
|
|
|
0
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
# Yes, stipulate the list without a range, so that this can work right on |
85
|
|
|
|
|
|
|
# all charsets that this module happens to run under. |
86
|
|
|
|
|
|
|
} |
87
|
2159
|
|
|
|
|
2861
|
return; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |