| 1 | ############################################################################# | ||||||||||||||||||||||||||||
| 2 | ## Name: ePod.pm | ||||||||||||||||||||||||||||
| 3 | ## Purpose: ePod - easy-POD converter to POD. | ||||||||||||||||||||||||||||
| 4 | ## Author: Graciliano M. P. | ||||||||||||||||||||||||||||
| 5 | ## Modified by: | ||||||||||||||||||||||||||||
| 6 | ## Created: 2004-01-13 | ||||||||||||||||||||||||||||
| 7 | ## RCS-ID: | ||||||||||||||||||||||||||||
| 8 | ## Copyright: (c) 2004 Graciliano M. P. | ||||||||||||||||||||||||||||
| 9 | ## Licence: This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 10 | ## modify it under the same terms as Perl itself | ||||||||||||||||||||||||||||
| 11 | ############################################################################# | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | package ePod ; | ||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use 5.006 ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use strict qw(vars); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | no warnings ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use vars qw($VERSION @ISA) ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | $VERSION = '0.05' ; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | require Exporter; | |||||||||||||||||||||||||||
| 24 | 1 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | our @EXPORT = qw(to_pod epod2pod) ; | |||||||||||||||||||||||||||
| 27 | 1 | our @EXPORT_OK = @EXPORT ; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | ######## | ||||||||||||||||||||||||||||
| 30 | # VARS # | ||||||||||||||||||||||||||||
| 31 | ######## | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | my $OVER_SIZE_DEF = 4 ; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | my $OVER_SIZE = $OVER_SIZE_DEF ; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | ####### | ||||||||||||||||||||||||||||
| 38 | # NEW # | ||||||||||||||||||||||||||||
| 39 | ####### | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.7
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | 1 | my $this = shift ; | |||||||||||||||||||||||||||
| 43 | 1 | ▶ | return( $this ) if ref($this) ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | my $class = $this || __PACKAGE__ ; | ||||||||||||||||||||||||||
|
Condition50%1/2
$this || __PACKAGE__
MC/DC0%0/1
$this || __PACKAGE__
$this
Truth table50%1/2
A
A= $this
| |||||||||||||||||||||||||||||
| 45 | 1 | $this = bless({} , $class) ; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | my ( %args ) = @_ ; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 1 | foreach my $Key ( keys %args ) { | |||||||||||||||||||||||||||
| 50 | 1 | my $k = $Key ; | |||||||||||||||||||||||||||
| 51 | 1 | $k =~ s/[\W_]//gs ; $k = uc($k) ; | |||||||||||||||||||||||||||
| 52 | 1 | $this->{$k} = $args{$Key} ; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 1 | ▶ | $this->{OVERSIZE} = $OVER_SIZE_DEF if !$this->{OVERSIZE} || $this->{OVERSIZE} !~ /^\d+$/s ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$this->{"OVERSIZE"} and $this->{"OVERSIZE"} =~ /^\d+$/s
MC/DC0%0/2
$this->{"OVERSIZE"} and $this->{"OVERSIZE"} =~ /^\d+$/s
$this->{"OVERSIZE"}
$this->{"OVERSIZE"} =~ /^\d+$/s
Truth table33%1/3
A and B
A= $this->{"OVERSIZE"}B= $this->{"OVERSIZE"} =~ /^\d+$/s
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 1 | return $this ; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | ########## | ||||||||||||||||||||||||||||
| 61 | # TO_POD # | ||||||||||||||||||||||||||||
| 62 | ########## | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub to_pod { | ||||||||||||||||||||||||||
|
Subroutine
to_pod: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $this = UNIVERSAL::isa($_[0] , 'ePod') ? shift : undef ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $this = ePod->new() if !$this ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | my ($data , $file) ; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ( ref($_[0]) eq 'GLOB' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | 1 while( read($_[0], $data , 1024*8 , length($data) ) ) ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | shift ; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | ▶ | elsif ( $_[0] !~ /[\r\n]/s && -s $_[0] ) { | |||||||||||||||||||||||||||
|
Condition0%0/3
not $_[0] =~ /[\r\n]/s and -s $_[0]
MC/DC0%0/2
not $_[0] =~ /[\r\n]/s and -s $_[0]
not $_[0] =~ /[\r\n]/s
-s $_[0]
Truth table0%0/3
not(A) and B
A= not $_[0] =~ /[\r\n]/sB= -s $_[0]
| |||||||||||||||||||||||||||||
| 75 | 0 | $file = shift ; | |||||||||||||||||||||||||||
| 76 | 0 | open (my $fh,$file) ; binmode($fh) ; | |||||||||||||||||||||||||||
| 77 | 0 | ▶ | 1 while( read($fh, $data , 1024*8 , length($data) ) ) ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | close ($fh) ; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 0 | else { $data = shift ;} | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my $new_file = ( $_[0] =~ /\.pod$/i && $_[0] !~ /[\r\n]/s ) ? shift : $file ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[0] =~ /\.pod$/i and not $_[0] =~ /[\r\n]/s
MC/DC0%0/2
$_[0] =~ /\.pod$/i and not $_[0] =~ /[\r\n]/s
$_[0] =~ /\.pod$/i
not $_[0] =~ /[\r\n]/s
Truth table0%0/3
A and not(B)
A= $_[0] =~ /\.pod$/iB= not $_[0] =~ /[\r\n]/s
| |||||||||||||||||||||||||||||
| 83 | 0 | my $replace = shift ; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ($new_file eq '') { 'unamed' ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | $new_file =~ s/\.epod$/.pod/i ; | |||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ( $new_file !~ /\.pod$/i) { $new_file .= '.pod' ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | while ( !$replace && -e $new_file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $replace and -e $new_file
MC/DC0%0/2
not $replace and -e $new_file
not $replace
-e $new_file
Truth table0%0/3
not(A) and B
A= not $replaceB= -e $new_file
| |||||||||||||||||||||||||||||
| 91 | 0 | $new_file =~ s/(?:-?(\d+))?(\.pod)$/ my $n = $1 + 1 ; "-$n$2" /gei ; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | $data = $this->epod2pod($data) ; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | open (my $fh,">$new_file") ; binmode($fh) ; | |||||||||||||||||||||||||||
| 97 | 0 | print $fh $data ; | |||||||||||||||||||||||||||
| 98 | 0 | close ($fh) ; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if ( wantarray ) { return( $new_file , $data ) ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | return $new_file ; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | ############ | ||||||||||||||||||||||||||||
| 105 | # EPOD2POD # | ||||||||||||||||||||||||||||
| 106 | ############ | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 5 | ▶ | sub epod2pod { | ||||||||||||||||||||||||||
|
Subroutine
epod2pod: called CC=16 SCAR=30.6
Pod
documented
| |||||||||||||||||||||||||||||
| 109 | 5 | ▶ | my $this = UNIVERSAL::isa($_[0] , 'ePod') ? shift : undef ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 5 | ▶ | $this = ePod->new() if !$this ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 5 | $OVER_SIZE = $this->{OVERSIZE} ; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 5 | my ($data , $fh , $no_close) ; | |||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ( ref($_[0]) eq 'GLOB' ) { $fh = $_[0] ; $no_close = 1 ;} | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | elsif ( $_[0] =~ /[\r\n]/s && !-e $_[0] ) { $data = $_[0] ;} | ||||||||||||||||||||||||||
|
Condition33%1/3
$_[0] =~ /[\r\n]/s and not -e $_[0]
MC/DC0%0/2
$_[0] =~ /[\r\n]/s and not -e $_[0]
$_[0] =~ /[\r\n]/s
not -e $_[0]
Truth table33%1/3
A and not(B)
A= $_[0] =~ /[\r\n]/sB= not -e $_[0]
| |||||||||||||||||||||||||||||
| 117 | 5 | else { open ($fh,$_[0]) ;} | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 5 | ▶ | if ( $fh ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 5 | binmode($fh) ; | |||||||||||||||||||||||||||
| 121 | 5 | ▶ | 1 while( read($fh, $data , 1024*8 , length($data) ) ) ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 5 | ▶ | close ($fh) if !$no_close ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 5 | $data =~ s/\r\n?/\n/gs ; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 5 | $data = "\n\n$data\n" ; | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 5 | $data =~ s/(\S)[ \t]+\n/$1\n/gs ; | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 5 | ▶ | 1 while( $data =~ s/(\n\S[^\n]*)(?:\n[ \t]*){2,}(\n\S[^\n]*\n)/$1\n$2/gxs ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 5 | ▶ | 1 while( $data =~ s/((?:^|\n)\S[^\n]*\n)([ \t]+\n)+/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 0 | my $init = $1 ; | |||||||||||||||||||||||||||
| 135 | 0 | my $ns = $2 ; | |||||||||||||||||||||||||||
| 136 | 0 | $ns =~ s~[ \t]~~gs ; | |||||||||||||||||||||||||||
| 137 | 0 | "$init$ns" | |||||||||||||||||||||||||||
| 138 | /gexs ) ; | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 5 | $data =~ s/\n=((?:head\d+|item)\s)/\n=EPOD_FIX_$1/gs ; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 5 | ▶ | $data =~ s/\n(?:=(>+)|(=+)>)[ \t]*/ my $n = length($1||$2) ; "\n=head$n " /ges ; | ||||||||||||||||||||||||||
|
Condition66%2/3
$1 || $2
MC/DC0%0/2
$1 || $2
$1
$2
Truth table66%2/3
A || B
A= $1B= $2
| |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 5 | my @blocks = split(/\n+=head[ \t]*/s , $data) ; | |||||||||||||||||||||||||||
| 145 | 5 | foreach my $blocks_i ( @blocks ) { | |||||||||||||||||||||||||||
| 146 | 27 | $blocks_i = adjust_spaces($blocks_i) ; | |||||||||||||||||||||||||||
| 147 | 27 | $blocks_i = adjust_itens($blocks_i) ; | |||||||||||||||||||||||||||
| 148 | 27 | $blocks_i = adjust_itens($blocks_i) ; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | 5 | $data = join("\n=head", @blocks) ; | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 5 | ▶ | return undef if $data !~ /\S/s ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 5 | $data =~ s/\n=EPOD_FIX_(\w+)/\n=$1/gs ; | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 5 | $data =~ s/\n(=\w)/\r$1/gs ; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 5 | $data =~ s/((?:\r|^)=\w+[^\r\n]*)\n+/$1\r\n\n/gs ; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 5 | $data =~ s/\r\n\n\r/\n\n/gs ; | |||||||||||||||||||||||||||
| 161 | 5 | $data =~ s/\r(=\w)/\n$1/gs ; | |||||||||||||||||||||||||||
| 162 | 5 | $data =~ s/\r//gs ; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 5 | $data =~ s/^\s*/\n\n/s ; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 5 | ▶ | $data =~ s/^\s*/\n\n=pod\n\n/s if $data !~ /^\s*?\n=\w+\s/s ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 5 | ▶ | $data =~ s/\s*$/\n\n=cut\n\n/s if $data !~ /\n=cut\s*$/ ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 5 | return $data ; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | ########### | ||||||||||||||||||||||||||||
| 174 | # IS_EPOD # | ||||||||||||||||||||||||||||
| 175 | ########### | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub is_epod { | ||||||||||||||||||||||||||
|
Subroutine
is_epod: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ( $_[0] =~ /(?:[\r\n]|^)(?:=+>|=>+|\*+>|\*>+)[^>]/ ) { return 1 ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 0 | return 1 ; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | ################# | ||||||||||||||||||||||||||||
| 183 | # ADJUST_SPACES # | ||||||||||||||||||||||||||||
| 184 | ################# | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 96 | ▶ | sub adjust_spaces { | ||||||||||||||||||||||||||
|
Subroutine
adjust_spaces: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 187 | 96 | my $block = shift ; | |||||||||||||||||||||||||||
| 188 | 96 | my ( $not_init ) = @_ ; | |||||||||||||||||||||||||||
| 189 | 96 | ▶ | $block =~ s/^((?:[^\n]+\n))\n*/$1\n\n/s if !$not_init ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 96 | $block =~ s/\n*$/\n/s ; | |||||||||||||||||||||||||||
| 191 | 96 | return( $block ) ; | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | ################ | ||||||||||||||||||||||||||||
| 195 | # ADJUST_ITENS # | ||||||||||||||||||||||||||||
| 196 | ################ | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 100 | ▶ | sub adjust_itens { | ||||||||||||||||||||||||||
|
Subroutine
adjust_itens: called CC=19 SCAR=29.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 199 | 100 | my $block = shift ; | |||||||||||||||||||||||||||
| 200 | 100 | my $level = shift ; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||
| 203 | 100 | my (@items) = ( $block =~ /(?:\n|^) | |||||||||||||||||||||||||||
| 204 | ( | ||||||||||||||||||||||||||||
| 205 | \/? | ||||||||||||||||||||||||||||
| 206 | (?: | ||||||||||||||||||||||||||||
| 207 | \*>+ | ||||||||||||||||||||||||||||
| 208 | | | ||||||||||||||||||||||||||||
| 209 | \*+> | ||||||||||||||||||||||||||||
| 210 | ) | ||||||||||||||||||||||||||||
| 211 | | | ||||||||||||||||||||||||||||
| 212 | \*+\/ | ||||||||||||||||||||||||||||
| 213 | ) | ||||||||||||||||||||||||||||
| 214 | /sxg ) ; | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 100 | ▶ | return( $block ) if !@items ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 23 | ▶ | if ( !$level ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 12 | foreach my $items_i ( @items ) { | |||||||||||||||||||||||||||
| 220 | 12 | my ($n1,$n2) = ( $items_i =~ /^(?:(\*+)>|\*(>+))$/ ); | |||||||||||||||||||||||||||
| 221 | 12 | ▶ | my $n = length($n1 || $n2) ; | ||||||||||||||||||||||||||
|
Condition66%2/3
$n1 || $n2
MC/DC0%0/2
$n1 || $n2
$n1
$n2
Truth table66%2/3
A || B
A= $n1B= $n2
| |||||||||||||||||||||||||||||
| 222 | 12 | ▶ | next if !$n ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 12 | $level = $n ; | |||||||||||||||||||||||||||
| 224 | 12 | last ; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | else { | ||||||||||||||||||||||||||||
| 228 | 11 | my $min_level ; | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 11 | foreach my $items_i ( @items ) { | |||||||||||||||||||||||||||
| 231 | 32 | my ($n1,$n2) = ( $items_i =~ /^(?:(\*+)>|\*(>+))$/ ); | |||||||||||||||||||||||||||
| 232 | 32 | ▶ | my $n = length($n1 || $n2) ; | ||||||||||||||||||||||||||
|
Condition100%3/3
$n1 || $n2
MC/DC100%2/2
$n1 || $n2
$n1
$n2
Truth table100%3/3
A || B
A= $n1B= $n2
| |||||||||||||||||||||||||||||
| 233 | 32 | ▶ | next if !$n ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 26 | ▶ | $min_level = $n if $n < $min_level || !$min_level ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$n < $min_level or not $min_level
MC/DC100%2/2
$n < $min_level or not $min_level
$n < $min_level
not $min_level
Truth table100%3/3
A or not(B)
A= $n < $min_levelB= not $min_level
| |||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 11 | ▶ | if ( $min_level > $level ) { $level = $min_level ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 23 | ▶ | $level = 1 if $level < 1 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | ########################## | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 23 | my ($block_itens , $block_rest) = split(/ | |||||||||||||||||||||||||||
| 246 | \n | ||||||||||||||||||||||||||||
| 247 | (?: | ||||||||||||||||||||||||||||
| 248 | \/\*>{$level} | ||||||||||||||||||||||||||||
| 249 | | | ||||||||||||||||||||||||||||
| 250 | \/\*{$level}> | ||||||||||||||||||||||||||||
| 251 | | | ||||||||||||||||||||||||||||
| 252 | \*{$level}\/ | ||||||||||||||||||||||||||||
| 253 | ) | ||||||||||||||||||||||||||||
| 254 | [^>] | ||||||||||||||||||||||||||||
| 255 | \n* | ||||||||||||||||||||||||||||
| 256 | /sx , "$block\n" , 2) ; | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 23 | ▶ | if ( $block_rest ) { $block_rest =~ s/\n$//s ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 15 | else { $block_itens =~ s/\n$//s ;} | |||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 23 | $block_itens =~ s/\n=(item\s)/\n=EPOD_FIX_$1/gs ; | |||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | ########################## | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 23 | $block_itens =~ s/ | |||||||||||||||||||||||||||
| 266 | (?:\n|^) | ||||||||||||||||||||||||||||
| 267 | (?: | ||||||||||||||||||||||||||||
| 268 | \*>{$level} | ||||||||||||||||||||||||||||
| 269 | | | ||||||||||||||||||||||||||||
| 270 | \*{$level}> | ||||||||||||||||||||||||||||
| 271 | ) | ||||||||||||||||||||||||||||
| 272 | ([^>]) | ||||||||||||||||||||||||||||
| 273 | [ \t]* | ||||||||||||||||||||||||||||
| 274 | /\n=item$1/gsx ; | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | ########################## | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 23 | my @itens = split(/\n+=item[ \t]*/s , $block_itens) ; | |||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 23 | my $top = shift(@itens) ; | |||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 23 | foreach my $itens_i ( @itens ) { | |||||||||||||||||||||||||||
| 283 | 37 | $itens_i = adjust_spaces($itens_i) ; | |||||||||||||||||||||||||||
| 284 | 37 | $itens_i = adjust_itens($itens_i , $level+1) ; | |||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 23 | ▶ | if ( $top =~ /(?:\n|^)(?:\*+>|\*>+)[^>]/s ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 1 | $top = adjust_itens( adjust_spaces($top,1) ) ; | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 23 | ▶ | $top =~ s/\s*$/\n\n=over $OVER_SIZE\n/s if @itens ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 23 | ▶ | $itens[ $#itens ] =~ s/\s*$/\n\n=back\n/s if @itens ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 23 | ▶ | $block_rest = adjust_itens( adjust_spaces($block_rest,1) ) if $block_rest ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | 23 | $block_rest =~ s/^\s*/\n/s ; | |||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 23 | $block = join("\n=item ", $top , @itens ) . $block_rest ; | |||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 23 | $block = adjust_spaces($block , 1) ; | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 23 | return $block ; | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | ####### | ||||||||||||||||||||||||||||
| 306 | # END # | ||||||||||||||||||||||||||||
| 307 | ####### | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 1 | 1; | |||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | __END__ | ||||||||||||||||||||||||||||