lib/ChordPro/Config.pm

filter: Statementstmt 65.1% 408 / 626 Branchbran 52.3% 178 / 340 Conditioncond 44.0% 96 / 218 MC/DCmcdc 12.6% 14 / 111 Subroutinesub 87.5% 49 / 56 Podpod 0.0% 0 / 28 totaltotal 54.0% 745 / 1379 CC 298 SCAR 52.1
CC
298
Cov
58%
configurator
534.0
config_final
240.0
_reduce
218.2
CRAP 183.8
« lib/ChordPro/A2Crd.pm ↑ Summary lib/ChordPro/Output/PDF/StringDiagram.pm »
1 #! perl
2  
3 package main;
4  
5 92 our $options;
6 92 our $config;
7  
8 package ChordPro::Config;
9  
10 92 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 92 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 92 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 92 ▶use feature qw( signatures state );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 92 ▶no warnings "experimental::signatures";
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 92 ▶use ChordPro;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 92 ▶use ChordPro::Files;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 92 ▶use ChordPro::Paths;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 92 ▶use ChordPro::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 92 ▶use ChordPro::Utils qw( enumerated );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 92 ▶use Scalar::Util qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 92 ▶use List::Util qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 92 ▶use Storable 'dclone';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 92 ▶use Hash::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 92 ▶use Ref::Util qw( is_arrayref is_hashref );
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 #sub hmerge($$;$);
28 #sub clone($);
29 #sub default_config();
30  
31 353 ▶sub new ( $pkg, $cf = {} ) {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
32 353 bless $cf => $pkg;
33 }
34  
35 215 ▶sub pristine_config {
Subroutine pristine_config: called CC=1 SCAR=0.0
Pod undocumented
36 92 ▶ use ChordPro::Config::Data;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 215 __PACKAGE__->new(ChordPro::Config::Data::config());
38 }
39  
40 215 ▶sub configurator ( $opts = undef ) {
Subroutine configurator: called CC=81 SCAR=62.8
Pod undocumented
41  
42 # Test programs call configurator without options.
43 # Prepare a minimal config.
44 215 ▶ unless ( $opts ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts) 91 124 215
45 91 my $cfg = pristine_config();
46 91 $config = $cfg;
47 91 $cfg->split_fc_aliases;
48 91 $options = { verbose => 0 };
49 91 process_config( $cfg, "<builtin>" );
50 91 $cfg->{settings}->{lineinfo} = 0;
51 91 return $cfg;
52 }
53 124 ▶ if ( keys(%$opts) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$opts) 9 115 124
54 9 ▶ $options = { %{$options//{}}, %$opts };
Condition50%1/2
$main::options // {}
l!l
90
MC/DC0%0/1
$main::options // {}
$main::options
Truth table50%1/2
A
A= $main::options
Aresult
11
00
55 }
56  
57 124 my @cfg;
58 124 ▶ my $verbose = $options->{verbose} //= 0;
Condition100%2/2
$main::options->{"verbose"} //= 0
l!l
2896
MC/DC100%1/1
$main::options->{"verbose"} //= 0
$main::options->{"verbose"}
Truth table100%2/2
A
A= $main::options->{"verbose"}
Aresult
11
00
59  
60 # Load defaults.
61 124 ▶ warn("Reading: <builtin>\n") if $verbose > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose > 1 0 124 124
62 124 my $cfg = pristine_config();
63  
64 # Default first.
65 124 @cfg = prep_configs( $cfg, "<builtin>" );
66 # Bubble default config to be the first.
67 124 ▶ unshift( @cfg, pop(@cfg) ) if @cfg > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @cfg > 1 124 0 124
68  
69 # Collect other config files.
70 11 ▶ my $add_config = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
71 11 my $fn = shift;
72 11 $cfg = get_config( $fn );
73 11 push( @cfg, $cfg->prep_configs($fn) );
74 124 };
75  
76 124 foreach my $c ( qw( sysconfig userconfig config ) ) {
77 372 ▶ next if $options->{"no$c"};
Branch: 1 branch
BranchTrueFalseTotal
if $$main::options{"no$c"} 363 9 372
78 9 ▶ if ( ref($options->{$c}) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $main::options->{$c} eq 'ARRAY') { } 2 7 9
79 2 $add_config->($_) foreach @{ $options->{$c} };
80 }
81 else {
82 7 ▶ warn("Adding config for $c\n") if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 7 7
83 7 $add_config->( $options->{$c} );
84 }
85 }
86  
87 # Now we have a list of all config files. Weed out dups.
88 124 ▶ for ( my $a = 0; $a < @cfg; $a++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a < @cfg) 259 124 383
89 259 ▶ if ( $a && $cfg[$a]->{_src} eq $cfg[$a-1]->{_src} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a and $cfg[$a]{"_src"} eq $cfg[$a - 1]{"_src"}) 0 259 259
Condition66%2/3
$a and $cfg[$a]{"_src"} eq $cfg[$a - 1]{"_src"}
!ll&&!rl&&r
1241350
MC/DC0%0/2
$a and $cfg[$a]{"_src"} eq $cfg[$a - 1]{"_src"}
$a $cfg[$a]{"_src"} eq $cfg[$a - 1]{"_src"}
Truth table66%2/3
A and B
A= $aB= $cfg[$a]{"_src"} eq $cfg[$a - 1]{"_src"}
ABresult
0X0
100
111
90 0 ▶ if ( $a == $#cfg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a == $#cfg) 0 0 0
91 # If this is the last entry, splice/redo will create
92 # a new, empty entry triggering issue #550.
93 0 pop(@cfg);
94 0 last;
95 }
96 0 splice( @cfg, $a, 1 );
97 0 redo;
98 }
99 259 ▶ warn("Config[$a]: ", $cfg[$a]->{_src}, "\n" )
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 259 259
100 if $verbose;
101 }
102  
103 124 $cfg = shift(@cfg);
104 124 ▶ warn("Process: $cfg->{_src}\n") if $verbose > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose > 1 0 124 124
105  
106 # Presets.
107 124 ▶ if ( $options->{reference} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($main::options->{'reference'}) { } 0 124 124
108 0 $cfg->{user}->{name} = "chordpro";
109 0 $cfg->{user}->{fullname} = ::runtimeinfo("short");
110 }
111 else {
112 $cfg->{user}->{name} =
113 lc( $ENV{USER} || $ENV{LOGNAME}
114 124 ▶ || getlogin() || getpwuid($<) || "chordpro" );
Condition36%4/11
$ENV{'USER'} || $ENV{'LOGNAME'} || getlogin || getpwuid $< || 'chordpro'
l!l
1240
$ENV{"USER"} or $ENV{"LOGNAME"} or getlogin or getpwuid $<
l!l&&r!l&&!r
01240
$ENV{"USER"} or $ENV{"LOGNAME"} or getlogin
l!l&&r!l&&!r
00124
$ENV{"USER"} or $ENV{"LOGNAME"}
l!l&&r!l&&!r
00124
MC/DC0%0/4
$ENV{'USER'} || $ENV{'LOGNAME'} || getlogin || getpwuid $< || 'chordpro'
$ENV{"USER"} $ENV{"LOGNAME"} getlogin getpwuid $<
Truth table20%1/5
A or B or C or D
A= $ENV{"USER"}B= $ENV{"LOGNAME"}C= getloginD= getpwuid $<
ABCDresult
1XXX1
01XX1
001X1
00011
00000
115 124 ▶ $cfg->{user}->{fullname} = eval { (getpwuid($<))[6] } || "";
Condition50%1/2
eval { do { (getpwuid $<)[6] } } || ''
l!l
0124
MC/DC0%0/1
eval { do { (getpwuid $<)[6] } } || ''
eval { do { (getpwuid $<)[6] } }
Truth table50%1/2
A
A= eval { do { (getpwuid $<)[6] } }
Aresult
11
00
116 }
117  
118 # Add some extra entries to prevent warnings.
119 124 for ( qw(title subtitle footer) ) {
120 372 ▶ next if exists($cfg->{pdf}->{formats}->{first}->{$_});
Branch: 1 branch
BranchTrueFalseTotal
if exists $cfg->{"pdf"}{"formats"}{"first"}{$_} 124 248 372
121 248 $cfg->{pdf}->{formats}->{first}->{$_} = "";
122 }
123  
124 my $backend_configurator =
125 124 UNIVERSAL::can( $options->{backend}, "configurator" );
126  
127 # Apply config files
128 124 foreach my $new ( @cfg ) {
129 135 my $file = $new->{_src}; # for diagnostics
130 # Handle obsolete keys.
131 135 my $ps = $new->{pdf};
132 135 ▶ if ( exists $ps->{diagramscolumn} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ps->{"diagramscolumn"}) 0 135 135
133 0 ▶ $ps->{diagrams}->{show} //= "right";
Condition0%0/2
$ps->{"diagrams"}{"show"} //= "right"
l!l
00
MC/DC0%0/1
$ps->{"diagrams"}{"show"} //= "right"
$ps->{"diagrams"}{"show"}
Truth table0%0/2
A
A= $ps->{"diagrams"}{"show"}
Aresult
11
00
134 0 delete $ps->{diagramscolumn};
135 0 warn("$file: pdf.diagramscolumn is obsolete, use pdf.diagrams.show instead\n");
136 }
137 135 ▶ if ( exists $ps->{formats}->{default}->{'toc-title'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ps->{"formats"}{"default"}{"toc-title"}) 0 135 135
138 0 ▶ $new->{toc}->{title} //= $ps->{formats}->{default}->{'toc-title'};
Condition0%0/3
$new->{"toc"}{"title"} //= $ps->{"formats"}{"default"}{"toc-title"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$new->{"toc"}{"title"} //= $ps->{"formats"}{"default"}{"toc-title"}
$new->{"toc"}{"title"} $ps->{"formats"}{"default"}{"toc-title"}
Truth table0%0/3
A //= B
A= $new->{"toc"}{"title"}B= $ps->{"formats"}{"default"}{"toc-title"}
ABresult
1X1
011
000
139 0 delete $ps->{formats}->{default}->{'toc-title'};
140 0 warn("$file: pdf.formats.default.toc-title is obsolete, use toc.title instead\n");
141 }
142  
143 # Page controls.
144 # Check for old and newer keywords conflicts.
145 135 ▶ if ( $ps->{songbook}
Branch: 1 branch
BranchTrueFalseTotal
if ($ps->{'songbook'} and is_hashref($ps->{'songbook'}) and %{$ps->{'songbook'};}) { } 0 135 135
Condition33%2/6
$ps->{"songbook"} and is_hashref($ps->{"songbook"}) and %{$ps->{"songbook"};}
!ll&&!rl&&r
13500
$ps->{"songbook"} and is_hashref($ps->{"songbook"})
!ll&&!rl&&r
13500
MC/DC0%0/3
$ps->{"songbook"} and is_hashref($ps->{"songbook"}) and %{$ps->{"songbook"};}
$ps->{"songbook"} is_hashref($ps->{"songbook"}) %{$ps->{"songbook"};}
Truth table25%1/4
A and B and C
A= $ps->{"songbook"}B= is_hashref($ps->{"songbook"})C= %{$ps->{"songbook"};}
ABCresult
0XX0
10X0
1100
1111
146 && is_hashref($ps->{songbook})
147 0 && %{$ps->{songbook}} ) {
148 # Using new style page controls.
149 0 my @depr;
150 0 for ( qw( front-matter back-matter sort-pages ) ) {
151 0 ▶ push( @depr, $_) if $ps->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $ps->{$_} 0 0 0
152 }
153 push( @depr, "even-odd-songs" )
154 0 ▶ if defined($ps->{'even-odd-songs'}) && $ps->{'even-odd-songs'} <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ps->{"even-odd-songs"} and $ps->{"even-odd-songs"} <= 0 0 0 0
Condition0%0/3
defined $ps->{"even-odd-songs"} and $ps->{"even-odd-songs"} <= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ps->{"even-odd-songs"} and $ps->{"even-odd-songs"} <= 0
defined $ps->{"even-odd-songs"} $ps->{"even-odd-songs"} <= 0
Truth table0%0/3
A and B
A= defined $ps->{"even-odd-songs"}B= $ps->{"even-odd-songs"} <= 0
ABresult
0X0
100
111
155 push( @depr, "pagealign-songs" )
156 0 ▶ if defined($ps->{'pagealign-songs'}) && $ps->{'pagealign-songs'} != 1;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ps->{"pagealign-songs"} and $ps->{"pagealign-songs"} != 1 0 0 0
Condition0%0/3
defined $ps->{"pagealign-songs"} and $ps->{"pagealign-songs"} != 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ps->{"pagealign-songs"} and $ps->{"pagealign-songs"} != 1
defined $ps->{"pagealign-songs"} $ps->{"pagealign-songs"} != 1
Truth table0%0/3
A and B
A= defined $ps->{"pagealign-songs"}B= $ps->{"pagealign-songs"} != 1
ABresult
0X0
100
111
157 0 ▶ if ( @depr ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@depr) 0 0 0
158 warn("Config \"$file\" uses \"pdf.songbook\", ignoring ",
159 0 enumerated( map { qq{"pdf.$_"} } @depr ), "\n" );
160 0 delete $ps->{$_} for @depr;
161 }
162 }
163 else {
164 135 migrate_songbook_pagectrl( $new, $ps );
165 }
166  
167 # use DDP; p $ps->{songbook}, as => "after \"$file\"";
168  
169 # Process.
170 135 local $::config = dclone($cfg);
171 135 process_config( $new, $file );
172 # Merge final.
173 135 $cfg = hmerge( $cfg, $new );
174 # die("PANIC! Config merge error")
175 # unless UNIVERSAL::isa( $cfg->{settings}->{strict}, 'JSON::Boolean' );
176 # use DDP; p $cfg->{pdf}->{songbook}, as => "accum after \"$file\"";
177 }
178  
179 # Handle defines from the command line.
180 # $cfg = hmerge( $cfg, prp2cfg( $options->{define}, $cfg ) );
181 # use DDP; p $options->{define}, as => "clo";
182 124 prpadd2cfg( $cfg, %{$options->{define}} );
183 124 migrate_songbook_pagectrl($cfg);
184 # use DDP; p $cfg->{pdf}->{songbook}, as => "accum after clo";
185  
186 # Sanitize added extra entries.
187 124 for my $format ( qw(title subtitle footer) ) {
188 delete($cfg->{pdf}->{formats}->{first}->{$format})
189 372 ▶ if ($cfg->{pdf}->{formats}->{first}->{$format} // 1) eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{"pdf"}{"formats"}{"first"}{$format} // 1) eq "" 248 124 372
Condition50%1/2
$cfg->{"pdf"}{"formats"}{"first"}{$format} // 1
l!l
3720
MC/DC0%0/1
$cfg->{"pdf"}{"formats"}{"first"}{$format} // 1
$cfg->{"pdf"}{"formats"}{"first"}{$format}
Truth table50%1/2
A
A= $cfg->{"pdf"}{"formats"}{"first"}{$format}
Aresult
11
00
190 372 for my $c ( qw(title first default filler) ) {
191 1488 for my $class ( $c, $c."-even" ) {
192 2976 my $t = $cfg->{pdf}->{formats}->{$class}->{$format};
193 # Allowed: null, false, [3], [[3], ...].
194 2976 ▶ next unless defined $t;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $t 2108 868 2976
195 868 ▶ $cfg->{pdf}->{formats}->{$class}->{$format} = ["","",""], next
Branch: 1 branch
BranchTrueFalseTotal
unless $t 0 868 868
196 unless $t;
197 868 ▶ die("Config error in pdf.formats.$class.$format: not an array\n")
Branch: 1 branch
BranchTrueFalseTotal
unless is_arrayref($t) 0 868 868
198 unless is_arrayref($t);
199 868 ▶ $t = [ $t ] unless is_arrayref($t->[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless is_arrayref($t->[0]) 868 0 868
200 868 for ( @$t) {
201 868 ▶ die("Config error in pdf.formats.$class.$format: ",
Branch: 1 branch
BranchTrueFalseTotal
if @$_ and @$_ != 3 0 868 868
Condition33%1/3
@$_ and @$_ != 3
!ll&&!rl&&r
08680
MC/DC0%0/2
@$_ and @$_ != 3
@$_ @$_ != 3
Truth table33%1/3
A and B
A= @$_B= @$_ != 3
ABresult
0X0
100
111
202 scalar(@$_), " fields instead of 3\n")
203 if @$_ && @$_ != 3;
204 }
205 868 $cfg->{pdf}->{formats}->{$class}->{$format} = $t;
206 }
207 }
208 }
209  
210 124 ▶ if ( $cfg->{pdf}->{fontdir} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{'pdf'}{'fontdir'}) { } 124 0 124
211 124 my @a;
212 124 ▶ if ( ref($cfg->{pdf}->{fontdir}) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $cfg->{'pdf'}{'fontdir'} eq 'ARRAY') { } 124 0 124
213 124 @a = @{ $cfg->{pdf}->{fontdir} };
214 }
215 else {
216 0 @a = ( $cfg->{pdf}->{fontdir} );
217 }
218 124 $cfg->{pdf}->{fontdir} = [];
219 124 ▶ my $split = $^O =~ /^MS*/ ? qr(;) : qr(:);
Branch: 1 branch
BranchTrueFalseTotal
$^O =~ /^MS*/u ? : 0 124 124
220 124 foreach ( @a ) {
221 0 push( @{ $cfg->{pdf}->{fontdir} },
222 0 map { expand_tilde($_) } split( $split, $_ ) );
223 }
224 }
225 else {
226 0 $cfg->{pdf}->{fontdir} = [];
227 }
228  
229 124 my @allfonts = keys(%{$cfg->{pdf}->{fonts}});
230 124 for my $ff ( @allfonts ) {
231 # Derived chords can have size or color only. Disable
232 # this test for now.
233 1488 unless ( 1 || $cfg->{pdf}->{fonts}->{$ff}->{name}
234 || $cfg->{pdf}->{fonts}->{$ff}->{description}
235 || $cfg->{pdf}->{fonts}->{$ff}->{file} ) {
236 delete( $cfg->{pdf}->{fonts}->{$ff} );
237 next;
238 }
239 1488 ▶ $cfg->{pdf}->{fonts}->{$ff}->{color} //= "foreground";
Condition50%1/2
$cfg->{"pdf"}{"fonts"}{$ff}{"color"} //= "foreground"
l!l
01488
MC/DC0%0/1
$cfg->{"pdf"}{"fonts"}{$ff}{"color"} //= "foreground"
$cfg->{"pdf"}{"fonts"}{$ff}{"color"}
Truth table50%1/2
A
A= $cfg->{"pdf"}{"fonts"}{$ff}{"color"}
Aresult
11
00
240 1488 ▶ $cfg->{pdf}->{fonts}->{$ff}->{background} //= "background";
Condition100%2/2
$cfg->{"pdf"}{"fonts"}{$ff}{"background"} //= "background"
l!l
1241364
MC/DC100%1/1
$cfg->{"pdf"}{"fonts"}{$ff}{"background"} //= "background"
$cfg->{"pdf"}{"fonts"}{$ff}{"background"}
Truth table100%2/2
A
A= $cfg->{"pdf"}{"fonts"}{$ff}{"background"}
Aresult
11
00
241 1488 for ( qw(name file description size) ) {
242 delete( $cfg->{pdf}->{fonts}->{$ff}->{$_} )
243 5952 ▶ unless defined( $cfg->{pdf}->{fonts}->{$ff}->{$_} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cfg->{"pdf"}{"fonts"}{$ff}{$_} 3224 2728 5952
244 }
245 }
246  
247 124 ▶ if ( defined $options->{diagrams} ) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $main::options->{'diagrams'}) { } 0 124 124
elsif (defined $main::options->{'user-chord-grids'}) { } 0 124 124
elsif (defined $main::options->{'chord-grids'}) { } 0 124 124
248 warn( "Invalid value for diagrams: ",
249 $options->{diagrams}, "\n" )
250 0 ▶ unless $options->{diagrams} =~ /^(all|none|user)$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $main::options->{"diagrams"} =~ /^(all|none|user)$/iu 0 0 0
251 0 $cfg->{diagrams}->{show} = lc $options->{'diagrams'};
252 }
253 elsif ( defined $options->{'user-chord-grids'} ) {
254 $cfg->{diagrams}->{show} =
255 0 ▶ $options->{'user-chord-grids'} ? "user" : 0;
Branch: 1 branch
BranchTrueFalseTotal
$main::options->{'user-chord-grids'} ? : 0 0 0
256 }
257 elsif ( defined $options->{'chord-grids'} ) {
258 $cfg->{diagrams}->{show} =
259 0 ▶ $options->{'chord-grids'} ? "all" : 0;
Branch: 1 branch
BranchTrueFalseTotal
$main::options->{'chord-grids'} ? : 0 0 0
260 }
261  
262 124 for ( qw( transpose transcode decapo lyrics-only strict ) ) {
263 620 ▶ next unless defined $options->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $main::options->{$_} 602 18 620
264 18 $cfg->{settings}->{$_} = $options->{$_};
265 }
266  
267 124 for ( "cover", "front-matter", "back-matter" ) {
268 372 ▶ next unless defined $options->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $main::options->{$_} 363 9 372
269 9 $cfg->{pdf}->{songbook}->{$_} = $options->{$_};
270 }
271  
272 124 ▶ if ( defined $options->{'chord-grids-sorted'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $main::options->{"chord-grids-sorted"}) 0 124 124
273 0 $cfg->{diagrams}->{sorted} = $options->{'chord-grids-sorted'};
274 }
275  
276 # For convenience...
277 124 bless( $cfg, __PACKAGE__ );
278  
279 124 ▶ return $cfg if $options->{'cfg-print'};
Branch: 1 branch
BranchTrueFalseTotal
if $main::options->{"cfg-print"} 0 124 124
280  
281 # Backend specific configs.
282 124 ▶ $backend_configurator->($cfg) if $backend_configurator;
Branch: 1 branch
BranchTrueFalseTotal
if $backend_configurator 13 111 124
283  
284 # Locking the hash is mainly for development.
285 124 $cfg->lock;
286  
287 124 ▶ if ( $options->{verbose} > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($main::options->{"verbose"} > 1) 0 124 124
288 0 ▶ my $cp = ChordPro::Chords::get_parser() // "";
Condition0%0/2
ChordPro::Chords::get_parser() // ""
l!l
00
MC/DC0%0/1
ChordPro::Chords::get_parser() // ""
ChordPro::Chords::get_parser()
Truth table0%0/2
A
A= ChordPro::Chords::get_parser()
Aresult
11
00
289 0 warn("Parsers:\n");
290 0 ▶ while ( my ($k, $v) = each %{ChordPro::Chords::Parser->parsers} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{"ChordPro::Chords::Parser"->parsers;}) 0 0 0
291 0 ▶ warn( " $k",
Branch: 1 branch
BranchTrueFalseTotal
$v eq $cp ? : 0 0 0
292 $v eq $cp ? " (active)": "",
293 "\n");
294 }
295 }
296  
297 124 return $cfg;
298 }
299  
300 # Get the decoded contents of a single config file.
301 137 ▶sub get_config ( $file ) {
Subroutine get_config: called CC=8 SCAR=28.7
Pod undocumented
302 137 ▶ Carp::confess("FATAL: Undefined config") unless defined $file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file 0 137 137
303 137 my $verbose = $options->{verbose};
304 137 ▶ warn("Reading: $file\n") if $verbose > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose > 1 0 137 137
305 137 $file = expand_tilde($file);
306  
307 137 ▶ if ( $file =~ /\.json$/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($file =~ /\.json$/iu) { } 137 0 137
elsif ($file =~ /\.prp$/iu) { } 0 0 0
308 137 ▶ if ( my $lines = fs_load( $file, { split => 1, fail => "soft" } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $lines = fs_load($file, {'split', 1, 'fail', 'soft'})) { } 137 0 137
309 137 my $new = json_load( join( "\n", @$lines, '' ), $file );
310 137 ▶ warn("JSON: $file ($ChordPro::Utils::json_last)\n") if $verbose > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose > 1 0 137 137
311 137 precheck( $new, $file );
312 137 return __PACKAGE__->new($new);
313 }
314 else {
315 0 die("Cannot open config $file [$!]\n");
316 }
317 }
318 elsif ( $file =~ /\.prp$/i ) {
319 0 ▶ if ( fs_test( efr => $file ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (fs_test('efr', $file)) { } 0 0 0
320 0 require ChordPro::Config::Properties;
321 0 my $cfg = Data::Properties->new;
322 0 $cfg->parse_file($file);
323 0 return __PACKAGE__->new($cfg->data);
324 }
325 else {
326 0 die("Cannot open config $file [$!]\n");
327 }
328 }
329 else {
330 0 Carp::confess("Unrecognized config type: $file\n");
331 }
332 }
333  
334 # Check config for includes, and prepend them.
335 259 ▶sub prep_configs ( $cfg, $src ) {
Subroutine prep_configs: called CC=5 SCAR=17.8
Pod undocumented
336 259 $cfg->{_src} = $src;
337  
338 259 my @res;
339  
340 # If there are includes, add them first.
341 259 my ( $vol, $dir, undef ) = fn_splitpath($cfg->{_src});
342 259 foreach my $c ( @{ $cfg->{include} } ) {
343 # Check for resource names.
344 124 ▶ if ( $c !~ m;[/.]; ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $c =~ m[[/.]]u) { } 124 0 124
elsif ($dir ne '' and not fn_is_absolute($c)) { } 0 0 0
345 124 $c = CP->findcfg($c);
346 }
347 ▶ elsif ( $dir ne ""
Condition0%0/3
$dir ne "" and not fn_is_absolute($c)
!ll&&!rl&&r
000
MC/DC0%0/2
$dir ne "" and not fn_is_absolute($c)
$dir ne "" not fn_is_absolute($c)
Truth table0%0/3
A and not(B)
A= $dir ne ""B= not fn_is_absolute($c)
ABresult
0X0
100
111
348 && !fn_is_absolute($c) ) {
349 # Prepend dir of the caller, if needed.
350 0 $c = fn_catpath( $vol, $dir, $c );
351 }
352 124 my $cfg = get_config($c);
353 # Recurse.
354 124 push( @res, $cfg->prep_configs($c) );
355 }
356  
357 # Push this and return.
358 259 $cfg->split_fc_aliases;
359 259 $cfg->expand_font_shortcuts;
360 259 push( @res, $cfg );
361 259 return @res;
362 }
363  
364 226 ▶sub process_config ( $cfg, $file ) {
Subroutine process_config: called CC=10 SCAR=24.0
Pod undocumented
365 226 my $verbose = $options->{verbose};
366  
367 226 ▶ warn("Process: $file\n") if $verbose > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose > 1 0 226 226
368  
369 226 ▶ if ( $cfg->{tuning} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{"tuning"}) 215 11 226
370 215 my $res =
371 ChordPro::Chords::set_tuning( $cfg );
372 215 ▶ warn( "Invalid tuning in config: ", $res, "\n" ) if $res;
Branch: 1 branch
BranchTrueFalseTotal
if $res 0 215 215
373 215 $cfg->{_tuning} = $cfg->{tuning};
374 215 $cfg->{tuning} = [];
375 }
376  
377 226 ChordPro::Chords::reset_parser;
378 226 ChordPro::Chords::Parser->reset_parsers;
379 226 local $::config = dclone(hmerge( $::config, $cfg ));
380 226 ▶ if ( $cfg->{chords} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{"chords"}) 215 11 226
381 215 ChordPro::Chords::push_parser($cfg->{notes}->{system});
382 215 my $c = $cfg->{chords};
383 215 ▶ if ( @$c && $c->[0] eq "append" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$c and $c->[0] eq "append") 0 215 215
Condition66%2/3
@$c and $c->[0] eq "append"
!ll&&!rl&&r
911240
MC/DC0%0/2
@$c and $c->[0] eq "append"
@$c $c->[0] eq "append"
Truth table66%2/3
A and B
A= @$cB= $c->[0] eq "append"
ABresult
0X0
100
111
384 0 shift(@$c);
385 }
386 215 foreach ( @$c ) {
387 143220 my $res =
388 ChordPro::Chords::add_config_chord($_);
389 warn( "Invalid chord in config: ",
390 143220 ▶ $_->{name}, ": ", $res, "\n" ) if $res;
Branch: 1 branch
BranchTrueFalseTotal
if $res 0 143220 143220
391 }
392 215 ▶ if ( $verbose > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose > 1) 0 215 215
393 0 warn( "Processed ", scalar(@$c), " chord entries\n");
394 0 warn( "Totals: ",
395 ChordPro::Chords::chord_stats(), "\n" );
396 }
397 215 $cfg->{_chords} = delete $cfg->{chords};
398 215 ChordPro::Chords::pop_parser();
399 }
400 226 $cfg->split_fc_aliases;
401 226 $cfg->expand_font_shortcuts;
402 }
403  
404 # Expand pdf.fonts.foo: bar to pdf.fonts.foo { description: bar }.
405  
406 487 ▶sub expand_font_shortcuts ( $cfg ) {
Subroutine expand_font_shortcuts: called CC=13 SCAR=25.8
Pod undocumented
407 487 ▶ return unless exists $cfg->{pdf}->{fonts};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $cfg->{"pdf"}{"fonts"} 270 217 487
408 217 for my $f ( keys %{$cfg->{pdf}->{fonts}} ) {
409 2590 ▶ next if ref($cfg->{pdf}->{fonts}->{$f}) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $cfg->{"pdf"}{"fonts"}{$f} eq "HASH" 5 2585 2590
410 2585 for ( $cfg->{pdf}->{fonts}->{$f} ) {
411 2585 my $v = $_;
412 2585 $v =~ s/\s*;\s*$//;
413 2585 my $i = {};
414  
415 # Break out ;xx=yy properties.
416 2585 ▶ while ( $v =~ s/\s*;\s*(\w+)\s*=\s*(.*?)\s*(;|$)/$3/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ s/\s*;\s*(\w+)\s*=\s*(.*?)\s*(;|$)/$3/u) 645 2585 3230
417 645 my ( $k, $v ) = ( $1, $2 );
418 645 ▶ if ( $k =~ /^(colou?r|background|frame|numbercolou?r|size)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /^(colou?r|background|frame|numbercolou?r|size)$/u) { } 645 0 645
419 645 $k =~ s/colour/color/;
420 645 $v =~ s/^(['"]?)(.*)\1$/$2/;
421 645 $i->{$k} = $v;
422 }
423 else {
424 0 warn("Unknown font property: $k (ignored)\n");
425 }
426 }
427  
428 # Break out size.
429 2585 ▶ if ( $v =~ /(.*?)(?:\s+(\d+(?:\.\d+)?))?\s*(?:;|$)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /(.*?)(?:\s+(\d+(?:\.\d+)?))?\s*(?:;|$)/u) 2585 0 2585
430 2585 ▶ $i->{size} //= $2 if $2;
Branch: 1 branch
BranchTrueFalseTotal
if $2 2370 215 2585
Condition33%1/3
$i->{"size"} //= $2
l!l&&r!l&&!r
023700
MC/DC0%0/2
$i->{"size"} //= $2
$i->{"size"} $2
Truth table33%1/3
A //= B
A= $i->{"size"}B= $2
ABresult
1X1
011
000
431 2585 $v = $1;
432 }
433  
434 # Check for filename.
435 2585 ▶ if ( $v =~ /^.*\.(ttf|otf)$/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($v =~ /^.*\.(ttf|otf)$/iu) { } 1 2584 2585
elsif (is_corefont($v)) { } 2151 433 2584
436 1 $i->{file} = $v;
437 }
438 # Check for corefonts.
439 elsif ( is_corefont($v) ) {
440 2151 $i->{name} = is_corefont($v);
441 }
442 else {
443 433 $i->{description} = $v;
444 $i->{description} .= " " . delete($i->{size})
445 433 ▶ if $i->{size};
Branch: 1 branch
BranchTrueFalseTotal
if $i->{"size"} 218 215 433
446 }
447 2585 $_ = $i;
448 }
449 }
450 }
451  
452 92 ▶use Storable qw(dclone);
Subroutine BEGIN: called CC=1 SCAR=0.0
453  
454 # Split fontconfig aliases into separate entries.
455  
456 576 ▶sub split_fc_aliases ( $cfg ) {
Subroutine split_fc_aliases: called CC=5 SCAR=16.1
Pod undocumented
457  
458 576 ▶ if ( $cfg->{pdf}->{fontconfig} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{"pdf"}{"fontconfig"}) 306 270 576
459 # Orig.
460 306 my $fc = $cfg->{pdf}->{fontconfig};
461 # Since we're going to delete/insert keys, we need a copy.
462 306 my %fc = %$fc;
463 306 ▶ while ( my($k,$v) = each(%fc) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %fc) 2721 306 3027
464 # Split on comma.
465 2721 my @k = split( /\s*,\s*/, $k );
466 2721 ▶ if ( @k > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@k > 1) 645 2076 2721
467 # We have aliases. Delete the original.
468 645 delete( $fc->{$k} );
469 # And insert individual entries.
470 645 $fc->{$_} = dclone($v) for @k;
471 }
472 }
473 }
474 }
475  
476 # Reverse of config_expand_font_shortcuts.
477  
478 1 ▶sub simplify_fonts( $cfg ) {
Subroutine simplify_fonts: called CC=17 SCAR=31.7
Pod undocumented
479  
480 1 ▶ return $cfg unless $cfg->{pdf}->{fonts};
Branch: 1 branch
BranchTrueFalseTotal
unless $cfg->{"pdf"}{"fonts"} 0 1 1
481  
482 1 foreach my $font ( keys %{$cfg->{pdf}->{fonts}} ) {
483 5 for ( $cfg->{pdf}->{fonts}->{$font} ) {
484 5 ▶ next unless is_hashref($_);
Branch: 1 branch
BranchTrueFalseTotal
unless is_hashref($_) 1 4 5
485  
486 delete $_->{color}
487 4 ▶ if $_->{color} && $_->{color} eq "foreground";
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"color"} and $_->{"color"} eq "foreground" 0 4 4
Condition33%1/3
$_->{"color"} and $_->{"color"} eq "foreground"
!ll&&!rl&&r
400
MC/DC0%0/2
$_->{"color"} and $_->{"color"} eq "foreground"
$_->{"color"} $_->{"color"} eq "foreground"
Truth table33%1/3
A and B
A= $_->{"color"}B= $_->{"color"} eq "foreground"
ABresult
0X0
100
111
488 delete $_->{background}
489 4 ▶ if $_->{background} && $_->{background} eq "background";
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"background"} and $_->{"background"} eq "background" 0 4 4
Condition33%1/3
$_->{"background"} and $_->{"background"} eq "background"
!ll&&!rl&&r
400
MC/DC0%0/2
$_->{"background"} and $_->{"background"} eq "background"
$_->{"background"} $_->{"background"} eq "background"
Truth table33%1/3
A and B
A= $_->{"background"}B= $_->{"background"} eq "background"
ABresult
0X0
100
111
490  
491 4 ▶ if ( exists( $_->{file} ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $_->{'file'}) { } 1 3 4
elsif (exists $_->{'description'}) { } 2 1 3
elsif (exists $_->{'name'} and exists $_->{'size'} and keys %$_ == 2) { } 1 0 1
492 1 delete $_->{description};
493 1 delete $_->{name};
494 }
495 elsif ( exists( $_->{description} ) ) {
496 2 delete $_->{name};
497 2 ▶ if ( $_->{size} && $_->{description} !~ /\s+[\d.]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"size"} and not $_->{"description"} =~ /\s+[\d.]+$/u) 1 1 2
Condition66%2/3
$_->{"size"} and not $_->{"description"} =~ /\s+[\d.]+$/u
!ll&&!rl&&r
011
MC/DC50%1/2
$_->{"size"} and not $_->{"description"} =~ /\s+[\d.]+$/u
$_->{"size"} not $_->{"description"} =~ /\s+[\d.]+$/u
Truth table66%2/3
A and not(B)
A= $_->{"size"}B= not $_->{"description"} =~ /\s+[\d.]+$/u
ABresult
0X0
100
111
498 1 $_->{description} .= " " . $_->{size};
499 }
500 2 delete $_->{size};
501 2 ▶ $_ = $_->{description} if keys %$_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if keys %$_ == 1 2 0 2
502 }
503 ▶ elsif ( exists( $_->{name} )
Condition33%2/6
exists $_->{"name"} and exists $_->{"size"} and keys %$_ == 2
!ll&&!rl&&r
001
exists $_->{"name"} and exists $_->{"size"}
!ll&&!rl&&r
001
MC/DC0%0/3
exists $_->{"name"} and exists $_->{"size"} and keys %$_ == 2
exists $_->{"name"} exists $_->{"size"} keys %$_ == 2
Truth table25%1/4
A and B and C
A= exists $_->{"name"}B= exists $_->{"size"}C= keys %$_ == 2
ABCresult
0XX0
10X0
1100
1111
504 && exists( $_->{size})
505 && keys %$_ == 2
506 ) {
507 1 $_ = $_->{name} .= " " . $_->{size};
508 }
509 }
510 }
511 }
512  
513 259 ▶sub migrate_songbook_pagectrl( $self, $ps = undef ) {
Subroutine migrate_songbook_pagectrl: called CC=23 SCAR=46.6
Pod undocumented
514  
515 # Migrate old to new.
516 259 ▶ $ps //= $self->{pdf};
Condition66%2/3
$ps //= $self->{"pdf"}
l!l&&r!l&&!r
1351240
MC/DC0%0/2
$ps //= $self->{"pdf"}
$ps $self->{"pdf"}
Truth table66%2/3
A //= B
A= $psB= $self->{"pdf"}
ABresult
1X1
011
000
517 259 ▶ my $sb = $ps->{songbook} // {};
Condition100%2/2
$ps->{"songbook"} // {}
l!l
124135
MC/DC100%1/1
$ps->{"songbook"} // {}
$ps->{"songbook"}
Truth table100%2/2
A
A= $ps->{"songbook"}
Aresult
11
00
518 259 for ( qw( front-matter back-matter ) ) {
519 518 ▶ $sb->{$_} = delete($ps->{$_}) if $ps->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $ps->{$_} 0 518 518
520 }
521 259 for ( $ps->{'even-odd-pages'} ) {
522 259 ▶ next unless defined;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 256 3 259
523 3 $sb->{'dual-pages'} = !!$_;
524 3 ▶ $sb->{'align-songs-spread'} = 1 if $_ < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $_ < 0 1 2 3
525 }
526 259 for ( $ps->{'pagealign-songs'} ) {
527 259 ▶ next unless defined;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 254 5 259
528 5 $sb->{'align-songs'} = !!$_;
529 5 $sb->{'align-songs-extend'} = $_ > 1;
530 }
531 259 for ( $ps->{'sort-pages'} ) {
532 259 ▶ next unless defined;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 259 0 259
533 0 my $a = $_;
534 0 $a =~ s/\s+//g;
535 0 my ( $sort, $desc, $spread, $compact );
536 0 $sort = $desc = "";
537 0 for ( split( /,/, lc $a ) ) {
538 0 ▶ if ( $_ eq "title" ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($_ eq 'title') { } 0 0 0
elsif ($_ eq 'subtitle') { } 0 0 0
elsif ($_ eq '2page') { } 0 0 0
elsif ($_ eq 'desc') { } 0 0 0
elsif ($_ eq 'compact') { } 0 0 0
539 0 $sort = "title";
540 }
541 elsif ( $_ eq "subtitle" ) {
542 0 ▶ $sort //= "subtitle";
Condition0%0/2
$sort //= "subtitle"
l!l
00
MC/DC0%0/1
$sort //= "subtitle"
$sort
Truth table0%0/2
A
A= $sort
Aresult
11
00
543 }
544 elsif ( $_ eq "2page" ) {
545 0 $spread++;
546 }
547 elsif ( $_ eq "desc" ) {
548 0 $desc = "-";
549 }
550 elsif ( $_ eq "compact" ) {
551 0 $compact++;
552 }
553 else {
554 0 warn("??? \"$_\"\n");
555 }
556 }
557 0 $sb->{'sort-songs'} = "${desc}${sort}";
558 0 ▶ $sb->{'compact-songs'} = 1 if $compact;
Branch: 1 branch
BranchTrueFalseTotal
if $compact 0 0 0
559 0 ▶ $sb->{'align-songs-spread'} = 1 if $spread;
Branch: 1 branch
BranchTrueFalseTotal
if $spread 0 0 0
560 }
561 259 $ps->{songbook} = $sb;
562 # Remove the obsoleted entries.
563 delete( $ps->{$_} )
564 259 for qw( even-odd-pages sort-pages pagealign-songs );
565  
566 }
567  
568 0 ▶sub config_final ( %args ) {
Subroutine config_final: not called CC=15 SCAR=54.8
Pod undocumented
569 0 ▶ my $delta = $args{delta} || 0;
Condition0%0/2
$args{'delta'} || 0
l!l
00
MC/DC0%0/1
$args{'delta'} || 0
$args{'delta'}
Truth table0%0/2
A
A= $args{'delta'}
Aresult
11
00
570 0 ▶ my $default = $args{default} || 0;
Condition0%0/2
$args{'default'} || 0
l!l
00
MC/DC0%0/1
$args{'default'} || 0
$args{'default'}
Truth table0%0/2
A
A= $args{'default'}
Aresult
11
00
571 0 $options->{'cfg-print'} = 1;
572  
573 0 my $defcfg; # pristine config
574 my $cfg; # actual config
575 0 ▶ if ( $default || $delta ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($default or $delta) 0 0 0
Condition0%0/3
$default or $delta
l!l&&r!l&&!r
000
MC/DC0%0/2
$default or $delta
$default $delta
Truth table0%0/3
A or B
A= $defaultB= $delta
ABresult
1X1
011
000
576 0 local $options->{nosysconfig} = 1;
577 0 local $options->{nouserconfig} = 1;
578 0 local $options->{noconfig} = 1;
579 0 $defcfg = pristine_config();
580 0 split_fc_aliases($defcfg);
581 0 expand_font_shortcuts($defcfg);
582 0 ▶ if ( $delta ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delta) 0 0 0
583 0 delete $defcfg->{chords};
584 0 delete $defcfg->{include};
585 }
586 0 bless $defcfg => __PACKAGE__;
587 0 ▶ $cfg = $defcfg if $default;
Branch: 1 branch
BranchTrueFalseTotal
if $default 0 0 0
588 }
589  
590 0 ▶ $cfg //= configurator($options);
Condition0%0/3
$cfg //= configurator($main::options)
l!l&&r!l&&!r
000
MC/DC0%0/2
$cfg //= configurator($main::options)
$cfg configurator($main::options)
Truth table0%0/3
A //= B
A= $cfgB= configurator($main::options)
ABresult
1X1
011
000
591  
592 # Remove unwanted data.
593 0 $cfg->unlock;
594 0 $cfg->{tuning} = delete $cfg->{_tuning};
595 0 ▶ if ( $delta ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delta) 0 0 0
596 0 for ( qw( tuning ) ) {
597 0 ▶ delete($cfg->{$_}) unless defined($cfg->{$_});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cfg->{$_} 0 0 0
598 }
599 0 for my $f ( keys( %{$cfg->{pdf}{fonts}} ) ) {
600 0 for ( qw( background color ) ) {
601 0 ▶ next if defined($defcfg->{pdf}{fonts}{$f}{$_});
Branch: 1 branch
BranchTrueFalseTotal
if defined $defcfg->{"pdf"}{"fonts"}{$f}{$_} 0 0 0
602 0 delete($cfg->{pdf}{fonts}{$f}{$_});
603 0 delete($defcfg->{pdf}{fonts}{$f}{$_});
604 }
605 }
606 }
607 0 delete $cfg->{_chords};
608 0 delete $cfg->{chords};
609 0 delete $cfg->{_src};
610  
611 0 my $parser = JSON::Relaxed::Parser->new( key_order => 1 );
612  
613 # Load schema.
614 0 my $schema = do {
615 0 my $schema = CP->findres( "config.schema", class => "config" );
616 0 my $data = fs_load( $schema, { split => 0 } );
617 0 $parser->decode($data);
618 };
619  
620 # Delta cannot handle reference config yet.
621 0 ▶ if ( $delta ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delta) 0 0 0
622 0 $defcfg->unlock;
623 0 $cfg->reduce( $defcfg );
624 0 return $parser->encode( data => {%$cfg},
625 pretty => 1, schema => $schema );
626 }
627  
628 0 my $config = do {
629 0 my $config = CP->findres( "chordpro.json", class => "config" );
630 0 my $data = fs_load( $config, { split => 0 } );
631 0 $parser->decode($data);
632 };
633  
634 # $cfg = hmerge( $config, $cfg );
635 0 $cfg->simplify_fonts;
636 0 return $parser->encode( data => {%{$cfg}},
637 pretty => 1, schema => $schema );
638 }
639  
640 0 ▶sub convert_config ( $from, $to ) {
Subroutine convert_config: not called CC=7 SCAR=40.3
Pod undocumented
641 # This is a completely independent function.
642  
643 # Establish a key order retaining parser.
644 0 my $parser = JSON::Relaxed::Parser->new( key_order => 1 );
645  
646 # First find and process the schema.
647 0 my $schema = CP->findres( "config.schema", class => "config" );
648 0 my $o = { split => 0, fail => 'soft' };
649 0 my $data = fs_load( $schema, $o );
650 0 ▶ die("$schema: ", $o->{error}, "\n") if $o->{error};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"error"} 0 0 0
651 0 $schema = $parser->decode($data);
652  
653 # Then load the config to be converted.
654 0 my $new;
655 0 $o = { split => 1, fail => 'soft' };
656 0 $data = fs_load( $from, $o );
657 0 ▶ die("Cannot open config $from [", $o->{error}, "]\n") if $o->{error};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"error"} 0 0 0
658 0 $data = join( "\n", @$data );
659  
660 0 ▶ if ( $data =~ /^\s*#/m ) { # #-comments -> prp
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ /^\s*#/mu) { } 0 0 0
661 0 require ChordPro::Config::Properties;
662 0 my $cfg = Data::Properties->new;
663 0 $cfg->parse_file($from);
664 0 $new = $cfg->data;
665 }
666 else { # assume JSON, RJSON, RRJSON
667 0 $new = $parser->decode($data);
668 }
669  
670 # And re-encode it using the schema.
671 0 my $res = $parser->encode( data => $new, pretty => 1,
672 nounicodeescapes => 1, schema => $schema );
673 # use DDP; p $res;
674 # Add trailer.
675 0 $res .= "\n// End of Config.\n";
676  
677 # Write if out.
678 0 ▶ if ( $to && $to ne "-" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to and $to ne '-') { } 0 0 0
Condition0%0/3
$to and $to ne "-"
!ll&&!rl&&r
000
MC/DC0%0/2
$to and $to ne "-"
$to $to ne "-"
Truth table0%0/3
A and B
A= $toB= $to ne "-"
ABresult
0X0
100
111
679 0 ▶ open( my $fd, '>', $to )
Branch: 1 branch
BranchTrueFalseTotal
open my $fd, ">", $to or die("${to}: $!\n") 0 0 0
680 or die("$to: $!\n");
681 0 print $fd $res;
682 0 $fd->close;
683 }
684 else {
685 0 print $res;
686 }
687  
688 0 1;
689 }
690  
691 # Config in properties format.
692  
693 0 ▶sub cfg2props ( $o, $path = "" ) {
Subroutine cfg2props: not called CC=11 SCAR=48.8
Pod undocumented
694 0 ▶ $path //= "";
Condition0%0/2
$path //= ""
l!l
00
MC/DC0%0/1
$path //= ""
$path
Truth table0%0/2
A
A= $path
Aresult
11
00
695 0 my $ret = "";
696 0 ▶ if ( !defined $o ) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $o) { } 0 0 0
elsif (is_hashref($o)) { } 0 0 0
elsif (is_arrayref($o)) { } 0 0 0
elsif ($o =~ /^\d+$/u) { } 0 0 0
697 0 $ret .= "$path: undef\n";
698 }
699 elsif ( is_hashref($o) ) {
700 0 ▶ $path .= "." unless $path eq "";
Branch: 1 branch
BranchTrueFalseTotal
unless $path eq "" 0 0 0
701 0 for ( sort keys %$o ) {
702 0 $ret .= cfg2props( $o->{$_}, $path . $_ );
703 }
704 }
705 elsif ( is_arrayref($o) ) {
706 0 ▶ $path .= "." unless $path eq "";
Branch: 1 branch
BranchTrueFalseTotal
unless $path eq "" 0 0 0
707 0 ▶ for ( my $i = 0; $i < @$o; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$o) 0 0 0
708 0 $ret .= cfg2props( $o->[$i], $path . "$i" );
709 }
710 }
711 elsif ( $o =~ /^\d+$/ ) {
712 0 $ret .= "$path: $o\n";
713 }
714 else {
715 0 $o =~ s/\\/\\\\/g;
716 0 $o =~ s/"/\\"/g;
717 0 $o =~ s/\n/\\n/;
718 0 $o =~ s/\t/\\t/;
719 0 $o =~ s/([^\x00-\xff])/sprintf("\\x{%x}", ord($1))/ge;
720 0 $ret .= "$path: \"$o\"\n";
721 }
722  
723 0 return $ret;
724 }
725  
726 # Locking/unlocking. Locking the hash is mainly for development, to
727 # trap accidental modifications and typos.
728  
729 398 ▶sub lock ( $self ) {
Subroutine lock: called CC=1 SCAR=0.0
Pod undocumented
730 398 Hash::Util::lock_hashref_recurse($self);
731 }
732  
733 354 ▶sub unlock ( $self ) {
Subroutine unlock: called CC=1 SCAR=0.0
Pod undocumented
734 354 Hash::Util::unlock_hashref_recurse($self);
735 }
736  
737 5 ▶sub is_locked ( $self ) {
Subroutine is_locked: called CC=1 SCAR=0.0
Pod undocumented
738 5 Hash::Util::hashref_locked($self);
739 }
740  
741 # Augment / Reduce.
742  
743 4 ▶sub augment ( $self, $hash ) {
Subroutine augment: called CC=3 SCAR=11.0
Pod undocumented
744  
745 4 my $locked = $self->is_locked;
746 4 ▶ $self->unlock if $locked;
Branch: 1 branch
BranchTrueFalseTotal
if $locked 3 1 4
747  
748 4 $self->_augment( $hash, "" );
749  
750 4 ▶ $self->lock if $locked;
Branch: 1 branch
BranchTrueFalseTotal
if $locked 3 1 4
751  
752 4 $self;
753 }
754  
755  
756 15 ▶sub _augment ( $self, $hash, $path ) {
Subroutine _augment: called CC=19 SCAR=40.3
757  
758 15 for my $key ( keys(%$hash) ) {
759  
760 warn("Config augment error: unknown item $path$key\n")
761 17 ▶ unless exists $self->{$key}
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$key} or $path =~ /^pdf\.(?:info|fonts|fontconfig)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^markup\.shortcodes\./u or $path =~ /^delegates\./u or $key =~ /^_/u 0 17 17
Condition33%6/18
exists $self->{$key} or $path =~ /^pdf\.(?:info|fonts|fontconfig)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^markup\.shortcodes\./u or $path =~ /^delegates\./u or $key =~ /^_/u
l!l&&r!l&&!r
1700
exists $self->{$key} or $path =~ /^pdf\.(?:info|fonts|fontconfig)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^markup\.shortcodes\./u or $path =~ /^delegates\./u
l!l&&r!l&&!r
1700
exists $self->{$key} or $path =~ /^pdf\.(?:info|fonts|fontconfig)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^markup\.shortcodes\./u
l!l&&r!l&&!r
1700
exists $self->{$key} or $path =~ /^pdf\.(?:info|fonts|fontconfig)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^(meta|gridstrum\.symbols)\./u
l!l&&r!l&&!r
1700
exists $self->{$key} or $path =~ /^pdf\.(?:info|fonts|fontconfig)\./u or $path =~ /^pdf\.formats\.\w+-even\./u
l!l&&r!l&&!r
1700
exists $self->{$key} or $path =~ /^pdf\.(?:info|fonts|fontconfig)\./u
l!l&&r!l&&!r
1700
MC/DC0%0/7
exists $self->{$key} or $path =~ /^pdf\.(?:info|fonts|fontconfig)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^markup\.shortcodes\./u or $path =~ /^delegates\./u or $key =~ /^_/u
exists $self->{$key} $path =~ /^pdf\.(?:info|fonts|fontconfig)\./u $path =~ /^pdf\.formats\.\w+-even\./u $path =~ /^(meta|gridstrum\.symbols)\./u $path =~ /^markup\.shortcodes\./u $path =~ /^delegates\./u $key =~ /^_/u
Truth table12%1/8
A or B or C or D or E or F or G
A= exists $self->{$key}B= $path =~ /^pdf\.(?:info|fonts|fontconfig)\./uC= $path =~ /^pdf\.formats\.\w+-even\./uD= $path =~ /^(meta|gridstrum\.symbols)\./uE= $path =~ /^markup\.shortcodes\./uF= $path =~ /^delegates\./uG= $key =~ /^_/u
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001XX1
000001X1
00000011
00000000
762 || $path =~ /^pdf\.(?:info|fonts|fontconfig)\./
763 || $path =~ /^pdf\.formats\.\w+-even\./
764 || $path =~ /^(meta|gridstrum\.symbols)\./
765 || $path =~ /^markup\.shortcodes\./
766 || $path =~ /^delegates\./
767 || $key =~ /^_/;
768  
769 # Hash -> Hash.
770 # Hash -> Array.
771 17 ▶ if ( ref($hash->{$key}) eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $hash->{$key} eq 'HASH') { } 11 6 17
elsif (ref $hash->{$key} eq 'ARRAY' and ref $self->{$key} eq 'ARRAY') { } 2 4 6
772 11 ▶ if ( ref($self->{$key}) eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $self->{$key} eq 'HASH') { } 11 0 11
elsif (ref $self->{$key} eq 'ARRAY') { } 0 0 0
773  
774 # Hashes. Recurse.
775 11 _augment( $self->{$key}, $hash->{$key}, "$path$key." );
776 }
777 elsif ( ref($self->{$key}) eq 'ARRAY' ) {
778  
779 # Hash -> Array.
780 # Update single array element using a hash index.
781 0 foreach my $ix ( keys(%{$hash->{$key}}) ) {
782 0 ▶ die unless $ix =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $ix =~ /^\d+$/u 0 0 0
783 0 $self->{$key}->[$ix] = $hash->{$key}->{$ix};
784 }
785 }
786 else {
787 # Overwrite.
788 0 $self->{$key} = $hash->{$key};
789 }
790 }
791  
792 # Array -> Array.
793 ▶ elsif ( ref($hash->{$key}) eq 'ARRAY'
Condition66%2/3
ref $hash->{$key} eq "ARRAY" and ref $self->{$key} eq "ARRAY"
!ll&&!rl&&r
402
MC/DC50%1/2
ref $hash->{$key} eq "ARRAY" and ref $self->{$key} eq "ARRAY"
ref $hash->{$key} eq "ARRAY" ref $self->{$key} eq "ARRAY"
Truth table66%2/3
A and B
A= ref $hash->{$key} eq "ARRAY"B= ref $self->{$key} eq "ARRAY"
ABresult
0X0
100
111
794 and ref($self->{$key}) eq 'ARRAY' ) {
795  
796 # Arrays. Overwrite or append.
797 2 ▶ if ( @{$hash->{$key}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$hash->{$key};}) { } 2 0 2
798 2 my @v = @{ $hash->{$key} };
799 2 ▶ if ( $v[0] eq "append" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($v[0] eq 'append') { } 0 2 2
elsif ($v[0] eq 'prepend') { } 1 1 2
800 0 shift(@v);
801 # Append the rest.
802 0 push( @{ $self->{$key} }, @v );
803 }
804 elsif ( $v[0] eq "prepend" ) {
805 1 shift(@v);
806 # Prepend the rest.
807 1 unshift( @{ $self->{$key} }, @v );
808 }
809 else {
810 # Overwrite.
811 1 $self->{$key} = $hash->{$key};
812 }
813 }
814 else {
815 # Overwrite.
816 0 $self->{$key} = $hash->{$key};
817 }
818 }
819  
820 else {
821 # Overwrite.
822 4 $self->{$key} = $hash->{$key};
823 }
824 }
825  
826 15 $self;
827 }
828  
829 92 ▶use constant DEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
830  
831 1 ▶sub reduce ( $self, $hash ) {
Subroutine reduce: called CC=2 SCAR=7.0
Pod undocumented
832  
833 1 my $locked = $self->is_locked;
834  
835 1 warn("O: ", qd($hash,1), "\n") if DEBUG > 1;
836 1 warn("N: ", qd($self,1), "\n") if DEBUG > 1;
837 1 my $state = _reduce( $self, $hash, "" );
838  
839 1 ▶ $self->lock if $locked;
Branch: 1 branch
BranchTrueFalseTotal
if $locked 0 1 1
840  
841 1 warn("== ", qd($self,1), "\n") if DEBUG > 1;
842 1 return $self;
843 }
844  
845 68 ▶sub _ref ( $self ) {
Subroutine _ref: called CC=2 SCAR=6.9
846 68 ▶ reftype($self) // ref($self);
Condition100%2/2
builtin::reftype($self) // ref $self
l!l
608
MC/DC100%1/1
builtin::reftype($self) // ref $self
builtin::reftype($self)
Truth table100%2/2
A
A= builtin::reftype($self)
Aresult
11
00
847 }
848  
849 6 ▶sub _reduce ( $self, $orig, $path ) {
Subroutine _reduce: called CC=49 SCAR=53.9
850  
851 6 my $state;
852  
853 6 ▶ if ( _ref($self) eq 'HASH' && _ref($orig) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_ref($self) eq "HASH" and _ref($orig) eq "HASH") 3 3 6
Condition66%2/3
_ref($self) eq "HASH" and _ref($orig) eq "HASH"
!ll&&!rl&&r
303
MC/DC50%1/2
_ref($self) eq "HASH" and _ref($orig) eq "HASH"
_ref($self) eq "HASH" _ref($orig) eq "HASH"
Truth table66%2/3
A and B
A= _ref($self) eq "HASH"B= _ref($orig) eq "HASH"
ABresult
0X0
100
111
854  
855 3 warn("D: ", qd($self,1), "\n") if DEBUG && !%$orig;
856 3 ▶ return 'D' unless %$orig;
Branch: 1 branch
BranchTrueFalseTotal
unless %$orig 0 3 3
857  
858 3 my %hh = map { $_ => 1 } keys(%$self), keys(%$orig);
859 3 for my $key ( sort keys(%hh) ) {
860  
861 warn("Config reduce error: unknown item $path$key\n")
862 6 ▶ unless exists $self->{$key}
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$key} or $key =~ /^_/u or $path =~ m[^pdf/\.fonts\.]u 0 6 6
Condition33%2/6
exists $self->{$key} or $key =~ /^_/u or $path =~ m[^pdf/\.fonts\.]u
l!l&&r!l&&!r
600
exists $self->{$key} or $key =~ /^_/u
l!l&&r!l&&!r
600
MC/DC0%0/3
exists $self->{$key} or $key =~ /^_/u or $path =~ m[^pdf/\.fonts\.]u
exists $self->{$key} $key =~ /^_/u $path =~ m[^pdf/\.fonts\.]u
Truth table25%1/4
A or B or C
A= exists $self->{$key}B= $key =~ /^_/uC= $path =~ m[^pdf/\.fonts\.]u
ABCresult
1XX1
01X1
0011
0000
863 || $key =~ /^_/
864 || $path =~ /^pdf\/\.fonts\./;
865  
866 6 ▶ unless ( exists $orig->{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $orig->{$key}) 0 6 6
867 0 warn("D: $path$key\n") if DEBUG;
868 0 delete $self->{$key};
869 0 ▶ $state //= 'M';
Condition0%0/2
$state //= "M"
l!l
00
MC/DC0%0/1
$state //= "M"
$state
Truth table0%0/2
A
A= $state
Aresult
11
00
870 0 next;
871 }
872  
873 # Hash -> Hash.
874 6 ▶ if ( _ref($orig->{$key}) eq 'HASH'
Branch: 3 branches
BranchTrueFalseTotal
if (_ref($orig->{$key}) eq 'HASH' and _ref($self->{$key}) eq 'HASH' or _ref($orig->{$key}) eq 'ARRAY' and _ref($self->{$key}) eq 'ARRAY') { } 4 2 6
elsif (($self->{$key} // '') eq ($orig->{$key} // '')) { } 1 1 2
elsif (not defined $self->{$key} and _ref($orig->{$key}) eq 'ARRAY' and not @{$orig->{$key};} or not defined $orig->{$key} and _ref($self->{$key}) eq 'ARRAY' and not @{$self->{$key};}) { } 0 1 1
Condition77%7/9
_ref($orig->{$key}) eq "HASH" and _ref($self->{$key}) eq "HASH" or _ref($orig->{$key}) eq "ARRAY" and _ref($self->{$key}) eq "ARRAY"
l!l&&r!l&&!r
222
_ref($orig->{$key}) eq "HASH" and _ref($self->{$key}) eq "HASH"
!ll&&!rl&&r
402
_ref($orig->{$key}) eq "ARRAY" and _ref($self->{$key}) eq "ARRAY"
!ll&&!rl&&r
202
MC/DC50%2/4
_ref($orig->{$key}) eq "HASH" and _ref($self->{$key}) eq "HASH" or _ref($orig->{$key}) eq "ARRAY" and _ref($self->{$key}) eq "ARRAY"
_ref($orig->{$key}) eq "HASH" _ref($self->{$key}) eq "HASH" _ref($orig->{$key}) eq "ARRAY" _ref($self->{$key}) eq "ARRAY"
Truth table42%3/7
A and B or C and D
A= _ref($orig->{$key}) eq "HASH"B= _ref($self->{$key}) eq "HASH"C= _ref($orig->{$key}) eq "ARRAY"D= _ref($self->{$key}) eq "ARRAY"
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
875 and _ref($self->{$key}) eq 'HASH'
876 or
877 _ref($orig->{$key}) eq 'ARRAY'
878 and _ref($self->{$key}) eq 'ARRAY' ) {
879 # Recurse.
880 4 my $m = _reduce( $self->{$key}, $orig->{$key}, "$path$key." );
881 4 ▶ delete $self->{$key} if $m eq 'D' || $m eq 'I';
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "D" or $m eq "I" 0 4 4
Condition33%1/3
$m eq "D" or $m eq "I"
l!l&&r!l&&!r
004
MC/DC0%0/2
$m eq "D" or $m eq "I"
$m eq "D" $m eq "I"
Truth table33%1/3
A or B
A= $m eq "D"B= $m eq "I"
ABresult
1X1
011
000
882 4 ▶ $state //= 'M' if $m ne 'I';
Branch: 1 branch
BranchTrueFalseTotal
if $m ne "I" 4 0 4
Condition100%2/2
$state //= "M"
l!l
22
MC/DC100%1/1
$state //= "M"
$state
Truth table100%2/2
A
A= $state
Aresult
11
00
883 }
884  
885 ▶ elsif ( ($self->{$key}//'') eq ($orig->{$key}//'') ) {
Condition50%2/4
$self->{$key} // ""
l!l
20
$orig->{$key} // ""
l!l
20
MC/DC0%0/1
$self->{$key} // ""
$self->{$key}
MC/DC0%0/1
$orig->{$key} // ""
$orig->{$key}
Truth table50%1/2
A
A= $self->{$key}
Aresult
11
00
Truth table50%1/2
A
A= $orig->{$key}
Aresult
11
00
886 1 warn("I: $path$key\n") if DEBUG;
887 1 delete $self->{$key};
888 }
889 ▶ elsif ( !defined($self->{$key})
Condition33%3/9
not defined $self->{$key} and _ref($orig->{$key}) eq "ARRAY" and not @{$orig->{$key};} or not defined $orig->{$key} and _ref($self->{$key}) eq "ARRAY" and not @{$self->{$key};}
l!l&&r!l&&!r
001
not defined $self->{$key} and _ref($orig->{$key}) eq "ARRAY" and not @{$orig->{$key};}
!ll&&!rl&&r
100
not defined $self->{$key} and _ref($orig->{$key}) eq "ARRAY"
!ll&&!rl&&r
100
MC/DC0%0/4
not defined $self->{$key} and _ref($orig->{$key}) eq "ARRAY" and not @{$orig->{$key};} or not defined $orig->{$key} and _ref($self->{$key}) eq "ARRAY" and not @{$self->{$key};}
not defined $self->{$key} _ref($orig->{$key}) eq "ARRAY" not @{$orig->{$key};} not defined $orig->{$key} and _ref($self->{$key}) eq "ARRAY" and not @{$self->{$key};}
Truth table14%1/7
not(A) and B and not(C) or D
A= not defined $self->{$key}B= _ref($orig->{$key}) eq "ARRAY"C= not @{$orig->{$key};}D= not defined $orig->{$key} and _ref($self->{$key}) eq "ARRAY" and not @{$self->{$key};}
ABCDresult
111X1
0XX11
10X11
11011
0XX00
10X00
11000
890 and _ref($orig->{$key}) eq 'ARRAY'
891 0 ▶ and !@{$orig->{$key}}
Condition33%2/6
not defined $orig->{$key} and _ref($self->{$key}) eq "ARRAY" and not @{$self->{$key};}
!ll&&!rl&&r
100
not defined $orig->{$key} and _ref($self->{$key}) eq "ARRAY"
!ll&&!rl&&r
100
MC/DC0%0/3
not defined $orig->{$key} and _ref($self->{$key}) eq "ARRAY" and not @{$self->{$key};}
not defined $orig->{$key} _ref($self->{$key}) eq "ARRAY" not @{$self->{$key};}
Truth table0%0/4
not(A) and B and not(C)
A= not defined $orig->{$key}B= _ref($self->{$key}) eq "ARRAY"C= not @{$self->{$key};}
ABCresult
0XX0
10X0
1100
1111
892 or
893 !defined($orig->{$key})
894 and _ref($self->{$key}) eq 'ARRAY'
895 0 and !@{$self->{$key}} ) {
896 # Properties input [] yields undef.
897 0 warn("I: $path$key\n") if DEBUG;
898 0 delete $self->{$key};
899 }
900 else {
901 # Overwrite.
902 1 warn("M: $path$key => $self->{$key}\n") if DEBUG;
903 1 ▶ $state //= 'M';
Condition50%1/2
$state //= "M"
l!l
01
MC/DC0%0/1
$state //= "M"
$state
Truth table50%1/2
A
A= $state
Aresult
11
00
904 }
905 }
906 3 ▶ return $state // 'I';
Condition50%1/2
$state // "I"
l!l
30
MC/DC0%0/1
$state // "I"
$state
Truth table50%1/2
A
A= $state
Aresult
11
00
907 }
908  
909 3 ▶ if ( _ref($self) eq 'ARRAY' && _ref($orig) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_ref($self) eq "ARRAY" and _ref($orig) eq "ARRAY") 3 0 3
Condition33%1/3
_ref($self) eq "ARRAY" and _ref($orig) eq "ARRAY"
!ll&&!rl&&r
003
MC/DC0%0/2
_ref($self) eq "ARRAY" and _ref($orig) eq "ARRAY"
_ref($self) eq "ARRAY" _ref($orig) eq "ARRAY"
Truth table33%1/3
A and B
A= _ref($self) eq "ARRAY"B= _ref($orig) eq "ARRAY"
ABresult
0X0
100
111
910  
911 # Arrays.
912 3 ▶ if ( any { _ref($_) } @$self ) {
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { _ref($_); } , @$self)) 1 2 3
913 # Complex arrays. Recurse.
914 1 ▶ for ( my $key = 0; $key < @$self; $key++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key < @$self) 1 1 2
915 1 my $m = _reduce( $self->[$key], $orig->[$key], "$path$key." );
916 #delete $self->{$key} if $m eq 'D'; # TODO
917 1 ▶ $state //= 'M' if $m ne 'I';
Branch: 1 branch
BranchTrueFalseTotal
if $m ne "I" 1 0 1
Condition50%1/2
$state //= "M"
l!l
01
MC/DC0%0/1
$state //= "M"
$state
Truth table50%1/2
A
A= $state
Aresult
11
00
918 }
919 1 ▶ return $state // 'I';
Condition50%1/2
$state // "I"
l!l
10
MC/DC0%0/1
$state // "I"
$state
Truth table50%1/2
A
A= $state
Aresult
11
00
920 }
921  
922 # Simple arrays (only scalar values).
923 2 ▶ if ( my $dd = @$self - @$orig ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dd = @$self - @$orig) 1 1 2
924 1 $path =~ s/\.$//;
925 1 ▶ if ( $dd > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dd > 0) { } 1 0 1
926 # New is larger. Check for prepend/append.
927 # Deal with either one, not both. Maybe later.
928 1 my $t;
929 1 ▶ for ( my $ix = 0; $ix < @$orig; $ix++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ix < @$orig) 1 0 1
930 1 ▶ next if $orig->[$ix] eq $self->[$ix];
Branch: 1 branch
BranchTrueFalseTotal
if $orig->[$ix] eq $self->[$ix] 0 1 1
931 1 $t++;
932 1 last;
933 }
934 1 ▶ unless ( $t ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($t) 0 1 1
935 0 warn("M: $path append @{$self}[-$dd..-1]\n") if DEBUG;
936 0 splice( @$self, 0, $dd, "append" );
937 0 return 'M';
938 }
939 1 undef $t;
940 1 ▶ for ( my $ix = $dd; $ix < @$self; $ix++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ix < @$self) 2 1 3
941 2 ▶ next if $orig->[$ix-$dd] eq $self->[$ix];
Branch: 1 branch
BranchTrueFalseTotal
if $$orig[$ix - $dd] eq $self->[$ix] 2 0 2
942 0 $t++;
943 0 last;
944 }
945 1 ▶ unless ( $t ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($t) 1 0 1
946 1 warn("M: $path prepend @{$self}[0..$dd-1]\n") if DEBUG;
947 1 splice( @$self, $dd );
948 1 unshift( @$self, "prepend" );
949 1 return 'M';
950 }
951 0 warn("M: $path => @$self\n") if DEBUG;
952 0 $state = 'M';
953 }
954 else {
955 0 warn("M: $path => @$self\n") if DEBUG;
956 0 $state = 'M';
957 }
958 0 ▶ return $state // 'I';
Condition0%0/2
$state // "I"
l!l
00
MC/DC0%0/1
$state // "I"
$state
Truth table0%0/2
A
A= $state
Aresult
11
00
959 }
960  
961 # Equal length arrays with scalar values.
962 1 my $t;
963 1 ▶ for ( my $ix = 0; $ix < @$orig; $ix++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ix < @$orig) 1 0 1
964 1 ▶ next if $orig->[$ix] eq $self->[$ix];
Branch: 1 branch
BranchTrueFalseTotal
if $orig->[$ix] eq $self->[$ix] 0 1 1
965 1 warn("M: $path$ix => $self->[$ix]\n") if DEBUG;
966 1 $t++;
967 1 last;
968 }
969 1 ▶ if ( $t ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t) 1 0 1
970 1 warn("M: $path\n") if DEBUG;
971 1 return 'M';
972 }
973 0 warn("I: $path\[]\n") if DEBUG;
974 0 return 'I';
975 }
976  
977 # Two scalar values.
978 0 $path =~ s/\.$//;
979 0 ▶ if ( $self eq $orig ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self eq $orig) 0 0 0
980 0 warn("I: $path\n") if DEBUG;
981 0 return 'I';
982 }
983  
984 0 warn("M $path $self\n") if DEBUG;
985 0 return 'M';
986 }
987  
988 9639 ▶sub hmerge( $left, $right, $path = "" ) {
Subroutine hmerge: called CC=22 SCAR=36.3
Pod undocumented
989  
990 # Merge hashes. Right takes precedence.
991 # Based on Hash::Merge::Simple by Robert Krimen.
992  
993 9639 my %res = %$left;
994  
995 9639 for my $key ( keys(%$right) ) {
996  
997 warn("Config error: unknown item $path$key\n")
998 39935 ▶ unless exists $res{$key}
Branch: 1 branch
BranchTrueFalseTotal
unless exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^pdf\.formats\./u and $key =~ /\w+-even$/u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^delegates\./u or $path =~ /^parser\.preprocess\./u or $path =~ /^markup\.shortcodes\./u or $path =~ /^debug\./u or $key =~ /^_/u 0 39935 39935
Condition63%21/33
exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^pdf\.formats\./u and $key =~ /\w+-even$/u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^delegates\./u or $path =~ /^parser\.preprocess\./u or $path =~ /^markup\.shortcodes\./u or $path =~ /^debug\./u or $key =~ /^_/u
l!l&&r!l&&!r
395633720
exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^pdf\.formats\./u and $key =~ /\w+-even$/u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^delegates\./u or $path =~ /^parser\.preprocess\./u or $path =~ /^markup\.shortcodes\./u or $path =~ /^debug\./u
l!l&&r!l&&!r
395630372
exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^pdf\.formats\./u and $key =~ /\w+-even$/u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^delegates\./u or $path =~ /^parser\.preprocess\./u or $path =~ /^markup\.shortcodes\./u
l!l&&r!l&&!r
395630372
exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^pdf\.formats\./u and $key =~ /\w+-even$/u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^delegates\./u or $path =~ /^parser\.preprocess\./u
l!l&&r!l&&!r
395630372
exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^pdf\.formats\./u and $key =~ /\w+-even$/u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^delegates\./u
l!l&&r!l&&!r
395630372
exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^pdf\.formats\./u and $key =~ /\w+-even$/u or $path =~ /^(meta|gridstrum\.symbols)\./u
l!l&&r!l&&!r
395630372
exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^pdf\.formats\./u and $key =~ /\w+-even$/u
l!l&&r!l&&!r
395630372
exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u or $path =~ /^pdf\.formats\.\w+-even\./u
l!l&&r!l&&!r
395630372
exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u
l!l&&r!l&&!r
395630372
exists $res{$key} or $path eq "pdf.fontconfig."
l!l&&r!l&&!r
395630372
$path =~ /^pdf\.formats\./u and $key =~ /\w+-even$/u
!ll&&!rl&&r
37200
MC/DC0%0/12
exists $res{$key} or $path eq "pdf.fontconfig." or $path =~ /^pdf\.(?:info|fonts)\./u or $path =~ /^pdf\.formats\.\w+-even\./u or $path =~ /^pdf\.formats\./u and $key =~ /\w+-even$/u or $path =~ /^(meta|gridstrum\.symbols)\./u or $path =~ /^delegates\./u or $path =~ /^parser\.preprocess\./u or $path =~ /^markup\.shortcodes\./u or $path =~ /^debug\./u or $key =~ /^_/u
exists $res{$key} $path eq "pdf.fontconfig." $path =~ /^pdf\.(?:info|fonts)\./u $path =~ /^pdf\.formats\.\w+-even\./u $path =~ /^pdf\.formats\./u $key =~ /\w+-even$/u $path =~ /^(meta|gridstrum\.symbols)\./u $path =~ /^delegates\./u $path =~ /^parser\.preprocess\./u $path =~ /^markup\.shortcodes\./u $path =~ /^debug\./u $key =~ /^_/u
Truth table10%2/19
A or B or C or D or E and F or G or H or I or J or K or L
A= exists $res{$key}B= $path eq "pdf.fontconfig."C= $path =~ /^pdf\.(?:info|fonts)\./uD= $path =~ /^pdf\.formats\.\w+-even\./uE= $path =~ /^pdf\.formats\./uF= $key =~ /\w+-even$/uG= $path =~ /^(meta|gridstrum\.symbols)\./uH= $path =~ /^delegates\./uI= $path =~ /^parser\.preprocess\./uJ= $path =~ /^markup\.shortcodes\./uK= $path =~ /^debug\./uL= $key =~ /^_/u
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
000011XXXXXX1
00000X1XXXXX1
0000101XXXXX1
00000X01XXXX1
00001001XXXX1
00000X001XXX1
000010001XXX1
00000X0001XX1
0000100001XX1
00000X00001X1
00001000001X1
00000X0000011
0000100000011
00000X0000000
0000100000000
999 || $path eq "pdf.fontconfig."
1000 || $path =~ /^pdf\.(?:info|fonts)\./
1001 || $path =~ /^pdf\.formats\.\w+-even\./
1002 || ( $path =~ /^pdf\.formats\./ && $key =~ /\w+-even$/ )
1003 || $path =~ /^(meta|gridstrum\.symbols)\./
1004 || $path =~ /^delegates\./
1005 || $path =~ /^parser\.preprocess\./
1006 || $path =~ /^markup\.shortcodes\./
1007 || $path =~ /^debug\./
1008 || $key =~ /^_/;
1009  
1010 39935 ▶ if ( ref($right->{$key}) eq 'HASH'
Branch: 2 branches
BranchTrueFalseTotal
if (ref $right->{$key} eq 'HASH' and ref $res{$key} eq 'HASH') { } 9276 30659 39935
elsif (ref $right->{$key} eq 'ARRAY' and ref $res{$key} eq 'ARRAY') { } 3238 27421 30659
Condition66%2/3
ref $right->{$key} eq "HASH" and ref $res{$key} eq "HASH"
!ll&&!rl&&r
3065909276
MC/DC50%1/2
ref $right->{$key} eq "HASH" and ref $res{$key} eq "HASH"
ref $right->{$key} eq "HASH" ref $res{$key} eq "HASH"
Truth table66%2/3
A and B
A= ref $right->{$key} eq "HASH"B= ref $res{$key} eq "HASH"
ABresult
0X0
100
111
1011 and
1012 ref($res{$key}) eq 'HASH' ) {
1013 # Hashes. Recurse.
1014 9276 $res{$key} = hmerge( $res{$key}, $right->{$key}, "$path$key." );
1015 }
1016 ▶ elsif ( ref($right->{$key}) eq 'ARRAY'
Condition100%3/3
ref $right->{$key} eq "ARRAY" and ref $res{$key} eq "ARRAY"
!ll&&!rl&&r
270493723238
MC/DC100%2/2
ref $right->{$key} eq "ARRAY" and ref $res{$key} eq "ARRAY"
ref $right->{$key} eq "ARRAY" ref $res{$key} eq "ARRAY"
Truth table100%3/3
A and B
A= ref $right->{$key} eq "ARRAY"B= ref $res{$key} eq "ARRAY"
ABresult
0X0
100
111
1017 and
1018 ref($res{$key}) eq 'ARRAY' ) {
1019 warn("AMERGE $key: ",
1020 join(" ", map { qq{"$_"} } @{ $res{$key} }),
1021 " + ",
1022 3238 join(" ", map { qq{"$_"} } @{ $right->{$key} }),
1023 " \n") if 0;
1024 # Arrays. Overwrite or append.
1025 3238 ▶ if ( @{$right->{$key}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$right->{$key};}) { } 1810 1428 3238
1026 1810 my @v = @{ $right->{$key} };
1027 1810 ▶ if ( $v[0] eq "append" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($v[0] eq 'append') { } 0 1810 1810
elsif ($v[0] eq 'prepend') { } 0 1810 1810
1028 0 shift(@v);
1029 # Append the rest.
1030 warn("PRE: ",
1031 join(" ", map { qq{"$_"} } @{ $res{$key} }),
1032 " + ",
1033 0 join(" ", map { qq{"$_"} } @v),
1034 "\n") if 0;
1035 0 push( @{ $res{$key} }, @v );
1036 warn("POST: ",
1037 0 join(" ", map { qq{"$_"} } @{ $res{$key} }),
1038 "\n") if 0;
1039 }
1040 elsif ( $v[0] eq "prepend" ) {
1041 0 shift(@v);
1042 # Prepend the rest.
1043 0 unshift( @{ $res{$key} }, @v );
1044 }
1045 else {
1046 # Overwrite.
1047 1810 $res{$key} = $right->{$key};
1048 }
1049 }
1050 else {
1051 # Overwrite.
1052 1428 $res{$key} = $right->{$key};
1053 }
1054 }
1055 else {
1056 # Overwrite.
1057 27421 $res{$key} = $right->{$key};
1058 }
1059 }
1060  
1061 9639 return \%res;
1062 }
1063  
1064 80 ▶sub clone ( $source ) {
Subroutine clone: called CC=2 SCAR=7.0
Pod undocumented
1065  
1066 80 ▶ return if not defined($source);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $source 0 80 80
1067  
1068 92 ▶ use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
1069 80 my $clone = Storable::dclone($source);
1070 80 $clone->unlock;
1071 80 return $clone;
1072  
1073 }
1074  
1075 137 ▶sub precheck ( $cfg, $file ) {
Subroutine precheck: called CC=2 SCAR=6.9
Pod undocumented
1076  
1077 137 my $verbose = $options->{verbose};
1078 137 ▶ warn("Verify config \"$file\"\n") if $verbose > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose > 1 0 137 137
1079 137 my $p;
1080 1589886 ▶ $p = sub {
Subroutine __ANON__: called CC=8 SCAR=20.8
1081 1589886 my ( $o, $path ) = @_;
1082 1589886 ▶ $path //= "";
Condition100%2/2
$path //= ""
l!l
1589749137
MC/DC100%1/1
$path //= ""
$path
Truth table100%2/2
A
A= $path
Aresult
11
00
1083 1589886 ▶ if ( is_hashref($o) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (is_hashref($o)) { } 143879 1446007 1589886
elsif (is_arrayref($o)) { } 165675 1280332 1446007
1084 143879 ▶ $path .= "." unless $path eq "";
Branch: 1 branch
BranchTrueFalseTotal
unless $path eq "" 143742 137 143879
1085 143879 for ( sort keys %$o ) {
1086 453455 $p->( $o->{$_}, $path . $_ );
1087 }
1088 }
1089 elsif ( is_arrayref($o) ) {
1090 165675 ▶ $path .= "." unless $path eq "";
Branch: 1 branch
BranchTrueFalseTotal
unless $path eq "" 165675 0 165675
1091 165675 ▶ for ( my $i = 0; $i < @$o; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$o) 1136294 165675 1301969
1092 1136294 $p->( $o->[$i], $path . "$i" );
1093 }
1094 }
1095 137 };
1096  
1097 137 $p->($cfg);
1098 }
1099  
1100  
1101 ## Data::Properties compatible API.
1102 #
1103 # Note: Lookup always takes the context into account.
1104 # Note: Always signals undefined values.
1105  
1106 92 my $prp_context = "";
1107  
1108 12 ▶sub get_property ( $p, $prp, $def = undef ) {
Subroutine get_property: called CC=9 SCAR=22.4
Pod undocumented
1109 12 ▶ for ( split( /\./,
Branch: 1 branch
BranchTrueFalseTotal
$prp_context eq '' ? : 6 6 12
1110 $prp_context eq ""
1111 ? $prp
1112 : "$prp_context.$prp" ) ) {
1113 34 ▶ if ( /^\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^\d+$/u) { } 5 29 34
1114 5 ▶ die("No config $prp\n") unless _ref($p) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless _ref($p) eq "ARRAY" 0 5 5
1115 5 $p = $p->[$_];
1116 }
1117 else {
1118 29 ▶ die("No config $prp\n") unless _ref($p) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless _ref($p) eq "HASH" 0 29 29
1119 29 $p = $p->{$_};
1120 }
1121 }
1122 12 ▶ $p //= $def;
Condition66%2/3
$p //= $def
l!l&&r!l&&!r
1110
MC/DC0%0/2
$p //= $def
$p $def
Truth table66%2/3
A //= B
A= $pB= $def
ABresult
1X1
011
000
1123 12 ▶ die("No config $prp\n") unless defined $p;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p 0 12 12
1124 12 $p;
1125 }
1126  
1127 92 *gps = \&get_property;
1128  
1129 0 ▶sub set_property {
Subroutine set_property: not called CC=1 SCAR=6.9
Pod undocumented
1130 0 ...;
1131 }
1132  
1133 2 ▶sub set_context ( $self, $ctx = "" ) {
Subroutine set_context: called CC=2 SCAR=6.9
Pod undocumented
1134 2 $prp_context = $ctx;
1135 }
1136  
1137 0 ▶sub get_context () {
Subroutine get_context: not called CC=1 SCAR=6.9
Pod undocumented
1138 0 $prp_context;
1139 }
1140  
1141 # For testing
1142 92 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
1143 92 our @EXPORT = qw( _c );
1144 12 ▶sub _c ( @args ) { $::config->gps(@args) }
Subroutine _c: called CC=1 SCAR=0.0
1145  
1146 # For convenience.
1147 152 ▶sub diagram_strings ( $self ) {
Subroutine diagram_strings: called CC=1 SCAR=0.0
Pod undocumented
1148 # tuning is usually removed from the config.
1149 # scalar( @{ $self->{tuning} } );
1150 152 ChordPro::Chords::strings();
1151 }
1152  
1153 0 ▶sub diagram_keys ( $self ) {
Subroutine diagram_keys: not called CC=1 SCAR=6.9
Pod undocumented
1154 0 $self->{kbdiagrams}->{keys};
1155 }
1156  
1157 # For debugging messages.
1158 0 ▶sub qd ( $val, $compact = 0 ) {
Subroutine qd: not called CC=4 SCAR=26.4
Pod undocumented
1159 92 ▶ use Data::Dumper qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
1160 0 local $Data::Dumper::Sortkeys = 1;
1161 0 local $Data::Dumper::Indent = 1;
1162 0 local $Data::Dumper::Quotekeys = 0;
1163 0 local $Data::Dumper::Deparse = 1;
1164 0 local $Data::Dumper::Terse = 1;
1165 0 local $Data::Dumper::Trailingcomma = !$compact;
1166 0 local $Data::Dumper::Useperl = 1;
1167 0 local $Data::Dumper::Useqq = 0; # I want unicode visible
1168 0 my $x = Data::Dumper::Dumper($val);
1169 0 ▶ if ( $compact ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) 0 0 0
1170 0 $x =~ s/^bless\( (.*), '[\w:]+' \)$/$1/s;
1171 0 $x =~ s/\s+/ /gs;
1172 }
1173 0 ▶ defined wantarray ? $x : warn($x,"\n");
Branch: 1 branch
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
1174 }
1175  
1176 92 1;
« lib/ChordPro/A2Crd.pm ↑ Summary lib/ChordPro/Output/PDF/StringDiagram.pm »