blib/lib/LaTeX/Replicase.pm

filter: Statementstmt 97.2% 1033 / 1062 Branchbran 91.9% 705 / 768 (5 uncoverable) Conditioncond 84.3% 452 / 536 MC/DCmcdc 71.5% 206 / 288 Subroutinesub 100% 26 / 26 Podpod 100% 6 / 6 totaltotal 90.4% 2428 / 2686 (5 uncoverable) CC 607 SCAR 44.1
CC
607
Cov
93%
onecell
144.8
_replisome
109.8
replication
102.8
CRAP 82.2
↑ Summary
1 package LaTeX::Replicase;
2  
3 6 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # no warnings 'numeric';
7 6 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 ▶use File::Basename qw(fileparse);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use File::Path qw(make_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use File::Compare;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 # use Data::Dumper;
14  
15 6 require Exporter;
16  
17 6 our @ISA = qw(Exporter);
18  
19 6 our %EXPORT_TAGS = ('all' => [ qw(
20 replication
21 tex_escape
22 REase
23 AGLkit
24 font_metrics
25 onecell
26 ) ],
27 );
28  
29 6 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
30 6 our @EXPORT = qw( );
31  
32 6 our $VERSION = '0.803';
33 6 our $DEBUG = 0;
34  
35 6 our $qs = qr/^|_|\b/o;
36 6 our $qe = qr/_|\b|$/o;
37  
38 # for glue
39 6 our $q = qr/\{\\hskip0pt +plus +0?.02em\}/o;
40 # our $p; $p = qr/\{\s*(?:(?>$q)|(??{$p}))*\s*\}/o;
41 6 our $m = '{\\hskip0pt plus .02em}';
42  
43 # '!'=>\x21 '"'=>\x22 '#'=>\x23 '$'=>\x24 '%'=>\x25 '&'=>\x26 "'"=>\x27
44 # '('=>\x28 ')'=>\x29 '*'=>\x2A '+'=>\x2B ','=>\x2C '-'=>\x2D '.'=>\x2E '/'=>\x2F
45 # ---
46 # ':'=>\x3A ';'=>\x3B '<'=>\x3C '='=>\x3D '>'=>\x3E '?'=>\x3F '@'=>\x40
47 # ---
48 # '['=>\x5B '\'=>\x5C ']'=>\x5D '^'=>\x5E '_'=>\x5F '`'=>\x60
49 # ---
50 # '{'=>\x7B '|'=>\x7C '}'=>\x7D '~'=>\x7E
51 6 our $sI = qr/[\s\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]/o;
52 6 our $sII = qr/[a-zA-Z0-9,=:;!\>\<\)\(\/\.\s\+\-\*\?]+/o;
53  
54 # font sizes, depending on the document's base font size (pt), see \documentclass[...pt]
55 6 our $fontSizeTeX = {
56 names => {tiny=>0, scriptsize=>1, footnotesize=>2, small=>3, normalsize=>4, large=>5, Large=>6, LARGE=>7, huge=>8, Huge=>9},
57 # 0 1 2 3 4 5 6 7 8 9
58 10 => [5, 7, 8, 9, 10, 12, 14.4, 17.28, 20.74, 24.88],
59 11 => [6, 8, 9, 10, 10.95, 12, 14.4, 17.28, 20.74, 24.88],
60 12 => [6, 8, 10, 10.95, 12, 14.4, 17.28, 20.74, 24.88, 24.88],
61 };
62  
63 6 our $refHypMsk = {
64 en => qr/[a-zA-Z\-]+/o,
65 ru => qr/[а-яёА-ЯЁ\-]+/o,
66 };
67  
68 #-------------------
69 # External functions
70 #-------------------
71  
72 # Masks (or replaces with equivalents) the active 9 TeX characters: &, %, $, #, _, {, }, ^, \
73 # with additionally replace character '~'
74 # INPUT:
75 # $_[0] string
76 # $_[1] HASH of options (only need 'esc' key) / SCALAR string with additional substitutions: '~_%_s_REase_'
77 # OUTPUT (and $_[1]->{mflag} if $_[1] is 'HASH'):
78 # 0 -- value NOT changed
79 # 1 -- value changed
80  
81 101 ▶sub tex_escape {
Subroutine tex_escape: called CC=43 SCAR=37.6
Pod documented
82 101 ▶ $_[0] or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0] or return 0 99 2 101
83  
84 99 our( $qs, $qe, $sI, $sII );
85  
86 99 my $opH = ref $_[1] eq 'HASH';
87 99 my $mflag = 0;
88 99 my $prm = '';
89  
90 99 ▶ if( $opH ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opH) { } 38 61 99
elsif (ref \$_[1] eq 'SCALAR') { } 60 1 61
91  
92 38 ▶ if( $_[1]->{_MFLAGS_} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1]{"_MFLAGS_"}) 4 34 38
93 4 ▶ return 0 if $_[1]->{_MFLAGS_} & 0b0100; # SUPPER critical changes in TeX-commands before
Branch: 1 branch
BranchTrueFalseTotal
if $_[1]{"_MFLAGS_"} & 4 1 3 4
94 3 ▶ goto _tex_escape_to_REase if $_[1]->{_MFLAGS_} & 0b0010; # critical changes in TeX-commands before
Branch: 1 branch
BranchTrueFalseTotal
if $_[1]{"_MFLAGS_"} & 2 2 1 3
95 }
96  
97 35 ▶ $prm = $_[1]->{esc} // '';
Condition100%2/2
$_[1]{"esc"} // ""
l!l
296
MC/DC100%1/1
$_[1]{"esc"} // ""
$_[1]{"esc"}
Truth table100%2/2
A
A= $_[1]{"esc"}
Aresult
11
00
98 }
99 elsif( ref \$_[1] eq 'SCALAR') {
100 60 ▶ $prm = $_[1] // '';
Condition100%2/2
$_[1] // ""
l!l
3822
MC/DC100%1/1
$_[1] // ""
$_[1]
Truth table100%2/2
A
A= $_[1]
Aresult
11
00
101 }
102  
103 96 ▶ goto _tex_escape_to_REase if $_[0] =~/\A${sII}\Z/m;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /\A$LaTeX::Replicase::sII\Z/m 17 79 96
104  
105 79 my $stag = ''; # start tag
106  
107 79 ▶ if( $_[0] =~/\A%%%:/ and $prm !~/!stag(?:$qe)/) { # SKIP start tag
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /\A%%%:/ and not $prm =~ /!stag(?:$LaTeX::Replicase::qe)/) 12 67 79
Condition100%3/3
$_[0] =~ /\A%%%:/ and not $prm =~ /!stag(?:$LaTeX::Replicase::qe)/
!ll&&!rl&&r
60712
MC/DC100%2/2
$_[0] =~ /\A%%%:/ and not $prm =~ /!stag(?:$LaTeX::Replicase::qe)/
$_[0] =~ /\A%%%:/ not $prm =~ /!stag(?:$LaTeX::Replicase::qe)/
Truth table100%3/3
A and not(B)
A= $_[0] =~ /\A%%%:/B= not $prm =~ /!stag(?:$LaTeX::Replicase::qe)/
ABresult
0X0
100
111
108  
109 12 ▶ if( $prm =~/\-stag(?:$qe)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($prm =~ /\-stag(?:$LaTeX::Replicase::qe)/) { } 2 10 12
elsif ($prm =~ /\+stag(?:$LaTeX::Replicase::qe)/) { } 8 2 10
110 2 $_[0] =~s/\A(%%%:)+//m; # remove ALL start tag(s)
111 2 my $s = $1;
112 2 ▶ $stag = $s if $prm =~/\+stag(?:$qe)/;
Branch: 1 branch
BranchTrueFalseTotal
if $prm =~ /\+stag(?:$LaTeX::Replicase::qe)/ 1 1 2
113 2 $mflag |= 0b0001; # simple text changes
114 }
115 elsif( $prm =~/\+stag(?:$qe)/) { # save start tag '%%%:'
116 8 ▶ return $mflag if $prm !~/(?:$qs)REase(?:$qe)/;
Branch: 1 branch
BranchTrueFalseTotal
unless $prm =~ /(?:$LaTeX::Replicase::qs)REase(?:$LaTeX::Replicase::qe)/ 7 1 8
117  
118 1 goto _tex_escape_to_REase;
119 }
120 else {
121 2 $_[0] =~s/\A%%%://m; # remove 1 start tag
122 2 $mflag |= 0b0001; # simple text changes
123 2 goto _tex_escape_to_REase;
124 }
125  
126 }
127  
128 69 ▶ if( $_[0] =~/\\/ ) { # check '\' symbol
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /\\/) { } 22 47 69
129  
130 22 my @arr = split /\\/, $_[0], -1;
131  
132 22 my $yes = 0;
133 22 my $z;
134 my $i;
135 22 foreach( @arr ) {
136 204 $z = length;
137  
138 204 ▶ if( ++$i > 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (++$i > 1) { } 182 22 204
elsif (not $z) { } 17 5 22
139  
140 182 ▶ if( ! $z ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($z) 17 165 182
141 17 $_ = 'char92\\/';
142 17 next;
143 }
144  
145 165 ▶ next if /^char92(?:\D|$)/ or /^textbackslash(?:[^a-zA-Z]|$)/
Branch: 1 branch
BranchTrueFalseTotal
if /^char92(?:\D|$)/ or /^textbackslash(?:[^a-zA-Z]|$)/ or /^relax(?:[^a-zA-Z]|$)/ or /^hskip\s*\d/ 25 140 165
Condition100%9/9
/^char92(?:\D|$)/ or /^textbackslash(?:[^a-zA-Z]|$)/ or /^relax(?:[^a-zA-Z]|$)/ or /^hskip\s*\d/
l!l&&r!l&&!r
205140
/^char92(?:\D|$)/ or /^textbackslash(?:[^a-zA-Z]|$)/ or /^relax(?:[^a-zA-Z]|$)/
l!l&&r!l&&!r
137145
/^char92(?:\D|$)/ or /^textbackslash(?:[^a-zA-Z]|$)/
l!l&&r!l&&!r
85152
MC/DC100%4/4
/^char92(?:\D|$)/ or /^textbackslash(?:[^a-zA-Z]|$)/ or /^relax(?:[^a-zA-Z]|$)/ or /^hskip\s*\d/
/^char92(?:\D|$)/ /^textbackslash(?:[^a-zA-Z]|$)/ /^relax(?:[^a-zA-Z]|$)/ /^hskip\s*\d/
Truth table100%5/5
A or B or C or D
A= /^char92(?:\D|$)/B= /^textbackslash(?:[^a-zA-Z]|$)/C= /^relax(?:[^a-zA-Z]|$)/D= /^hskip\s*\d/
ABCDresult
1XXX1
01XX1
001X1
00011
00000
146 or /^relax(?:[^a-zA-Z]|$)/
147 or /^hskip\s*\d/;
148  
149 140 ▶ if( $prm !~/(?:$qs)strong(?:$qe)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($prm =~ /(?:$LaTeX::Replicase::qs)strong(?:$LaTeX::Replicase::qe)/) 116 24 140
150 116 ▶ if( $prm =~/(?:$qs)mutual(?:$qe)/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($prm =~ /(?:$LaTeX::Replicase::qs)mutual(?:$LaTeX::Replicase::qe)/) { } 24 92 116
elsif (m[^[\$\t%&}{\-\*/=\._\^~#'`",;!\>]]) { } 79 13 92
151 24 ▶ next if /^[\$\t%&}{\-\*\/=\._\^~#'`"]/; # classic active TeX & LaTeX symbols, but without '\<space>' command
Branch: 1 branch
BranchTrueFalseTotal
if m[^[\$\t%&}{\-\*/=\._\^~#'`"]] 18 6 24
152 }
153 elsif( /^[\$\t%&}{\-\*\/=\._\^~#'`",;!\>]/ ) { # active symbols allowed in LaTeX
154 79 next;
155 }
156 }
157  
158 43 ▶ $_ = 'char92'.(/^$sI/ ? '':'\\/'). $_;
Branch: 1 branch
BranchTrueFalseTotal
/^$LaTeX::Replicase::sI/ ? : 31 12 43
159  
160 }
161 elsif( ! $z ) {
162 17 next;
163 }
164  
165 48 s/[%}{_&#\$]/\\$&/g; # masking active symbols
166 48 s|\^|\\^\\/|g; # ^ --> \^\/
167  
168 48 ▶ if( $prm =~/~/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prm =~ /~/) 41 7 48
169 41 s|~|\\~\\/|g; # tilde (~) --> \~\/
170 }
171  
172 48 ▶ if( $prm =~/(?:$qs)hyphen(?:$qe)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prm =~ /(?:$LaTeX::Replicase::qs)hyphen(?:$LaTeX::Replicase::qe)/) 9 39 48
173 9 s/(?<=[[:alpha:]])\-(?=[[:alpha:]])/"=/gi; #"# make compound words with 'active' hyphens
174 }
175  
176 }
177 continue {
178 204 ▶ if( $z != length ) { # critical changes for TeX-commands
Branch: 1 branch
BranchTrueFalseTotal
if ($z != length $_) 64 140 204
179 64 ▶ $yes ||= 1;
Condition100%2/2
$yes ||= 1
l!l
5311
MC/DC100%1/1
$yes ||= 1
$yes
Truth table100%2/2
A
A= $yes
Aresult
11
00
180 64 $mflag |= 0b0010;
181 }
182 }
183  
184 22 ▶ if( $yes ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($yes) 11 11 22
185 11 $_[0] = join '\\', @arr;
186 11 $_[0] =~s|(?<![~\^])\\/(?=\\)||g; # '\/\' --> '\'
187 }
188  
189 }
190 else {
191  
192 47 for( $_[0] ) {
193 47 my $z = length;
194  
195 47 s/[%}{_&#\$]/\\$&/g; # masking active symbols
196 47 s|\^|\\^\\/|g; # ^ --> \^\/
197  
198 47 ▶ if( $prm =~/~/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prm =~ /~/) 20 27 47
199 20 s|~|\\~\\/|g; # tilde (~) --> \~\/
200 }
201  
202 47 ▶ if( $prm =~/(?:$qs)hyphen(?:$qe)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prm =~ /(?:$LaTeX::Replicase::qs)hyphen(?:$LaTeX::Replicase::qe)/) 7 40 47
203 7 s/(?<=[[:alpha:]])\-(?=[[:alpha:]])/"=/gi; #"# make compound words with 'active' hyphens
204 }
205  
206 47 s|(?<![~\^])\\/(?=\\)||g; # '\/\' --> '\'
207  
208 47 ▶ $mflag |= 0b0010 if $z != length; # critical changes for TeX-commands
Branch: 1 branch
BranchTrueFalseTotal
if $z != length $_ 38 9 47
209 }
210  
211 }
212  
213 69 ▶ $_[0] = $stag . $_[0] if $stag; # add start tag
Branch: 1 branch
BranchTrueFalseTotal
if $stag 1 68 69
214  
215 _tex_escape_to_REase:
216  
217 91 ▶ if( $prm =~/(?:$qs)REase(?:$qe)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prm =~ /(?:$LaTeX::Replicase::qs)REase(?:$LaTeX::Replicase::qe)/) 12 79 91
218 12 ▶ if( $opH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opH) { } 4 8 12
219 4 $_[1]->{_MFLAGS_} += 0;
220 4 $_[1]->{_MFLAGS_} |= $mflag;
221  
222 4 $mflag |= &REase;
223 }
224 else {
225 8 $mflag |= &REase( $_[0], { _MFLAGS_ => $mflag, esc => $prm } );
226 }
227  
228 }
229  
230  
231 91 ▶ return $mflag if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 87 4 91
232 }
233  
234 # REstrictase
235 # INPUT:
236 # $_[0] string
237 # $_[1] HASH of options
238 # OUTPUT:
239 # 0 -- value NOT changed
240 # 1 -- value changed
241 67 ▶sub REase {
Subroutine REase: called CC=26 SCAR=32.6
Pod documented
242 67 ▶ $_[0] or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0] or return 0 64 3 67
243  
244 64 our( $qs, $qe, $q, $m, $sI );
245  
246 64 my $opH = ref $_[1] eq 'HASH';
247  
248 64 my $prm = '';
249 64 my $n = 3; # size of tile, by default
250  
251 64 ▶ if( $opH ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opH) { } 45 19 64
elsif (ref \$_[1] eq 'SCALAR') { } 17 2 19
252 45 ▶ return 0 if $_[1]->{_MFLAGS_} and $_[1]->{_MFLAGS_} & 0b0100; # there were super critical changes in TeX-commands before
Branch: 1 branch
BranchTrueFalseTotal
if $_[1]{"_MFLAGS_"} and $_[1]{"_MFLAGS_"} & 4 1 44 45
Condition100%3/3
$_[1]{"_MFLAGS_"} and $_[1]{"_MFLAGS_"} & 4
!ll&&!rl&&r
25191
MC/DC100%2/2
$_[1]{"_MFLAGS_"} and $_[1]{"_MFLAGS_"} & 4
$_[1]{"_MFLAGS_"} $_[1]{"_MFLAGS_"} & 4
Truth table100%3/3
A and B
A= $_[1]{"_MFLAGS_"}B= $_[1]{"_MFLAGS_"} & 4
ABresult
0X0
100
111
253  
254 44 ▶ $prm = $_[1]->{esc} // '';
Condition100%2/2
$_[1]{"esc"} // ""
l!l
2915
MC/DC100%1/1
$_[1]{"esc"} // ""
$_[1]{"esc"}
Truth table100%2/2
A
A= $_[1]{"esc"}
Aresult
11
00
255 44 ▶ $n = $& if $_[1]->{tile} and $_[1]->{tile} =~/[2-9]/; # 2..9
Branch: 1 branch
BranchTrueFalseTotal
if $_[1]{"tile"} and $_[1]{"tile"} =~ /[2-9]/ 9 35 44
Condition100%3/3
$_[1]{"tile"} and $_[1]{"tile"} =~ /[2-9]/
!ll&&!rl&&r
3419
MC/DC100%2/2
$_[1]{"tile"} and $_[1]{"tile"} =~ /[2-9]/
$_[1]{"tile"} $_[1]{"tile"} =~ /[2-9]/
Truth table100%3/3
A and B
A= $_[1]{"tile"}B= $_[1]{"tile"} =~ /[2-9]/
ABresult
0X0
100
111
256 }
257 elsif( ref \$_[1] eq 'SCALAR') {
258 17 ▶ $prm = $_[1] // '';
Condition100%2/2
$_[1] // ""
l!l
215
MC/DC100%1/1
$_[1] // ""
$_[1]
Truth table100%2/2
A
A= $_[1]
Aresult
11
00
259 }
260  
261 63 my $mflag = 0;
262  
263 63 ▶ if( $_[0] =~/^%%%:/ and $prm !~/!stag(?:$qe)/) { # SKIP start tag
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /^%%%:/ and not $prm =~ /!stag(?:$LaTeX::Replicase::qe)/) 3 60 63
Condition100%3/3
$_[0] =~ /^%%%:/ and not $prm =~ /!stag(?:$LaTeX::Replicase::qe)/
!ll&&!rl&&r
5823
MC/DC100%2/2
$_[0] =~ /^%%%:/ and not $prm =~ /!stag(?:$LaTeX::Replicase::qe)/
$_[0] =~ /^%%%:/ not $prm =~ /!stag(?:$LaTeX::Replicase::qe)/
Truth table100%3/3
A and not(B)
A= $_[0] =~ /^%%%:/B= not $prm =~ /!stag(?:$LaTeX::Replicase::qe)/
ABresult
0X0
100
111
264  
265 3 ▶ if( $prm =~/\-stag(?:$qe)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prm =~ /\-stag(?:$LaTeX::Replicase::qe)/) { } 1 2 3
266 1 $_[0] =~s/^(%%%:)+//; # remove ALL start tags
267 1 $mflag |= 0b0001; # simple text changes (without TeX-commands)
268 }
269 else {
270 2 $_[0] =~s/^%%%://; # remove 1 start tag only
271 2 return 0b0001;
272 }
273 }
274  
275 61 ▶ return 0 if $_[0] =~/\\relax\\\/$/ # exists etag
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ m[\\relax\\/$] or $_[0] =~ /^(?:%%%:)?$LaTeX::Replicase::q/ or length $_[0] < $n + 2 29 32 61
Condition100%6/6
$_[0] =~ m[\\relax\\/$] or $_[0] =~ /^(?:%%%:)?$LaTeX::Replicase::q/ or length $_[0] < $n + 2
l!l&&r!l&&!r
32632
$_[0] =~ m[\\relax\\/$] or $_[0] =~ /^(?:%%%:)?$LaTeX::Replicase::q/
l!l&&r!l&&!r
2158
MC/DC100%3/3
$_[0] =~ m[\\relax\\/$] or $_[0] =~ /^(?:%%%:)?$LaTeX::Replicase::q/ or length $_[0] < $n + 2
$_[0] =~ m[\\relax\\/$] $_[0] =~ /^(?:%%%:)?$LaTeX::Replicase::q/ length $_[0] < $n + 2
Truth table100%4/4
A or B or C
A= $_[0] =~ m[\\relax\\/$]B= $_[0] =~ /^(?:%%%:)?$LaTeX::Replicase::q/C= length $_[0] < $n + 2
ABCresult
1XX1
01X1
0011
0000
276 or $_[0] =~/^(?:%%%:)?$q/ # protection against reuse
277 or length( $_[0] ) < $n + 2;
278  
279 32 my @arr = split /\s+/, $_[0], -1;
280  
281 32 ▶ my $stag = ($arr[0] =~s/^%%%://) ? $& : ''; # start tag
Branch: 1 branch
BranchTrueFalseTotal
$arr[0] =~ s/^%%%:// ? : 2 30 32
282 32 ▶ my $etag = ($_[0] =~/\s+$/) ? $& : ''; # end tag
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /\s+$/ ? : 2 30 32
283  
284 32 for( @arr ) {
285 51 ▶ next if $n + 2 > length
Branch: 1 branch
BranchTrueFalseTotal
if $n + 2 > length $_ or /^\p{Alpha}+$/ 15 36 51
Condition100%3/3
$n + 2 > length $_ or /^\p{Alpha}+$/
l!l&&r!l&&!r
12336
MC/DC100%2/2
$n + 2 > length $_ or /^\p{Alpha}+$/
$n + 2 > length $_ /^\p{Alpha}+$/
Truth table100%3/3
A or B
A= $n + 2 > length $_B= /^\p{Alpha}+$/
ABresult
1X1
011
000
286 or /^\p{Alpha}+$/;
287  
288 36 my $z = $_;
289  
290 36 s/(?:(?<b>.{2,$n}[^\x5C])|(?<b>[^\x5C]|\b))(?<s>[^\x5C\p{Alpha}\.><\}\{'`=_\"-])(?(1)|(?=\p{Alpha}))/$+{b}$m$+{s}$m/g; #'
291  
292 36 s/-{1,3}/$m$&$m/g; # don't touch the em dash
293 36 s/\<{1,2}/$m$&/g;
294 36 s/\>{1,2}/$&$m/g;
295  
296 # removal of excess glue:
297 36 s/(?<=[\(\[\{«])(?:$q)+(?=[[:alnum:]])//g; # after the opening parenthesis
298 36 s/(?<=[[:alnum:]])(?:$q)+(?=[\)\]\}»])//g; # before the closing parenthesis
299  
300 36 s/(?<=\p{Alpha})(?:$q)+([,\.:!;])/$1$m/g; # permutation for these symbols
301  
302 # final removal of excess glue:
303 36 s/^(?:\s*$q\s*)+|(?:$q\s*)+$//g; # start & end glue
304 36 s/\x5C(?:$q)+/\\/g; # JIC: glue after '\'
305  
306 36 ▶ s|(?<=\\char)(?:$q)?9(?:$q)?2(${sI}?)|'92'.$1//'\\/'|eg; # restore '/'
Condition50%1/2
'92' . $1 // "\\/"
l!l
130
MC/DC0%0/1
'92' . $1 // "\\/"
'92' . $1
Truth table50%1/2
A
A= '92' . $1
Aresult
11
00
307  
308 # delete an extra:
309 36 s|(?<=\\char92)($q)\\/|$1|g; # remove '\/'
310 36 s|(?<=\\char92)\\(?!$q)/|$m|g; # '\/' --> glue
311 36 s|(?<=\x5C\^)($q)\\/|$1|g; # '\^\/'
312 36 s|(?<=\\~)($q)\\/|$1|g; # '\~\/'
313 36 s/(?:$q){2,}/$m/g;
314  
315 36 ▶ $mflag |= 0b0111 if $z ne $_;
Branch: 1 branch
BranchTrueFalseTotal
if $z ne $_ 34 2 36
316 }
317  
318 32 ▶ if( $mflag ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mflag) 31 1 32
319 31 $arr[0] = $stag . $m . $arr[0];
320 31 $_[0] = join ' ', @arr;
321 31 ▶ $_[0] =~s/ +$/$etag/ if $etag;
Branch: 1 branch
BranchTrueFalseTotal
if $etag 1 30 31
322 }
323  
324 32 ▶ return $mflag if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 31 1 32
325 }
326  
327  
328 36 ▶sub replication {
Subroutine replication: called CC=86 SCAR=46.3
Pod documented
329 36 my( $source, $info, %op ) = @_;
330  
331 36 our $DEBUG;
332 36 ▶ $op{debug} //= $DEBUG;
Condition66%2/3
$op{"debug"} //= $LaTeX::Replicase::DEBUG
l!l&&r!l&&!r
2970
MC/DC0%0/2
$op{"debug"} //= $LaTeX::Replicase::DEBUG
$op{"debug"} $LaTeX::Replicase::DEBUG
Truth table66%2/3
A //= B
A= $op{"debug"}B= $LaTeX::Replicase::DEBUG
ABresult
1X1
011
000
333  
334 36 our( $qs, $qe, $sI, $sII );
335  
336 36 my $rstype = ref \$source;
337 36 my $stype = ref $source;
338  
339 36 my @logs;
340  
341 36 ▶ if( defined( $source ) && length( $source ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $source and length $source) { } 34 2 36
Condition100%3/3
defined $source and length $source
!ll&&!rl&&r
1134
MC/DC100%2/2
defined $source and length $source
defined $source length $source
Truth table100%3/3
A and B
A= defined $sourceB= length $source
ABresult
0X0
100
111
342  
343 34 ▶ if( $rstype eq 'SCALAR') {
Branch: 2 branches
BranchTrueFalseTotal
if ($rstype eq 'SCALAR') { } 29 5 34
elsif ($stype ne 'ARRAY') { } 1 4 5
344 29 for( $source ) {
345 29 s/^\s+//;
346 29 s/\s+.*//s;
347  
348 6 ▶ $_ = (glob)[0] if $^O =~/(?:linux|bsd|darwin|solaris|sunos)/;
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $^O =~ /(?:linux|bsd|darwin|solaris|sunos)/ 28 1 29
349 }
350 }
351 elsif( $stype ne 'ARRAY') {
352 1 $_ = "!!! ERROR#6: invalid FILE or ARRAY input!";
353 1 ▶ $op{silent} or carp $_;
Branch: 1 branch
BranchTrueFalseTotal
$op{"silent"} or carp($_) 1 0 1
354  
355 1 push @logs, $_;
356 1 return \@logs;
357 }
358  
359 }
360 else {
361 2 $_ = "!!! ERROR#0: undefined input FILE or ARRAY!";
362 # uncoverable branch true
363 2 ▶ $op{silent} or carp $_;
Branch: 1 branch
BranchTrueFalseTotal
$op{"silent"} or carp($_) 2 0 2
364  
365 2 push @logs, $_;
366 2 return \@logs;
367 }
368  
369 33 ▶push @logs, "--> Checking source data: '$source'" if $op{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op{"debug"} 4 29 33
370  
371 33 ▶ if(( $rstype eq 'SCALAR' and ! -s $source) or ( $stype eq 'ARRAY' and ! @$source)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rstype eq "SCALAR" and not -s $source or $stype eq "ARRAY" and not @$source) 1 32 33
Condition77%7/9
$rstype eq "SCALAR" and not -s $source or $stype eq "ARRAY" and not @$source
l!l&&r!l&&!r
1032
$rstype eq "SCALAR" and not -s $source
!ll&&!rl&&r
4281
$stype eq "ARRAY" and not @$source
!ll&&!rl&&r
2840
MC/DC50%2/4
$rstype eq "SCALAR" and not -s $source or $stype eq "ARRAY" and not @$source
$rstype eq "SCALAR" not -s $source $stype eq "ARRAY" not @$source
Truth table42%3/7
A and not(B) or C and not(D)
A= $rstype eq "SCALAR"B= not -s $sourceC= $stype eq "ARRAY"D= not @$source
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
372 1 $_ = "!!! ERROR#1: source ('$source') does NOT exist or is EMPTY!";
373 # uncoverable branch true
374 1 ▶ $op{silent} or carp $_;
Branch: 1 branch
BranchTrueFalseTotal
$op{"silent"} or carp($_) 1 0 1
375  
376 1 push @logs, $_;
377 1 return \@logs;
378 }
379  
380 # global data of TeX file
381 32 my $dtype = ref $info;
382 32 ▶ unless( $info
Branch: 1 branch
BranchTrueFalseTotal
unless ($info and $dtype eq "HASH" && %$info || $dtype eq "ARRAY" && @$info) 2 30 32
Condition83%10/12
$info and $dtype eq "HASH" && %$info || $dtype eq "ARRAY" && @$info
!ll&&!rl&&r
0230
$dtype eq "HASH" and %$info or $dtype eq "ARRAY" and @$info
l!l&&r!l&&!r
2462
$dtype eq "HASH" and %$info
!ll&&!rl&&r
7124
$dtype eq "ARRAY" and @$info
!ll&&!rl&&r
206
MC/DC60%3/5
$info and $dtype eq "HASH" && %$info || $dtype eq "ARRAY" && @$info
$info $dtype eq "HASH" %$info $dtype eq "ARRAY" @$info
Truth table50%4/8
A and B and C or D and E
A= $infoB= $dtype eq "HASH"C= %$infoD= $dtype eq "ARRAY"E= @$info
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
383 and (( $dtype eq 'HASH' and %$info ) or ($dtype eq 'ARRAY' and @$info ))
384 ) {
385 2 $_= "!!! ERROR#2: EMPTY or WRONG data!";
386 2 ▶ $op{silent} or carp $_;
Branch: 1 branch
BranchTrueFalseTotal
$op{"silent"} or carp($_) 2 0 2
387  
388 2 push @logs, $_;
389 2 return \@logs;
390 }
391  
392 # environments: global for %%%V:, %%%VAR: ; and local for %%%VAR:
393 30 my $data = my $vardata = $info;
394  
395 30 my( $filename, $dir );
396 30 ▶ if( $rstype eq 'SCALAR') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rstype eq 'SCALAR') { } 26 4 30
397 26 ( $filename, $dir, my($ext)) = fileparse( $source );
398 }
399 else { # for ARRAY input
400 4 $filename = 'ready.tex';
401 4 $dir = '.';
402 }
403  
404 30 my( $fh, $ofile );
405 30 ▶ if( defined( $_ = $op{ofile} ) && length ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $op{'ofile'}) and length $_) { } 27 3 30
Condition66%2/3
defined($_ = $op{"ofile"}) and length $_
!ll&&!rl&&r
3027
MC/DC50%1/2
defined($_ = $op{"ofile"}) and length $_
defined($_ = $op{"ofile"}) length $_
Truth table66%2/3
A and B
A= defined($_ = $op{"ofile"})B= length $_
ABresult
0X0
100
111
406 27 ▶ if(/::STDOUT$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/::STDOUT$/) { } 1 26 27
407 1 $fh = $ofile = $_;
408 }
409 else {
410 26 s/^\s+//;
411 26 s/\s+.*//s;
412 26 ▶ $ofile = ( $^O =~/(?:linux|bsd|darwin|solaris|sunos)/ ) ? (glob)[0] : $_;
Branch: 1 branch
BranchTrueFalseTotal
$^O =~ /(?:linux|bsd|darwin|solaris|sunos)/ ? : 25 1 26
413 }
414 }
415 else {
416 3 ▶ my $outdir = $op{outdir} // "$dir/$$"; # Target dir for ready TeX file
Condition50%1/2
$op{"outdir"} // "$dir/${$}"
l!l
30
MC/DC0%0/1
$op{"outdir"} // "$dir/${$}"
$op{"outdir"}
Truth table50%1/2
A
A= $op{"outdir"}
Aresult
11
00
417 3 ▶ if( length $outdir ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $outdir) { } 2 1 3
418 2 for( $outdir ) {
419 2 s/^\s+//;
420 2 s/\s+.*//s;
421  
422 2 ▶ $_ = (glob)[0] if $^O =~/(?:linux|bsd|darwin|solaris|sunos)/;
Branch: 1 branch
BranchTrueFalseTotal
if $^O =~ /(?:linux|bsd|darwin|solaris|sunos)/ 2 0 2
423 }
424 }
425 else { # for $outdir = ''
426 1 $outdir = "./$$";
427 }
428  
429 3 ▶ unless( -d $outdir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $outdir) 2 1 3
430 2 make_path( $outdir, {error => \my $err} );
431  
432 # uncoverable branch true
433 2 ▶ if ($err && @$err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err and @$err) 0 2 2
Condition33%1/3
$err and @$err
!ll&&!rl&&r
020
MC/DC0%0/2
$err and @$err
$err @$err
Truth table33%1/3
A and B
A= $errB= @$err
ABresult
0X0
100
111
434  
435 0 for my $diag (@$err) {
436 0 my( $path, $message ) = %$diag;
437 0 ▶ $_ = ( $path && length( $path ) ) ?
Branch: 1 branch
BranchTrueFalseTotal
$path && length $path ? : 0 0 0
Condition0%0/3
$path and length $path
!ll&&!rl&&r
000
MC/DC0%0/2
$path and length $path
$path length $path
Truth table0%0/3
A and B
A= $pathB= length $path
ABresult
0X0
100
111
438 "!!! ERROR#7: ('$path' creation problem) $message" :
439 "!!! ERROR#8: (general error) $message";
440  
441 # uncoverable branch true
442 # uncoverable branch false
443 0 ▶ $op{silent} or carp $_;
Branch: 1 branch
BranchTrueFalseTotal
$op{"silent"} or carp($_) 0 0 0
444 0 push @logs, $_;
445 }
446  
447 0 return \@logs;
448 }
449  
450 }
451  
452 3 $ofile = "$outdir/$filename";
453 }
454  
455 30 ▶push @logs, "--> Using '$ofile' file as output" if $op{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op{"debug"} 4 26 30
456  
457 # new file must be different
458 30 ▶ if( -s $ofile and $rstype eq 'SCALAR'
Branch: 1 branch
BranchTrueFalseTotal
if (-s $ofile and $rstype eq "SCALAR" and $source eq $ofile && compare($source, $ofile) == 0 || join(",", stat $source) eq join(",", stat $ofile)) 1 29 30
Condition75%9/12
-s $ofile and $rstype eq "SCALAR" and $source eq $ofile && compare($source, $ofile) == 0 || join(",", stat $source) eq join(",", stat $ofile)
!ll&&!rl&&r
2631
-s $ofile and $rstype eq "SCALAR"
!ll&&!rl&&r
2604
$source eq $ofile and compare($source, $ofile) == 0 or join(",", stat $source) eq join(",", stat $ofile)
l!l&&r!l&&!r
103
$source eq $ofile and compare($source, $ofile) == 0
!ll&&!rl&&r
301
MC/DC40%2/5
-s $ofile and $rstype eq "SCALAR" and $source eq $ofile && compare($source, $ofile) == 0 || join(",", stat $source) eq join(",", stat $ofile)
-s $ofile $rstype eq "SCALAR" $source eq $ofile compare($source, $ofile) == 0 join(",", stat $source) eq join(",", stat $ofile)
Truth table42%3/7
A and B and C and D or E
A= -s $ofileB= $rstype eq "SCALAR"C= $source eq $ofileD= compare($source, $ofile) == 0E= join(",", stat $source) eq join(",", stat $ofile)
ABCDEresult
0XXXX0
10XXX0
110X00
111000
1111X1
110X11
111011
459 and (
460 ( $source eq $ofile and compare( $source, $ofile ) == 0 )
461 or
462 ( join(',', stat $source) eq join(',', stat $ofile) )
463 )
464 ) {
465 1 $_= "!!! ERROR#3: Input (template) & output files match. Can't overwrite template file!";
466 1 ▶ $op{silent} or carp $_;
Branch: 1 branch
BranchTrueFalseTotal
$op{"silent"} or carp($_) 1 0 1
467  
468 1 push @logs, $_;
469 1 return \@logs;
470 }
471  
472 29 my $TEMPLATE;
473 29 ▶ if( $rstype eq 'SCALAR') {
Branch: 1 branch
BranchTrueFalseTotal
if ($rstype eq "SCALAR") 25 4 29
474 25 ▶ my $mode = $op{utf8} ? ':utf8' : '';
Branch: 1 branch
BranchTrueFalseTotal
$op{'utf8'} ? : 3 22 25
475  
476 25 ▶push @logs, "--> Open '$source'" if $op{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op{"debug"} 4 21 25
477  
478 25 ▶ open $TEMPLATE, "<:raw$mode", $source or do{
Branch: 1 branch
BranchTrueFalseTotal
open $TEMPLATE, "<:raw$mode", $source or do { $_ = "!!! ERROR#4: $!"; $op{"silent"} or carp($_); push @logs, $_; return \@logs } 25 0 25
479 0 $_= "!!! ERROR#4: $!";
480 0 ▶ $op{silent} or carp $_;
Branch: 1 branch
BranchTrueFalseTotal
$op{"silent"} or carp($_) 0 0 0
481  
482 0 push @logs, $_;
483 0 return \@logs;
484 };
485 }
486  
487 29 ▶ unless( $fh ) { # it's not "::STDOUT"
Branch: 1 branch
BranchTrueFalseTotal
unless ($fh) 28 1 29
488 28 ▶ my $mode = $op{utf8} ? ':encoding(utf8)' : '';
Branch: 1 branch
BranchTrueFalseTotal
$op{'utf8'} ? : 3 25 28
489  
490 28 ▶push @logs, "--> Open '$ofile'" if $op{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op{"debug"} 4 24 28
491  
492 28 ▶ open $fh, ">$mode", $ofile or do{
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">$mode", $ofile or do { $_ = "!!! ERROR#5: $!"; $op{"silent"} or carp($_); push @logs, $_; return \@logs } 28 0 28
493 0 $_= "!!! ERROR#5: $!";
494 0 ▶ $op{silent} or carp $_;
Branch: 1 branch
BranchTrueFalseTotal
$op{"silent"} or carp($_) 0 0 0
495  
496 0 push @logs, $_;
497 0 return \@logs;
498 };
499 }
500  
501 29 my %actions = (
502 tex_escape => \&tex_escape,
503 REase => \&REase,
504 );
505  
506 29 ▶ if( ref $op{_ACTIONS_} eq 'ARRAY' and @{ $op{_ACTIONS_} } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $op{'_ACTIONS_'} eq 'ARRAY' and @{$op{'_ACTIONS_'};}) { } 4 25 29
elsif ($op{'esc'}) { } 4 21 25
Condition100%3/3
ref $op{"_ACTIONS_"} eq "ARRAY" and @{$op{"_ACTIONS_"};}
!ll&&!rl&&r
2414
MC/DC100%2/2
ref $op{"_ACTIONS_"} eq "ARRAY" and @{$op{"_ACTIONS_"};}
ref $op{"_ACTIONS_"} eq "ARRAY" @{$op{"_ACTIONS_"};}
Truth table100%3/3
A and B
A= ref $op{"_ACTIONS_"} eq "ARRAY"B= @{$op{"_ACTIONS_"};}
ABresult
0X0
100
111
507  
508 4 my %done;
509  
510 4 for my $f ( @{ $op{_ACTIONS_} } ) { # Check subs and setup
511 25 ▶ $f or next;
Branch: 1 branch
BranchTrueFalseTotal
$f or next 20 5 25
512  
513 20 my $rftype = ref \$f;
514 20 my $ftype = ref $f;
515  
516 20 ▶ if( $rftype eq 'SCALAR') {
Branch: 3 branches
BranchTrueFalseTotal
if ($rftype eq 'SCALAR') { } 9 11 20
elsif ($ftype eq 'CODE') { } 2 9 11
elsif ($ftype eq 'HASH' and ref $f->{'_code_'} eq 'CODE') { } 7 2 9
517 9 ▶ if( exists $actions{$f} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $actions{$f}) { } 7 2 9
518  
519 7 ▶ if( exists( $done{$f} ) or exists( $done{ $actions{$f} } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $done{$f} or exists $done{$actions{$f}}) { } 4 3 7
Condition100%3/3
exists $done{$f} or exists $done{$actions{$f}}
l!l&&r!l&&!r
133
MC/DC100%2/2
exists $done{$f} or exists $done{$actions{$f}}
exists $done{$f} exists $done{$actions{$f}}
Truth table100%3/3
A or B
A= exists $done{$f}B= exists $done{$actions{$f}}
ABresult
1X1
011
000
520 4 $done{$f} = $done{ $actions{$f} } = undef;
521 4 undef $f;
522 }
523 else {
524 3 $done{$f} = $done{ $actions{$f} } = undef;
525 $f = {
526 _name_ => $f,
527 3 _code_ => $actions{$f},
528 };
529 }
530 }
531 else {
532 2 undef $f;
533 }
534 9 next;
535 }
536 elsif( $ftype eq 'CODE') {
537  
538 2 ▶ if( exists $done{$f} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $done{$f}) { } 1 1 2
539 1 undef $f;
540 }
541 else {
542 1 $done{$f} = undef;
543 1 $f = {
544 _code_ => $f,
545 };
546 }
547 2 next;
548 }
549 ▶ elsif( $ftype eq 'HASH' and ref $f->{_code_} eq 'CODE') {
Condition100%3/3
$ftype eq "HASH" and ref $f->{"_code_"} eq "CODE"
!ll&&!rl&&r
117
MC/DC100%2/2
$ftype eq "HASH" and ref $f->{"_code_"} eq "CODE"
$ftype eq "HASH" ref $f->{"_code_"} eq "CODE"
Truth table100%3/3
A and B
A= $ftype eq "HASH"B= ref $f->{"_code_"} eq "CODE"
ABresult
0X0
100
111
550  
551 7 ▶ if( exists $done{ $f->{_code_} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $done{$f->{'_code_'}}) { } 1 6 7
552 1 undef $f;
553 }
554 else {
555 6 $done{ $f->{_code_} } = undef;
556 }
557 }
558 else {
559 2 undef $f;
560 }
561  
562 }
563  
564 4 ▶ if( $op{esc} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op{"esc"}) 2 2 4
565 2 my $f = 'tex_escape';
566 2 ▶ if( ! exists $done{$f} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $done{$f}) 1 1 2
567 1 unshift @{ $op{_ACTIONS_} }, { # must be 1st if not specified
568 _name_ => $f,
569 1 _code_ => $actions{$f},
570 };
571  
572 1 $done{$f} = undef;
573 }
574  
575 2 $f = 'REase';
576 2 ▶ if( $op{esc} =~/(?:$qs)$f(?:$qe)/ and ! exists $done{$f} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op{"esc"} =~ /(?:$LaTeX::Replicase::qs)$f(?:$LaTeX::Replicase::qe)/ and not exists $done{$f}) 1 1 2
Condition66%2/3
$op{"esc"} =~ /(?:$LaTeX::Replicase::qs)$f(?:$LaTeX::Replicase::qe)/ and not exists $done{$f}
!ll&&!rl&&r
011
MC/DC50%1/2
$op{"esc"} =~ /(?:$LaTeX::Replicase::qs)$f(?:$LaTeX::Replicase::qe)/ and not exists $done{$f}
$op{"esc"} =~ /(?:$LaTeX::Replicase::qs)$f(?:$LaTeX::Replicase::qe)/ not exists $done{$f}
Truth table66%2/3
A and not(B)
A= $op{"esc"} =~ /(?:$LaTeX::Replicase::qs)$f(?:$LaTeX::Replicase::qe)/B= not exists $done{$f}
ABresult
0X0
100
111
577 1 push @{ $op{_ACTIONS_} }, { # must be last if not specified
578 _name_ => $f,
579 1 _code_ => $actions{$f},
580 };
581  
582 1 $done{$f} = undef;
583 1 $op{esc} =~s/$f//g;
584 }
585 }
586  
587 4 @{ $op{_ACTIONS_} } = grep{ defined } @{ $op{_ACTIONS_} }; # getting rid of uncertainties
588  
589 }
590 elsif( $op{esc} ) {
591 4 my $f = 'tex_escape';
592 $op{_ACTIONS_} = [
593 { # must be 1st
594 _name_ => $f,
595 4 _code_ => $actions{$f},
596 }
597 ];
598  
599 4 $f = 'REase';
600 4 ▶ if( $op{esc} =~/(?:$qs)$f(?:$qe)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op{"esc"} =~ /(?:$LaTeX::Replicase::qs)$f(?:$LaTeX::Replicase::qe)/) 1 3 4
601 1 push @{ $op{_ACTIONS_} }, { # must be last
602 _name_ => $f,
603 1 _code_ => $actions{$f},
604 };
605  
606 1 $op{esc} =~s/$f//g;
607 }
608  
609 }
610 else {
611 21 $op{_ACTIONS_} = [];
612 }
613  
614 29 $op{fh} = $fh;
615 29 $op{logs} = \@logs;
616 29 $op{nlo} = 1; # Number Line Output, start of 1
617  
618 29 my $chkVAR = 0; # check %%%VAR for ARRAY|HASH|SCALAR|REF->SCALAR type
619 29 my $key;
620 my $tdz; # flag of The Dead Zone
621 29 my @columns;
622 29 my $end = 0;
623  
624 =for comment
625 =begin comment
626 @columns:
627 [...]: -- table columns
628 [...]{...} -- descriptions (properties) of table columns:
629 {ki} -- name (key || index ) of a variable from $data->{ $key }
630 {%} -- NO \par
631 {x} -- check the eXistence of Value (or eXpanded)
632 {v} -- to paste by default text (located in template) if variable =~/^\x{001}$/
633 {p} -- to paste text on right
634 {head}[...] -- TeX strings before %%%V:
635 {tail}[...] -- TeX strings after %%%V:
636 {eX}[...] -- indices of {head} that eXcept for the first and last elements and rows of %%%VAR:
637 =end comment
638 =cut
639  
640 29 ▶ if( $TEMPLATE ) { # source is file
Branch: 1 branch
BranchTrueFalseTotal
if ($TEMPLATE) { } 25 4 29
641 25 ▶ while( my $z = <$TEMPLATE> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $z = readline $TEMPLATE)) 1333 3 1336
642  
643 1333 $end = &_replisome( $info, \$z, \$data, \$vardata, \$chkVAR, \$key, \$tdz, \@columns, \%op );
644  
645 1333 ▶ if( $end ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($end) 22 1311 1333
646 22 ▶ print { $fh } <$TEMPLATE> if $end != 3; # %%%ENDT:
Branch: 1 branch
BranchTrueFalseTotal
if $end != 3 17 5 22
647  
648 22 last; #--> Exit template: \endinput AND \end{document}
649 }
650 1311 undef $z;
651  
652 }
653 25 close $TEMPLATE;
654 }
655 else { # source is ARRAY
656 4 for my $z ( @$source ) {
657  
658 308 ▶ if( $end ) { # %%%ENDT:
Branch: 1 branch
BranchTrueFalseTotal
if ($end) { } 4 304 308
659 4 print { $fh } $z;
660 }
661 else {
662 304 $end = &_replisome( $info, \$z, \$data, \$vardata, \$chkVAR, \$key, \$tdz, \@columns, \%op );
663  
664 304 ▶ last if $end == 3; # \endinput OR \end{document}
Branch: 1 branch
BranchTrueFalseTotal
if $end == 3 3 301 304
665 }
666 }
667 }
668  
669 29 ▶ if( ! $end and defined( $key ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $end and defined $key) 2 27 29
Condition100%3/3
not $end and defined $key
!ll&&!rl&&r
2612
MC/DC100%2/2
not $end and defined $key
not $end defined $key
Truth table100%3/3
not(A) and B
A= not $endB= defined $key
ABresult
0X0
100
111
670 2 &_var_output( $key, $vardata, \@columns, \%op );
671  
672 2 $_ = "~~> l.EOF. WARNING#1: Missing '%%%ENDx' tag for '$key'";
673 2 ▶ $op{silent} or carp $_;
Branch: 1 branch
BranchTrueFalseTotal
$op{"silent"} or carp($_) 1 1 2
674 2 push @logs, $_;
675 }
676  
677 29 ▶ $ofile =~/::STDOUT$/ or close $fh;
Branch: 1 branch
BranchTrueFalseTotal
$ofile =~ /::STDOUT$/ or close $fh 1 28 29
678  
679 29 ▶ return @logs ? \@logs : undef;
Branch: 1 branch
BranchTrueFalseTotal
@logs ? : 18 11 29
680 }
681  
682 #---------------------
683 # Internal functions
684  
685 1637 ▶sub _replisome {
Subroutine _replisome: called CC=108 SCAR=47.0
686 1637 my( $info, $z, $data, $vardata, $chkVAR, $key, $tdz, $columns, $op ) = @_;
687  
688 1637 ▶ if( defined $$key ) { # We are in VAR-structure
Branch: 2 branches
BranchTrueFalseTotal
if (defined $$key) { } 738 899 1637
elsif ($$z =~ /%%%+END(?<t>[TZ]?):/) { } 54 845 899
689  
690 738 ▶ return 0 unless $$z =~/%%%[AETV]\S*:/; # Nope control tags --> drop TeX line
Branch: 1 branch
BranchTrueFalseTotal
unless $$z =~ /%%%[AETV]\S*:/ 157 581 738
691  
692 581 my $vtype = ref $$vardata;
693  
694 581 ▶ if( $$z =~/%%%(?:END(?<t>[TZ]?)|TDZ|VAR):/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$z =~ /%%%(?:END(?<t>[TZ]?)|TDZ|VAR):/) { } 116 465 581
695 116 my $t = $+{t};
696  
697 116 my $end = &_var_output( $$key, $$vardata, $columns, $op );
698  
699 # Clear the VAR-structure for the next external VARiable
700 116 $$chkVAR = 0;
701 116 undef $$key;
702 116 @$columns = ();
703  
704 116 ▶ return $end if $end;
Branch: 1 branch
BranchTrueFalseTotal
if $end 5 111 116
705  
706 111 ▶ if( $t ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t) 12 99 111
707 12 ▶ return 1 if $t eq 'T'; # END of Template area --> output everything to the end of template without substitution
Branch: 1 branch
BranchTrueFalseTotal
if $t eq "T" 9 3 12
708 3 undef $$tdz; # if $t eq 'Z';
709 }
710  
711 102 ▶ return 0 if $$z =~/%%%ENDZ?:/; # end of %%%VAR: tag
Branch: 1 branch
BranchTrueFalseTotal
if $$z =~ /%%%ENDZ?:/ 84 18 102
712  
713 18 ▶ if( $$z =~/%%%+TDZ:/) { # The Dead Zone
Branch: 1 branch
BranchTrueFalseTotal
if ($$z =~ /%%%+TDZ:/) 10 8 18
714 10 $$tdz = 1;
715 10 return 0;
716 }
717 }
718 else {
719 465 ▶ my $vk = $vtype eq 'HASH' ? $$vardata->{ $$key } : $$vardata->[ $$key ];
Branch: 1 branch
BranchTrueFalseTotal
$vtype eq 'HASH' ? : 453 12 465
720 465 ▶ my $sclr = (ref(\$vk) eq 'SCALAR' or ref($vk) eq 'SCALAR');
Condition100%3/3
ref \$vk eq 'SCALAR' || ref $vk eq 'SCALAR'
l!l&&r!l&&!r
326427
MC/DC100%2/2
ref \$vk eq 'SCALAR' || ref $vk eq 'SCALAR'
ref \$vk eq 'SCALAR' ref $vk eq 'SCALAR'
Truth table100%3/3
A || B
A= ref \$vk eq 'SCALAR'B= ref $vk eq 'SCALAR'
ABresult
1X1
011
000
721  
722 # Index of column in target table
723 465 ▶ my $j = ( @$columns && exists( $columns->[-1]{ki} ) ) ?
Branch: 1 branch
BranchTrueFalseTotal
@$columns && exists $columns->[-1]{'ki'} ? : 193 272 465
Condition100%3/3
@$columns and exists $columns->[-1]{"ki"}
!ll&&!rl&&r
76196193
MC/DC100%2/2
@$columns and exists $columns->[-1]{"ki"}
@$columns exists $columns->[-1]{"ki"}
Truth table100%3/3
A and B
A= @$columnsB= exists $columns->[-1]{"ki"}
ABresult
0X0
100
111
724 @$columns :
725 $#$columns; # ($#$columns // 0);
726 465 ▶ $j = 0 if $j < 0 or $sclr;
Branch: 1 branch
BranchTrueFalseTotal
if $j < 0 or $sclr 114 351 465
Condition100%3/3
$j < 0 or $sclr
l!l&&r!l&&!r
7638351
MC/DC100%2/2
$j < 0 or $sclr
$j < 0 $sclr
Truth table100%3/3
A or B
A= $j < 0B= $sclr
ABresult
1X1
011
000
727  
728 465 ▶ if( ! $sclr and $$z =~/^(.*?)\s?%%%+V:\s*(\*?)([^\s:%#\*]+)(%?)\s?(.*)/) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $sclr and $$z =~ /^(.*?)\s?%%%+V:\s*(\*?)([^\s:%#\*]+)(%?)\s?(.*)/) { } 190 275 465
elsif ($$z =~ /(?<s>.+?)\s?%%%+ADD(?<t>[AEX]?):(?<p>%?)/ or $$z =~ /^\s*%%%+ADD(?<t>[AEX]?):(?<p>%?)\s?(?<s>.*?)[\r\n]*$/) { } 264 11 275
Condition100%3/3
not $sclr and $$z =~ /^(.*?)\s?%%%+V:\s*(\*?)([^\s:%#\*]+)(%?)\s?(.*)/
!ll&&!rl&&r
38237190
MC/DC100%2/2
not $sclr and $$z =~ /^(.*?)\s?%%%+V:\s*(\*?)([^\s:%#\*]+)(%?)\s?(.*)/
not $sclr $$z =~ /^(.*?)\s?%%%+V:\s*(\*?)([^\s:%#\*]+)(%?)\s?(.*)/
Truth table100%3/3
not(A) and B
A= not $sclrB= $$z =~ /^(.*?)\s?%%%+V:\s*(\*?)([^\s:%#\*]+)(%?)\s?(.*)/
ABresult
0X0
100
111
729 # the non-SCALAR V-variable is nested in a VAR-structure
730 190 my $dV = $1; # Value, by default
731 190 my $eXi = $2; # check the eXistence of Value (or eXpanded)
732 190 my $ki = $3; # name (key or index) of V-variable
733 190 my $Np = $4; # NO \par
734 190 my $paste = $5; # on right
735  
736 190 ▶ if( $$chkVAR == 0b0001
Branch: 3 branches
BranchTrueFalseTotal
if ($$chkVAR == 1 or $$chkVAR == 4 or $$chkVAR == 8) { } 80 110 190
elsif ($$chkVAR == 2) { } 62 48 110
elsif (ref $vk eq 'HASH' and exists $vk->{$ki} and ref \$vk->{$ki} eq 'SCALAR' || ref $vk->{$ki} eq 'SCALAR' || $ki eq '@' && ref $vk->{'@'} eq 'ARRAY') { } 42 12 54
Condition100%6/6
$$chkVAR == 1 or $$chkVAR == 4 or $$chkVAR == 8
l!l&&r!l&&!r
782110
$$chkVAR == 1 or $$chkVAR == 4
l!l&&r!l&&!r
5325112
MC/DC100%3/3
$$chkVAR == 1 or $$chkVAR == 4 or $$chkVAR == 8
$$chkVAR == 1 $$chkVAR == 4 $$chkVAR == 8
Truth table100%4/4
A or B or C
A= $$chkVAR == 1B= $$chkVAR == 4C= $$chkVAR == 8
ABCresult
1XX1
01X1
0011
0000
737 or $$chkVAR == 0b0100
738 or $$chkVAR == 0b01000
739 ) { # V-variable is in {HASH|ARRAY}.ARRAY or SCALAR or REF->SCALAR in regular ARRAY of VAR-structure
740  
741 80 ▶ if( $ki eq '@') {
Branch: 3 branches
BranchTrueFalseTotal
if ($ki eq '@') { } 7 73 80
elsif ($ki =~ /^\-*(\d+)$/ and $1 < @$vk || $ki < 0 && $1 == @$vk) { } 38 35 73
elsif ($ki =~ /^[\d,\-]+$/) { } 33 2 35
742 7 $ki = '0-'; # ALL elements
743 7 $columns->[$j]{ki} = $ki; # starting index (unnamed meaning)
744 }
745 ▶ elsif( $ki =~/^\-*(\d+)$/ && ($1 < @$vk or ($ki < 0 && $1 == @$vk)) ) {
Condition100%9/9
$ki =~ /^\-*(\d+)$/ and $1 < @$vk || $ki < 0 && $1 == @$vk
!ll&&!rl&&r
191638
$1 < @$vk or $ki < 0 and $1 == @$vk
l!l&&r!l&&!r
34416
$ki < 0 and $1 == @$vk
!ll&&!rl&&r
1334
MC/DC100%4/4
$ki =~ /^\-*(\d+)$/ and $1 < @$vk || $ki < 0 && $1 == @$vk
$ki =~ /^\-*(\d+)$/ $1 < @$vk $ki < 0 $1 == @$vk
Truth table100%5/5
A and B or C and D
A= $ki =~ /^\-*(\d+)$/B= $1 < @$vkC= $ki < 0D= $1 == @$vk
ABCDresult
0XXX0
100X0
10100
11XX1
10111
746 # specific indices, e.g.: 0 or 3 or -1
747 38 $columns->[$j]{ki} = $ki;
748 }
749 elsif( $ki =~/^[\d,\-]+$/) {
750 # mixed indexes, e.g.: 1-3,6-7-9,-,4,-5,0,7- or 3- (i.e. 3..arr_end) or 0-5 (0..5) or -1- (-1,-2,..arr_start)
751 33 for( $ki ) {
752 33 s/\-+/-/g;
753 33 s/,+/,/g;
754 }
755 33 $columns->[$j]{ki} = $ki;
756 }
757 else {
758 2 ▶push @{$op->{logs}}, "~~> l.$. WARNING#8: ARRAY index is not numeric in %%%V:". $ki if $op->{debug} or ! $op->{ignore};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} or not $op->{"ignore"} 2 0 2
Condition66%2/3
$op->{"debug"} or not $op->{"ignore"}
l!l&&r!l&&!r
110
MC/DC0%0/2
$op->{"debug"} or not $op->{"ignore"}
$op->{"debug"} not $op->{"ignore"}
Truth table66%2/3
A or not(B)
A= $op->{"debug"}B= not $op->{"ignore"}
ABresult
1X1
011
000
759 }
760  
761 }
762 elsif( $$chkVAR == 0b0010) { # V-variable is in {HASH|ARRAY}.HASH of VAR-structure
763  
764 62 for my $d ( @$vk ) {
765 65 ▶ if( exists $d->{$ki} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $d->{$ki}) 62 3 65
766 62 $columns->[$j]{ki} = $ki; # save variable name in j-th column
767 62 last;
768 }
769 }
770 }
771 ▶ elsif( ref $vk eq 'HASH'
Condition86%13/15
ref $vk eq "HASH" and exists $vk->{$ki} and ref \$vk->{$ki} eq "SCALAR" || ref $vk->{$ki} eq "SCALAR" || $ki eq "\@" && ref $vk->{"\@"} eq "ARRAY"
!ll&&!rl&&r
4242
ref $vk eq "HASH" and exists $vk->{$ki}
!ll&&!rl&&r
0444
ref \$vk->{$ki} eq "SCALAR" or ref $vk->{$ki} eq "SCALAR" or $ki eq "\@" and ref $vk->{"\@"} eq "ARRAY"
l!l&&r!l&&!r
3932
ref \$vk->{$ki} eq "SCALAR" or ref $vk->{$ki} eq "SCALAR"
l!l&&r!l&&!r
3815
$ki eq "\@" and ref $vk->{"\@"} eq "ARRAY"
!ll&&!rl&&r
203
MC/DC66%4/6
ref $vk eq "HASH" and exists $vk->{$ki} and ref \$vk->{$ki} eq "SCALAR" || ref $vk->{$ki} eq "SCALAR" || $ki eq "\@" && ref $vk->{"\@"} eq "ARRAY"
ref $vk eq "HASH" exists $vk->{$ki} ref \$vk->{$ki} eq "SCALAR" ref $vk->{$ki} eq "SCALAR" $ki eq "\@" ref $vk->{"\@"} eq "ARRAY"
Truth table71%5/7
A and B and C or D or E and F
A= ref $vk eq "HASH"B= exists $vk->{$ki}C= ref \$vk->{$ki} eq "SCALAR"D= ref $vk->{$ki} eq "SCALAR"E= $ki eq "\@"F= ref $vk->{"\@"} eq "ARRAY"
ABCDEFresult
0XXXXX0
10XXXX0
11000X0
1100100
111XXX1
1101XX1
1100111
772 and exists( $vk->{$ki} )
773 and ( ref \$vk->{$ki} eq 'SCALAR'
774 or ref $vk->{$ki} eq 'SCALAR'
775 or ( $ki eq '@' and ref $vk->{'@'} eq 'ARRAY')
776 )
777 ) {
778 42 $columns->[$j]{ki} = $ki; # save variable key in j-th element
779 }
780  
781 190 ▶ &_set_column( $dV, $eXi, $Np, $paste, $columns->[$j] ) if exists $columns->[$j]{ki};
Branch: 1 branch
BranchTrueFalseTotal
if exists $columns->[$j]{"ki"} 182 8 190
782 }
783 ▶ elsif( $$z =~/(?<s>.+?)\s?%%%+ADD(?<t>[AEX]?):(?<p>%?)/
Condition100%3/3
$$z =~ /(?<s>.+?)\s?%%%+ADD(?<t>[AEX]?):(?<p>%?)/ or $$z =~ /^\s*%%%+ADD(?<t>[AEX]?):(?<p>%?)\s?(?<s>.*?)[\r\n]*$/
l!l&&r!l&&!r
2214311
MC/DC100%2/2
$$z =~ /(?<s>.+?)\s?%%%+ADD(?<t>[AEX]?):(?<p>%?)/ or $$z =~ /^\s*%%%+ADD(?<t>[AEX]?):(?<p>%?)\s?(?<s>.*?)[\r\n]*$/
$$z =~ /(?<s>.+?)\s?%%%+ADD(?<t>[AEX]?):(?<p>%?)/ $$z =~ /^\s*%%%+ADD(?<t>[AEX]?):(?<p>%?)\s?(?<s>.*?)[\r\n]*$/
Truth table100%3/3
A or B
A= $$z =~ /(?<s>.+?)\s?%%%+ADD(?<t>[AEX]?):(?<p>%?)/B= $$z =~ /^\s*%%%+ADD(?<t>[AEX]?):(?<p>%?)\s?(?<s>.*?)[\r\n]*$/
ABresult
1X1
011
000
784 or $$z =~/^\s*%%%+ADD(?<t>[AEX]?):(?<p>%?)\s?(?<s>.*?)[\r\n]*$/
785 ) {
786 264 my $s = $+{s};
787  
788 264 ▶ if( $+{p} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($+{'p'}) { } 59 205 264
789 59 ▶ length($s) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
length $s or return 0 58 1 59
790 }
791 else {
792 205 $s .= "\n";
793 }
794  
795 263 ▶ if( $+{t} eq 'A') { # %%%ADDA:
Branch: 2 branches
BranchTrueFalseTotal
if ($+{'t'} eq 'A') { } 5 258 263
elsif ($+{'t'} eq 'E') { } 36 222 258
796 5 push @{ $columns->[$j]{head} }, $s;
797 5 $columns->[$j]{ki} = '%%%ADDA'; # phantom
798 5 $columns->[$j]{'%'} = 1;
799 }
800 elsif( $+{t} eq 'E') { # %%%ADDE:
801 36 ▶ if( @$columns && ( $sclr or (exists( $columns->[-1]{ki} ) && ! $columns->[$j]) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$columns and $sclr || exists $columns->[-1]{'ki'} && !$columns->[$j]) { } 32 4 36
Condition88%8/9
@$columns and $sclr || exists $columns->[-1]{"ki"} && !$columns->[$j]
!ll&&!rl&&r
3132
$sclr or exists $columns->[-1]{"ki"} and not $columns->[$j]
l!l&&r!l&&!r
15171
exists $columns->[-1]{"ki"} and not $columns->[$j]
!ll&&!rl&&r
1017
MC/DC75%3/4
@$columns and $sclr || exists $columns->[-1]{"ki"} && !$columns->[$j]
@$columns $sclr exists $columns->[-1]{"ki"} not $columns->[$j]
Truth table80%4/5
A and B or C and not(D)
A= @$columnsB= $sclrC= exists $columns->[-1]{"ki"}D= not $columns->[$j]
ABCDresult
0XXX0
100X0
10100
11XX1
10111
802 32 push @{ $columns->[-1]{tail} }, $s;
803 }
804 else {
805 4 push @{ $columns->[$j]{head} }, $s;
806 }
807 }
808 else { # %%%ADD[X]:
809 222 push @{ $columns->[$j]{head} }, $s;
810 222 ▶ $columns->[$j]{eX}{ $#{ $columns->[$j]{head} } } = undef if ! $sclr and $+{t} eq 'X'; # $$chkVAR && ... %%%ADDX:
Branch: 1 branch
BranchTrueFalseTotal
if not $sclr and $+{"t"} eq "X" 46 176 222
Condition100%3/3
not $sclr and $+{"t"} eq "X"
!ll&&!rl&&r
1815846
MC/DC100%2/2
not $sclr and $+{"t"} eq "X"
not $sclr $+{"t"} eq "X"
Truth table100%3/3
not(A) and B
A= not $sclrB= $+{"t"} eq "X"
ABresult
0X0
100
111
811 }
812 }
813  
814 464 return 0;
815 }
816 # else {
817 # return 0;
818 # }
819  
820 }
821 elsif( $$z =~/%%%+END(?<t>[TZ]?):/) { # end of template area
822  
823 # Clear the VAR-structure for the next external variable
824 54 $$chkVAR = 0;
825 54 undef $$key;
826 54 @$columns = ();
827  
828 54 ▶ return 1 if $+{t} eq 'T'; # END of Template area --> output everything to the end of template without substitution
Branch: 1 branch
BranchTrueFalseTotal
if $+{"t"} eq "T" 9 45 54
829  
830 45 ▶ undef $$tdz if $+{t} eq 'Z'; # End of TDZ
Branch: 1 branch
BranchTrueFalseTotal
if $+{"t"} eq "Z" 28 17 45
831 45 return 0;
832 }
833  
834 853 ▶ $$tdz = 1 if $$z =~s/^\s*%%%+TDZ:\s?[\r\n]*//; # The Dead Zone
Branch: 1 branch
BranchTrueFalseTotal
if $$z =~ s/^\s*%%%+TDZ:\s?[\r\n]*// 13 840 853
835  
836 853 ▶ if( $$tdz ) { # The Dead Zone is ON
Branch: 1 branch
BranchTrueFalseTotal
if ($$tdz) 172 681 853
837 172 ▶ if( length $$z ) {# Output TeX
Branch: 1 branch
BranchTrueFalseTotal
if (length $$z) 161 11 172
838 161 print { $op->{fh} } $$z;
839 161 ++$op->{nlo};
840 }
841 172 return 0;
842 }
843  
844 681 ▶ if( $$z =~/(.*?)\s?%%%+VAR:\s*(\*?)([^\s:%#\*]+)(%?)\s?(.*)/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($$z =~ /(.*?)\s?%%%+VAR:\s*(\*?)([^\s:%#\*]+)(%?)\s?(.*)/) { } 144 537 681
elsif ($$z =~ /%%%V:\s*=(def|esc|ignore|silent|debug)=\s*([\d~%]*)/) { } 9 528 537
elsif ($$z =~ /^(?<v>.*?)\s?%%%+V:\s*(?<x>\*?)(?<k>[^\s:%#\*]+)(?<p>%?)\s?(?<s>.*)/) { } 75 453 528
845 144 my $before = $1; # Value, by default
846 144 my $eXi = $2; # eXistence of Value
847 144 my $k = my $k0 = $3; # name (key)
848 144 my $Np = $4; # NO \par
849 144 my $paste = $5; # on right text for SCALAR only
850  
851 # root or global structure (environment)
852 144 ▶ my $vd = ( $k =~s/^\/+//) ? $info : $$data;
Branch: 1 branch
BranchTrueFalseTotal
$k =~ s[^/+][] ? : 12 132 144
853  
854 144 my $xk; # for unknown/undefined sub-key
855 144 my @kk = grep length, split '/', $k;
856  
857 # Search nested sub-keys
858 144 foreach my $sk ( @kk ) {
859 151 $$vardata = $vd;
860  
861 151 my $vtype = ref $vd;
862  
863 151 ▶ if( $sk =~/^\d+$/ and $vtype eq 'ARRAY' and defined( $vd->[$sk] )) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sk =~ /^\d+$/ and $vtype eq 'ARRAY' and defined $vd->[$sk]) { } 18 133 151
elsif ($vtype eq 'HASH' and exists $vd->{$sk}) { } 110 23 133
Condition66%4/6
$sk =~ /^\d+$/ and $vtype eq "ARRAY" and defined $vd->[$sk]
!ll&&!rl&&r
133018
$sk =~ /^\d+$/ and $vtype eq "ARRAY"
!ll&&!rl&&r
133018
MC/DC33%1/3
$sk =~ /^\d+$/ and $vtype eq "ARRAY" and defined $vd->[$sk]
$sk =~ /^\d+$/ $vtype eq "ARRAY" defined $vd->[$sk]
Truth table50%2/4
A and B and C
A= $sk =~ /^\d+$/B= $vtype eq "ARRAY"C= defined $vd->[$sk]
ABCresult
0XX0
10X0
1100
1111
864 18 ▶ last if &_data_redef( $sk, $vd->[$sk], \$k, \$vd, \$xk );
Branch: 1 branch
BranchTrueFalseTotal
if &_data_redef($sk, $vd->[$sk], \$k, \$vd, \$xk) 6 12 18
865 }
866 ▶ elsif( $vtype eq 'HASH' and exists( $vd->{$sk} )) {
Condition100%3/3
$vtype eq "HASH" and exists $vd->{$sk}
!ll&&!rl&&r
617110
MC/DC100%2/2
$vtype eq "HASH" and exists $vd->{$sk}
$vtype eq "HASH" exists $vd->{$sk}
Truth table100%3/3
A and B
A= $vtype eq "HASH"B= exists $vd->{$sk}
ABresult
0X0
100
111
867 110 ▶ last if &_data_redef( $sk, $vd->{$sk}, \$k, \$vd, \$xk );
Branch: 1 branch
BranchTrueFalseTotal
if &_data_redef($sk, $vd->{$sk}, \$k, \$vd, \$xk) 44 66 110
868 }
869 else {
870 23 $xk = $sk;
871 23 last;
872 }
873 }
874  
875 # Clear the VAR-structure for a new variable
876 144 $$chkVAR = 0;
877 144 undef $$key;
878 144 @$columns = ();
879  
880 144 ▶ if( $xk ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xk) 24 120 144
881 24 ▶push @{$op->{logs}}, "~~> l.$. WARNING#2: unknown or undef ARRAY|HASH|SCALAR|REF.SCALAR of sub-key '$xk' in %%%VAR:". $k0 if $op->{debug} or ! $op->{ignore};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} or not $op->{"ignore"} 19 5 24
Condition100%3/3
$op->{"debug"} or not $op->{"ignore"}
l!l&&r!l&&!r
7125
MC/DC100%2/2
$op->{"debug"} or not $op->{"ignore"}
$op->{"debug"} not $op->{"ignore"}
Truth table100%3/3
A or not(B)
A= $op->{"debug"}B= not $op->{"ignore"}
ABresult
1X1
011
000
882  
883 24 $$vardata = $$data;
884 24 print { $op->{fh} } $$z;
885 24 ++$op->{nlo};
886 24 return 0;
887 }
888  
889 # key or sub-...sub-key is found
890 120 ▶push @{$op->{logs}}, "--> l.$. Found %%%VAR:". $k0 if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 18 102 120
891  
892 120 ▶ my $vk = ref $$vardata eq 'HASH' ? $$vardata->{$k} : $$vardata->[$k];
Branch: 1 branch
BranchTrueFalseTotal
ref $$vardata eq 'HASH' ? : 108 12 120
893  
894 120 ▶push @{$op->{logs}}, "~~> l.$. NOT defined key in %%%VAR:". $k0 if ! defined($vk) && $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $vk and $op->{"debug"} 1 119 120
Condition100%3/3
not defined $vk and $op->{"debug"}
!ll&&!rl&&r
11361
MC/DC100%2/2
not defined $vk and $op->{"debug"}
not defined $vk $op->{"debug"}
Truth table100%3/3
not(A) and B
A= not defined $vkB= $op->{"debug"}
ABresult
0X0
100
111
895  
896 120 ▶ return 0 if &_chk_var( $k, $vk, $eXi, $Np, \$paste, \$before, $chkVAR, $columns, $z, $op );
Branch: 1 branch
BranchTrueFalseTotal
if &_chk_var($k, $vk, $eXi, $Np, \$paste, \$before, $chkVAR, $columns, $z, $op) 2 118 120
897  
898 # push @{$op->{logs}}, "--> l.$. Remember key = '$k' (chkVAR=$$chkVAR), type: ".ref($vk) if $op->{debug}; ###AG
899  
900 118 $$key = $k; # save key name
901 118 return 0;
902  
903 }
904 elsif( $$z =~/%%%V:\s*=(def|esc|ignore|silent|debug)=\s*([\d~%]*)/) { # setting up facultative options
905 9 my $k = $1;
906 9 ▶ my $x = $2 || 0;
Condition100%2/2
$2 || 0
l!l
54
MC/DC100%1/1
$2 || 0
$2
Truth table100%2/2
A
A= $2
Aresult
11
00
907 9 ▶ my $i = ( $op->{$k} && $op->{$k} =~/\d\d?/ ) ? $& : 0;
Branch: 1 branch
BranchTrueFalseTotal
$op->{$k} && $op->{$k} =~ /\d\d?/ ? : 3 6 9
Condition100%3/3
$op->{$k} and $op->{$k} =~ /\d\d?/
!ll&&!rl&&r
513
MC/DC100%2/2
$op->{$k} and $op->{$k} =~ /\d\d?/
$op->{$k} $op->{$k} =~ /\d\d?/
Truth table100%3/3
A and B
A= $op->{$k}B= $op->{$k} =~ /\d\d?/
ABresult
0X0
100
111
908  
909 9 ▶ if( $i < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 2) 8 1 9
910 8 $op->{$k} = $x ;
911  
912 8 ▶push @{$op->{logs}}, "~~> l.$. Option =$k= set to $x" if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 5 3 8
913  
914 }
915  
916 9 return 0;
917 }
918 elsif( $$z =~/^(?<v>.*?)\s?%%%+V:\s*(?<x>\*?)(?<k>[^\s:%#\*]+)(?<p>%?)\s?(?<s>.*)/) {
919 75 my $k = $+{k};
920  
921 75 my %el;
922 75 &_set_column( $+{v}, $+{x}, $+{p}, $+{s}, \%el );
923  
924 75 my $inidata = $$data; # save initial environment
925  
926 75 my $slash;
927 75 ▶ if( $k =~s/^\/+//) {
Branch: 2 branches
BranchTrueFalseTotal
if ($k =~ s[^/+][]) { } 13 62 75
elsif ($k =~ m[/]) { } 3 59 62
928 13 $slash = 1;
929 13 $$data = $info; # reset to root environment
930  
931 13 ▶ length($k) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
length $k or return 0 9 4 13
932 }
933 elsif( $k =~/\//) {
934 3 $slash = 1;
935 }
936  
937 # Search nested sub-keys
938 71 my $x = 0; # 1 is SCALAR value found or unknown sub-key
939 71 my @kk = grep length, split '/', $k;
940  
941 71 my $i = 0;
942 71 foreach my $sk ( @kk ) {
943  
944 83 my $dtype = ref $$data;
945  
946 83 my $d;
947 83 ▶ if( $sk =~/^\-*(\d+)$/
Branch: 2 branches
BranchTrueFalseTotal
if ($sk =~ /^\-*(\d+)$/ and $dtype eq 'ARRAY' and $1 < @{$$data;} || $sk + 0 < 0 && $1 == @{$$data;}) { } 11 72 83
elsif ($dtype eq 'HASH' and exists $$data->{$sk}) { } 34 38 72
Condition66%6/9
$sk =~ /^\-*(\d+)$/ and $dtype eq "ARRAY" and $1 < @{$$data;} || $sk + 0 < 0 && $1 == @{$$data;}
!ll&&!rl&&r
72011
$sk =~ /^\-*(\d+)$/ and $dtype eq "ARRAY"
!ll&&!rl&&r
621011
$1 < @{$$data;} or $sk + 0 < 0 and $1 == @{$$data;}
l!l&&r!l&&!r
1100
MC/DC50%2/4
$sk =~ /^\-*(\d+)$/ and $dtype eq "ARRAY" and $1 < @{$$data;} || $sk + 0 < 0 && $1 == @{$$data;}
$sk =~ /^\-*(\d+)$/ $dtype eq "ARRAY" $1 < @{$$data;} $sk + 0 < 0 and $1 == @{$$data;}
Truth table60%3/5
A and B and C or D
A= $sk =~ /^\-*(\d+)$/B= $dtype eq "ARRAY"C= $1 < @{$$data;}D= $sk + 0 < 0 and $1 == @{$$data;}
ABCDresult
0XXX0
10XX0
11000
111X1
11011
948 and $dtype eq 'ARRAY'
949 0 ▶ and ( $1 < @{$$data} or ( $sk+0 < 0 and $1 == @{$$data} ))
Condition0%0/3
$sk + 0 < 0 and $1 == @{$$data;}
!ll&&!rl&&r
000
MC/DC0%0/2
$sk + 0 < 0 and $1 == @{$$data;}
$sk + 0 < 0 $1 == @{$$data;}
Truth table0%0/3
A and B
A= $sk + 0 < 0B= $1 == @{$$data;}
ABresult
0X0
100
111
950 ) {
951 11 $d = $$data->[$sk];
952 }
953 ▶ elsif( $dtype eq 'HASH' && exists( $$data->{$sk} )) {
Condition100%3/3
$dtype eq "HASH" and exists $$data->{$sk}
!ll&&!rl&&r
63234
MC/DC100%2/2
$dtype eq "HASH" and exists $$data->{$sk}
$dtype eq "HASH" exists $$data->{$sk}
Truth table100%3/3
A and B
A= $dtype eq "HASH"B= exists $$data->{$sk}
ABresult
0X0
100
111
954 34 $d = $$data->{$sk};
955 }
956 else {
957 38 ▶push @{$op->{logs}}, "~~> l.$. WARNING#3: unknown sub-key '$sk' in %%%V:". $k if $op->{debug} or ! $op->{ignore};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} or not $op->{"ignore"} 33 5 38
Condition100%3/3
$op->{"debug"} or not $op->{"ignore"}
l!l&&r!l&&!r
13205
MC/DC100%2/2
$op->{"debug"} or not $op->{"ignore"}
$op->{"debug"} not $op->{"ignore"}
Truth table100%3/3
A or not(B)
A= $op->{"debug"}B= not $op->{"ignore"}
ABresult
1X1
011
000
958  
959 38 print { $op->{fh} } $$z;
960 38 ++$op->{nlo};
961  
962 38 $x = 1;
963 38 last;
964 }
965  
966 45 my $dtp = ref $d;
967  
968 # Check type
969 45 ▶ if( $dtp =~/^(?:ARRAY|HASH)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtp =~ /^(?:ARRAY|HASH)$/) 15 30 45
970  
971 15 ▶ if( $slash ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($slash) 14 1 15
972 14 $$data = $d; # sub-key (path) found: redefined
973 14 next;
974 }
975  
976 1 ▶push @{$op->{logs}}, "~~> l.$. WARNING#5: (ARRAY|HASH) w/o '/' is wrong type of '$sk' in %%%V:". $k if $op->{debug} or ! $op->{ignore};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} or not $op->{"ignore"} 1 0 1
Condition33%1/3
$op->{"debug"} or not $op->{"ignore"}
l!l&&r!l&&!r
100
MC/DC0%0/2
$op->{"debug"} or not $op->{"ignore"}
$op->{"debug"} not $op->{"ignore"}
Truth table33%1/3
A or not(B)
A= $op->{"debug"}B= not $op->{"ignore"}
ABresult
1X1
011
000
977  
978 1 print { $op->{fh} } $$z;
979 1 ++$op->{nlo};
980  
981 1 $x = 1;
982 1 last;
983 }
984  
985 30 my $v;
986 30 ▶ if( ref \$d eq 'SCALAR') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref \$d eq 'SCALAR') { } 28 2 30
elsif ($dtp eq 'SCALAR') { } 1 1 2
987 28 $v = $d;
988 }
989 elsif( $dtp eq 'SCALAR') { # REF->SCALAR
990 1 $v = $$d;
991 }
992 else {
993 1 ▶push @{$op->{logs}}, "~~> l.$. WARNING#4: wrong type (not SCALAR|ARRAY|HASH) of '$sk' in %%%V:". $k if $op->{debug} or ! $op->{ignore};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} or not $op->{"ignore"} 1 0 1
Condition33%1/3
$op->{"debug"} or not $op->{"ignore"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$op->{"debug"} or not $op->{"ignore"}
$op->{"debug"} not $op->{"ignore"}
Truth table33%1/3
A or not(B)
A= $op->{"debug"}B= not $op->{"ignore"}
ABresult
1X1
011
000
994  
995 1 print { $op->{fh} } $$z;
996 1 ++$op->{nlo};
997  
998 1 $x = 1;
999 1 last;
1000 }
1001  
1002 29 ▶ $_ = &_v_print( $k, $v, \%el, $op ) and return $_;
Branch: 1 branch
BranchTrueFalseTotal
$_ = &_v_print($k, $v, \%el, $op) and return $_ 3 26 29
1003  
1004 26 ▶push @{$op->{logs}}, "~~> l.$. WARNING#9: '$sk' is not at the end of %%%V:". $k if $i < $#kk and ( $op->{debug} or ! $op->{ignore} );
Branch: 1 branch
BranchTrueFalseTotal
if $i < $#kk and $op->{"debug"} || !$op->{"ignore"} 1 25 26
Condition50%3/6
$i < $#kk and $op->{"debug"} || !$op->{"ignore"}
!ll&&!rl&&r
2501
$op->{"debug"} or not $op->{"ignore"}
l!l&&r!l&&!r
100
MC/DC33%1/3
$i < $#kk and $op->{"debug"} || !$op->{"ignore"}
$i < $#kk $op->{"debug"} not $op->{"ignore"}
Truth table50%2/4
A and B or not(C)
A= $i < $#kkB= $op->{"debug"}C= not $op->{"ignore"}
ABCresult
0XX0
1000
11X1
1011
1005  
1006 26 $x = 1;
1007 26 last;
1008 }
1009 continue {
1010 14 ++$i;
1011 }
1012  
1013 68 ▶ $$data = $inidata if $x; # SCALAR value found or unknown sub-key: reset to initial environment
Branch: 1 branch
BranchTrueFalseTotal
if $x 66 2 68
1014  
1015 68 return 0;
1016 }
1017  
1018 453 print { $op->{fh} } $$z;
1019 453 ++$op->{nlo};
1020  
1021 453 return 0;
1022 }
1023  
1024  
1025 306 ▶sub _set_column {
Subroutine _set_column: called CC=5 SCAR=16.1
1026 306 my( $dV, $eXi, $Np, $paste, $column ) = @_;
1027  
1028 306 ▶ $column->{v} = $dV if length $dV; # Value, by default
Branch: 1 branch
BranchTrueFalseTotal
if length $dV 226 80 306
1029 306 ▶ $column->{x} = 1 if $eXi; # check the eXistence of Value
Branch: 1 branch
BranchTrueFalseTotal
if $eXi 2 304 306
1030 306 ▶ $column->{'%'} = 1 if $Np; # NO \par
Branch: 1 branch
BranchTrueFalseTotal
if $Np 48 258 306
1031 306 ▶ $column->{p} = $paste if length $paste; # on right text for SCALAR only
Branch: 1 branch
BranchTrueFalseTotal
if length $paste 25 281 306
1032 }
1033  
1034  
1035 128 ▶sub _data_redef {
Subroutine _data_redef: called CC=5 SCAR=16.1
1036 128 my( $sk, $d, $k, $data, $xk ) = @_;
1037  
1038 128 ▶ if( ref $d eq 'ARRAY' or ref $d eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $d eq "ARRAY" or ref $d eq "HASH") 78 50 128
Condition100%3/3
ref $d eq "ARRAY" or ref $d eq "HASH"
l!l&&r!l&&!r
591950
MC/DC100%2/2
ref $d eq "ARRAY" or ref $d eq "HASH"
ref $d eq "ARRAY" ref $d eq "HASH"
Truth table100%3/3
A or B
A= ref $d eq "ARRAY"B= ref $d eq "HASH"
ABresult
1X1
011
000
1039 78 $$data = $d; # redefined for %%%VAR:
1040 78 $$k = $sk;
1041 78 return 0;
1042 }
1043  
1044 50 ▶ if( ref \$d eq 'SCALAR' or ref $d eq 'SCALAR') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref \$d eq 'SCALAR' or ref $d eq 'SCALAR') { } 49 1 50
Condition100%3/3
ref \$d eq "SCALAR" or ref $d eq "SCALAR"
l!l&&r!l&&!r
4631
MC/DC100%2/2
ref \$d eq "SCALAR" or ref $d eq "SCALAR"
ref \$d eq "SCALAR" ref $d eq "SCALAR"
Truth table100%3/3
A or B
A= ref \$d eq "SCALAR"B= ref $d eq "SCALAR"
ABresult
1X1
011
000
1045 49 $$k = $sk;
1046 }
1047 else {
1048 1 $$xk = $sk;
1049 }
1050 50 return 1;
1051 }
1052  
1053 120 ▶sub _chk_var {
Subroutine _chk_var: called CC=15 SCAR=27.1
1054 120 my( $k, $vk, $eXi, $Np, $paste, $before, $chkVAR, $columns, $z, $op ) = @_;
1055  
1056 120 ▶ if( ref $vk eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $vk eq 'ARRAY') { } 53 67 120
elsif (ref \$vk eq 'SCALAR' or ref $vk eq 'SCALAR') { } 49 18 67
1057  
1058 53 ▶ if( @{ $vk } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$vk;}) { } 52 1 53
1059 # Check ARRAY.{ARRAY|HASH|SCALAR[.REF]}
1060  
1061 52 for my $d ( @{ $vk } ) {
1062 178 my $dtype = ref $d;
1063  
1064 178 ▶ if($dtype eq 'ARRAY'){
Branch: 4 branches
BranchTrueFalseTotal
if ($dtype eq 'ARRAY') { } 52 126 178
elsif ($dtype eq 'HASH') { } 41 85 126
elsif (ref \$d eq 'SCALAR') { } 80 5 85
elsif ($dtype eq 'SCALAR') { } 4 1 5
1065 52 $$chkVAR |= 0b00001;
1066 }
1067 elsif($dtype eq 'HASH') {
1068 41 $$chkVAR |= 0b00010;
1069 }
1070 elsif(ref \$d eq 'SCALAR') {
1071 80 $$chkVAR |= 0b00100;
1072 }
1073 elsif($dtype eq 'SCALAR') { # REF->SCALAR
1074 4 $$chkVAR |= 0b01000;
1075 }
1076 else {
1077 1 $$chkVAR |= 0b10000; # other
1078 }
1079 }
1080 }
1081 else {
1082 1 $$chkVAR |= 0b00100; # by default, SCALAR
1083 }
1084  
1085 53 ▶ if( $$chkVAR > 0b01000 or ($$chkVAR & ($$chkVAR - 1)) ) { # ! $$chkVAR or
Branch: 1 branch
BranchTrueFalseTotal
if ($$chkVAR > 8 or $$chkVAR & $$chkVAR - 1) 2 51 53
Condition66%2/3
$$chkVAR > 8 or $$chkVAR & $$chkVAR - 1
l!l&&r!l&&!r
2051
MC/DC50%1/2
$$chkVAR > 8 or $$chkVAR & $$chkVAR - 1
$$chkVAR > 8 $$chkVAR & $$chkVAR - 1
Truth table66%2/3
A or B
A= $$chkVAR > 8B= $$chkVAR & $$chkVAR - 1
ABresult
1X1
011
000
1086 2 ▶push @{$op->{logs}}, "~~> l.$. WARNING#6: mixed types (ARRAY with HASH with SCALAR or other) of %%%VAR:". $k if $op->{debug} or ! $op->{ignore};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} or not $op->{"ignore"} 2 0 2
Condition33%1/3
$op->{"debug"} or not $op->{"ignore"}
l!l&&r!l&&!r
020
MC/DC0%0/2
$op->{"debug"} or not $op->{"ignore"}
$op->{"debug"} not $op->{"ignore"}
Truth table33%1/3
A or not(B)
A= $op->{"debug"}B= not $op->{"ignore"}
ABresult
1X1
011
000
1087  
1088 2 print { $op->{fh} } $$z;
1089 2 ++$op->{nlo};
1090 2 return 1;
1091 }
1092 }
1093 ▶ elsif( ref \$vk eq 'SCALAR' or ref $vk eq 'SCALAR') {
Condition100%3/3
ref \$vk eq "SCALAR" or ref $vk eq "SCALAR"
l!l&&r!l&&!r
46318
MC/DC100%2/2
ref \$vk eq "SCALAR" or ref $vk eq "SCALAR"
ref \$vk eq "SCALAR" ref $vk eq "SCALAR"
Truth table100%3/3
A or B
A= ref \$vk eq "SCALAR"B= ref $vk eq "SCALAR"
ABresult
1X1
011
000
1094 49 $columns->[0]{ki} = $k;
1095 49 &_set_column('', $eXi, $Np, $$paste, $columns->[0] );
1096 }
1097  
1098 118 ▶ if( $$before ) {# Output prefix TeX
Branch: 1 branch
BranchTrueFalseTotal
if ($$before) 19 99 118
1099 19 print { $op->{fh} } $$before;
1100 # ++$op->{nlo};
1101 }
1102  
1103 118 return 0;
1104 }
1105  
1106 # VALUE output
1107 646 ▶sub _v_print {
Subroutine _v_print: called CC=25 SCAR=32.3
1108 646 my( $k, $v, $el, $op ) = @_;
1109 646 ▶ $v = $$v if ref $v eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $v eq "SCALAR" 3 643 646
1110  
1111 646 ▶ unless( defined $v ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $v) 56 590 646
1112 56 ▶ if( $op->{def} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->{"def"}) 52 4 56
1113 52 ▶push @{$op->{logs}}, "~~> l.$.".' NOT defined %%%V[AR]:'. $k if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 5 47 52
1114  
1115 52 return 0;
1116 }
1117 4 $v = '';
1118 }
1119  
1120 594 ▶ if( $el->{x} && length($v) ) { # for '*param'
Branch: 1 branch
BranchTrueFalseTotal
if ($el->{'x'} and length $v) { } 4 590 594
Condition100%3/3
$el->{"x"} and length $v
!ll&&!rl&&r
58914
MC/DC100%2/2
$el->{"x"} and length $v
$el->{"x"} length $v
Truth table100%3/3
A and B
A= $el->{"x"}B= length $v
ABresult
0X0
100
111
1121  
1122 4 my $f;
1123 4 for('v','p') {
1124 8 ▶ exists( $el->{$_} ) or next;
Branch: 1 branch
BranchTrueFalseTotal
exists $el->{$_} or next 8 0 8
1125  
1126 8 print { $op->{fh} } $el->{$_};
1127 8 $f = 1;
1128 }
1129  
1130 0 ▶push @{$op->{logs}}, "--> l.$.>". $op->{nlo} .' Insert by eXistence condition (*) of %%%V[AR]:'. $k .'= '. $el->{v} if $f && $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $f and $op->{"debug"} 0 4 4
Condition33%1/3
$f and $op->{"debug"}
!ll&&!rl&&r
040
MC/DC0%0/2
$f and $op->{"debug"}
$f $op->{"debug"}
Truth table33%1/3
A and B
A= $fB= $op->{"debug"}
ABresult
0X0
100
111
1131  
1132 }
1133 else {
1134 590 ▶ if( $v =~s/^\x{01}//) { # by default text from template
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ s/^\x{01}//) 4 586 590
1135 4 ▶ if( exists $el->{v} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $el->{"v"}) 3 1 4
1136 3 print { $op->{fh} } $el->{v};
1137  
1138 0 ▶push @{$op->{logs}}, "--> l.$.>". $op->{nlo} .' Insert text by default %%%V[AR]:'. $k .'= '. $el->{v} if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 0 3 3
1139 }
1140 }
1141  
1142 590 ▶ if( $v =~/^\x{03}(\x{03}?)/) { # END of INPUT template
Branch: 3 branches
BranchTrueFalseTotal
if ($v =~ /^\x{03}(\x{03}?)/) { } 3 587 590
elsif ($v =~ /^\x{04}/) { } 5 582 587
elsif (length $v) { } 560 22 582
1143 3 ▶ say { $op->{fh} } $1 ? '\bye' : '\endinput';
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 1 2 3
1144 3 ++$op->{nlo};
1145  
1146 3 return 3;
1147 }
1148 elsif( $v =~/^\x{04}/) { # END of INPUT template, similar to \bye
1149 5 say { $op->{fh} } '\end{document}';
1150 5 ++$op->{nlo};
1151  
1152 5 return 3;
1153 }
1154 elsif( length $v ) {
1155 560 $op->{_MFLAGS_} = 0; # value modification (change) flag: 0 is 'NO', 1 -- 'YES' for ordinary text, 2 -- 'YES' for TeX-commands
1156 560 for my $f ( @{ $op->{_ACTIONS_} } ) {
1157 74 ▶ $f or next;
Branch: 1 branch
BranchTrueFalseTotal
$f or next 65 9 74
1158  
1159 65 ▶ $_ = int( $f->{_code_}->( $v, $op ) // 0 );
Condition100%2/2
$f->{"_code_"}->($v, $op) // 0
l!l
623
MC/DC100%1/1
$f->{"_code_"}->($v, $op) // 0
$f->{"_code_"}->($v, $op)
Truth table100%2/2
A
A= $f->{"_code_"}->($v, $op)
Aresult
11
00
1160 65 $op->{_MFLAGS_} += 0;
1161 65 $op->{_MFLAGS_} |= $_;
1162 }
1163  
1164 560 ▶push @{$op->{logs}}, "--> l.$.>". $op->{nlo} .' Insert %%%V[AR]:'. $k .'= '. $v if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 75 485 560
1165  
1166 560 print { $op->{fh} } $v;
1167 560 ▶ ++$op->{nlo} while $v =~/\n/g;
Branch: 1 branch
BranchTrueFalseTotal
$v =~ /\n/g and do { ++$op->{"nlo"} } 18 560 578
1168  
1169 560 ▶ print { $op->{fh} } $el->{p} if exists $el->{p};
Branch: 1 branch
BranchTrueFalseTotal
if exists $el->{"p"} 15 545 560
1170 }
1171 }
1172  
1173 586 ▶ unless( $el->{'%'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($el->{"%"}) 433 153 586
1174 433 print { $op->{fh} } "\n"; # NO:YES \par
1175 433 ++$op->{nlo};
1176 }
1177  
1178 586 return 0;
1179 }
1180  
1181 # HEAD-TAIL output
1182 1229 ▶sub _ht_print {
Subroutine _ht_print: called CC=8 SCAR=20.8
1183 1229 my( $el, $ht, $op, $border ) = @_;
1184  
1185 1229 ▶ $el->{$ht} or return;
Branch: 1 branch
BranchTrueFalseTotal
$el->{$ht} or return 575 654 1229
1186  
1187 575 my $i = 0;
1188 575 foreach( @{ $el->{$ht} } ) {
1189 692 ▶ next if $ht eq 'head' and $border && exists( $el->{eX} ) && exists( $el->{eX}{$i} );
Branch: 1 branch
BranchTrueFalseTotal
if $ht eq "head" and ($border and exists $el->{"eX"} and exists $el->{"eX"}{$i}) 46 646 692
Condition100%9/9
$ht eq "head" and ($border and exists $el->{"eX"} and exists $el->{"eX"}{$i})
!ll&&!rl&&r
6358346
$border and exists $el->{"eX"} and exists $el->{"eX"}{$i}
!ll&&!rl&&r
5632046
$border and exists $el->{"eX"}
!ll&&!rl&&r
5441966
MC/DC100%4/4
$ht eq "head" and ($border and exists $el->{"eX"} and exists $el->{"eX"}{$i})
$ht eq "head" $border exists $el->{"eX"} exists $el->{"eX"}{$i}
Truth table100%5/5
A and B and C and D
A= $ht eq "head"B= $borderC= exists $el->{"eX"}D= exists $el->{"eX"}{$i}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1190  
1191 646 ▶push @{$op->{logs}}, "-->\tl.$.>". $op->{nlo} ." Insert $ht: ". $_ if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 68 578 646
1192  
1193 646 print { $op->{fh} } $_;
1194 646 ++$op->{nlo};
1195 }
1196 continue {
1197 692 ++$i;
1198 }
1199  
1200 }
1201  
1202 # HEAD-VALUE-TAIL output
1203 644 ▶sub _hvt_print {
Subroutine _hvt_print: called CC=6 SCAR=17.9
1204 644 my( $ki, $val, $el, $op, $border ) = @_;
1205  
1206 644 ▶ if( length($ki) and ! defined $val ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $ki and not defined $val) 30 614 644
Condition100%3/3
length $ki and not defined $val
!ll&&!rl&&r
5356130
MC/DC100%2/2
length $ki and not defined $val
length $ki not defined $val
Truth table100%3/3
A and not(B)
A= length $kiB= not defined $val
ABresult
0X0
100
111
1207 30 ▶ if( $op->{def} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->{"def"}) 27 3 30
1208 27 ▶ push @{$op->{logs}}, "~~> l.$.".' NOT defined %%%V:'. $ki if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 10 17 27
1209 27 return 0;
1210 }
1211  
1212 3 $val = '';
1213 }
1214  
1215 # output head of variable
1216 617 &_ht_print( $el, 'head', $op, $border );
1217  
1218 # output value of variable ( $ki, $val, $el, $op )
1219 617 ▶ $_ = &_v_print and return $_;
Branch: 1 branch
BranchTrueFalseTotal
$_ = &_v_print and return $_ 5 612 617
1220  
1221 # output tail of variable
1222 612 &_ht_print( $el, 'tail', $op, 0);
1223  
1224 612 return 0;
1225 }
1226  
1227  
1228 273 ▶sub _s_a_prn {
Subroutine _s_a_prn: called CC=9 SCAR=22.1
1229 273 my( $i, $values, $el, $op, $border, $col ) = @_;
1230  
1231 273 my $val = $values->[$i];
1232 273 ▶ $val = $$val if ref $val eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $val eq "SCALAR" 4 269 273
1233  
1234 273 my $end = 0;
1235  
1236 273 ▶ if( ref \$val eq 'SCALAR') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref \$val eq 'SCALAR') { } 267 6 273
elsif (ref $val eq 'ARRAY') { } 5 1 6
1237 267 $end = &_hvt_print( $i, $val, $el, $op, $$border );
1238  
1239 267 ++$$col;
1240 267 $$border = 0;
1241 }
1242 elsif( ref $val eq 'ARRAY') { # [...].ARRAY.ARRAY
1243  
1244 5 for( @$val ) {
1245 27 ▶ next if ref \$_ ne 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref \$_ ne "SCALAR" 1 26 27
1246  
1247 # [...].ARRAY.ARRAY.SCALAR
1248 26 $end = &_hvt_print( $i, $_, $el, $op, $$border );
1249  
1250 26 ++$$col;
1251 26 $$border = 0;
1252  
1253 26 ▶ last if $end;
Branch: 1 branch
BranchTrueFalseTotal
if $end 0 26 26
1254 }
1255 }
1256 else {
1257 1 ▶push @{$op->{logs}}, "~~> l.$. WARNING#10: ...ARRAY.ARRAY[$i] is NOT a SCALAR in %%%V:$i ...skipped" if $op->{debug} or ! $op->{ignore};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} or not $op->{"ignore"} 1 0 1
Condition33%1/3
$op->{"debug"} or not $op->{"ignore"}
l!l&&r!l&&!r
100
MC/DC0%0/2
$op->{"debug"} or not $op->{"ignore"}
$op->{"debug"} not $op->{"ignore"}
Truth table33%1/3
A or not(B)
A= $op->{"debug"}B= not $op->{"ignore"}
ABresult
1X1
011
000
1258 }
1259  
1260 273 return $end;
1261 }
1262  
1263  
1264 194 ▶sub _mixed_indices {
Subroutine _mixed_indices: called CC=23 SCAR=31.4
1265 194 my( $ki, $values, $el, $op, $border ) = @_;
1266  
1267 194 my $nd = @$values;
1268 194 my $col = my $end = 0;
1269  
1270 194 for my $ii ( split ',', $ki ) { # e.g. -1-,1-3,6-7-9,-,4,-5,0,7-
1271 211 ▶ next if $ii eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $ii eq "-" 1 210 211
1272  
1273 210 ▶ if( $ii =~/^(\-[1-9]\d*)\-(\d*)$/) { # -1- i.e. reverse: -1,-2,..-@arr (i.e. arr_start)
Branch: 1 branch
BranchTrueFalseTotal
if ($ii =~ /^(\-[1-9]\d*)\-(\d*)$/) 12 198 210
1274 12 my $s = $1;
1275 12 ▶ my $e = -1*($2 || $nd);
Condition66%2/3
$2 || $nd
l!l&&r!l&&!r
2100
MC/DC0%0/2
$2 || $nd
$2 $nd
Truth table66%2/3
A || B
A= $2B= $nd
ABresult
1X1
011
000
1276 12 ▶ $s = -1*$nd if abs($s) > $nd;
Branch: 1 branch
BranchTrueFalseTotal
if abs $s > $nd 1 11 12
1277 12 ▶ $e = -1*$nd if abs($e) > $nd;
Branch: 1 branch
BranchTrueFalseTotal
if abs $e > $nd 1 11 12
1278 12 ▶ ($s, $e) = ($e, $s) if $e > $s;
Branch: 1 branch
BranchTrueFalseTotal
if $e > $s 1 11 12
1279  
1280 12 ▶ for( my $i = $s; $i >= $e; --$i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= $e) 38 12 50
1281 38 ▶ $end = &_s_a_prn( $i, $values, $el, $op, \$border, \$col ) and last;
Branch: 1 branch
BranchTrueFalseTotal
$end = &_s_a_prn($i, $values, $el, $op, \$border, \$col) and last 0 38 38
1282 }
1283  
1284 12 ▶ $end ? last : next;
Branch: 1 branch
BranchTrueFalseTotal
$end ? : 0 12 12
1285 }
1286  
1287 198 ▶ if( $ii =~/^\-[0-9]+$/ ) { # -5
Branch: 1 branch
BranchTrueFalseTotal
if ($ii =~ /^\-[0-9]+$/) 4 194 198
1288 4 my $i = $ii+0;
1289  
1290 4 ▶ if( abs($i) <= $nd ) {
Branch: 1 branch
BranchTrueFalseTotal
if (abs $i <= $nd) 3 1 4
1291 3 ▶ $end = &_s_a_prn( $i, $values, $el, $op, \$border, \$col ) and last;
Branch: 1 branch
BranchTrueFalseTotal
$end = &_s_a_prn($i, $values, $el, $op, \$border, \$col) and last 1 2 3
1292 }
1293  
1294 3 next;
1295 }
1296  
1297 194 my @n = grep{length} sort{$a <=> $b} split '-', $ii;
1298  
1299 194 ▶ if( @n < 2 and $n[0] < $nd ) { # e.g. 4 || 0 || 7(-)
Branch: 1 branch
BranchTrueFalseTotal
if (@n < 2 and $n[0] < $nd) { } 188 6 194
Condition100%3/3
@n < 2 and $n[0] < $nd
!ll&&!rl&&r
42188
MC/DC100%2/2
@n < 2 and $n[0] < $nd
@n < 2 $n[0] < $nd
Truth table100%3/3
A and B
A= @n < 2B= $n[0] < $nd
ABresult
0X0
100
111
1300 188 ▶ if( $ii =~/\-$/) { # 7(-)
Branch: 1 branch
BranchTrueFalseTotal
if ($ii =~ /\-$/) { } 18 170 188
1301  
1302 18 ▶ for( my $i = $n[0]; $i < $nd; ++$i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $nd) 51 18 69
1303 51 ▶ $end = &_s_a_prn( $i, $values, $el, $op, \$border, \$col ) and last;
Branch: 1 branch
BranchTrueFalseTotal
$end = &_s_a_prn($i, $values, $el, $op, \$border, \$col) and last 0 51 51
1304 }
1305  
1306 }
1307 else { # 4 || 0
1308 170 ▶ $end = &_s_a_prn( $n[0], $values, $el, $op, \$border, \$col ) and last;
Branch: 1 branch
BranchTrueFalseTotal
$end = &_s_a_prn($n[0], $values, $el, $op, \$border, \$col) and last 0 170 170
1309 }
1310  
1311 }
1312 else { # 1-3 ->(1..3) || 6-7-9 ->(6..9)
1313 6 ▶ for( my $i = $n[0]; $i <= $n[-1]; ++$i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $n[-1]) 11 4 15
1314 11 ▶ $end = &_s_a_prn( $i, $values, $el, $op, \$border, \$col ) and last;
Branch: 1 branch
BranchTrueFalseTotal
$end = &_s_a_prn($i, $values, $el, $op, \$border, \$col) and last 2 9 11
1315 }
1316 }
1317  
1318 194 ▶ last if $end;
Branch: 1 branch
BranchTrueFalseTotal
if $end 2 192 194
1319 }
1320  
1321 194 return( $col, $end );
1322 }
1323  
1324  
1325 118 ▶sub _var_output {
Subroutine _var_output: called CC=70 SCAR=44.4
1326 118 my( $key, $vardata, $columns, $op ) = @_;
1327 118 ▶ my $values = (ref $vardata eq 'HASH') ? $vardata->{ $key } : $vardata->[ $key ];
Branch: 1 branch
BranchTrueFalseTotal
ref $vardata eq 'HASH' ? : 106 12 118
1328  
1329 118 ▶ @$columns or return;
Branch: 1 branch
BranchTrueFalseTotal
@$columns or return 118 0 118
1330  
1331 118 my $end = 0;
1332  
1333 118 ▶ if( ref \$values eq 'SCALAR' or ref $values eq 'SCALAR') { # key => SCALAR
Branch: 1 branch
BranchTrueFalseTotal
if (ref \$values eq "SCALAR" or ref $values eq "SCALAR") 49 69 118
Condition100%3/3
ref \$values eq "SCALAR" or ref $values eq "SCALAR"
l!l&&r!l&&!r
46369
MC/DC100%2/2
ref \$values eq "SCALAR" or ref $values eq "SCALAR"
ref \$values eq "SCALAR" ref $values eq "SCALAR"
Truth table100%3/3
A or B
A= ref \$values eq "SCALAR"B= ref $values eq "SCALAR"
ABresult
1X1
011
000
1334 49 return &_hvt_print( $key, $values, $columns->[0], $op );
1335 }
1336  
1337 69 ▶ if( ref $values eq 'ARRAY') { # key => ARRAY
Branch: 2 branches
BranchTrueFalseTotal
if (ref $values eq 'ARRAY') { } 51 18 69
elsif (ref $values eq 'HASH') { } 18 0 18
1338  
1339 51 ▶ unless( @$values ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$values) 1 50 51
1340 1 ▶push @{$op->{logs}}, "~~> l.$. WARNING#7: empty ARRAY of %%%VAR:". $key if $op->{debug} or ! $op->{ignore};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} or not $op->{"ignore"} 1 0 1
Condition33%1/3
$op->{"debug"} or not $op->{"ignore"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$op->{"debug"} or not $op->{"ignore"}
$op->{"debug"} not $op->{"ignore"}
Truth table33%1/3
A or not(B)
A= $op->{"debug"}B= not $op->{"ignore"}
ABresult
1X1
011
000
1341 1 return 0;
1342 }
1343  
1344 # Forming a table
1345 50 my $row = 0;
1346 50 my $nd = @$values;
1347  
1348 _var_output_M0:
1349 50 foreach my $d ( @$values ) { # loop through table rows
1350  
1351 129 ▶push @{$op->{logs}}, '--> Table row = '. $row if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 20 109 129
1352  
1353 129 my $col = 0;
1354 129 foreach my $el ( @$columns ) { # loop through table columns (for ARRAY.HASH) or rows (for ARRAY.SCALAR)
1355  
1356 448 my $ki = $el->{ki};
1357 448 ▶ my $border = ((! $row and ! $col) or ($row >= $#{ $values } and (!defined( $ki ) or !length( $ki )) ) ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
!($row || $col) || $row >= $#{$values;} && !(defined $ki && length $ki) ? : 64 384 448
Condition91%11/12
not $row || $col or $row >= $#{$values;} and not defined $ki && length $ki
l!l&&r!l&&!r
5014384
$row || $col
l!l&&r!l&&!r
29610250
$row >= $#{$values;} and not defined $ki && length $ki
!ll&&!rl&&r
27510914
defined $ki && length $ki
!ll&&!rl&&r
140109
MC/DC80%4/5
not $row || $col or $row >= $#{$values;} and not defined $ki && length $ki
$row $col $row >= $#{$values;} defined $ki length $ki
Truth table77%7/9
not(A || B) or C and not(D && E)
A= $rowB= $colC= $row >= $#{$values;}D= defined $kiE= length $ki
ABCDEresult
00XXX1
1X10X1
1X1101
0110X1
011101
1X0XX0
1X1110
010XX0
011110
1358  
1359 448 my $val;
1360 448 ▶ if( defined $ki ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ki) { } 398 50 448
1361 398 ▶ if( $ki eq '%%%ADDA') {
Branch: 5 branches
BranchTrueFalseTotal
if ($ki eq '%%%ADDA') { } 7 391 398
elsif (ref \$d eq 'SCALAR' or ref $d eq 'SCALAR') { } 32 359 391
elsif (ref $d eq 'HASH') { } 185 174 359
elsif (ref $d eq 'ARRAY') { } 174 0 174
elsif ($op->{'def'}) { } 0 0 0
1362 7 $val = '';
1363 }
1364 ▶ elsif( ref \$d eq 'SCALAR' or ref $d eq 'SCALAR') { # (ARRAY.SCALAR or ARRAY.REF->SCALAR) in regular vector
Condition100%3/3
ref \$d eq "SCALAR" or ref $d eq "SCALAR"
l!l&&r!l&&!r
293359
MC/DC100%2/2
ref \$d eq "SCALAR" or ref $d eq "SCALAR"
ref \$d eq "SCALAR" ref $d eq "SCALAR"
Truth table100%3/3
A or B
A= ref \$d eq "SCALAR"B= ref $d eq "SCALAR"
ABresult
1X1
011
000
1365  
1366 32 ▶ if( $ki =~/^[\d,\-]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ki =~ /^[\d,\-]+$/) 32 0 32
1367 # mixed indices, e.g.: 1-3,6-7-9,-,4,-5,0,7- or 3- (i.e. 3..arr_end) or 0-5 (0..5) or -1- (-1,-2,..arr_start)
1368 32 ▶ last _var_output_M0 if $row;
Branch: 1 branch
BranchTrueFalseTotal
if $row 12 20 32
1369  
1370 20 ($_, $end) = &_mixed_indices( $ki, $values, $el, $op, $border );
1371 20 ▶ $col += $_ - 1 if $_;
Branch: 1 branch
BranchTrueFalseTotal
if $_ 19 1 20
1372 }
1373  
1374 20 ▶ $end ? last _var_output_M0 : next;
Branch: 1 branch
BranchTrueFalseTotal
$end ? : 2 18 20
1375 }
1376 elsif( ref $d eq 'HASH') { # ARRAY.HASH
1377 185 $val = $d->{$ki};
1378  
1379 185 ▶ if( defined( $val ) && ref $val eq 'ARRAY') { # ARRAY.HASH.ARRAY
Branch: 2 branches
BranchTrueFalseTotal
if (defined $val and ref $val eq 'ARRAY') { } 2 183 185
elsif (ref \$val ne 'SCALAR' and ref $val ne 'SCALAR') { } 1 364 365
Condition100%3/3
defined $val and ref $val eq "ARRAY"
!ll&&!rl&&r
151682
MC/DC100%2/2
defined $val and ref $val eq "ARRAY"
defined $val ref $val eq "ARRAY"
Truth table100%3/3
A and B
A= defined $valB= ref $val eq "ARRAY"
ABresult
0X0
100
111
1380 2 for my $vv ( @$val ) {
1381 14 ▶ next unless ref \$vv eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
unless ref \$vv eq "SCALAR" 0 14 14
1382  
1383 14 ▶ last _var_output_M0 if $end = &_hvt_print( $ki, $vv, $el, $op, $border );
Branch: 1 branch
BranchTrueFalseTotal
if $end = &_hvt_print($ki, $vv, $el, $op, $border) 0 14 14
1384 14 ++$col;
1385 }
1386  
1387 2 ▶ $end ? last _var_output_M0 : next;
Branch: 1 branch
BranchTrueFalseTotal
$end ? : 0 2 2
1388 }
1389 ▶ elsif( ref \$val ne 'SCALAR' and ref $val ne 'SCALAR') {
Condition66%2/3
ref \$val ne "SCALAR" and ref $val ne "SCALAR"
!ll&&!rl&&r
18201
MC/DC50%1/2
ref \$val ne "SCALAR" and ref $val ne "SCALAR"
ref \$val ne "SCALAR" ref $val ne "SCALAR"
Truth table66%2/3
A and B
A= ref \$val ne "SCALAR"B= ref $val ne "SCALAR"
ABresult
0X0
100
111
1390 1 next;
1391 }
1392 }
1393 elsif( ref $d eq 'ARRAY') { # ARRAY.ARRAY
1394  
1395 174 ▶ if( $ki =~/^[\d,\-]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ki =~ /^[\d,\-]+$/) 174 0 174
1396 # mixed indices, e.g.: 1-3,6-7-9,-,4,-5,0,7- or 3- (i.e. 3..arr_end) or 0-5 (0..5) or -1- (-1,-2,..arr_start)
1397 174 ($_, $end) = &_mixed_indices( $ki, $d, $el, $op, $border );
1398 174 ▶ $col += $_ - 1 if $_;
Branch: 1 branch
BranchTrueFalseTotal
if $_ 173 1 174
1399 }
1400  
1401 174 ▶ $end ? last _var_output_M0 : next;
Branch: 1 branch
BranchTrueFalseTotal
$end ? : 1 173 174
1402 }
1403 elsif( $op->{def} ) {
1404  
1405 0 ▶push @{$op->{logs}}, "~~> l.$. NOT defined %%%V:". $ki if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 0 0 0
1406  
1407 0 next;
1408 }
1409 }
1410 else {
1411 # empty parameter -- at the very end of the columns (parameters)
1412 50 $ki = '';
1413 }
1414  
1415 239 ▶ last _var_output_M0 if $end = &_hvt_print( $ki, $val, $el, $op, $border );
Branch: 1 branch
BranchTrueFalseTotal
if $end = &_hvt_print($ki, $val, $el, $op, $border) 0 239 239
1416 }
1417 continue {
1418 433 ++$col;
1419 }
1420  
1421 114 ▶ last if $end;
Branch: 1 branch
BranchTrueFalseTotal
if $end 0 114 114
1422 }
1423 continue {
1424 114 ++$row;
1425 }
1426  
1427 }
1428 elsif( ref $values eq 'HASH') {
1429  
1430 18 my $col = 0;
1431 18 foreach my $el ( @$columns ) { # loop through parameters of %%%VAR-structure
1432  
1433 48 my $ki = $el->{ki};
1434 48 ▶ my $border = ( ! $col or ($col >= $#{ $columns } and (!defined( $ki ) or !length( $ki )) )) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
!$col || $col >= $#{$columns;} && !(defined $ki && length $ki) ? : 20 28 48
Condition88%8/9
not $col or $col >= $#{$columns;} and not defined $ki && length $ki
l!l&&r!l&&!r
18228
$col >= $#{$columns;} and not defined $ki && length $ki
!ll&&!rl&&r
2172
defined $ki && length $ki
!ll&&!rl&&r
207
MC/DC75%3/4
not $col or $col >= $#{$columns;} and not defined $ki && length $ki
not $col $col >= $#{$columns;} defined $ki length $ki
Truth table80%4/5
not(A) or B and not(C && D)
A= not $colB= $col >= $#{$columns;}C= defined $kiD= length $ki
ABCDresult
1XXX1
010X1
01101
00XX0
01110
1435  
1436 48 my $val;
1437 48 ▶ if( defined $ki ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ki) { } 45 3 48
1438 45 ▶ if( $ki eq '%%%ADDA') {
Branch: 5 branches
BranchTrueFalseTotal
if ($ki eq '%%%ADDA') { } 3 42 45
elsif (ref \$values->{$ki} eq 'SCALAR' and !$op->{'def'} || defined $values->{$ki}) { } 32 10 42
elsif (ref $values->{$ki} eq 'SCALAR' and !$op->{'def'} || defined ${$$values{$ki};}) { } 1 9 10
elsif ($ki eq '@' and ref $values->{'@'} eq 'ARRAY') { } 3 6 9
elsif ($op->{'def'}) { } 6 0 6
1439 3 $val = '';
1440 }
1441 ▶ elsif( ref \$values->{$ki} eq 'SCALAR' and ( !$op->{def} or defined( $values->{$ki} ) ) ) { # HASH.SCALAR
Condition100%6/6
ref \$values->{$ki} eq "SCALAR" and !$op->{"def"} || defined $values->{$ki}
!ll&&!rl&&r
4632
not $op->{"def"} or defined $values->{$ki}
l!l&&r!l&&!r
6266
MC/DC100%3/3
ref \$values->{$ki} eq "SCALAR" and !$op->{"def"} || defined $values->{$ki}
ref \$values->{$ki} eq "SCALAR" not $op->{"def"} defined $values->{$ki}
Truth table100%4/4
A and not(B) or C
A= ref \$values->{$ki} eq "SCALAR"B= not $op->{"def"}C= defined $values->{$ki}
ABCresult
0XX0
1000
11X1
1011
1442 32 $val = $values->{$ki};
1443 }
1444 1 ▶ elsif( ref $values->{$ki} eq 'SCALAR' and ( !$op->{def} or defined( ${ $values->{$ki} } ) ) ) { # HASH.REF->SCALAR
Condition50%3/6
ref $values->{$ki} eq "SCALAR" and !$op->{"def"} || defined ${$$values{$ki};}
!ll&&!rl&&r
901
not $op->{"def"} or defined ${$$values{$ki};}
l!l&&r!l&&!r
010
MC/DC33%1/3
ref $values->{$ki} eq "SCALAR" and !$op->{"def"} || defined ${$$values{$ki};}
ref $values->{$ki} eq "SCALAR" not $op->{"def"} defined ${$$values{$ki};}
Truth table50%2/4
A and not(B) or C
A= ref $values->{$ki} eq "SCALAR"B= not $op->{"def"}C= defined ${$$values{$ki};}
ABCresult
0XX0
1000
11X1
1011
1445 1 $val = ${ $values->{$ki} };
1446 }
1447 ▶ elsif( $ki eq '@' and ref $values->{'@'} eq 'ARRAY') {
Condition66%2/3
$ki eq "\@" and ref $values->{"\@"} eq "ARRAY"
!ll&&!rl&&r
603
MC/DC50%1/2
$ki eq "\@" and ref $values->{"\@"} eq "ARRAY"
$ki eq "\@" ref $values->{"\@"} eq "ARRAY"
Truth table66%2/3
A and B
A= $ki eq "\@"B= ref $values->{"\@"} eq "ARRAY"
ABresult
0X0
100
111
1448 3 for my $k ( @{ $values->{'@'} } ) {
1449 13 ▶ next unless defined($k) && exists( $values->{$k} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $k and exists $values->{$k} 2 11 13
Condition100%3/3
defined $k and exists $values->{$k}
!ll&&!rl&&r
1111
MC/DC100%2/2
defined $k and exists $values->{$k}
defined $k exists $values->{$k}
Truth table100%3/3
A and B
A= defined $kB= exists $values->{$k}
ABresult
0X0
100
111
1450  
1451 11 my $v;
1452 11 ▶ if( ref \$values->{$k} eq 'SCALAR') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref \$values->{$k} eq 'SCALAR') { } 9 2 11
elsif (ref $values->{$k} eq 'SCALAR') { } 1 1 2
elsif ($op->{'def'}) { } 1 0 1
1453 9 $v = $values->{$k};
1454 }
1455 elsif( ref $values->{$k} eq 'SCALAR') {
1456 1 $v = ${ $values->{$k} };
1457 }
1458 elsif( $op->{def} ) {
1459 0 ▶push @{$op->{logs}}, "-->\tl.$. ". 'NOT HASH.ARRAY.SCALAR %%%V:@->{'.$k.'} in %%%VAR:'. $key if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 0 1 1
1460  
1461 1 next;
1462 }
1463  
1464 10 ▶ last if $end = &_hvt_print( $k, $v, $el, $op, $border );
Branch: 1 branch
BranchTrueFalseTotal
if $end = &_hvt_print($k, $v, $el, $op, $border) 1 9 10
1465 9 $border = 0;
1466 }
1467  
1468 3 ▶ $end ? last : next;
Branch: 1 branch
BranchTrueFalseTotal
$end ? : 1 2 3
1469 }
1470 elsif( $op->{def} ) {
1471 0 ▶push @{$op->{logs}}, "~~> l.$. NOT HASH.SCALAR or NOT defined %%%V:". $ki if $op->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"debug"} 0 6 6
1472  
1473 6 next;
1474 }
1475 }
1476 else {
1477 # empty parameter -- at the very end of the columns (parameters)
1478 3 $ki = '';
1479 }
1480  
1481 39 ▶ last if $end = &_hvt_print( $ki, $val, $el, $op, $border );
Branch: 1 branch
BranchTrueFalseTotal
if $end = &_hvt_print($ki, $val, $el, $op, $border) 1 38 39
1482 }
1483 continue {
1484 46 ++$col;
1485 }
1486 }
1487  
1488 68 return $end;
1489 }
1490  
1491  
1492 258675 ▶sub _get_mate {
Subroutine _get_mate: called CC=7 SCAR=19.5
1493 258675 my( $glyph, $agl, $op ) = @_;
1494  
1495 258675 ▶ %$agl or return $glyph;
Branch: 1 branch
BranchTrueFalseTotal
%$agl or return $glyph 215682 42993 258675
1496  
1497 215682 ▶ return $agl->{ $glyph } if exists( $agl->{ $glyph } ) && defined( $agl->{ $glyph } );
Branch: 1 branch
BranchTrueFalseTotal
if exists $agl->{$glyph} and defined $agl->{$glyph} 138731 76951 215682
Condition66%2/3
exists $agl->{$glyph} and defined $agl->{$glyph}
!ll&&!rl&&r
769510138731
MC/DC50%1/2
exists $agl->{$glyph} and defined $agl->{$glyph}
exists $agl->{$glyph} defined $agl->{$glyph}
Truth table66%2/3
A and B
A= exists $agl->{$glyph}B= defined $agl->{$glyph}
ABresult
0X0
100
111
1498  
1499 76951 my $mate = $glyph;
1500  
1501 76951 ▶ if( $glyph =~/^uni([0-9A-F]{4}|[0-9A-F]{8})/ ) { # sprintf("uni0%X", $_)# , uniXXXX
Branch: 1 branch
BranchTrueFalseTotal
if ($glyph =~ /^uni([0-9A-F]{4}|[0-9A-F]{8})/) { } 76915 36 76951
1502 76915 my $code = $1;
1503  
1504 76915 ▶ if( $op->{mate} =~/^sym/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->{'mate'} =~ /^sym/) { } 15329 61586 76915
elsif ($op->{'mate'} =~ /^hex/) { } 15329 46257 61586
1505 15329 $mate = chr(hex( $code ));
1506 }
1507 elsif( $op->{mate} =~/^hex/) {
1508 15329 $mate = $code;
1509 }
1510 else { # dec
1511 46257 $mate = hex $code;
1512 }
1513 }
1514 else {
1515 36 carp "Undefined glyph: '$glyph'";
1516 36 undef $mate;
1517 }
1518  
1519 76951 return $mate;
1520 }
1521  
1522 #-------------------
1523 # External functions
1524 #-------------------
1525 # Get kit/set of 'Adobe Glyph List'
1526 # $op->{glyphlist} -- glyphlist file
1527 # $op->{mate} = 'symbol' of Unicode | 'hex' Unicode number (native). By default, decimal Unicode number
1528  
1529 14 ▶sub AGLkit {
Subroutine AGLkit: called CC=30 SCAR=34.0
Pod documented
1530 14 my( $op ) = @_;
1531 14 my $agl = {};
1532  
1533 14 ▶ if( $op->{glyphlist} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->{'glyphlist'}) { } 10 4 14
1534 10 ▶ open( my $AGL, '<', $op->{glyphlist} ) or croak "Can't find the AGL file: '$op->{glyphlist}'";
Branch: 1 branch
BranchTrueFalseTotal
open my $AGL, "<", $op->{"glyphlist"} or croak(qq[Can't find the AGL file: '$op->{"glyphlist"}']) 10 0 10
1535  
1536 10 ▶ while( <$AGL> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $AGL)) 43310 10 43320
1537 43310 ▶ next if /^\s*$/ or /^\s*#/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*$/ or /^\s*#/ 460 42850 43310
Condition100%3/3
/^\s*$/ or /^\s*#/
l!l&&r!l&&!r
2044042850
MC/DC100%2/2
/^\s*$/ or /^\s*#/
/^\s*$/ /^\s*#/
Truth table100%3/3
A or B
A= /^\s*$/B= /^\s*#/
ABresult
1X1
011
000
1538  
1539 42850 my( $glyph, $codes ) = split /\s*;\s*/;
1540 42850 ▶ next unless $glyph && $codes;
Branch: 1 branch
BranchTrueFalseTotal
unless $glyph and $codes 20 42830 42850
Condition100%3/3
$glyph and $codes
!ll&&!rl&&r
101042830
MC/DC100%2/2
$glyph and $codes
$glyph $codes
Truth table100%3/3
A and B
A= $glyphB= $codes
ABresult
0X0
100
111
1541  
1542 42830 $glyph =~s/\s+//g;
1543 42830 $codes =~s/^\s+|\s+$//g;
1544 42830 $codes =~s/\s+/ /g;
1545  
1546 42830 ▶ next if ! $glyph or $glyph =~/^\.notdef$/i or $glyph =~/[^0-9A-Za-z]/
Branch: 1 branch
BranchTrueFalseTotal
if not $glyph or $glyph =~ /^\.notdef$/i or $glyph =~ /[^0-9A-Za-z]/ or not $codes or length $codes < 4 or not $codes =~ /^[0-9A-Fa-f\s]+$/ 20 42810 42830
Condition73%11/15
not $glyph or $glyph =~ /^\.notdef$/i or $glyph =~ /[^0-9A-Za-z]/ or not $codes or length $codes < 4 or not $codes =~ /^[0-9A-Fa-f\s]+$/
l!l&&r!l&&!r
20042810
not $glyph or $glyph =~ /^\.notdef$/i or $glyph =~ /[^0-9A-Za-z]/ or not $codes or length $codes < 4
l!l&&r!l&&!r
20042810
not $glyph or $glyph =~ /^\.notdef$/i or $glyph =~ /[^0-9A-Za-z]/ or not $codes
l!l&&r!l&&!r
20042810
not $glyph or $glyph =~ /^\.notdef$/i or $glyph =~ /[^0-9A-Za-z]/
l!l&&r!l&&!r
101042810
not $glyph or $glyph =~ /^\.notdef$/i
l!l&&r!l&&!r
01042820
MC/DC33%2/6
not $glyph or $glyph =~ /^\.notdef$/i or $glyph =~ /[^0-9A-Za-z]/ or not $codes or length $codes < 4 or not $codes =~ /^[0-9A-Fa-f\s]+$/
not $glyph $glyph =~ /^\.notdef$/i $glyph =~ /[^0-9A-Za-z]/ not $codes length $codes < 4 not $codes =~ /^[0-9A-Fa-f\s]+$/
Truth table42%3/7
not(A) or B or C or not(D) or E or not(F)
A= not $glyphB= $glyph =~ /^\.notdef$/iC= $glyph =~ /[^0-9A-Za-z]/D= not $codesE= length $codes < 4F= not $codes =~ /^[0-9A-Fa-f\s]+$/
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
1547 or ! $codes or length( $codes ) < 4 or $codes !~/^[0-9A-Fa-f\s]+$/;
1548  
1549 # $codes =~y/0-9A-Fa-f //cd;
1550 # next if ! $codes or length( $codes ) < 4;
1551  
1552 42810 my $mate;
1553 42810 ▶ if( $op->{mate} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->{"mate"}) 21405 21405 42810
1554 21405 ▶ if( $op->{mate} =~/^sym/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->{'mate'} =~ /^sym/) { } 8562 12843 21405
elsif ($op->{'mate'} =~ /^hex/) { } 8562 4281 12843
1555 8562 $mate = join('', map{ chr hex } split /\s+/, $codes );
1556 }
1557 elsif( $op->{mate} =~/^hex/) {
1558 8562 ($mate = $codes) =~s/\s+/ /g;
1559 8562 $mate = uc $mate;
1560 }
1561 }
1562  
1563 42810 ▶ $agl->{ $glyph } = $mate // join(' ', map{ hex } split /\s+/, $codes );
Condition100%2/2
$mate // join(" ", map({hex $_;} split(/\s+/, $codes, 0)))
l!l
1712425686
MC/DC100%1/1
$mate // join(" ", map({hex $_;} split(/\s+/, $codes, 0)))
$mate
Truth table100%2/2
A
A= $mate
Aresult
11
00
1564 # push @{ $agl->{'@'}{ $arr[0] } } = $agl->{ $glyph } if @arr > 1; # ???
1565 }
1566  
1567 10 close $AGL;
1568 }
1569 else {
1570 4 $agl = {
1571 exclamdown => ord('¡'), # \u00A1
1572 cent => ord('¢'), # \u00A2
1573 sterling => ord('£'), # \u00A3
1574 currency => ord('¤'), # \u00A4
1575 yen => ord('¥'), # \u00A5
1576 brokenbar => ord('¦'), # \u00A6
1577 section => ord('§'), # \u00A7
1578 dieresis => ord('¨'), # \u00A8
1579 copyright => ord('©'), # \u00A9
1580 ordfeminine => ord('ª'), # \u00AA
1581 guillemotleft => ord('«'), # \u00AB
1582 logicalnot => ord('¬'), # \u00AC
1583 # sfthyphen => ord(''), # \u00AD
1584 registered => ord('®'), # \u00AE
1585 macron => ord('¯'), # \u00AF
1586 #---
1587 degree => ord('°'), # \u00B0
1588 plusminus => ord('±'), # \u00B1
1589 twosuperior => ord('²'), # \u00B2
1590 threesuperior => ord('³'), # \u00B3
1591 acute => ord('´'), # \u00B4
1592 mu => ord('µ'), # \u00B5
1593 paragraph => ord('¶'), # \u00B6
1594 periodcentered => ord('·'), # \u00B7
1595 cedilla => ord('¸'), # \u00B8
1596 onesuperior => ord('¹'), # \u00B9
1597 ordmasculine => ord('º'), # \u00BA
1598 guillemotright => ord('»'), # \u00BB
1599 onequarter => ord('¼'), # \u00BC
1600 onehalf => ord('½'), # \u00BD
1601 threequarters => ord('¾'), # \u00BE
1602 questiondown => ord('¿'), # \u00BF
1603 #---
1604 Agrave => ord('À'), # \u00C0
1605 Aacute => ord('Á'), # \u00C1
1606 Acircumflex => ord('Â'), # \u00C2
1607 Atilde => ord('Ã'), # \u00C3
1608 Adieresis => ord('Ä'), # \u00C4
1609 #---
1610 Aring => ord('Å'), # \u00C5
1611 AE => ord('Æ'), # \u00C6
1612 Ccedilla => ord('Ç'), # \u00C7
1613 Egrave => ord('È'), # \u00C8
1614 Eacute => ord('É'), # \u00C9
1615 Ecircumflex => ord('Ê'), # \u00CA
1616 Edieresis => ord('Ë'), # \u00CB
1617 Igrave => ord('Ì'), # \u00CC
1618 Iacute => ord('Í'), # \u00CD
1619 Icircumflex => ord('Î'), # \u00CE
1620 Idieresis => ord('Ï'), # \u00CF
1621 #---
1622 Eth => ord('Ð'), # \u00D0
1623 Ntilde => ord('Ñ'), # \u00D1
1624 Ograve => ord('Ò'), # \u00D2
1625 Oacute => ord('Ó'), # \u00D3
1626 Ocircumflex => ord('Ô'), # \u00D4
1627 Otilde => ord('Õ'), # \u00D5
1628 Odieresis => ord('Ö'), # \u00D6
1629 multiply => ord('×'), # \u00D7
1630 Oslash => ord('Ø'), # \u00D8
1631 Ugrave => ord('Ù'), # \u00D9
1632 Uacute => ord('Ú'), # \u00DA
1633 Ucircumflex => ord('Û'), # \u00DB
1634 Udieresis => ord('Ü'), # \u00DC
1635 Yacute => ord('Ý'), # \u00DD
1636 Thorn => ord('Þ'), # \u00DE
1637 germandbls => ord('ß'), # \u00DF
1638 #---
1639 agrave => ord('à'), # \u00E0
1640 aacute => ord('á'), # \u00E1
1641 acircumflex => ord('â'), # \u00E2
1642 atilde => ord('ã'), # \u00E3
1643 adieresis => ord('ä'), # \u00E4
1644 aring => ord('å'), # \u00E5
1645 ae => ord('æ'), # \u00E6
1646 ccedilla => ord('ç'), # \u00E7
1647 egrave => ord('è'), # \u00E8
1648 eacute => ord('é'), # \u00E9
1649 ecircumflex => ord('ê'), # \u00EA
1650 edieresis => ord('ë'), # \u00EB
1651 igrave => ord('ì'), # \u00EC
1652 iacute => ord('í'), # \u00ED
1653 icircumflex => ord('î'), # \u00EE
1654 idieresis => ord('ï'), # \u00EF
1655 #---
1656 eth => ord('ð'), # \u00F0
1657 ntilde => ord('ñ'), # \u00F1
1658 ograve => ord('ò'), # \u00F2
1659 oacute => ord('ó'), # \u00F3
1660 ocircumflex => ord('ô'), # \u00F4
1661 otilde => ord('õ'), # \u00F5
1662 odieresis => ord('ö'), # \u00F6
1663 divide => ord('÷'), # \u00F7
1664 oslash => ord('ø'), # \u00F8
1665 ugrave => ord('ù'), # \u00F9
1666 uacute => ord('ú'), # \u00FA
1667 ucircumflex => ord('û'), # \u00FB
1668 udieresis => ord('ü'), # \u00FC
1669 yacute => ord('ý'), # \u00FD
1670 thorn => ord('þ'), # \u00FE
1671 ydieresis => ord('ÿ'), # \u00FF
1672 #---
1673 afii10064 => ord('δ'), # echo -e "\u03B4" # a.? \uF6C5 see "Adobe Standard Cyrillic Font Specification"
1674 afii10063 => ord('ι'), # a.? \uF6C4
1675 afii10192 => ord('g'), # a.? \uF6C6
1676 afii10831 => ord('й'), # a.? \uF6C7
1677 afii10832 => ord('ш'), # a.? \uF6C8
1678 afii10846 => ord('ә'), # \u04D9
1679 afii61352 => ord('№'), # \u2116
1680 # Symbol and Punctuation Glyph
1681 minus => ord('−'), # \u2212
1682 trademark => ord('™'), # 2122
1683 bullet => ord('•'), # echo -e "\u2022"
1684 ellipsis => ord('…'), # \u2026
1685 endash => ord('–'), # \u2013
1686 emdash => ord('—'), # \u2014
1687 dagger => ord('†'), # \u2020
1688 daggerdbl => ord('‡'), # \u2021
1689 quotedblbase => ord('„'), # \u201E
1690 quotedblleft => ord('“'), # \u201C
1691 quotedblright => ord('”'), # \u201D
1692 quoteleft => ord("‘"), # \u2018
1693 quoteright => ord("’"), # \u2019
1694 quotesinglbase => ord('‚'), # \u201A
1695 perthousand => ord('‰'), # \u2030
1696 guilsinglleft => ord('‹'), # \u2039
1697 guilsinglright => ord('›'), # \u203A
1698 circumflex => ord('ˆ'), # \u02C6
1699 tilde => ord('˜'), # \u02DC
1700 hungarumlaut => ord('˝'), # \u02DD
1701 ring => ord('˚'), # \u02DA
1702 caron => ord('ˇ'), # \u02C7
1703 breve => ord('˘'), # \u02D8
1704 dotaccent => ord('˙'), # \u02D9
1705 ogonek => ord('˛'), # \u02DB
1706 dotlessi => ord('ı'), # \u0131
1707 dotlessj => ord(''), # \uF6BE
1708 fi => ord('fi'), # \uFB01
1709 fl => ord('fl'), # \uFB02
1710  
1711 };
1712  
1713 4 $agl->{$_} = ord($_) for 'A'..'Z', 'a'..'z'; # ASCII Glyph Names: 65..90, 97..122
1714  
1715 # also ASCII Glyph Names, but 32..64, 91..96, 123..126
1716 4 @{$agl}{qw(
1717 space exclam quotedbl numbersign dollar percent ampersand quotesingle parenleft parenright
1718 asterisk plus comma hyphen period slash zero one two three four five six seven eight nine
1719 colon semicolon less equal greater question at
1720 bracketleft backslash bracketright asciicircumb underscore grave
1721 braceleft bar braceright asciitilde
1722 )} = ( ord(' ')..ord('@'), ord('[')..ord('`'), ord('{')..ord('~') ); #}
1723  
1724 # Cyrillic Glyph Names: Uppercase (afiiXXXXX)
1725 4 my $x = 10017; # start of 'А'...'Я' from afii10017 to afii10049
1726 4 for( ord('А')..ord('Е'), ord('Ё'), ord('Ж')..ord('Я') ) {
1727 132 $agl->{"afii$x"} = $_;
1728 132 ++$x;
1729 }
1730 4 for('Ґ','Ђ','Ѓ','Є','Ѕ','І','Ї','Ј','Љ','Њ','Ћ','Ќ','Ў') { # from afii10050 to afii10062
1731 52 $agl->{"afii$x"} = ord $_;
1732 52 ++$x;
1733 }
1734 4 $x = 10145;
1735 4 for('Џ','Ѣ','Ѳ','Ѵ') { # from afii10145 to afii10148
1736 16 $agl->{"afii$x"} = ord $_;
1737 16 ++$x;
1738 }
1739  
1740 # Cyrillic Glyph Names: Lowercase
1741 4 $x = 10065; # start of "а"..."я" from afii10065 to afii10097
1742 4 for( ord('а')..ord('е'), ord('ё'), ord('ж')..ord('я') ) {
1743 132 $agl->{"afii$x"} = $_;
1744 132 ++$x;
1745 }
1746 4 for('ґ','ђ','ѓ','є','ѕ','і','ї','ј','љ','њ','ћ','ќ','ў') { # from afii10098 to afii10110
1747 52 $agl->{"afii$x"} = ord $_;
1748 52 ++$x;
1749 }
1750 4 $x = 10193;
1751 4 for('џ','ѣ','ѳ','ѵ') { # from afii10193 to afii10196
1752 16 $agl->{"afii$x"} = ord $_;
1753 16 ++$x;
1754 }
1755  
1756 4 ▶ if( $op->{mate} && $op->{mate} =~/^(?:(sym)|hex)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->{"mate"} and $op->{"mate"} =~ /^(?:(sym)|hex)/) 2 2 4
Condition100%3/3
$op->{"mate"} and $op->{"mate"} =~ /^(?:(sym)|hex)/
!ll&&!rl&&r
112
MC/DC100%2/2
$op->{"mate"} and $op->{"mate"} =~ /^(?:(sym)|hex)/
$op->{"mate"} $op->{"mate"} =~ /^(?:(sym)|hex)/
Truth table100%3/3
A and B
A= $op->{"mate"}B= $op->{"mate"} =~ /^(?:(sym)|hex)/
ABresult
0X0
100
111
1757 2 ▶ my $f = $1 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 1 1 2
1758  
1759 2 for( values %$agl ) {
1760 650 ▶ $_ = $f ? chr : sprintf("%04X", $_);
Branch: 1 branch
BranchTrueFalseTotal
$f ? : 325 325 650
1761 }
1762 }
1763  
1764 }
1765  
1766 14 return $agl;
1767 }
1768  
1769 # Get font metrics from Adobe Font Metric file
1770 # IN:
1771 # $op->{glyphlist} -- glyphlist file
1772 # $op->{noBbox} -- without 'B'-box
1773 # $op->{noKPX} -- without 'KPX'
1774 # $op->{mate} = 'glyph' of Adobe | 'symbol' of Unicode | 'hex' Unicode number (native). By default, decimal Unicode number
1775 # OUT:
1776 # $font_metrics->
1777 # {WX}{ $mate } -- symbol width of mate
1778 # {Bbox}{ $mate } -- Bounding Box of mate
1779 # {KPX}{ $mateA }{ $mateB } -- paired kerning of mateA & mateB
1780  
1781 7 ▶sub font_metrics {
Subroutine font_metrics: called CC=20 SCAR=30.1
Pod documented
1782 7 my( $AFMfile, $op ) = @_;
1783  
1784 7 ▶ $op->{mate} //= '';
Condition100%2/2
$op->{"mate"} //= ""
l!l
52
MC/DC100%1/1
$op->{"mate"} //= ""
$op->{"mate"}
Truth table100%2/2
A
A= $op->{"mate"}
Aresult
11
00
1785 7 ▶ my $agl = ($op->{mate} =~/^glyph/) ? {} : &AGLkit( $op );
Branch: 1 branch
BranchTrueFalseTotal
$op->{'mate'} =~ /^glyph/ ? : 1 6 7
1786  
1787 7 my %font_metrics;
1788  
1789 7 ▶ open( my $AFM, '<', $AFMfile ) or croak "Can't find the AFM file";
Branch: 1 branch
BranchTrueFalseTotal
open my $AFM, "<", $AFMfile or croak("Can't find the AFM file") 7 0 7
1790 7 ▶ while( <$AFM> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $AFM)) 155274 1 155275
1791 # next if /^StartComposites/ .. /^EndComposites/; # composites not parsed yet
1792  
1793 155274 ▶ if( /^StartCharMetrics/i .. /^EndCharMetrics/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^StartCharMetrics/i .. /^EndCharMetrics/i) 5040 150234 155274
1794 5040 ▶ /^CH?\s/ or next; # only lines that start with "C" or "CH" are parsed
Branch: 1 branch
BranchTrueFalseTotal
/^CH?\s/ or next 5026 14 5040
1795  
1796 # C 32 ; WX 300 ; N space ; B 0 0 0 0 ;
1797 5026 ▶ /;\s*WX\s*(\d+)\s*;\s*N\s+([\w.]{1,63})\s*;/ or next;
Branch: 1 branch
BranchTrueFalseTotal
/;\s*WX\s*(\d+)\s*;\s*N\s+([\w.]{1,63})\s*;/ or next 5019 7 5026
1798 5019 my( $wx, $glyph ) = ($1, $2);
1799  
1800 5019 ▶ my $bbox = /;\s*B\s*([^;]+)\s*;/ ? $1 : '';
Branch: 1 branch
BranchTrueFalseTotal
/;\s*B\s*([^;]+)\s*;/ ? : 5019 0 5019
1801 5019 $bbox =~ s/\s+/ /g;
1802 5019 $bbox =~ s/^\s+|\s+$//g;
1803  
1804 5019 my $mate = &_get_mate( $glyph, $agl, $op );
1805  
1806 5019 ▶ if( defined $mate ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mate) 4983 36 5019
1807 4983 $font_metrics{WX}{ $mate } = $wx;
1808 4983 ▶ $op->{noBbox} or $font_metrics{Bbox}{ $mate } = $bbox; # 'B'-box
Branch: 1 branch
BranchTrueFalseTotal
$op->{"noBbox"} or $font_metrics{"Bbox"}{$mate} = $bbox 2133 2850 4983
1809 }
1810  
1811 5019 next;
1812 }
1813  
1814 150234 ▶ next if $op->{noKPX}; # without 'KPX'
Branch: 1 branch
BranchTrueFalseTotal
if $op->{"noKPX"} 21462 128772 150234
1815  
1816 128772 ▶ if( /^StartKernPairs/i .. /^EndKernPairs/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^StartKernPairs/i .. /^EndKernPairs/i) 128616 156 128772
1817 128616 ▶ /^KPX\s/ or next; # only lines that start with "KPX" are parsed
Branch: 1 branch
BranchTrueFalseTotal
/^KPX\s/ or next 126834 1782 128616
1818  
1819 # KPX space A -55
1820 126834 my( undef, $glyphA, $glyphB, $kpx ) = split /\s+/o;
1821  
1822 126834 $kpx =~y/0-9-//cd;
1823 126834 ▶ $kpx or next;
Branch: 1 branch
BranchTrueFalseTotal
$kpx or next 126828 6 126834
1824  
1825 126828 my $mateA = &_get_mate( $glyphA, $agl, $op );
1826 126828 my $mateB = &_get_mate( $glyphB, $agl, $op );
1827  
1828 $font_metrics{KPX}{ $mateA }{ $mateB } ||= $kpx
1829 126828 ▶ if defined( $mateA ) && defined( $mateB ) && ! exists( $font_metrics{KPX}{ $mateA }{ $mateB } );
Branch: 1 branch
BranchTrueFalseTotal
if defined $mateA and defined $mateB and not exists $font_metrics{"KPX"}{$mateA}{$mateB} 122808 4020 126828
Condition44%4/9
defined $mateA and defined $mateB and not exists $font_metrics{"KPX"}{$mateA}{$mateB}
!ll&&!rl&&r
04020122808
defined $mateA and defined $mateB
!ll&&!rl&&r
00126828
$font_metrics{"KPX"}{$mateA}{$mateB} ||= $kpx
l!l&&r!l&&!r
01228080
MC/DC33%1/3
defined $mateA and defined $mateB and not exists $font_metrics{"KPX"}{$mateA}{$mateB}
defined $mateA defined $mateB not exists $font_metrics{"KPX"}{$mateA}{$mateB}
MC/DC0%0/2
$font_metrics{"KPX"}{$mateA}{$mateB} ||= $kpx
$font_metrics{"KPX"}{$mateA}{$mateB} $kpx
Truth table50%2/4
A and B and not(C)
A= defined $mateAB= defined $mateBC= not exists $font_metrics{"KPX"}{$mateA}{$mateB}
ABCresult
0XX0
10X0
1100
1111
Truth table33%1/3
A ||= B
A= $font_metrics{"KPX"}{$mateA}{$mateB}B= $kpx
ABresult
1X1
011
000
1830  
1831 126828 next;
1832 }
1833  
1834 156 ▶ last if /^EndFontMetrics/;
Branch: 1 branch
BranchTrueFalseTotal
if /^EndFontMetrics/ 6 150 156
1835 }
1836 7 close $AFM;
1837  
1838 7 return \%font_metrics;
1839 }
1840  
1841  
1842 # IN:
1843 # $str -- string (strand)
1844 # $op->
1845 # {cell_width} -- width of cell/box (pt).
1846 # {font_metrics} -- table of font metrics with {WX} key -- for decimal Unicode number, and {KPX} key -- for paired kerning.
1847 # {base_font_size} -- depending on the document's base font size (pt), see \documentclass[...pt].
1848 # {font_size} -- TeX-font size of text in cell/box, e.g. 'small', 'normalsize', 'large', etc.
1849 # {shrink} -- space compressibility (the extent to which a space can become narrower than its base value if the line is compressed).
1850 # {merge} = 1 -- return a combined string (paragraph) and its total width (length) in (pt), rather than an array of strings.
1851 # {offset} -- offset from the beginning of $str from which characters for cell are extracted. By default, 0.
1852 # {limit} -- the maximum allowable number of lines for a cell.
1853 # {hyphenation} => # a array of methods for hyphenating words in specified languages, e.g.:
1854 # [
1855 # { name =>'en', action => $hyp_en, },
1856 # { name =>'ru', action => $hyp_ru, },
1857 # ]
1858 # OR
1859 # [
1860 # { msk => qr/[a-zA-Z]+/o, action => $hyp_en, },
1861 # { msk => qr/[а-яА-Я]+/o, action => $hyp_ru, },
1862 # ]
1863  
1864 # OUT:
1865 # HASH with keys:
1866 # 'lines' -- arrays of no empty lines.
1867 # 'wxL' -- arrays of line widths (*100pt) from 'lines'.
1868 # 'numL' -- number of no empty lines.
1869 # 'stop' -- position in $str where the extraction of symbols into cell stopped.
1870 # If all non-whitespace characters have been extracted from $str and 'limit' option is specified, then '-1' is returned.
1871 # or
1872 # SCALAR is number of lines
1873  
1874 29 ▶sub onecell {
Subroutine onecell: called CC=137 SCAR=49.8
Pod documented
1875 29 ▶ return if ! defined( $_[0] )
Branch: 1 branch
BranchTrueFalseTotal
if not defined $_[0] or ref \$_[0] ne "SCALAR" or not $_[1] or ref $_[1] ne "HASH" 4 25 29
Condition100%9/9
not defined $_[0] or ref \$_[0] ne "SCALAR" or not $_[1] or ref $_[1] ne "HASH"
l!l&&r!l&&!r
3125
not defined $_[0] or ref \$_[0] ne "SCALAR" or not $_[1]
l!l&&r!l&&!r
2126
not defined $_[0] or ref \$_[0] ne "SCALAR"
l!l&&r!l&&!r
1127
MC/DC100%4/4
not defined $_[0] or ref \$_[0] ne "SCALAR" or not $_[1] or ref $_[1] ne "HASH"
not defined $_[0] ref \$_[0] ne "SCALAR" not $_[1] ref $_[1] ne "HASH"
Truth table100%5/5
not(A) or B or not(C) or D
A= not defined $_[0]B= ref \$_[0] ne "SCALAR"C= not $_[1]D= ref $_[1] ne "HASH"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1876 or ref \$_[0] ne 'SCALAR'
1877 or ! $_[1]
1878 or ref $_[1] ne 'HASH';
1879  
1880 25 my $ArSc = wantarray;
1881  
1882 25 my $op = $_[1];
1883  
1884 25 ▶ if( $_[0] =~/^\s*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /^\s*$/) 2 23 25
1885 2 ▶ return $ArSc ? {lines => [ $_[0] ], wxL => [0], numL => 0, stop => 0,} : 0;
Branch: 1 branch
BranchTrueFalseTotal
$ArSc ? : 1 1 2
1886 }
1887  
1888 23 ▶ $op->{cell_width} or croak "Cell width is NOT specified!";
Branch: 1 branch
BranchTrueFalseTotal
$op->{"cell_width"} or croak("Cell width is NOT specified!") 22 1 23
1889  
1890 22 ▶ my $offset = $op->{offset} // 0;
Condition100%2/2
$op->{"offset"} // 0
l!l
175
MC/DC100%1/1
$op->{"offset"} // 0
$op->{"offset"}
Truth table100%2/2
A
A= $op->{"offset"}
Aresult
11
00
1891 22 my $szStr = length $_[0];
1892  
1893 22 ▶ return if $offset < 0 or $offset >= $szStr;
Branch: 1 branch
BranchTrueFalseTotal
if $offset < 0 or $offset >= $szStr 2 20 22
Condition100%3/3
$offset < 0 or $offset >= $szStr
l!l&&r!l&&!r
1120
MC/DC100%2/2
$offset < 0 or $offset >= $szStr
$offset < 0 $offset >= $szStr
Truth table100%3/3
A or B
A= $offset < 0B= $offset >= $szStr
ABresult
1X1
011
000
1894  
1895 20 ▶ my $limit = $op->{limit} // 0;
Condition100%2/2
$op->{"limit"} // 0
l!l
911
MC/DC100%1/1
$op->{"limit"} // 0
$op->{"limit"}
Truth table100%2/2
A
A= $op->{"limit"}
Aresult
11
00
1896 20 $limit += 0;
1897 20 ▶ $limit = 0 if $limit < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $limit < 0 5 15 20
1898  
1899 # font character width table
1900 20 ▶ my $symWX = $op->{font_metrics}{WX} or croak "Font metrics are NOT specified!";
Branch: 1 branch
BranchTrueFalseTotal
my $symWX = $op->{"font_metrics"}{"WX"} or croak("Font metrics are NOT specified!") 19 1 20
1901 19 ▶ my $symKPX = $op->{font_metrics}{KPX} || {};
Condition100%2/2
$op->{'font_metrics'}{'KPX'} || {}
l!l
181
MC/DC100%1/1
$op->{'font_metrics'}{'KPX'} || {}
$op->{'font_metrics'}{'KPX'}
Truth table100%2/2
A
A= $op->{'font_metrics'}{'KPX'}
Aresult
11
00
1902  
1903 19 our( $q, $m );
1904  
1905 19 ▶ my $space = ($op->{space} // 0) * 100 || $symWX->{32} or croak "Base whitespace width is NOT specified!";
Branch: 1 branch
BranchTrueFalseTotal
my $space = ($op->{"space"} // 0) * 100 || $symWX->{32} or croak("Base whitespace width is NOT specified!") 18 1 19
Condition100%5/5
($op->{'space'} // 0) * 100 || $symWX->{'32'}
l!l&&r!l&&!r
1621
$op->{"space"} // 0
l!l
163
MC/DC100%2/2
($op->{'space'} // 0) * 100 || $symWX->{'32'}
$op->{"space"} $symWX->{'32'}
Truth table100%3/3
A || B
A= $op->{"space"}B= $symWX->{'32'}
ABresult
1X1
011
000
1906 18 ▶ $space -= ($op->{shrink} // 0) * 100; # reduce by the maximum whitespace compression, if specified
Condition100%2/2
$op->{"shrink"} // 0
l!l
171
MC/DC100%1/1
$op->{"shrink"} // 0
$op->{"shrink"}
Truth table100%2/2
A
A= $op->{"shrink"}
Aresult
11
00
1907 18 ▶ my $spcKPX = $symKPX->{32} || {}; # paired kerning for whitespace
Condition100%2/2
$symKPX->{'32'} || {}
l!l
171
MC/DC100%1/1
$symKPX->{'32'} || {}
$symKPX->{'32'}
Truth table100%2/2
A
A= $symKPX->{'32'}
Aresult
11
00
1908  
1909 18 my $hyphen = $symWX->{45}; # ord('-') -- hyphen width
1910 18 my $wideS = $symWX->{64}; # ord('@') -- width of the average-to-maximum-width character
1911  
1912 18 our $fontSizeTeX;
1913 18 our $refHypMsk;
1914  
1915 18 ▶ my $base_font_size = $op->{base_font_size} || 10; # base document font size (pt)
Condition100%2/2
$op->{'base_font_size'} || 10
l!l
513
MC/DC100%1/1
$op->{'base_font_size'} || 10
$op->{'base_font_size'}
Truth table100%2/2
A
A= $op->{'base_font_size'}
Aresult
11
00
1916  
1917 18 ▶ my $font_id = $fontSizeTeX->{names}{ $op->{font_size} || 'normalsize'}; # for 'normalsize' = 4
Condition100%2/2
$op->{'font_size'} || 'normalsize'
l!l
135
MC/DC100%1/1
$op->{'font_size'} || 'normalsize'
$op->{'font_size'}
Truth table100%2/2
A
A= $op->{'font_size'}
Aresult
11
00
1918  
1919 # cell-to-'normalsize' scaling factor
1920 my $scale = ( $font_id == 4) ?
1921 1 :
1922 18 ▶ $fontSizeTeX->{ $base_font_size }[4] / $fontSizeTeX->{ $base_font_size }[ $font_id ]; # to 'normalsize'
Branch: 1 branch
BranchTrueFalseTotal
$font_id == 4 ? : 18 0 18
1923  
1924 18 my $cell_width = $op->{cell_width} * $scale * 100; # scale the cell width to 'normalsize' (*100pt)
1925  
1926 18 my @lines = (''); # cell/box with filled lines
1927 18 my @wxL; # line width (*100pt)
1928 18 my $numL = 0; # number of lines
1929 18 my $numSeq = 0; # number of sequences in input string
1930  
1931 18 my $prevKPX = {}; # KPX previous (prev) symbol
1932 18 my $curKPX = {}; # KPX current (cur) symbol
1933 18 my $curSize = 0; # width of current (fillable) string
1934  
1935 18 my $yhp = 0; # > 0 -- flag for the presence/necessity of hyphenation in $word:
1936 # 1 -- hyphenation method(s) is specified;
1937 # 2 -- hyphenation points have already been inserted in the word;
1938 # 3 -- short word (<4 characters) | 4 -- word NOT found | 5 -- NO hyphens
1939  
1940 # checking for the presence of method(s) for hyphenating words
1941 18 ▶ if( $_ = $op->{hyphenation}
Branch: 1 branch
BranchTrueFalseTotal
if ($_ = $op->{"hyphenation"} and ref $_ eq "ARRAY" and @$_) 15 3 18
Condition100%6/6
$_ = $op->{"hyphenation"} and ref $_ eq "ARRAY" and @$_
!ll&&!rl&&r
2115
$_ = $op->{"hyphenation"} and ref $_ eq "ARRAY"
!ll&&!rl&&r
1116
MC/DC100%3/3
$_ = $op->{"hyphenation"} and ref $_ eq "ARRAY" and @$_
$_ = $op->{"hyphenation"} ref $_ eq "ARRAY" @$_
Truth table100%4/4
A and B and C
A= $_ = $op->{"hyphenation"}B= ref $_ eq "ARRAY"C= @$_
ABCresult
0XX0
10X0
1100
1111
1942 and ref $_ eq 'ARRAY'
1943 and @$_
1944 ) {
1945 15 my $hyp = $_;
1946 15 @$hyp = grep{ ( ($_->{msk} or ( $_->{name} && exists( $refHypMsk->{lc $_->{name}} ) ))
1947 && exists( $_->{action} )
1948 && ( ref( $_->{action} ) eq 'CODE'
1949 31 ▶ or ( ref( $_->{action} ) =~/::Hyphen/ and $_->{action}->can('hyphenate') )
Condition61%11/18
($_->{'msk'} || $_->{'name'} && exists $$LaTeX::Replicase::refHypMsk{lc $_->{'name'}}) && exists $_->{'action'} && (ref $_->{'action'} eq 'CODE' || ref($_->{'action'}) =~ /::Hyphen/ && $_->{'action'}->can('hyphenate'))
!ll&&!rl&&r
1030
$_->{"msk"} || $_->{"name"} && exists $$LaTeX::Replicase::refHypMsk{lc $_->{"name"}} and exists $_->{"action"}
!ll&&!rl&&r
1030
$_->{"msk"} or $_->{"name"} and exists $$LaTeX::Replicase::refHypMsk{lc $_->{"name"}}
l!l&&r!l&&!r
15151
$_->{"name"} and exists $$LaTeX::Replicase::refHypMsk{lc $_->{"name"}}
!ll&&!rl&&r
0115
ref $_->{"action"} eq "CODE" or ref($_->{"action"}) =~ /::Hyphen/ and $_->{"action"}->can("hyphenate")
l!l&&r!l&&!r
0300
ref($_->{"action"}) =~ /::Hyphen/ and $_->{"action"}->can("hyphenate")
!ll&&!rl&&r
0030
MC/DC28%2/7
($_->{'msk'} || $_->{'name'} && exists $$LaTeX::Replicase::refHypMsk{lc $_->{'name'}}) && exists $_->{'action'} && (ref $_->{'action'} eq 'CODE' || ref($_->{'action'}) =~ /::Hyphen/ && $_->{'action'}->can('hyphenate'))
$_->{"msk"} $_->{"name"} exists $$LaTeX::Replicase::refHypMsk{lc $_->{"name"}} exists $_->{"action"} ref $_->{"action"} eq "CODE" ref($_->{"action"}) =~ /::Hyphen/ $_->{"action"}->can("hyphenate")
Truth table25%3/12
A or B and C and D && E or F and G
A= $_->{"msk"}B= $_->{"name"}C= exists $$LaTeX::Replicase::refHypMsk{lc $_->{"name"}}D= exists $_->{"action"}E= ref $_->{"action"} eq "CODE"F= ref($_->{"action"}) =~ /::Hyphen/G= $_->{"action"}->can("hyphenate")
ABCDEFGresult
00XXXXX0
010XXXX0
1XX0XXX0
0110XXX0
1XX100X0
1XX10100
011100X0
01110100
1XX11XX1
1XX10111
01111XX1
01110111
1950 )
1951 ) } @$hyp;
1952  
1953 15 ▶ $yhp = @$hyp ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
@$hyp ? : 15 0 15
1954 }
1955  
1956 18 pos $_[0] = $offset;
1957 18 my $stop = $offset;
1958 18 my $new; # 1 = new sequence
1959  
1960 _onecell_M0:
1961 18 ▶ while( $_[0] =~/(\S+)/g ) { # extracting character words from input string
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /(\S+)/g) 232 16 248
1962 232 $_ = $1;
1963 232 $stop = pos $_[0];
1964 232 $new = 1;
1965  
1966 232 my @cage = grep{ length } split /(\p{Alpha}{4,})/; # to split words into alphabetic and non-alphabetic words
1967  
1968 232 ▶ $yhp &&= 1;
Condition100%2/2
$yhp &&= 1
!ll
84148
MC/DC100%1/1
$yhp &&= 1
$yhp
Truth table100%2/2
A
A= $yhp
Aresult
00
11
1969  
1970 232 ▶ while( defined( my $word = shift @cage ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $word = shift @cage)) 349 230 579
1971  
1972 463 my $szl = length $lines[-1];
1973  
1974 463 my $alpha; # 1 -- alphabetic word
1975 463 ▶ if( $word =~/^[\p{Alpha}\-]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word =~ /^[\p{Alpha}\-]+$/) { } 425 38 463
1976 425 $alpha = 1;
1977 }
1978 else {
1979 38 $alpha = 0;
1980 38 ▶ $yhp &&= 1; # Reset settings
Condition100%2/2
$yhp &&= 1
!ll
929
MC/DC100%1/1
$yhp &&= 1
$yhp
Truth table100%2/2
A
A= $yhp
Aresult
00
11
1981 }
1982  
1983 463 my $delta = $cell_width - $curSize;
1984  
1985 # in a cell line, there are preceding word(s), and this is not a fragment
1986 463 ▶ $delta -= $space if $szl
Branch: 1 branch
BranchTrueFalseTotal
if $szl and $new || !~~@cage and not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/ 213 250 463
Condition100%9/9
$szl and $new || !~~@cage and not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
!ll&&!rl&&r
20644213
$szl and $new || !~~@cage
!ll&&!rl&&r
13769257
$new or not ~~@cage
l!l&&r!l&&!r
2134469
MC/DC50%2/4
$szl and $new || !~~@cage and not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
$szl $new not ~~@cage not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
Truth table66%4/6
A and B or not(C) and not(D)
A= $szlB= $newC= not ~~@cageD= not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
1987 and ($new or ! ~~@cage)
1988 and $lines[-1] !~/(?:\\-|$q)$/;
1989  
1990 463 my $wS; # width of current symbol (*100pt)
1991 my $wH; # width of hyphen taking pair kerning into account (*100pt)
1992 463 my $wW = 0; # width of word/fragment (*100pt)
1993 463 my $f = 1; # flag that the word fits into a cell line
1994 463 my $nS = 0; # ordinal number (position) of symbol in word
1995  
1996 463 my @ss = split //, $word;
1997  
1998 # to split word into symbols and get its decimal ID
1999 463 foreach my $sid ( map{ ord($_) } @ss ) { # current symbol id
2000 1445 ▶ $wH = @cage ? $hyphen : 0;
Branch: 1 branch
BranchTrueFalseTotal
@cage ? : 372 1073 1445
2001  
2002 1445 ▶ if( exists $symWX->{ $sid } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $symWX->{$sid}) { } 1442 3 1445
2003 1442 $wS = $symWX->{ $sid };
2004 1442 ▶ $curKPX = $symKPX->{ $sid } || {};
Condition100%2/2
$symKPX->{$sid} || {}
l!l
843599
MC/DC100%1/1
$symKPX->{$sid} || {}
$symKPX->{$sid}
Truth table100%2/2
A
A= $symKPX->{$sid}
Aresult
11
00
2005  
2006 # to take pair kerning into account: prev+cur
2007 1442 ▶ $wS += $prevKPX->{ $sid } // 0;
Condition100%2/2
$prevKPX->{$sid} // 0
l!l
1861256
MC/DC100%1/1
$prevKPX->{$sid} // 0
$prevKPX->{$sid}
Truth table100%2/2
A
A= $prevKPX->{$sid}
Aresult
11
00
2008 1442 ▶ $wH += $curKPX->{45} // 0 if @cage; # for cur+hyphen
Branch: 1 branch
BranchTrueFalseTotal
if @cage 372 1070 1442
Condition100%2/2
$curKPX->{45} // 0
l!l
67305
MC/DC100%1/1
$curKPX->{45} // 0
$curKPX->{45}
Truth table100%2/2
A
A= $curKPX->{45}
Aresult
11
00
2009 }
2010 else {
2011 3 carp 'Undefined width for symbol with hexcode: '. sprintf("%04X", $sid);
2012 3 $wS = $wideS;
2013 3 $curKPX = {};
2014 }
2015  
2016 # say "1=> word='$word', symbol='". chr($sid) ."', curSize=$curSize, delta=$delta, wW=$wW, wS=$wS, nS=$nS, f=$f, yhp=$yhp, cage=".~~@cage;
2017 # say Dumper \@cage;
2018  
2019 # это: 'буквенный фрагмент/слово' И 'не последняя буква' И 'следующий фрагмент тоже буквенныы'
2020 1445 ▶ my $cnd = ($alpha && ($nS < $#ss or (@cage && $cage[0] =~/^\p{Alpha}+$/)) ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$alpha && ($nS < $#ss || @cage && $cage[0] =~ /^\p{Alpha}+$/) ? : 1148 297 1445
Condition100%9/9
$alpha and $nS < $#ss || @cage && $cage[0] =~ /^\p{Alpha}+$/
!ll&&!rl&&r
512461148
$nS < $#ss or @cage and $cage[0] =~ /^\p{Alpha}+$/
l!l&&r!l&&!r
108266246
@cage and $cage[0] =~ /^\p{Alpha}+$/
!ll&&!rl&&r
2172966
MC/DC100%4/4
$alpha and $nS < $#ss || @cage && $cage[0] =~ /^\p{Alpha}+$/
$alpha $nS < $#ss @cage $cage[0] =~ /^\p{Alpha}+$/
Truth table100%5/5
A and B or C and D
A= $alphaB= $nS < $#ssC= @cageD= $cage[0] =~ /^\p{Alpha}+$/
ABCDresult
0XXX0
100X0
10100
11XX1
10111
2021  
2022 # symbol width or (+hyphen) > cell width
2023 1445 ▶ if( $wS > $cell_width
Branch: 1 branch
BranchTrueFalseTotal
if ($wS > $cell_width or $cnd and $wS + $wH > $cell_width) 27 1418 1445
Condition100%6/6
$wS > $cell_width or $cnd and $wS + $wH > $cell_width
l!l&&r!l&&!r
2521418
$cnd and $wS + $wH > $cell_width
!ll&&!rl&&r
28211362
MC/DC100%3/3
$wS > $cell_width or $cnd and $wS + $wH > $cell_width
$wS > $cell_width $cnd $wS + $wH > $cell_width
Truth table100%4/4
A or B and C
A= $wS > $cell_widthB= $cndC= $wS + $wH > $cell_width
ABCresult
1XX1
0111
00X0
0100
2024 or ($cnd and $wS + $wH > $cell_width)
2025 ) {
2026 27 $f = -1;
2027 27 last;
2028 }
2029  
2030 # width of fragment > remaining (unfilled portion) cell width
2031 1418 ▶ if( $wW + $wS > $delta
Branch: 1 branch
BranchTrueFalseTotal
if ($wW + $wS > $delta or $cnd and $wW + $wS + $wH > $delta) 127 1291 1418
Condition100%6/6
$wW + $wS > $delta or $cnd and $wW + $wS + $wH > $delta
l!l&&r!l&&!r
109181291
$cnd and $wW + $wS + $wH > $delta
!ll&&!rl&&r
263102818
MC/DC100%3/3
$wW + $wS > $delta or $cnd and $wW + $wS + $wH > $delta
$wW + $wS > $delta $cnd $wW + $wS + $wH > $delta
Truth table100%4/4
A or B and C
A= $wW + $wS > $deltaB= $cndC= $wW + $wS + $wH > $delta
ABCresult
1XX1
0111
00X0
0100
2032 or ($cnd and $wW + $wS + $wH > $delta)
2033 ) {
2034 127 $f = 0;
2035 127 last;
2036 }
2037  
2038 1291 $wW += $wS;
2039 1291 $prevKPX = $curKPX; # for pair kerning next symbol
2040 1291 ++$nS;
2041 }
2042 463 ▶ $numL ||= 1; # JIC
Condition100%2/2
$numL ||= 1
l!l
44518
MC/DC100%1/1
$numL ||= 1
$numL
Truth table100%2/2
A
A= $numL
Aresult
11
00
2043  
2044 # if( $word =~/^WA$/) {
2045 # say "2=> word='$word', curSize=$curSize, delta=$delta, wW=$wW, wS=$wS, nS=$nS, #ss=".$#ss.", f=$f, yhp=$yhp, cage=".~~@cage;
2046 # say Dumper \@lines;
2047 # }
2048  
2049 463 ▶ if( $f > 0 ) { # word (or fragment) is placed into the cell line in its entirety
Branch: 1 branch
BranchTrueFalseTotal
if ($f > 0) 309 154 463
2050 309 ▶ if( $szl && $lines[-1] !~/(?:\\-|$q)$/ ) { # there is prev.word(s) in the cell line and it is not fragment
Branch: 1 branch
BranchTrueFalseTotal
if ($szl and not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/) 145 164 309
Condition100%3/3
$szl and not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
!ll&&!rl&&r
10262145
MC/DC100%2/2
$szl and not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
$szl not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
Truth table100%3/3
A and not(B)
A= $szlB= not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
ABresult
0X0
100
111
2051
2052 # add whitespace for prev.word
2053 145 $curSize += $space; # + ($prevKPX->{32} // 0);
2054 145 $lines[-1] .= ' ';
2055 }
2056  
2057 # add cur.word in cell line
2058 309 $curSize += $wW;
2059 309 $lines[-1] .= $word;
2060  
2061 309 ▶ if( @cage ) { # this is fragment (word continues further on)
Branch: 1 branch
BranchTrueFalseTotal
if (@cage) 84 225 309
2062 84 ▶ $lines[-1] .= ($alpha && $cage[0] =~/^\p{Alpha}+$/) ? '\\-' : $m; # + supposed hyphen or glue (\hskip)
Branch: 1 branch
BranchTrueFalseTotal
$alpha && $cage[0] =~ /^\p{Alpha}+$/ ? : 59 25 84
Condition66%2/3
$alpha and $cage[0] =~ /^\p{Alpha}+$/
!ll&&!rl&&r
02559
MC/DC50%1/2
$alpha and $cage[0] =~ /^\p{Alpha}+$/
$alpha $cage[0] =~ /^\p{Alpha}+$/
Truth table66%2/3
A and B
A= $alphaB= $cage[0] =~ /^\p{Alpha}+$/
ABresult
0X0
100
111
2063 }
2064  
2065 309 next;
2066 }
2067  
2068 154 my @chunks = $word=~/(.{$nS})(.)(.*)/;
2069  
2070 154 ▶ if( $f < 0 ) { # symbol width > cell width
Branch: 1 branch
BranchTrueFalseTotal
if ($f < 0) 27 127 154
2071  
2072 27 ▶ if( (! defined( $chunks[2] ) or ! length( $chunks[2] )) && ! @cage ) { # NOT "tail" or fragments
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $chunks[2] && length $chunks[2] || @cage) { } 6 21 27
Condition83%5/6
defined $chunks[2] && length $chunks[2] || @cage
l!l&&r!l&&!r
1836
defined $chunks[2] and length $chunks[2]
!ll&&!rl&&r
0918
MC/DC66%2/3
defined $chunks[2] && length $chunks[2] || @cage
defined $chunks[2] length $chunks[2] @cage
Truth table60%3/5
A and B || C
A= defined $chunks[2]B= length $chunks[2]C= @cage
ABCresult
11X1
0X11
1011
0X00
1000
2073 # add whitespace
2074 6 $chunks[1] .= ' ';
2075 6 $wS += $space; # + ($prevKPX->{32} // 0);
2076 6 $prevKPX = $spcKPX; # for paired kerning of space + next.symbol
2077  
2078 }
2079 else { # exists "tail"
2080 21 ▶ if( $alpha && ($chunks[2] =~/^\p{Alpha}+$/ or $cage[0] =~/^\p{Alpha}+$/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha and $chunks[2] =~ /^\p{Alpha}+$/ || $cage[0] =~ /^\p{Alpha}+$/) { } 12 9 21
Condition100%6/6
$alpha and $chunks[2] =~ /^\p{Alpha}+$/ || $cage[0] =~ /^\p{Alpha}+$/
!ll&&!rl&&r
7212
$chunks[2] =~ /^\p{Alpha}+$/ or $cage[0] =~ /^\p{Alpha}+$/
l!l&&r!l&&!r
1112
MC/DC100%3/3
$alpha and $chunks[2] =~ /^\p{Alpha}+$/ || $cage[0] =~ /^\p{Alpha}+$/
$alpha $chunks[2] =~ /^\p{Alpha}+$/ $cage[0] =~ /^\p{Alpha}+$/
Truth table100%4/4
A and B or C
A= $alphaB= $chunks[2] =~ /^\p{Alpha}+$/C= $cage[0] =~ /^\p{Alpha}+$/
ABCresult
0XX0
1000
11X1
1011
2081 12 $chunks[1] .= '\\-'; # symbol + hyphen
2082 # $wS += $wH; # width of (cur.symbol + hyphen + paired kerning): cur+hyphen
2083 }
2084 else {
2085 9 $chunks[1] .= $m; # +glue
2086 }
2087 }
2088  
2089 27 ▶ if( $nS ) { # exists "head" (prefix)
Branch: 1 branch
BranchTrueFalseTotal
if ($nS) { } 6 21 27
2090  
2091 6 $lines[-1] .= $chunks[0];
2092  
2093 6 ▶ if( $chunks[0] =~/^\p{Alpha}+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chunks[0] =~ /^\p{Alpha}+$/) { } 6 0 6
2094 6 $lines[-1] .= '\\-'; # + hyphen
2095 # push @wxL, $curSize + $wW + $hyphen + ($prevKPX->{45} // 0) if $ArSc; # taking paired kerning into account: prev+hyphen
2096 }
2097 else {
2098 0 $lines[-1] .= $m; # + glue
2099 }
2100 6 ▶ push @wxL, $curSize + $wW if $ArSc;
Branch: 1 branch
BranchTrueFalseTotal
if $ArSc 5 1 6
2101  
2102 6 ▶ if( $limit && @lines >= $limit ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($limit and @lines >= $limit) 1 5 6
Condition66%2/3
$limit and @lines >= $limit
!ll&&!rl&&r
501
MC/DC50%1/2
$limit and @lines >= $limit
$limit @lines >= $limit
Truth table66%2/3
A and B
A= $limitB= @lines >= $limit
ABresult
0X0
100
111
2103 1 $stop -= (length( join('', $word, @cage) ) - $nS);
2104 1 last _onecell_M0;
2105 }
2106  
2107 # Next up is a new cell line
2108 5 ++$numL;
2109 5 push @lines, $chunks[1];
2110 }
2111 else { # NO "head" (prefix)
2112 21 ▶ if( $szl ) { # and cell line is NOT empty (partially filled)
Branch: 1 branch
BranchTrueFalseTotal
if ($szl) { } 2 19 21
2113  
2114 2 my $add = 0;
2115 2 ▶ if( $lines[-1] !~/(?:\\-|$q)$/ and ! ~~@cage ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/ or ~~@cage) 2 0 2
Condition33%1/3
$lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/ or ~~@cage
l!l&&r!l&&!r
002
MC/DC0%0/2
$lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/ or ~~@cage
$lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/ ~~@cage
Truth table33%1/3
A or B
A= $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/B= ~~@cage
ABresult
1X1
011
000
2116 # In cell line no word fragment at the beginning, but there is a complete word
2117 2 $lines[-1] .= ' ';
2118 2 $add = $space; # + ($prevKPX->{32} // 0);
2119 }
2120 2 ▶ push @wxL, $curSize + $add if $ArSc;
Branch: 1 branch
BranchTrueFalseTotal
if $ArSc 2 0 2
2121  
2122 2 ▶ if( $limit && @lines >= $limit ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($limit and @lines >= $limit) 0 2 2
Condition33%1/3
$limit and @lines >= $limit
!ll&&!rl&&r
200
MC/DC0%0/2
$limit and @lines >= $limit
$limit @lines >= $limit
Truth table33%1/3
A and B
A= $limitB= @lines >= $limit
ABresult
0X0
100
111
2123 0 $stop -= length( join('', $word, @cage) );
2124 0 last _onecell_M0;
2125 }
2126  
2127 # Next up is a new cell line
2128 2 ++$numL;
2129 2 push @lines, $chunks[1]; # with hyphen or glue (see above)
2130 }
2131 else { # cell line is EMPTY
2132 19 $lines[-1] .= $chunks[1]; # with posible? hyphen or glue
2133 }
2134 }
2135  
2136 26 ▶ push @wxL, $wS if $ArSc; # width of symbol + space
Branch: 1 branch
BranchTrueFalseTotal
if $ArSc 25 1 26
2137  
2138 26 ▶ if( $limit && @lines >= $limit ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($limit and @lines >= $limit) 0 26 26
Condition33%1/3
$limit and @lines >= $limit
!ll&&!rl&&r
2600
MC/DC0%0/2
$limit and @lines >= $limit
$limit @lines >= $limit
Truth table33%1/3
A and B
A= $limitB= @lines >= $limit
ABresult
0X0
100
111
2139 0 $stop -= ( length( join('', $word, @cage) ) - ($nS + 1));
2140 0 last _onecell_M0;
2141 }
2142  
2143 # Next up is a new cell line
2144 26 ++$numL;
2145 26 $curSize = 0;
2146 26 $prevKPX = {};
2147 26 push @lines, '';
2148  
2149 26 ▶ if( $chunks[2] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chunks[2]) 18 8 26
2150 18 $word = $chunks[2];
2151  
2152 # say "3=> word='$word', chunks[2]=$chunks[2]";
2153  
2154 18 redo;
2155 }
2156  
2157 # say "4=> word='$word', chunks[2]=$chunks[2]";
2158  
2159 8 next;
2160 }
2161  
2162 127 ▶ if( $alpha && $yhp && $yhp < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha and $yhp and $yhp < 3) 92 35 127
Condition100%6/6
$alpha and $yhp and $yhp < 3
!ll&&!rl&&r
32392
$alpha and $yhp
!ll&&!rl&&r
23095
MC/DC100%3/3
$alpha and $yhp and $yhp < 3
$alpha $yhp $yhp < 3
Truth table100%4/4
A and B and C
A= $alphaB= $yhpC= $yhp < 3
ABCresult
0XX0
10X0
1100
1111
2163 # This is alphabetic word, and a method (action) for breaking words into hyphens is specified
2164  
2165 92 ▶ if( $yhp == 2 ) { # for word it was already broken by hyphens
Branch: 2 branches
BranchTrueFalseTotal
if ($yhp == 2) { } 35 57 92
elsif ($#ss > 2) { } 36 21 57
2166  
2167 35 ▶ if( $szl ) { # and cell line is not empty (partially filled)
Branch: 1 branch
BranchTrueFalseTotal
if ($szl) 31 4 35
2168  
2169 31 my $add = 0;
2170 31 ▶ if( $lines[-1] !~/(?:\\-|$q)$/) { # there is a full word : and ! ~~@cage
Branch: 1 branch
BranchTrueFalseTotal
unless ($lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/) 10 21 31
2171 10 $lines[-1] .= ' ';
2172 10 $add = $space; # + ($prevKPX->{32} // 0);
2173 }
2174 31 ▶ push @wxL, $curSize + $add if $ArSc;
Branch: 1 branch
BranchTrueFalseTotal
if $ArSc 25 6 31
2175  
2176 31 ▶ if( $limit && @lines >= $limit ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($limit and @lines >= $limit) 0 31 31
Condition66%2/3
$limit and @lines >= $limit
!ll&&!rl&&r
21100
MC/DC0%0/2
$limit and @lines >= $limit
$limit @lines >= $limit
Truth table66%2/3
A and B
A= $limitB= @lines >= $limit
ABresult
0X0
100
111
2177 0 $stop -= length( join('', $word, @cage) );
2178 0 last _onecell_M0;
2179 }
2180  
2181 # Try placing it into
2182 # Next up is a new cell line
2183 31 ++$numL;
2184 31 $curSize = 0;
2185  
2186 # $lines[-1] =~/.$/;
2187 31 $prevKPX = {}; # $symKPX->{ord($&)} || ;
2188 31 push @lines, '';
2189  
2190 31 redo; # repeat in a new cell line
2191 }
2192 }
2193 elsif( $#ss > 2 ) { # length of word/fragment > 3 symbols
2194 36 for my $h ( @{ $op->{hyphenation} } ) {
2195 49 my $msk;
2196 49 ▶ if( $h->{msk} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($h->{'msk'}) { } 13 36 49
elsif ($h->{'name'}) { } 36 0 36
2197 13 $msk = $h->{msk};
2198 }
2199 elsif( $h->{name} ) {
2200 36 $msk = $refHypMsk->{lc $h->{name}};
2201 }
2202  
2203 49 ▶ if( $msk && $word =~/^$msk$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($msk and $word =~ /^$msk$/) { } 31 18 49
Condition66%2/3
$msk and $word =~ /^$msk$/
!ll&&!rl&&r
01831
MC/DC50%1/2
$msk and $word =~ /^$msk$/
$msk $word =~ /^$msk$/
Truth table66%2/3
A and B
A= $mskB= $word =~ /^$msk$/
ABresult
0X0
100
111
2204  
2205 my @arr = ( ref( $h->{action} ) eq 'CODE') ?
2206 $h->{action}( $word ) :
2207 31 ▶ $h->{action}->hyphenate( $word );
Branch: 1 branch
BranchTrueFalseTotal
ref $h->{'action'} eq 'CODE' ? : 0 31 31
2208  
2209 31 ▶ if( @arr > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arr > 1) { } 30 1 31
2210 30 $yhp = 2; # YES word breaks (hyphenations)
2211 30 unshift @cage, @arr;
2212 }
2213 else {
2214 1 $yhp = 3; # NO word breaks (hyphenations)
2215 }
2216 31 last;
2217 }
2218 else {
2219 18 $yhp = 4; # word NOT found
2220 }
2221 }
2222 36 ▶ next if $yhp == 2; # hyphenation has been added to the words
Branch: 1 branch
BranchTrueFalseTotal
if $yhp == 2 30 6 36
2223 }
2224 else {
2225 21 $yhp = 5; # a small word (<4 symbols)
2226 }
2227  
2228 }
2229  
2230 # symbol < cell width, but did not fit into the current cell line
2231  
2232 66 ▶ if( $szl && $lines[-1] !~/(?:\\-|$q)$/) { # In cell line no word fragment at the beginning, but there is a complete word.
Branch: 1 branch
BranchTrueFalseTotal
if ($szl and not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/) 56 10 66
Condition100%3/3
$szl and not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
!ll&&!rl&&r
9156
MC/DC100%2/2
$szl and not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
$szl not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
Truth table100%3/3
A and not(B)
A= $szlB= not $lines[-1] =~ /(?:\\-|$LaTeX::Replicase::q)$/
ABresult
0X0
100
111
2233 56 $lines[-1] .= ' ';
2234 56 $curSize += $space; # + ($prevKPX->{32} // 0);
2235 }
2236  
2237 66 ▶ my $alpha_0 = $chunks[0] =~/^\p{Alpha}+$/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$chunks[0] =~ /^\p{Alpha}+$/ ? : 34 32 66
2238  
2239  
2240 # if( $word =~/^A$/) {
2241 # say "5=> word='$word', wW=$wW, wS=$wS, nS=$nS, #ss=".$#ss.", f=$f, yhp=$yhp, szl=$szl, alpha_0=$alpha_0, cage=".~~@cage;
2242 # say Dumper \@lines;
2243 # exit;
2244 # }
2245  
2246 66 ▶ if( $nS && ($nS > 1 or ! $curSize or ! $alpha_0) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($nS and $nS > 1 || !$curSize || !$alpha_0) { } 31 35 66
elsif ($ArSc) { } 30 5 35
Condition100%9/9
$nS and $nS > 1 || !$curSize || !$alpha_0
!ll&&!rl&&r
27831
$nS > 1 or not $curSize or not $alpha_0
l!l&&r!l&&!r
3018
$nS > 1 or not $curSize
l!l&&r!l&&!r
2289
MC/DC100%4/4
$nS and $nS > 1 || !$curSize || !$alpha_0
$nS $nS > 1 not $curSize not $alpha_0
Truth table100%5/5
A and B or not(C) or not(D)
A= $nSB= $nS > 1C= not $curSizeD= not $alpha_0
ABCDresult
0XXX0
10000
11XX1
101X1
10011
2247 # hyphenation allowed only after the first 2 letters, or cell is EMPTY, or if the character is not a letter
2248 31 $lines[-1] .= $chunks[0];
2249  
2250 # my $add = 0;
2251 31 ▶ if( $alpha_0 && $alpha ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha_0 and $alpha) { } 26 5 31
Condition66%2/3
$alpha_0 and $alpha
!ll&&!rl&&r
5026
MC/DC50%1/2
$alpha_0 and $alpha
$alpha_0 $alpha
Truth table66%2/3
A and B
A= $alpha_0B= $alpha
ABresult
0X0
100
111
2252 26 $lines[-1] .= '\\-'; # + hyphen
2253 # $add = $hyphen + ($prevKPX->{45} // 0);
2254 }
2255 else {
2256 5 $lines[-1] .= $m; # + glue
2257 }
2258  
2259 31 ▶ push @wxL, $curSize + $wW if $ArSc; # taking into account kerning pairs prev+hyphen
Branch: 1 branch
BranchTrueFalseTotal
if $ArSc 31 0 31
2260  
2261 31 $word = $chunks[1].$chunks[2];
2262 }
2263 elsif( $ArSc ) { # current synbol is the 1st character of the word/fragment
2264 30 push @wxL, $curSize;
2265 }
2266  
2267 66 ▶ if( $limit && @lines >= $limit ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($limit and @lines >= $limit) 1 65 66
Condition100%3/3
$limit and @lines >= $limit
!ll&&!rl&&r
5961
MC/DC100%2/2
$limit and @lines >= $limit
$limit @lines >= $limit
Truth table100%3/3
A and B
A= $limitB= @lines >= $limit
ABresult
0X0
100
111
2268 1 $stop -= length( join('', $word, @cage) );
2269 1 last _onecell_M0;
2270 }
2271  
2272 # Next up is a new cell line
2273 65 ++$numL;
2274 65 $curSize = 0;
2275 65 $prevKPX = $curKPX; # for paired kerning of the next symbol
2276 65 push @lines, '';
2277  
2278 65 redo; # repeat in a new cell line
2279 }
2280 continue {
2281 347 $new = 0;
2282 }
2283 }
2284 continue {
2285 230 ++$numSeq;
2286 }
2287  
2288 18 ▶ push @wxL, $curSize if $ArSc && $curSize && $#wxL < $#lines;
Branch: 1 branch
BranchTrueFalseTotal
if $ArSc and $curSize and $#wxL < $#lines 11 7 18
Condition100%6/6
$ArSc and $curSize and $#wxL < $#lines
!ll&&!rl&&r
6111
$ArSc and $curSize
!ll&&!rl&&r
2412
MC/DC100%3/3
$ArSc and $curSize and $#wxL < $#lines
$ArSc $curSize $#wxL < $#lines
Truth table100%4/4
A and B and C
A= $ArScB= $curSizeC= $#wxL < $#lines
ABCresult
0XX0
10X0
1100
1111
2289  
2290 18 ▶ $stop = -1 if $limit
Branch: 1 branch
BranchTrueFalseTotal
if $limit and $stop >= $szStr || @lines < $limit || $_[0] =~ /\A.{$stop}\s+\z/ 1 17 18
Condition77%7/9
$limit and $stop >= $szStr || @lines < $limit || $_[0] =~ /\A.{$stop}\s+\z/
!ll&&!rl&&r
1521
$stop >= $szStr or @lines < $limit or $_[0] =~ /\A.{$stop}\s+\z/
l!l&&r!l&&!r
102
$stop >= $szStr or @lines < $limit
l!l&&r!l&&!r
012
MC/DC50%2/4
$limit and $stop >= $szStr || @lines < $limit || $_[0] =~ /\A.{$stop}\s+\z/
$limit $stop >= $szStr @lines < $limit $_[0] =~ /\A.{$stop}\s+\z/
Truth table60%3/5
A and B or C or D
A= $limitB= $stop >= $szStrC= @lines < $limitD= $_[0] =~ /\A.{$stop}\s+\z/
ABCDresult
0XXX0
10000
11XX1
101X1
10011
2291 and ( $stop >= $szStr or @lines < $limit or $_[0] =~/\A.{$stop}\s+\z/ );
2292  
2293 # Final preparations
2294 18 @lines = grep{ ! /^\s*$/ } @lines;
2295  
2296 18 my $i = 0;
2297 18 for( @lines ) {
2298 143 s/(?<=[[:alpha:]])$q(?=[\.,\?!:;%'])//g; #'
2299 143 ▶ s/(?<=[[:alpha:]])$q$// if $i < $#lines and $lines[$i+1] =~/^[\.,\?!:;%']/; #'
Branch: 1 branch
BranchTrueFalseTotal
if $i < $#lines and $lines[$i + 1] =~ /^[\.,\?!:;%']/ 1 142 143
Condition100%3/3
$i < $#lines and $lines[$i + 1] =~ /^[\.,\?!:;%']/
!ll&&!rl&&r
181241
MC/DC100%2/2
$i < $#lines and $lines[$i + 1] =~ /^[\.,\?!:;%']/
$i < $#lines $lines[$i + 1] =~ /^[\.,\?!:;%']/
Truth table100%3/3
A and B
A= $i < $#linesB= $lines[$i + 1] =~ /^[\.,\?!:;%']/
ABresult
0X0
100
111
2300 143 s/(?:\\-|$q)(?=\S+\s\S)//g;
2301 143 ++$i;
2302 }
2303  
2304 18 ▶ if( $lines[-1] =~s/ $// && $ArSc ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lines[-1] =~ s/ $// and $ArSc) 4 14 18
Condition100%3/3
$lines[-1] =~ s/ $// and $ArSc
!ll&&!rl&&r
1314
MC/DC100%2/2
$lines[-1] =~ s/ $// and $ArSc
$lines[-1] =~ s/ $// $ArSc
Truth table100%3/3
A and B
A= $lines[-1] =~ s/ $//B= $ArSc
ABresult
0X0
100
111
2305 4 $wxL[-1] -= $space;
2306 }
2307  
2308 18 my $wxLsum = 0;
2309 18 ▶ if( $ArSc && $op->{merge} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ArSc and $op->{"merge"}) 1 17 18
Condition100%3/3
$ArSc and $op->{"merge"}
!ll&&!rl&&r
2151
MC/DC100%2/2
$ArSc and $op->{"merge"}
$ArSc $op->{"merge"}
Truth table100%3/3
A and B
A= $ArScB= $op->{"merge"}
ABresult
0X0
100
111
2310 1 $wxLsum += $_ for @wxL;
2311 }
2312  
2313 return $ArSc ?
2314 {
2315 lines => ($op->{merge} ? [ join '', @lines ] : \@lines),
2316 18 ▶ wxL => ($op->{merge} ? [ $wxLsum ] : \@wxL),
Branch: 3 branches
BranchTrueFalseTotal
$ArSc ? : 16 2 18
$op->{'merge'} ? : 1 15 16
$op->{'merge'} ? : 1 15 16
2317 numL => ~~@lines, # $numL,
2318 stop => $stop,
2319 } :
2320 ~~@lines; # $numL
2321 }
2322  
2323 6 1;
2324  
2325 __END__
↑ Summary