| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # This file is part of WebDyne. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Full license text is available at: | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # <http://dev.perl.org/licenses/> | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # Compiler pragma | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use strict qw(vars); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # Use the base modules | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use WebDyne::Util; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | ▶ | use WebDyne; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # External modules | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | ▶ | use Cwd qw(realpath); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | use File::Temp qw(tempfile); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | ▶ | use File::Copy qw(move); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | ▶ | use ExtUtils::MakeMaker qw(prompt); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | use FindBin qw($RealBin $Script); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # Local customisation | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | local $Data::Dumper::Indent=1; | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | local $Data::Dumper::Sortkeys=1; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # Version Info, must be all one line for MakeMaker, CPAN. | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 4 | $VERSION='3.029'; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # Run main | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | ▶ | exit ${&main(\@ARGV) || die errdump()}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
&main(\@ARGV) || die(errdump())
MC/DC0%0/1
&main(\@ARGV) || die(errdump())
&main(\@ARGV)
Truth table50%1/2
A
A= &main(\@ARGV)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | #=================================================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | ▶ | sub main { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
main: called CC=19 SCAR=36.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # Get argv array ref | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | my $argv_ar=shift(); | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # Now import command line options. | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 4 | my %opt; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | GetOptions( | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | \%opt, | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | my @opt=( | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 'status', | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'enable', | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 'disable', | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 'version', | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 'help|?', | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 'man', | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 'directory|dir:s', | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 'dump_opt|dump-opt|opt', | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 'yes' | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | pod2usage(-verbose => 99, -sections => 'SYNOPSIS|OPTIONS', -exitval => 1) if $opt{'help'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | ▶ | pod2usage(-verbose => 2) if $opt{'man'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $opt{'version'} && do {print "$Script version: $VERSION\n"; exit 0}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # Dump options for debugging | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 4 | ▶ | die Dumper(\%opt) if $opt{'dump_opt'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # Check if user really wants to do this | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | ▶ | if (($opt{'enable'} || $opt{'disable'}) && !$opt{'yes'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$opt{"enable"} || $opt{"disable"} and not $opt{"yes"}
$opt{"enable"} or $opt{"disable"}
MC/DC0%0/3
$opt{"enable"} || $opt{"disable"} and not $opt{"yes"}
$opt{"enable"}
$opt{"disable"}
not $opt{"yes"}
Truth table60%3/5
A or B and not(C)
A= $opt{"enable"}B= $opt{"disable"}C= not $opt{"yes"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $yesno=ExtUtils::MakeMaker::prompt( | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | "\nWARNING: This script will edit installed WebDyne.pm and support files to turn on/off debugging. " . | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | "It is intended only for use in a test environment, and may have unintended consquences:\n\n" . | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 'Are you sure you wish to proceed ?', 'no' | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | exit 0 unless ($yesno=~/^y/i); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # User can specify only one file, or file path to modify from command line | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 3 | my $debug_fn=$argv_ar->[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # Whihc routines to run | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | my $debug_cr; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | if ($opt{'enable'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | $debug_cr=\&enable; | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | elsif ($opt{'disable'}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | $debug_cr=\&disable; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | #$debug_cr=\&status; | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | $debug_cr=sub {\undef}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # Find base location of the actual WebDyne module and test | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | my %webdyne_fn; | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | my ($webdyne_dn, $webdyne_pm); | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | ▶ | unless ($webdyne_dn=$opt{'directory'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $webdyne_dn=$webdyne_pm=$INC{'WebDyne.pm'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $webdyne_fn=(File::Spec->splitpath($webdyne_dn))[2]; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $webdyne_dn=~s/\Q$webdyne_fn\E$//; | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | print "debug module location: $webdyne_dn\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 3 | $webdyne_pm=File::Spec->catfile($webdyne_dn, 'WebDyne.pm'); | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | ▶ | unless (-f $webdyne_pm) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return err("unable to find Webdyne.pm in directory: $webdyne_dn !"); | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | ▶ | if (!$debug_fn || ($debug_fn && ($webdyne_pm=~/\Q$debug_fn\E$/))) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
not $debug_fn or $debug_fn and $webdyne_pm =~ /\Q$debug_fn\E$/
$debug_fn and $webdyne_pm =~ /\Q$debug_fn\E$/
MC/DC0%0/3
not $debug_fn or $debug_fn and $webdyne_pm =~ /\Q$debug_fn\E$/
not $debug_fn
$debug_fn
$webdyne_pm =~ /\Q$debug_fn\E$/
Truth table25%1/4
not(A) or B and C
A= not $debug_fnB= $debug_fnC= $webdyne_pm =~ /\Q$debug_fn\E$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | $debug_cr->($webdyne_pm) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | return err(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 3 | ▶ | &status($webdyne_pm, $webdyne_dn) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | return err(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | $webdyne_fn{$webdyne_pm}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # Now all sub modules | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 3 | my $webdyne_display_dn; | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | 3 | ▶ | unless ($webdyne_dn=$opt{'directory'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $webdyne_dn=$INC{'WebDyne/Util.pm'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $webdyne_fn=(File::Spec->splitpath($webdyne_dn))[2]; | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $webdyne_dn=~s/\Q$webdyne_fn\E$//; | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $webdyne_display_dn=realpath(File::Spec->catdir($webdyne_dn, File::Spec->updir)); | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | $webdyne_display_dn=$webdyne_dn; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | $webdyne_dn=File::Spec->catfile($webdyne_dn, 'WebDyne'); | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 6 | ▶ | my $wanted_cr=sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=22.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 6 | ▶ | return unless $File::Find::name=~/.pm$/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | ▶ | return if $webdyne_fn{$File::Find::name}++; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | ▶ | if ($debug_fn) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | return unless $File::Find::name=~/\Q$debug_fn\E$/ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | ▶ | $debug_cr->($File::Find::name) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | return err(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | ▶ | &status($File::Find::name, $webdyne_display_dn) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | return err(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | find($wanted_cr, $webdyne_dn); | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # Done | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | return \undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | sub enable { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable: called CC=10 SCAR=23.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | my $fn=shift(); | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | ▶ | my $fh=IO::File->new($fn, O_RDONLY) || return err( | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'IO::File'->new($fn, 0) || (return err("unable to open file $fn for read, $!"))
MC/DC0%0/1
'IO::File'->new($fn, 0) || (return err("unable to open file $fn for read, $!"))
'IO::File'->new($fn, 0)
Truth table50%1/2
A
A= 'IO::File'->new($fn, 0)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | "unable to open file $fn for read, $!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | my ($temp_fh, $temp_fn)=tempfile(); | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | my $modified; | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | ▶ | while (my $line=<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 6 | ▶ | if ($line=~/^\s*(\d?)\s+&&\s+debug/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | ▶ | if ($1 eq '0') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | $line=~s/^(\s*)(\d+)/${1}1/; | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | $modified++; | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 6 | ▶ | print $temp_fh $line or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | return err("unable to print to temp file handle, $!"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | $fh->close(); | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | $temp_fh->close(); | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | if ($modified) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | my $perm; | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | ▶ | if ($^O=~/MSWin[32|64]/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | system('attrib', '-r', $fn); | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | my $perm=(stat $fn)[2] & 07777; | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | chmod($perm | 0600, $fn); | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | ▶ | move($temp_fn, $fn) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | return err("unable to move $temp_fn=>$fn, $!"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | ▶ | chmod($perm, $fn) if $perm; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | return \undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | ▶ | sub disable { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disable: called CC=12 SCAR=25.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | my $fn=shift(); | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | ▶ | my $fh=IO::File->new($fn, O_RDONLY) || return err( | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'IO::File'->new($fn, 0) || (return err("unable to open file $fn for read, $!"))
MC/DC0%0/1
'IO::File'->new($fn, 0) || (return err("unable to open file $fn for read, $!"))
'IO::File'->new($fn, 0)
Truth table50%1/2
A
A= 'IO::File'->new($fn, 0)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | "unable to open file $fn for read, $!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | my ($temp_fh, $temp_fn)=tempfile(); | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | my $modified; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | while (my $line=<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 6 | ▶ | if ($line=~/^\s*(\d?)\s+&&\s+debug/ || $line=~/^\s*debug/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$line =~ /^\s*(\d?)\s+&&\s+debug/ or $line =~ /^\s*debug/
MC/DC100%2/2
$line =~ /^\s*(\d?)\s+&&\s+debug/ or $line =~ /^\s*debug/
$line =~ /^\s*(\d?)\s+&&\s+debug/
$line =~ /^\s*debug/
Truth table100%3/3
A or B
A= $line =~ /^\s*(\d?)\s+&&\s+debug/B= $line =~ /^\s*debug/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | ▶ | if ($1 == 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | $line=~s/^(\s*)(\d+)/${1}0/; | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | $modified++; | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | elsif ($1 eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | $line=~s/debug(\s*)\(/0 && debug$1\(/; | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | $modified++; | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 6 | ▶ | print $temp_fh $line or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | return err("unable to print to temp file handle, $!"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | $fh->close(); | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | $temp_fh->close(); | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | ▶ | if ($modified) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | my $perm; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | ▶ | if ($^O=~/MSWin[32|64]/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | system('attrib', '-r', $fn); | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 2 | my $perm=(stat $fn)[2] & 07777; | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | 2 | chmod($perm | 0600, $fn); | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | ▶ | move($temp_fn, $fn) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | return err("unable to move $temp_fn=>$fn, $!"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | ▶ | chmod($perm, $fn) if $perm; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | return \undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 6 | ▶ | sub status { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 6 | my ($fn, $dn)=@_; | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | 6 | ▶ | my $fh=IO::File->new($fn, O_RDONLY) || die( | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'IO::File'->new($fn, 0) || die("unable to open file $fn for read, $!")
MC/DC0%0/1
'IO::File'->new($fn, 0) || die("unable to open file $fn for read, $!")
'IO::File'->new($fn, 0)
Truth table50%1/2
A
A= 'IO::File'->new($fn, 0)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | "unable to open file $fn for read, $!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 6 | my ($debug, $found); | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | 6 | ▶ | while (my $line=<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 12 | ▶ | next unless ($line=~/^\s*(\d?)\s+&&\s+debug/ || $line=~/^\s*debug/); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$line =~ /^\s*(\d?)\s+&&\s+debug/ or $line =~ /^\s*debug/
MC/DC100%2/2
$line =~ /^\s*(\d?)\s+&&\s+debug/ or $line =~ /^\s*debug/
$line =~ /^\s*(\d?)\s+&&\s+debug/
$line =~ /^\s*debug/
Truth table100%3/3
A or B
A= $line =~ /^\s*(\d?)\s+&&\s+debug/B= $line =~ /^\s*debug/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | #print "line $line, $1\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 6 | ▶ | $debug=($1 eq '0') ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 6 | $found++; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | 6 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 6 | $fh->close(); | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | 6 | $fn=~s/^\Q$dn\E//; | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | 6 | $fn=~s/^\///; | |||||||||||||||||||||||||||||||||||||||||||||
| 290 | 6 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | 6 | ▶ | if ($debug) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 3 | $result=' enabled' | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | elsif ($found) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 3 | $result='disabled' | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $result=' n/a' | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 6 | print "debug $result: $fn\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 6 | return \undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||