| 1 | package Pod::Simple::XMLOutStream; | ||||||||||||||||||||||||||||
| 2 | 29 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 29 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 29 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 29 | ▶ | use Pod::Simple (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 29 | our $VERSION = '3.48'; | |||||||||||||||||||||||||||
| 7 | 29 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 8 | 29 | our @ISA = ('Pod::Simple'); | |||||||||||||||||||||||||||
| 9 | 29 | ▶ | *DEBUG = \&Pod::Simple::DEBUG unless defined &DEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 29 | our $ATTR_PAD; | |||||||||||||||||||||||||||
| 13 | 29 | ▶ | $ATTR_PAD = "\n" unless defined $ATTR_PAD; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | # Don't mess with this unless you know what you're doing. | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 29 | our $SORT_ATTRS; | |||||||||||||||||||||||||||
| 17 | 29 | ▶ | $SORT_ATTRS = 0 unless defined $SORT_ATTRS; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 469 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | 469 | my $self = shift; | |||||||||||||||||||||||||||
| 21 | 469 | my $new = $self->SUPER::new(@_); | |||||||||||||||||||||||||||
| 22 | 469 | ▶ | $new->{'output_fh'} ||= *STDOUT{IO}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$new->{"output_fh"} ||= *STDOUT{"IO"}
MC/DC0%0/1
$new->{"output_fh"} ||= *STDOUT{"IO"}
$new->{"output_fh"}
Truth table50%1/2
A
A= $new->{"output_fh"}
| |||||||||||||||||||||||||||||
| 23 | 469 | $new->keep_encoding_directive(1); | |||||||||||||||||||||||||||
| 24 | #$new->accept_codes('VerbatimFormatted'); | ||||||||||||||||||||||||||||
| 25 | 469 | return $new; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1870 | ▶ | sub _handle_element_start { | ||||||||||||||||||||||||||
|
Subroutine
_handle_element_start: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||
| 31 | # ($self, $element_name, $attr_hash_r) | ||||||||||||||||||||||||||||
| 32 | 1870 | my $fh = $_[0]{'output_fh'}; | |||||||||||||||||||||||||||
| 33 | 1870 | my($key, $value); | |||||||||||||||||||||||||||
| 34 | 1870 | DEBUG and print STDERR "++ $_[1]\n"; | |||||||||||||||||||||||||||
| 35 | 1870 | print $fh "<", $_[1]; | |||||||||||||||||||||||||||
| 36 | 1870 | ▶ | if($SORT_ATTRS) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 1160 | foreach my $key (sort keys %{$_[2]}) { | |||||||||||||||||||||||||||
| 38 | 2043 | ▶ | unless($key =~ m/^~/s) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 1602 | ▶ | next if $key eq 'start_line' and $_[0]{'hide_line_numbers'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$key eq "start_line" and $_[0]{"hide_line_numbers"}
MC/DC50%1/2
$key eq "start_line" and $_[0]{"hide_line_numbers"}
$key eq "start_line"
$_[0]{"hide_line_numbers"}
Truth table66%2/3
A and B
A= $key eq "start_line"B= $_[0]{"hide_line_numbers"}
| |||||||||||||||||||||||||||||
| 40 | 695 | _xml_escape($value = $_[2]{$key}); | |||||||||||||||||||||||||||
| 41 | 695 | print $fh $ATTR_PAD, $key, '="', $value, '"'; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } else { # faster | ||||||||||||||||||||||||||||
| 45 | 710 | ▶ | while(($key,$value) = each %{$_[2]}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 834 | ▶ | unless($key =~ m/^~/s) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 764 | ▶ | next if $key eq 'start_line' and $_[0]{'hide_line_numbers'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$key eq "start_line" and $_[0]{"hide_line_numbers"}
MC/DC100%2/2
$key eq "start_line" and $_[0]{"hide_line_numbers"}
$key eq "start_line"
$_[0]{"hide_line_numbers"}
Truth table100%3/3
A and B
A= $key eq "start_line"B= $_[0]{"hide_line_numbers"}
| |||||||||||||||||||||||||||||
| 48 | 197 | _xml_escape($value); | |||||||||||||||||||||||||||
| 49 | 197 | print $fh $ATTR_PAD, $key, '="', $value, '"'; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 1870 | print $fh ">"; | |||||||||||||||||||||||||||
| 54 | 1870 | return; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 1278 | ▶ | sub _handle_text { | ||||||||||||||||||||||||||
|
Subroutine
_handle_text: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 58 | 1278 | DEBUG and print STDERR "== \"$_[1]\"\n"; | |||||||||||||||||||||||||||
| 59 | 1278 | ▶ | if(length $_[1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 1267 | my $text = $_[1]; | |||||||||||||||||||||||||||
| 61 | 1267 | _xml_escape($text); | |||||||||||||||||||||||||||
| 62 | 1267 | print {$_[0]{'output_fh'}} $text; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | 1278 | return; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 1870 | ▶ | sub _handle_element_end { | ||||||||||||||||||||||||||
|
Subroutine
_handle_element_end: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | 1870 | DEBUG and print STDERR "-- $_[1]\n"; | |||||||||||||||||||||||||||
| 69 | 1870 | print {$_[0]{'output_fh'}} "</", $_[1], ">"; | |||||||||||||||||||||||||||
| 70 | 1870 | return; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||
| 74 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 2159 | ▶ | sub _xml_escape { | ||||||||||||||||||||||||||
|
Subroutine
_xml_escape: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||
| 77 | 2159 | foreach my $x (@_) { | |||||||||||||||||||||||||||
| 78 | # Escape things very cautiously: | ||||||||||||||||||||||||||||
| 79 | 2159 | ▶ | if ("$]" >= 5.007_003) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 2159 | $x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/'&#'.(utf8::native_to_unicode(ord($1))).';'/eg; | |||||||||||||||||||||||||||
| 81 | } else { # Is broken for non-ASCII platforms on early perls | ||||||||||||||||||||||||||||
| 82 | 0 | $x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/'&#'.(ord($1)).';'/eg; | |||||||||||||||||||||||||||
| 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 | return; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||||||||||||||||||||||||||
| 91 | 29 | 1; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | __END__ | ||||||||||||||||||||||||||||