| 1 | #============================================================= -*-Perl-*- | ||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||
| 3 | # Pod::POM | ||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||
| 5 | # DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||
| 6 | # Parses POD from a file or text string and builds a tree structure, | ||||||||||||||||||||||||||||||||||||||||
| 7 | # hereafter known as the POD Object Model (POM). | ||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||
| 9 | # AUTHOR | ||||||||||||||||||||||||||||||||||||||||
| 10 | # Andy Wardley <abw@wardley.org> | ||||||||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||||||||
| 12 | # Andrew Ford <A.Ford@ford-mason.co.uk> (co-maintainer as of 03/2009) | ||||||||||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||||||||||
| 14 | # COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||
| 15 | # Copyright (C) 2000-2009 Andy Wardley. All Rights Reserved. | ||||||||||||||||||||||||||||||||||||||||
| 16 | # Copyright (C) 2009 Andrew Ford. All Rights Reserved. | ||||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||||
| 18 | # This module is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||
| 19 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||
| 20 | # | ||||||||||||||||||||||||||||||||||||||||
| 21 | # REVISION | ||||||||||||||||||||||||||||||||||||||||
| 22 | # $Id: POM.pm 91 2013-12-31 07:36:02Z ford $ | ||||||||||||||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||||||||||||||
| 24 | #======================================================================== | ||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||
| 26 | package Pod::POM; | ||||||||||||||||||||||||||||||||||||||||
| 27 | 18 | $Pod::POM::VERSION = '2.01'; | |||||||||||||||||||||||||||||||||||||||
| 28 | 18 | require 5.006; | |||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||
| 30 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 31 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||
| 33 | 18 | ▶ | use Pod::POM::Constants qw( :all ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 34 | 18 | ▶ | use Pod::POM::Nodes; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 35 | 18 | ▶ | use Pod::POM::View::Pod; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||
| 37 | 18 | ▶ | use parent qw( Exporter ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||
| 39 | 18 | ▶ | our $DEBUG = 0 unless defined $DEBUG; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 40 | 18 | our $ROOT = 'Pod::POM::Node::Pod'; # root node class | |||||||||||||||||||||||||||||||||||||||
| 41 | 18 | our $TEXTSEQ = 'Pod::POM::Node::Sequence'; # text sequence class | |||||||||||||||||||||||||||||||||||||||
| 42 | 18 | our $DEFAULT_VIEW = 'Pod::POM::View::Pod'; # default view class | |||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||
| 45 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 46 | # allow 'meta' to be specified as a load option to activate =meta tags | ||||||||||||||||||||||||||||||||||||||||
| 47 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||
| 49 | 18 | our @EXPORT_OK = qw( meta ); | |||||||||||||||||||||||||||||||||||||||
| 50 | 18 | our @EXPORT_FAIL = qw( meta ); | |||||||||||||||||||||||||||||||||||||||
| 51 | 18 | our $ALLOW_META = 0; | |||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | sub export_fail { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
export_fail: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my $meta = shift; | |||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | return ($meta, @_) unless $meta eq 'meta'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | $ALLOW_META++; | |||||||||||||||||||||||||||||||||||||||
| 58 | 1 | return @_; | |||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||
| 63 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 64 | # new(\%options) | ||||||||||||||||||||||||||||||||||||||||
| 65 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||
| 67 | 21 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 68 | 21 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||
| 69 | 21 | ▶ | my $config = ref $_[0] eq 'HASH' ? shift : { @_ }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||
| 71 | bless { | ||||||||||||||||||||||||||||||||||||||||
| 72 | CODE => $config->{ code } || 0, | ||||||||||||||||||||||||||||||||||||||||
| 73 | WARN => $config->{ warn } || 0, | ||||||||||||||||||||||||||||||||||||||||
| 74 | 21 | ▶ | META => $config->{ meta } || $ALLOW_META, | ||||||||||||||||||||||||||||||||||||||
|
Condition85%6/7
$config->{'code'} || 0
$config->{'warn'} || 0
$config->{'meta'} || $Pod::POM::ALLOW_META
MC/DC100%1/1
$config->{'code'} || 0
$config->{'code'}
MC/DC100%1/1
$config->{'warn'} || 0
$config->{'warn'}
MC/DC50%1/2
$config->{'meta'} || $Pod::POM::ALLOW_META
$config->{'meta'}
$Pod::POM::ALLOW_META
Truth table100%2/2
A
A= $config->{'code'}
Truth table100%2/2
A
A= $config->{'warn'}
Truth table66%2/3
A || B
A= $config->{'meta'}B= $Pod::POM::ALLOW_META
| |||||||||||||||||||||||||||||||||||||||||
| 75 | WARNINGS => [ ], | ||||||||||||||||||||||||||||||||||||||||
| 76 | FILENAME => '', | ||||||||||||||||||||||||||||||||||||||||
| 77 | ERROR => '', | ||||||||||||||||||||||||||||||||||||||||
| 78 | }, $class; | ||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||
| 82 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 83 | # parse($text_or_file) | ||||||||||||||||||||||||||||||||||||||||
| 84 | # | ||||||||||||||||||||||||||||||||||||||||
| 85 | # General purpose parse method which attempts to Do The Right Thing in | ||||||||||||||||||||||||||||||||||||||||
| 86 | # calling parse_file() or parse_text() according to the argument | ||||||||||||||||||||||||||||||||||||||||
| 87 | # passed. A hash reference can be specified that contains a 'text' | ||||||||||||||||||||||||||||||||||||||||
| 88 | # or 'file' key and corresponding value. Otherwise, the argument can | ||||||||||||||||||||||||||||||||||||||||
| 89 | # be a reference to an input handle which is passed off to parse_file(). | ||||||||||||||||||||||||||||||||||||||||
| 90 | # If the argument is a text string that contains '=' at the start of | ||||||||||||||||||||||||||||||||||||||||
| 91 | # any line then it is treated as Pod text and passed to parse_text(), | ||||||||||||||||||||||||||||||||||||||||
| 92 | # otherwise it is assumed to be a filename and passed to parse_file(). | ||||||||||||||||||||||||||||||||||||||||
| 93 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my ($self, $input) = @_; | |||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if (ref $input eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if ($input = $input->{ text }) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $result = $self->parse_text($input, $input->{ name }); | |||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||
| 103 | elsif ($input = $input->{ file }) { | ||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $result = $self->parse_file($input); | |||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||
| 106 | else { | ||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $result = $self->error("no 'text' or 'file' specified"); | |||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||
| 110 | ▶ | elsif (ref $input || $input !~ /^=/m) { # doesn't look like POD text | |||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $input or not $input =~ /^=/m
MC/DC0%0/2
ref $input or not $input =~ /^=/m
ref $input
not $input =~ /^=/m
Truth table0%0/3
A or not(B)
A= ref $inputB= not $input =~ /^=/m
| |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $result = $self->parse_file($input); | |||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||
| 113 | else { # looks like POD text | ||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $result = $self->parse_text($input); | |||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||
| 121 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 122 | # parse_file($filename_or_handle) | ||||||||||||||||||||||||||||||||||||||||
| 123 | # | ||||||||||||||||||||||||||||||||||||||||
| 124 | # Reads the content of a Pod file specified by name or file handle, and | ||||||||||||||||||||||||||||||||||||||||
| 125 | # passes it to parse_text() for parsing. | ||||||||||||||||||||||||||||||||||||||||
| 126 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||
| 128 | 5 | ▶ | sub parse_file { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_file: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||
| 130 | 5 | my ($text, $name); | |||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||
| 132 | 5 | ▶ | if (ref $file) { # assume open filehandle | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||
| 134 | 4 | $name = '<filehandle>'; | |||||||||||||||||||||||||||||||||||||||
| 135 | 4 | $text = <$file>; | |||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||
| 137 | else { # a file which must be opened | ||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | local *FP; | |||||||||||||||||||||||||||||||||||||||
| 139 | 1 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||
| 140 | 1 | ▶ | $name = ( $file eq '-' ? '<standard input>' : $file ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | ▶ | open(FP, $file) || return $self->error("$file: $!"); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | $text = <FP>; | |||||||||||||||||||||||||||||||||||||||
| 143 | 1 | close(FP); | |||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | $self->parse_text($text, $name); | |||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||
| 150 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 151 | # parse_text($text, $name) | ||||||||||||||||||||||||||||||||||||||||
| 152 | # | ||||||||||||||||||||||||||||||||||||||||
| 153 | # Main parser method. Scans the input text for Pod sections and splits | ||||||||||||||||||||||||||||||||||||||||
| 154 | # them into paragraphs. Builds a tree of Pod::POM::Node::* objects | ||||||||||||||||||||||||||||||||||||||||
| 155 | # to represent the Pod document in object model form. | ||||||||||||||||||||||||||||||||||||||||
| 156 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||
| 158 | 58 | ▶ | sub parse_text { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_text: called CC=36 SCAR=39.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 159 | 58 | my ($self, $text, $name) = @_; | |||||||||||||||||||||||||||||||||||||||
| 160 | 58 | my ($para, $paralen, $gap, $type, $line, $inpod, $code, $result, $verbatim); | |||||||||||||||||||||||||||||||||||||||
| 161 | 58 | my $warn = $self->{ WARNINGS } = [ ]; | |||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||
| 163 | 58 | my @stack = ( ); | |||||||||||||||||||||||||||||||||||||||
| 164 | 58 | my $item = $ROOT->new($self); | |||||||||||||||||||||||||||||||||||||||
| 165 | 58 | ▶ | return $self->error($ROOT->error()) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 166 | unless defined $item; | ||||||||||||||||||||||||||||||||||||||||
| 167 | 58 | push(@stack, $item); | |||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||
| 169 | 58 | ▶ | $name = '<input text>' unless defined $name; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 170 | 58 | $self->{ FILENAME } = $name; | |||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||
| 172 | 58 | $code = $self->{ CODE }; | |||||||||||||||||||||||||||||||||||||||
| 173 | 58 | $line = \$self->{ LINE }; | |||||||||||||||||||||||||||||||||||||||
| 174 | 58 | $$line = 1; | |||||||||||||||||||||||||||||||||||||||
| 175 | 58 | $inpod = 0; | |||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||
| 177 | 58 | my @encchunks = split /^(=encoding.*)/m, $text; | |||||||||||||||||||||||||||||||||||||||
| 178 | 58 | $text = shift @encchunks; | |||||||||||||||||||||||||||||||||||||||
| 179 | 58 | ▶ | while (@encchunks) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | my($encline,$chunk) = splice @encchunks, 0, 2; | |||||||||||||||||||||||||||||||||||||||
| 181 | 2 | require Encode; | |||||||||||||||||||||||||||||||||||||||
| 182 | 2 | my($encoding) = $encline =~ /^=encoding\s+(\S+)/; | |||||||||||||||||||||||||||||||||||||||
| 183 | 2 | ▶ | if ($encoding ne 'utf8' || !Encode::is_utf8($chunk)) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$encoding ne "utf8" or not &Encode::is_utf8($chunk)
MC/DC50%1/2
$encoding ne "utf8" or not &Encode::is_utf8($chunk)
$encoding ne "utf8"
not &Encode::is_utf8($chunk)
Truth table66%2/3
A or not(B)
A= $encoding ne "utf8"B= not &Encode::is_utf8($chunk)
| |||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | Encode::from_to($chunk, $encoding, "utf8"); | |||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | Encode::_utf8_on($chunk); | |||||||||||||||||||||||||||||||||||||||
| 187 | # $text .= "xxx$encline"; | ||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | $text .= $chunk; | |||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||
| 191 | # patch from JJ | ||||||||||||||||||||||||||||||||||||||||
| 192 | # while ($text =~ /(?:(.*?)(\n{2,}))|(.+$)/sg) { | ||||||||||||||||||||||||||||||||||||||||
| 193 | 58 | ▶ | while ($text =~ /(?:(.*?)((?:\s*\n){2,}))|(.+$)/sg) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 194 | 846 | ▶ | ($para, $gap) = defined $1 ? ($1, $2) : ($3, ''); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||
| 196 | 846 | ▶ | if ($para =~ s/^==?(\w+)\s*//) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||
| 197 | 431 | $type = $1; | |||||||||||||||||||||||||||||||||||||||
| 198 | # switch on for =pod or any other =cmd, switch off for =cut | ||||||||||||||||||||||||||||||||||||||||
| 199 | 431 | ▶ | if ($type eq 'pod') { $inpod = 1; next } | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 200 | 13 | elsif ($type eq 'cut') { $inpod = 0; next } | |||||||||||||||||||||||||||||||||||||||
| 201 | 416 | else { $inpod = 1 }; | |||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||
| 203 | 416 | ▶ | if ($type eq 'meta') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 204 | $self->{ META } | ||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | ? $stack[0]->metadata(split(/\s+/, $para, 2)) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 206 | : $self->warning("metadata not allowed", $name, $$line); | ||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | next; | |||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||
| 210 | elsif (! $inpod) { | ||||||||||||||||||||||||||||||||||||||||
| 211 | 9 | ▶ | next unless $code; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 212 | 4 | $type = 'code'; | |||||||||||||||||||||||||||||||||||||||
| 213 | 4 | $para .= $gap; | |||||||||||||||||||||||||||||||||||||||
| 214 | 4 | $gap = ''; | |||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||
| 216 | elsif ($para =~ /^\s+/) { | ||||||||||||||||||||||||||||||||||||||||
| 217 | 39 | $verbatim .= $para; | |||||||||||||||||||||||||||||||||||||||
| 218 | 39 | $verbatim .= $gap; | |||||||||||||||||||||||||||||||||||||||
| 219 | 39 | next; | |||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||
| 221 | else { | ||||||||||||||||||||||||||||||||||||||||
| 222 | 367 | $type = 'text'; | |||||||||||||||||||||||||||||||||||||||
| 223 | 367 | chomp($para); # catches last line in file | |||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||
| 226 | 785 | ▶ | if ($verbatim) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 227 | 23 | ▶ | while(@stack) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 228 | 38 | $verbatim =~ s/\s+$//s; | |||||||||||||||||||||||||||||||||||||||
| 229 | 38 | $result = $stack[-1]->add($self, 'verbatim', $verbatim); | |||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||
| 231 | 38 | ▶ | if (! defined $result) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $self->warning($stack[-1]->error(), $name, $$line); | |||||||||||||||||||||||||||||||||||||||
| 233 | 0 | undef $verbatim; | |||||||||||||||||||||||||||||||||||||||
| 234 | 0 | last; | |||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||
| 236 | elsif (ref $result) { | ||||||||||||||||||||||||||||||||||||||||
| 237 | 23 | push(@stack, $result); | |||||||||||||||||||||||||||||||||||||||
| 238 | 23 | undef $verbatim; | |||||||||||||||||||||||||||||||||||||||
| 239 | 23 | last; | |||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||
| 241 | elsif ($result == REDUCE) { | ||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | pop @stack; | |||||||||||||||||||||||||||||||||||||||
| 243 | 0 | undef $verbatim; | |||||||||||||||||||||||||||||||||||||||
| 244 | 0 | last; | |||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||
| 246 | elsif ($result == REJECT) { | ||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $self->warning($stack[-1]->error(), $name, $$line); | |||||||||||||||||||||||||||||||||||||||
| 248 | 0 | pop @stack; | |||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||
| 250 | elsif (@stack == 1) { | ||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $self->warning("unexpected $type", $name, $$line); | |||||||||||||||||||||||||||||||||||||||
| 252 | 0 | undef $verbatim; | |||||||||||||||||||||||||||||||||||||||
| 253 | 0 | last; | |||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||
| 255 | else { | ||||||||||||||||||||||||||||||||||||||||
| 256 | 15 | pop @stack; | |||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||
| 261 | 785 | ▶ | while(@stack) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 262 | 1356 | $result = $stack[-1]->add($self, $type, $para); | |||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||
| 264 | 1356 | ▶ | if (! defined $result) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||
| 265 | 3 | $self->warning($stack[-1]->error(), $name, $$line); | |||||||||||||||||||||||||||||||||||||||
| 266 | 3 | last; | |||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||
| 268 | elsif (ref $result) { | ||||||||||||||||||||||||||||||||||||||||
| 269 | 725 | push(@stack, $result); | |||||||||||||||||||||||||||||||||||||||
| 270 | 725 | last; | |||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||
| 272 | elsif ($result == REDUCE) { | ||||||||||||||||||||||||||||||||||||||||
| 273 | 54 | pop @stack; | |||||||||||||||||||||||||||||||||||||||
| 274 | 54 | last; | |||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||
| 276 | elsif ($result == REJECT) { | ||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | $self->warning($stack[-1]->error(), $name, $$line); | |||||||||||||||||||||||||||||||||||||||
| 278 | 3 | pop @stack; | |||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||
| 280 | elsif (@stack == 1) { | ||||||||||||||||||||||||||||||||||||||||
| 281 | 3 | $self->warning("unexpected $type", $name, $$line); | |||||||||||||||||||||||||||||||||||||||
| 282 | 3 | last; | |||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||
| 284 | else { | ||||||||||||||||||||||||||||||||||||||||
| 285 | 568 | pop @stack; | |||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||
| 289 | continue { | ||||||||||||||||||||||||||||||||||||||||
| 290 | 846 | $$line += ($para =~ tr/\n//); | |||||||||||||||||||||||||||||||||||||||
| 291 | 846 | $$line += ($gap =~ tr/\n//); | |||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||
| 294 | 58 | ▶ | if ($verbatim) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | ▶ | while(@stack) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | $verbatim =~ s/\s+$//s; | |||||||||||||||||||||||||||||||||||||||
| 297 | 1 | $result = $stack[-1]->add($self, 'verbatim', $verbatim); | |||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | ▶ | if (! defined $result) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->warning($stack[-1]->error(), $name, $$line); | |||||||||||||||||||||||||||||||||||||||
| 301 | 0 | undef $verbatim; | |||||||||||||||||||||||||||||||||||||||
| 302 | 0 | last; | |||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||
| 304 | elsif (ref $result) { | ||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | push(@stack, $result); | |||||||||||||||||||||||||||||||||||||||
| 306 | 1 | undef $verbatim; | |||||||||||||||||||||||||||||||||||||||
| 307 | 1 | last; | |||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||
| 309 | elsif ($result == REDUCE) { | ||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | pop @stack; | |||||||||||||||||||||||||||||||||||||||
| 311 | 0 | undef $verbatim; | |||||||||||||||||||||||||||||||||||||||
| 312 | 0 | last; | |||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||
| 314 | elsif ($result == REJECT) { | ||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $self->warning($stack[-1]->error(), $name, $$line); | |||||||||||||||||||||||||||||||||||||||
| 316 | 0 | pop @stack; | |||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||
| 318 | elsif (@stack == 1) { | ||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $self->warning("unexpected $type", $name, $$line); | |||||||||||||||||||||||||||||||||||||||
| 320 | 0 | undef $verbatim; | |||||||||||||||||||||||||||||||||||||||
| 321 | 0 | last; | |||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||
| 323 | else { | ||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | pop @stack; | |||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||
| 329 | 58 | return $stack[0]; | |||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||
| 333 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 334 | # parse_sequence($text) | ||||||||||||||||||||||||||||||||||||||||
| 335 | # | ||||||||||||||||||||||||||||||||||||||||
| 336 | # Parse a text paragraph to identify internal sequences (e.g. B<foo>) | ||||||||||||||||||||||||||||||||||||||||
| 337 | # which may be nested within each other. Returns a simple scalar (no | ||||||||||||||||||||||||||||||||||||||||
| 338 | # embedded sequences) or a reference to a Pod::POM::Text object. | ||||||||||||||||||||||||||||||||||||||||
| 339 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||
| 341 | 640 | ▶ | sub parse_sequence { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_sequence: called CC=11 SCAR=24.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 342 | 640 | my ($self, $text) = @_; | |||||||||||||||||||||||||||||||||||||||
| 343 | 640 | my ($cmd, $lparen, $rparen, $plain); | |||||||||||||||||||||||||||||||||||||||
| 344 | 640 | my ($name, $line, $warn) = @$self{ qw( FILENAME LINE WARNINGS ) }; | |||||||||||||||||||||||||||||||||||||||
| 345 | 640 | my @stack; | |||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||
| 347 | 640 | push(@stack, [ '', '', 'EOF', $name, $line, [ ] ] ); | |||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||
| 349 | 640 | ▶ | while ($text =~ / | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 350 | (?: ([A-Z]) (< (?:<+\s)?) ) # open | ||||||||||||||||||||||||||||||||||||||||
| 351 | | ( (?:\s>+)? > ) # or close | ||||||||||||||||||||||||||||||||||||||||
| 352 | | (?: (.+?) # or text... | ||||||||||||||||||||||||||||||||||||||||
| 353 | (?= # ...up to | ||||||||||||||||||||||||||||||||||||||||
| 354 | (?: [A-Z]< ) # open | ||||||||||||||||||||||||||||||||||||||||
| 355 | | (?: (?: \s>+)? > ) # or close | ||||||||||||||||||||||||||||||||||||||||
| 356 | | $ # or EOF | ||||||||||||||||||||||||||||||||||||||||
| 357 | ) | ||||||||||||||||||||||||||||||||||||||||
| 358 | ) | ||||||||||||||||||||||||||||||||||||||||
| 359 | /gxs) { | ||||||||||||||||||||||||||||||||||||||||
| 360 | 1386 | ▶ | if (defined $1) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||
| 361 | 192 | ($cmd, $lparen) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||
| 362 | 192 | $lparen =~ s/\s$//; | |||||||||||||||||||||||||||||||||||||||
| 363 | 192 | ($rparen = $lparen) =~ tr/</>/; | |||||||||||||||||||||||||||||||||||||||
| 364 | 192 | push(@stack, [ $cmd, $lparen, $rparen, $name, $line, [ ] ]); | |||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||
| 366 | elsif (defined $3) { | ||||||||||||||||||||||||||||||||||||||||
| 367 | 204 | $rparen = $3; | |||||||||||||||||||||||||||||||||||||||
| 368 | 204 | $rparen =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||
| 369 | 204 | ▶ | if ($rparen eq $stack[-1]->[RPAREN]) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 370 | 189 | ▶ | $cmd = $TEXTSEQ->new(pop(@stack)) | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$Pod::POM::TEXTSEQ->new(pop @stack) || (return $self->error($Pod::POM::TEXTSEQ->error))
MC/DC0%0/1
$Pod::POM::TEXTSEQ->new(pop @stack) || (return $self->error($Pod::POM::TEXTSEQ->error))
$Pod::POM::TEXTSEQ->new(pop @stack)
Truth table50%1/2
A
A= $Pod::POM::TEXTSEQ->new(pop @stack)
| |||||||||||||||||||||||||||||||||||||||||
| 371 | || return $self->error($TEXTSEQ->error()); | ||||||||||||||||||||||||||||||||||||||||
| 372 | 189 | push(@{ $stack[-1]->[CONTENT] }, $cmd); | |||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||
| 374 | else { | ||||||||||||||||||||||||||||||||||||||||
| 375 | 15 | ▶ | $self->warning((scalar @stack > 1 | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 376 | ? "expected '$stack[-1]->[RPAREN]' not '$rparen'" | ||||||||||||||||||||||||||||||||||||||||
| 377 | : "spurious '$rparen'"), $name, $line); | ||||||||||||||||||||||||||||||||||||||||
| 378 | 15 | push(@{ $stack[-1]->[CONTENT] }, $rparen); | |||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||
| 381 | elsif (defined $4) { | ||||||||||||||||||||||||||||||||||||||||
| 382 | 990 | $plain = $4; | |||||||||||||||||||||||||||||||||||||||
| 383 | 990 | push(@{ $stack[-1]->[CONTENT] }, $plain); | |||||||||||||||||||||||||||||||||||||||
| 384 | 990 | $line += ($plain =~ tr/\n//); | |||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||
| 386 | else { | ||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $self->warning("unexpected end of input", $name, $line); | |||||||||||||||||||||||||||||||||||||||
| 388 | 0 | last; | |||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||
| 392 | 640 | ▶ | while (@stack > 1) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 393 | 3 | $cmd = pop @stack; | |||||||||||||||||||||||||||||||||||||||
| 394 | 3 | $self->warning("unterminated '$cmd->[CMD]$cmd->[LPAREN]' starting", | |||||||||||||||||||||||||||||||||||||||
| 395 | $name, $cmd->[LINE]); | ||||||||||||||||||||||||||||||||||||||||
| 396 | 3 | ▶ | $cmd = $TEXTSEQ->new($cmd) | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$Pod::POM::TEXTSEQ->new($cmd) || $self->error($Pod::POM::TEXTSEQ->error)
MC/DC0%0/2
$Pod::POM::TEXTSEQ->new($cmd) || $self->error($Pod::POM::TEXTSEQ->error)
$Pod::POM::TEXTSEQ->new($cmd)
$self->error($Pod::POM::TEXTSEQ->error)
Truth table33%1/3
A || B
A= $Pod::POM::TEXTSEQ->new($cmd)B= $self->error($Pod::POM::TEXTSEQ->error)
| |||||||||||||||||||||||||||||||||||||||||
| 397 | || $self->error($TEXTSEQ->error()); | ||||||||||||||||||||||||||||||||||||||||
| 398 | 3 | push(@{ $stack[-1]->[CONTENT] }, $cmd); | |||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||
| 401 | 640 | ▶ | return $TEXTSEQ->new(pop(@stack)) | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$Pod::POM::TEXTSEQ->new(pop @stack) || $self->error($Pod::POM::TEXTSEQ->error)
MC/DC0%0/2
$Pod::POM::TEXTSEQ->new(pop @stack) || $self->error($Pod::POM::TEXTSEQ->error)
$Pod::POM::TEXTSEQ->new(pop @stack)
$self->error($Pod::POM::TEXTSEQ->error)
Truth table33%1/3
A || B
A= $Pod::POM::TEXTSEQ->new(pop @stack)B= $self->error($Pod::POM::TEXTSEQ->error)
| |||||||||||||||||||||||||||||||||||||||||
| 402 | || $self->error($TEXTSEQ->error()); | ||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||
| 406 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 407 | # default_view($viewer) | ||||||||||||||||||||||||||||||||||||||||
| 408 | # | ||||||||||||||||||||||||||||||||||||||||
| 409 | # Accessor method to return or update the $DEFVIEW package variable, | ||||||||||||||||||||||||||||||||||||||||
| 410 | # loading the module for any package name specified. | ||||||||||||||||||||||||||||||||||||||||
| 411 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||
| 413 | 1 | ▶ | sub default_view { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_view: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 414 | 1 | my ($self, $viewer) = @_; | |||||||||||||||||||||||||||||||||||||||
| 415 | 1 | ▶ | return $DEFAULT_VIEW unless $viewer; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | ▶ | unless (ref $viewer) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 417 | 1 | my $file = $viewer; | |||||||||||||||||||||||||||||||||||||||
| 418 | 1 | $file =~ s[::][/]g; | |||||||||||||||||||||||||||||||||||||||
| 419 | 1 | $file .= '.pm'; | |||||||||||||||||||||||||||||||||||||||
| 420 | 1 | eval { require $file }; | |||||||||||||||||||||||||||||||||||||||
| 421 | 1 | ▶ | return $self->error($@) if $@; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||
| 424 | 1 | return ($DEFAULT_VIEW = $viewer); | |||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||
| 428 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 429 | # warning($msg, $file, $line) | ||||||||||||||||||||||||||||||||||||||||
| 430 | # | ||||||||||||||||||||||||||||||||||||||||
| 431 | # Appends a string of the form " at $file line $line" to $msg if | ||||||||||||||||||||||||||||||||||||||||
| 432 | # $file is specified and then stores $msg in the internals | ||||||||||||||||||||||||||||||||||||||||
| 433 | # WARNINGS list. If the WARN option is set then the warning is | ||||||||||||||||||||||||||||||||||||||||
| 434 | # raised, either via warn(), or by dispatching to a subroutine | ||||||||||||||||||||||||||||||||||||||||
| 435 | # when WARN is defined as such. | ||||||||||||||||||||||||||||||||||||||||
| 436 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||
| 438 | 27 | ▶ | sub warning { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
warning: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 439 | 27 | my ($self, $msg, $file, $line) = @_; | |||||||||||||||||||||||||||||||||||||||
| 440 | 27 | my $warn = $self->{ WARN }; | |||||||||||||||||||||||||||||||||||||||
| 441 | 27 | ▶ | $line = 'unknown' unless defined $line && length $line; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $line and length $line
MC/DC0%0/2
defined $line and length $line
defined $line
length $line
Truth table33%1/3
A and B
A= defined $lineB= length $line
| |||||||||||||||||||||||||||||||||||||||||
| 442 | 27 | ▶ | $msg .= " at $file line $line" if $file; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||
| 444 | 27 | push(@{ $self->{ WARNINGS } }, $msg); | |||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||
| 446 | 27 | ▶ | if (ref $warn eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 447 | 6 | &$warn($msg); | |||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||
| 449 | elsif ($warn) { | ||||||||||||||||||||||||||||||||||||||||
| 450 | 6 | warn($msg, "\n"); | |||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||
| 455 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 456 | # warnings() | ||||||||||||||||||||||||||||||||||||||||
| 457 | # | ||||||||||||||||||||||||||||||||||||||||
| 458 | # Returns a reference to the (possibly empty) list of warnings raised by | ||||||||||||||||||||||||||||||||||||||||
| 459 | # the most recent call to any of the parse_XXX() methods | ||||||||||||||||||||||||||||||||||||||||
| 460 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||
| 462 | 4 | ▶ | sub warnings { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
warnings: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 463 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 464 | 4 | ▶ | return wantarray ? @{ $self->{ WARNINGS } } : $self->{ WARNINGS }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||
| 468 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 469 | # error($msg) | ||||||||||||||||||||||||||||||||||||||||
| 470 | # | ||||||||||||||||||||||||||||||||||||||||
| 471 | # Sets the internal ERROR member and returns undef when called with an | ||||||||||||||||||||||||||||||||||||||||
| 472 | # argument(s), returns the current value when called without. | ||||||||||||||||||||||||||||||||||||||||
| 473 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=4 SCAR=26.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my $errvar; | |||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||
| 479 | { | ||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | no strict qw( refs ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | if (ref $self) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $errvar = \$self->{ ERROR }; | |||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||
| 484 | else { | ||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $errvar = \${"$self\::ERROR"}; | |||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | $$errvar = ref($_[0]) ? shift : join('', @_); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||
| 492 | else { | ||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | return $$errvar; | |||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | sub DEBUG { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
DEBUG: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | print STDERR "DEBUG: ", @_ if $DEBUG; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||
| 503 | 18 | 1; | |||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||
| 505 | __END__ | ||||||||||||||||||||||||||||||||||||||||