| 1 | package UI::Dialog::Backend; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> | ||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # modify it under the terms of the GNU Lesser General Public | ||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # License as published by the Free Software Foundation; either | ||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # version 2.1 of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # This library is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # Lesser General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # You should have received a copy of the GNU Lesser General Public | ||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # License along with this library; if not, write to the Free Software | ||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 16 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 16 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 16 | ▶ | use Cwd qw( abs_path ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 16 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 16 | ▶ | use Text::Wrap qw( wrap ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 16 | ▶ | use String::ShellQuote; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 16 | ▶ | use File::Slurp; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 16 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 16 | ▶ | $VERSION = '1.20'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | #: Constructor Method | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | #: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | #: not even really necessary as this class is inherited, and the constructor is | ||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | #: more often than not overridden by the backend inheriting it. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $proto = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my $cfg = ((ref($_[0]) eq "HASH") ? $_[0] : (@_) ? { @_ } : {}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $self = { '_opts' => $cfg }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $self->{'test_mode'} = $cfg->{'test_mode'} if exists $cfg->{'test_mode'}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->{'test_mode_result'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | #: Accessory Methods | ||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | #: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | #: Return the path to the dialog variant binary | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | sub get_bin { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | return $_[0]->{'_opts'}{'bin'} if defined $_[0]->{'_opts'}{'bin'}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_bin: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | #: Provide the API interface to nautilus | ||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | sub nautilus { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nautilus: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | my $nautilus = $self->{'_nautilus'} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'_nautilus'} || {}
MC/DC0%0/1
$self->{'_nautilus'} || {}
$self->{'_nautilus'}
Truth table0%0/2
A
A= $self->{'_nautilus'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | unless (ref($nautilus) eq "UI::Dialog::Backend::Nautilus") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($self->_find_bin('nautilus')) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if (eval "require UI::Dialog::Backend::Nautilus; 1") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | require UI::Dialog::Backend::Nautilus; | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->{'_nautilus'} = new UI::Dialog::Backend::Nautilus; | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | return($self->{'_nautilus'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | #: Provide the API interface to osd_cat (aka: xosd) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | sub xosd { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xosd: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | my @args = (@_ %2 == 0) ? (@_) : (); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my $xosd = $self->{'_xosd'} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'_xosd'} || {}
MC/DC0%0/1
$self->{'_xosd'} || {}
$self->{'_xosd'}
Truth table0%0/2
A
A= $self->{'_xosd'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | unless (ref($xosd) eq "UI::Dialog::Backend::XOSD") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ($self->_find_bin('osd_cat')) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if (eval "require UI::Dialog::Backend::XOSD; 1") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | require UI::Dialog::Backend::XOSD; | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $self->{'_xosd'} = new UI::Dialog::Backend::XOSD (@args); | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return($self->{'_xosd'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | #: Provide the API interface to notify-send | ||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | sub notify_send { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notify_send: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | my @args = (@_ %2 == 0) ? (@_) : (); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | my $notify_send = $self->{'_notify_send'} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'_notify_send'} || {}
MC/DC0%0/1
$self->{'_notify_send'} || {}
$self->{'_notify_send'}
Truth table0%0/2
A
A= $self->{'_notify_send'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | unless (ref($notify_send) eq "UI::Dialog::Backend::NotifySend") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ($self->_find_bin('notify-send')) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if (eval "require UI::Dialog::Backend::NotifySend; 1") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | require UI::Dialog::Backend::NotifySend; | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->{'_notify_send'} = new UI::Dialog::Backend::NotifySend (@args); | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | return($self->{'_notify_send'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | #: State Methods | ||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | #: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | #: enable altering of attributes | ||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | sub attr { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attr: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $name = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | unless ($_[2]) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | return($self->{'_opts'}->{$name}) unless not $self->{'_opts'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return(undef()); | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if ($_[2] == 0 || $_[2] =~ /^NULL$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[2] == 0 or $_[2] =~ /^NULL$/i
MC/DC0%0/2
$_[2] == 0 or $_[2] =~ /^NULL$/i
$_[2] == 0
$_[2] =~ /^NULL$/i
Truth table0%0/3
A or B
A= $_[2] == 0B= $_[2] =~ /^NULL$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $self->{'_opts'}->{$name} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->{'_opts'}->{$name} = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | return($self->{'_opts'}->{$name}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | #: return the last response data as an ARRAY | ||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | sub ra { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ra: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if (@argv) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if (defined $argv[0] && $argv[0] =~ m!^null$!i) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $argv[0] and $argv[0] =~ /^null$/i
MC/DC0%0/2
defined $argv[0] and $argv[0] =~ /^null$/i
defined $argv[0]
$argv[0] =~ /^null$/i
Truth table0%0/3
A and B
A= defined $argv[0]B= $argv[0] =~ /^null$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $self->{'_state'}{'ra'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->{'_state'}{'ra'} = \@argv; | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | $self->{'_state'}->{'ra'} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"_state"}{"ra"} ||= []
MC/DC0%0/1
$self->{"_state"}{"ra"} ||= []
$self->{"_state"}{"ra"}
Truth table0%0/2
A
A= $self->{"_state"}{"ra"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return(@{ $self->{'_state'}->{'ra'} }); | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | #: return the last response data as a SCALAR | ||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | sub rs { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rs: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if (@argv) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if (defined $argv[0] && $argv[0] =~ m!^null$!i) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $argv[0] and $argv[0] =~ /^null$/i
MC/DC0%0/2
defined $argv[0] and $argv[0] =~ /^null$/i
defined $argv[0]
$argv[0] =~ /^null$/i
Truth table0%0/3
A and B
A= defined $argv[0]B= $argv[0] =~ /^null$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $self->{'_state'}{'rs'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $self->{'_state'}{'rs'} = $argv[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return($self->{'_state'}->{'rs'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | #: return the last exit code as a SCALAR | ||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | sub rv { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rv: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if (@argv) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if (defined $argv[0] && $argv[0] =~ m!^null$!i) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $argv[0] and $argv[0] =~ /^null$/i
MC/DC0%0/2
defined $argv[0] and $argv[0] =~ /^null$/i
defined $argv[0]
$argv[0] =~ /^null$/i
Truth table0%0/3
A and B
A= defined $argv[0]B= $argv[0] =~ /^null$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->{'_state'}{'rv'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->{'_state'}{'rv'} = $argv[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | return($self->{'_state'}->{'rv'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | #: report on the state of the last dialog variant execution. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | sub state { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | my $rv = $self->rv() || 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->rv || 0
MC/DC0%0/1
$self->rv || 0
$self->rv
Truth table0%0/2
A
A= $self->rv
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | $self->_debug((join(" | ",(caller())))." > state() > is: ".($rv||'NULL'),2); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rv || 'NULL'
MC/DC0%0/1
$rv || 'NULL'
$rv
Truth table0%0/2
A
A= $rv
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($rv == 1 or $rv == 129) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition0%0/3
$rv == 1 or $rv == 129
MC/DC0%0/2
$rv == 1 or $rv == 129
$rv == 1
$rv == 129
Truth table0%0/3
A or B
A= $rv == 1B= $rv == 129
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | return("CANCEL"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | elsif ($rv == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | return("HELP"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | elsif ($rv == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | return("EXTRA"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | elsif ($rv == 254) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return("ERROR"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | elsif ($rv == 255) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return("ESC"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ▶ | elsif (not $rv or $rv =~ /^null$/i) { | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not $rv or $rv =~ /^null$/i
MC/DC0%0/2
not $rv or $rv =~ /^null$/i
not $rv
$rv =~ /^null$/i
Truth table0%0/3
not(A) or B
A= not $rvB= $rv =~ /^null$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | return("OK"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return("UNKNOWN(".$rv.")"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | #: Preparation Methods | ||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | #: construct a HASHREF for command {{tag}} substitutions | ||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | sub make_kvt { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | my ($self,$args,$value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_kvt: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | return | ||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | literal => ($args->{'literal'} || 0), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | width => ($args->{'width'}||'65'), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | trust => ($args->{'trust-input'} || 0), | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$args->{'literal'} || 0
$args->{'width'} || '65'
$args->{'trust-input'} || 0
$value || ''
MC/DC0%0/1
$args->{'literal'} || 0
$args->{'literal'}
MC/DC0%0/1
$args->{'width'} || '65'
$args->{'width'}
MC/DC0%0/1
$args->{'trust-input'} || 0
$args->{'trust-input'}
MC/DC0%0/1
$value || ''
$value
Truth table0%0/2
A
A= $args->{'literal'}
Truth table0%0/2
A
A= $args->{'width'}
Truth table0%0/2
A
A= $args->{'trust-input'}
Truth table0%0/2
A
A= $value
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | value => ($value || '') | ||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | sub make_kvl { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | my ($self,$args,$value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_kvl: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | return | ||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | literal => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | width => ($args->{'width'}||'65'), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | trust => ($args->{'trust-input'} || 0), | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$args->{'width'} || '65'
$args->{'trust-input'} || 0
$value || ''
MC/DC0%0/1
$args->{'width'} || '65'
$args->{'width'}
MC/DC0%0/1
$args->{'trust-input'} || 0
$args->{'trust-input'}
MC/DC0%0/1
$value || ''
$value
Truth table0%0/2
A
A= $args->{'width'}
Truth table0%0/2
A
A= $args->{'trust-input'}
Truth table0%0/2
A
A= $value
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | value => ($value || '') | ||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | #: Helper method to generate a base format string, accepts additional | ||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | #: strings which are considered trusted programmer template input. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | sub prepare_format { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | my $self = shift(@_); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_format: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $args = shift(@_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # start with our binary path | ||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $fmt = $self->{'_opts'}{'bin'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $fmt = $self->append_format_check($args,$fmt,'title','--title {{title}}'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | return $fmt; | |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | sub append_format { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | my ($self,$fmt,$value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append_format: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if (ref($fmt) eq "SCALAR") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $$fmt .= ' '.$value; | |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $fmt .= ' '.$value; | |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | return $fmt; | |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | #: simple test and if true; append value to format | ||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | sub append_format_check { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | my ($self,$args,$fmt,$key,$value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append_format_check: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if (exists $args->{$key} and defined $args->{$key} and $args->{$key}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $args->{$key} and defined $args->{$key} and $args->{$key}
exists $args->{$key} and defined $args->{$key}
MC/DC0%0/3
exists $args->{$key} and defined $args->{$key} and $args->{$key}
exists $args->{$key}
defined $args->{$key}
$args->{$key}
Truth table0%0/4
A and B and C
A= exists $args->{$key}B= defined $args->{$key}C= $args->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $fmt = $self->append_format($fmt,$value); | |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | return $fmt; | |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | sub clean_format { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | my ($self,$trust,$sref) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_format: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | unless (ref($sref) eq "SCALAR") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | die("Programmer error. clean_format requires a SCALAR ref, found: ".ref($sref)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $$sref =~ s!\x00!!mg; # remove nulls | |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | #unless ($trust) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | #$$sref =~ s!\`!'!mg; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | #$$sref =~ s!\$\(!\(!mg; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | #$$sref =~ s!\$!\\\$!mg; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | #$$sref =~ s!"!\\"!mg; # escape double-quotes | ||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return $sref; | |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | sub trust_quote { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | my ($self,$kv,$string) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trust_quote: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if ($kv->{trust}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | return '"'.$string.'"'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return shell_quote($string); | |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | #: Given a command string "format" and any key/value replacement pairs, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | #: construct the exec'able command string. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | sub prepare_command { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | my $self = shift(@_); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_command: not called CC=24 SCAR=64.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $args = shift(@_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $format = shift(@_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my (%rpl_add) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my %rpl = (); | |||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | foreach my $key (keys %{$args}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | $rpl{$key} = $self->make_kvl($args,$args->{$key}||''); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{$key} || ''
MC/DC0%0/1
$args->{$key} || ''
$args->{$key}
Truth table0%0/2
A
A= $args->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | foreach my $key (keys %rpl_add) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $rpl{$key} = $rpl_add{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | foreach my $key (keys %rpl) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | my $value = $rpl{$key}->{value}||''; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rpl{$key}{'value'} || ''
MC/DC0%0/1
$rpl{$key}{'value'} || ''
$rpl{$key}{'value'}
Truth table0%0/2
A
A= $rpl{$key}{'value'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if (ref($value) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | #: menu, checklist, radiolist... | ||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $list = ''; | |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | foreach my $item (@{$value}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if (ref($item) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # checklist, radiolist... | ||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if (@{$item} == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $list .= ' '.$self->trust_quote($rpl{$key},$item->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | $list .= ' '.($item->[1] ? 'on' : 'off'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | elsif (@{$item} == 3) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $list .= ' '.$self->trust_quote($rpl{$key},$item->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | $list .= ' '.($item->[1] ? 'on' : 'off'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | $list .= ' '.($self->trust_quote($rpl{$key},$item->[2])||1); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->trust_quote($rpl{$key}, $item->[2]) || 1
MC/DC0%0/1
$self->trust_quote($rpl{$key}, $item->[2]) || 1
$self->trust_quote($rpl{$key}, $item->[2])
Truth table0%0/2
A
A= $self->trust_quote($rpl{$key}, $item->[2])
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | elsif (@{$item} == 4) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $list .= ' ' . $self->trust_quote($rpl{$key},$item->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $list .= ' '.($item->[1] ? 'on' : 'off'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | $list .= ' '.($self->trust_quote($rpl{$key},$item->[2])||1); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->trust_quote($rpl{$key}, $item->[2]) || 1
MC/DC0%0/1
$self->trust_quote($rpl{$key}, $item->[2]) || 1
$self->trust_quote($rpl{$key}, $item->[2])
Truth table0%0/2
A
A= $self->trust_quote($rpl{$key}, $item->[2])
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $list .= ' '.$self->trust_quote($rpl{$key},$item->[3]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # menu... | ||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $list .= ' '.$self->trust_quote($rpl{$key},$item); | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $format =~ s!\{\{\Q${key}\E\}\}!${list}!mg; | |||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } # if (ref($value) eq "ARRAY") | ||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | elsif ($key eq "list") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # assume this has been manipulated already? | ||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $format =~ s!\{\{\Q${key}\E\}\}!${value}!mg; | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | $value ||= '' unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$value ||= ""
MC/DC0%0/1
$value ||= ""
$value
Truth table0%0/2
A
A= $value
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | $value = "$1" if $value =~ m!^(\d+)$!; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if (ref(\$value) eq "SCALAR") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | unless ($rpl{$key}->{'trust'}||$rpl{$key}->{literal}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rpl{$key}{"trust"} or $rpl{$key}{"literal"}
MC/DC0%0/2
$rpl{$key}{"trust"} or $rpl{$key}{"literal"}
$rpl{$key}{"trust"}
$rpl{$key}{"literal"}
Truth table0%0/3
A or B
A= $rpl{$key}{"trust"}B= $rpl{$key}{"literal"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | $value = $self->_organize_text | ||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ( $value, $rpl{$key}->{width}, $rpl{$key}->{'trust'} ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $value = $self->trust_quote($rpl{$key},$value); | |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $format =~ s!\{\{\Q${key}\E\}\}!${value}!mg; | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | return $format; | |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | #: Execution Methods | ||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | #: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | sub is_unit_test_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_unit_test_mode: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | return 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | if ( exists $self->{'test_mode'} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | && | ||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | defined $self->{'test_mode'} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | && | ||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | $self->{'test_mode'} | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $self->{"test_mode"} and defined $self->{"test_mode"} and $self->{"test_mode"}
exists $self->{"test_mode"} and defined $self->{"test_mode"}
MC/DC0%0/3
exists $self->{"test_mode"} and defined $self->{"test_mode"} and $self->{"test_mode"}
exists $self->{"test_mode"}
defined $self->{"test_mode"}
$self->{"test_mode"}
Truth table0%0/4
A and B and C
A= exists $self->{"test_mode"}B= defined $self->{"test_mode"}C= $self->{"test_mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | sub get_unit_test_result { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_unit_test_result: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | return $self->{'test_mode_result'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | #: run command and return the rv and any text output from stderr | ||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | sub perform_command { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perform_command: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my $cmnd = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if ($self->is_unit_test_mode()) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $self->{'test_mode_result'} = $cmnd; | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | return (0,'test_mode_result'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $self->_debug("perform_command: ".$cmnd.";"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $tmp_stderr = $self->gen_tempfile_name(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | system($cmnd." 2> ".$tmp_stderr); | |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $rv = $? >> 8; | |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $text = read_file($tmp_stderr); | |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | unlink($tmp_stderr) if -f $tmp_stderr; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | $self->_debug("perform_command: stderr=".shell_quote($text),2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | return ($rv,$text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | #: execute a simple command (return the exit code only); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | sub command_state { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command_state: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $cmnd = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if ($self->is_unit_test_mode()) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $self->{'test_mode_result'} = $cmnd; | |||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my ($rv,$text) = $self->perform_command($cmnd); | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $self->_debug("command_state: rv=".$rv,1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $self->rv($rv); | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $self->rs('null'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $self->ra('null'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | return($rv); | |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | #: execute a command and return the exit code and one-line SCALAR | ||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | sub command_string { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command_string: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $cmnd = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | if ($self->is_unit_test_mode()) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $self->{'test_mode_result'} = $cmnd; | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | return (wantarray) ? (0,'') : ''; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my ($rv,$text) = $self->perform_command($cmnd); | |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | chomp($text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $self->_debug("command_string: rv=".$rv.", rs=".shell_quote($text),1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $self->rv($rv); | |||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $self->rs($text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $self->ra('null'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | return($text) unless defined wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | return (wantarray) ? ($rv,$text) : $text; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | #: execute a command and return the exit code and ARRAY of data | ||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | sub command_array { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command_array: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $cmnd = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | if ($self->is_unit_test_mode()) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | $self->{'test_mode_result'} = $cmnd; | |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | return (wantarray) ? (0,[]) : []; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my ($rv,$text) = $self->perform_command($cmnd); | |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $self->_debug("command_array: rv=".$rv.", rs=".shell_quote($text),1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $self->rv($rv); | |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | $self->rs($text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # this is so hackish that it may just work | ||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $alt_text = $text; | |||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $alt_text =~ s!\r??\n!__\\n!mg; #: replace newlines with "a symbol" | |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my @alt_items = split(/_\\n/,$alt_text); #: split on "part symbol" | |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my @alt_final = (); | |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | foreach my $alt_item (@alt_items) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $i = $alt_item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $i =~ s!_$!!; #: remove the trailing bit of symbol | |||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | push(@alt_final,$i); | |||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | $self->ra(@alt_final); #: final array can now contain blanks | |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | return([$self->ra()]) unless defined wantarray and wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined wantarray and wantarray
MC/DC0%0/2
defined wantarray and wantarray
defined wantarray
wantarray
Truth table0%0/3
A and B
A= defined wantarrayB= wantarray
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | return (wantarray) ? ($rv,[$self->ra()]) : [$self->ra()]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | #: Utility Methods | ||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | #: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | #: make some noise | ||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | sub beep { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
beep: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | return($self->_beep(1)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | #: Clear terminal screen. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | sub clear { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | return($self->_clear(1)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # word-wrap a line | ||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | sub word_wrap { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
word_wrap: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | my $width = shift() || 65; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 65
MC/DC0%0/1
shift() || 65
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | my $indent = shift() || ""; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | my $sub_indent = shift() || ""; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $Text::Wrap::columns = $width - 3; | |||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my $raw = join("\n",@_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my $string = wrap($indent, $sub_indent, $raw); | |||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | return(split(m!\n!,$string)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | # generate a temporary file name | ||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | sub gen_tempfile_name { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_tempfile_name: not called CC=10 SCAR=45.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | my $template = $self->{'_opts'}->{'tempfiletemplate'} || "UI_Dialog_tempfile_XXXXX"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'_opts'}{'tempfiletemplate'} || 'UI_Dialog_tempfile_XXXXX'
MC/DC0%0/1
$self->{'_opts'}{'tempfiletemplate'} || 'UI_Dialog_tempfile_XXXXX'
$self->{'_opts'}{'tempfiletemplate'}
Truth table0%0/2
A
A= $self->{'_opts'}{'tempfiletemplate'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | if (eval("require File::Temp; 1")) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 16 | ▶ | use File::Temp qw( tempfile ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | my ($fh,$filename) = tempfile( UNLINK => 1 ) or croak( "Can't create tempfile: $!" ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | return($fh,$filename); | |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | close($fh); # actually required on win32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | return($filename); | |||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | return($fh,$filename); | |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my $mktemp = $self->_find_bin('mktemp'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | if ($mktemp && -x $mktemp) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mktemp and -x $mktemp
MC/DC0%0/2
$mktemp and -x $mktemp
$mktemp
-x $mktemp
Truth table0%0/3
A and B
A= $mktempB= -x $mktemp
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | chomp(my $tempfile = `$mktemp "$template"`); | |||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | return($tempfile); | |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | #pseudo-random filename coming up! | ||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | my $tempdir = "/tmp"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | unless (-d $tempdir) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | if (-d "/var/tmp") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $tempdir = "/var/tmp"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $tempdir = "."; | |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $self->gen_random_string(5); | |||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | my $tempfile = "UI_Dialog_tempfile_".$self->gen_random_string(5); | |||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | while (-e $tempdir."/".$tempfile) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $self->gen_random_string(5); | |||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $tempfile = "UI_Dialog_tempfile_".$self->gen_random_string(5); | |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | return($tempdir."/".$tempfile); | |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # generate a random string as a (possibly) suitable failover option in the | ||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | # event that File::Temp is not installed and the 'mktemp' program does not | ||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # exist in the path. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | sub gen_random_string { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_random_string: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | my $length = $_[1] || 5; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[1] || 5
MC/DC0%0/1
$_[1] || 5
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | my $string = ""; | |||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my $counter = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | while ($counter < $length) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | # 33 - 127 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $num = rand(128); | |||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | while ($num < 33 or $num > 127) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$num < 33 or $num > 127
MC/DC0%0/2
$num < 33 or $num > 127
$num < 33
$num > 127
Truth table0%0/3
A or B
A= $num < 33B= $num > 127
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | $num = rand(128); | |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | $string .= chr($num); | |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $counter++; | |||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | return($string); | |||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | #: Widget Wrapping Methods | ||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | #: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | #: file select | ||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | sub fselect { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fselect: not called CC=39 SCAR=73.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | my $caller = (caller(1))[3] || 'main'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
(caller 1)[3] || 'main'
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
(caller 2)[3] or "main"
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | if ($_[0] && $_[0] eq 'caller') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[0] and $_[0] eq "caller"
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0]
$_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | shift(); $caller = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my $args = $self->_pre($caller,@_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | $self->rv('NULL'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $self->rs('NULL'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | $self->ra('NULL'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $self->_beep($args->{'beepbefore'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | my $cwd = abs_path(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | $args->{'path'} ||= abs_path(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args->{"path"} ||= abs_path()
MC/DC0%0/2
$args->{"path"} ||= abs_path()
$args->{"path"}
abs_path()
Truth table0%0/3
A ||= B
A= $args->{"path"}B= abs_path()
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my $pre_selection = $args->{'path'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $path = $args->{'path'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | if (-f $pre_selection) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | $path = dirname($path); | |||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | if (!$path || $path =~ /^(\.|\.\/)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $path or $path =~ m[^(\.|\./)$]
MC/DC0%0/2
not $path or $path =~ m[^(\.|\./)$]
not $path
$path =~ m[^(\.|\./)$]
Truth table0%0/3
not(A) or B
A= not $pathB= $path =~ m[^(\.|\./)$]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | $path = $cwd; | |||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $user_selection = $pre_selection; | |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | my ($menu,$list) = ([],[]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | FSEL: while ($self->state() ne "ESC" && $self->state() ne "CANCEL") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->state ne "ESC" and $self->state ne "CANCEL"
MC/DC0%0/2
$self->state ne "ESC" and $self->state ne "CANCEL"
$self->state ne "ESC"
$self->state ne "CANCEL"
Truth table0%0/3
A and B
A= $self->state ne "ESC"B= $self->state ne "CANCEL"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | my $entries = ($args->{'dselect'}) ? ['[new directory]'] : ['[new file]']; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | ($menu, $list) = $self->_list_dir($path, $entries, $args->{'dselect'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 575 | $user_selection = $self->menu | ||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | ( height=>$args->{'height'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | width=>$args->{'width'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | listheight=>($args->{'listheight'}||$args->{'menuheight'}), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | title=>$args->{'title'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | backtitle=>$args->{'backtitle'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | text=>"Select a ".($args->{'dselect'}?'path':'file').": ".$path, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{'listheight'} || $args->{'menuheight'}
MC/DC0%0/2
$args->{'listheight'} || $args->{'menuheight'}
$args->{'listheight'}
$args->{'menuheight'}
Truth table0%0/3
A || B
A= $args->{'listheight'}B= $args->{'menuheight'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | list=>$menu | ||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | if ($self->state() eq "CANCEL") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $self->rv(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $self->rs('NULL'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $self->ra('NULL'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | last FSEL; | |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | elsif ($user_selection ne "") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | if ($list->[($user_selection - 1 || 0)] =~ /^\[(new\sdirectory|new\sfile)\]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition0%0/2
$user_selection - 1 || 0
MC/DC0%0/1
$user_selection - 1 || 0
$user_selection - 1
Truth table0%0/2
A
A= $user_selection - 1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | my $nfn; | |||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | while (!$nfn || -e $path."/".$nfn) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $nfn or -e $path . '/' . $nfn
MC/DC0%0/2
not $nfn or -e $path . '/' . $nfn
not $nfn
-e $path . '/' . $nfn
Truth table0%0/3
not(A) or B
A= not $nfnB= -e $path . '/' . $nfn
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | $nfn = $self->inputbox | ||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | ( height=>$args->{'height'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | width=>$args->{'width'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | title=>$args->{'title'}, | |||||||||||||||||||||||||||||||||||||||||||||||
| 598 | text=>'Enter a name (will have a base directory of: '.$path.')' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | next FSEL if $self->state() eq "ESC" or $self->state() eq "CANCEL"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->state eq "ESC" or $self->state eq "CANCEL"
MC/DC0%0/2
$self->state eq "ESC" or $self->state eq "CANCEL"
$self->state eq "ESC"
$self->state eq "CANCEL"
Truth table0%0/3
A or B
A= $self->state eq "ESC"B= $self->state eq "CANCEL"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | if (-e $path."/".$nfn) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $self->msgbox | |||||||||||||||||||||||||||||||||||||||||||||||
| 603 | ( title=>'error', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | text=>$path."/".$nfn.' exists. Choose another name please.'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $user_selection = $path."/".$nfn; | |||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | $user_selection =~ s!/$!! unless $user_selection =~ m!^/$!; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $user_selection =~ s!/\./!/!g; $user_selection =~ s!/+!/!g; | |||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | last FSEL; | |||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | ▶ | elsif ($list->[($user_selection - 1 || 0)] eq "../") { | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$user_selection - 1 || 0
MC/DC0%0/1
$user_selection - 1 || 0
$user_selection - 1
Truth table0%0/2
A
A= $user_selection - 1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | $path = dirname($path); | |||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | ▶ | elsif ($list->[($user_selection - 1 || 0)] eq "./") { | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$user_selection - 1 || 0
MC/DC0%0/1
$user_selection - 1 || 0
$user_selection - 1
Truth table0%0/2
A
A= $user_selection - 1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | $user_selection = $path; | |||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | $user_selection =~ s!/$!! unless $user_selection =~ m!^/$!; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | $user_selection =~ s!/\./!/!g; $user_selection =~ s!/+!/!g; | |||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | last FSEL; | |||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | ▶ | elsif (-d $path."/".$list->[($user_selection - 1 || 0)]) { | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$user_selection - 1 || 0
MC/DC0%0/1
$user_selection - 1 || 0
$user_selection - 1
Truth table0%0/2
A
A= $user_selection - 1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | $path = $path."/".$list->[($user_selection - 1 || 0)]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$user_selection - 1 || 0
MC/DC0%0/1
$user_selection - 1 || 0
$user_selection - 1
Truth table0%0/2
A
A= $user_selection - 1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | ▶ | elsif (-e $path."/".$list->[($user_selection - 1 || 0)]) { | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$user_selection - 1 || 0
MC/DC0%0/1
$user_selection - 1 || 0
$user_selection - 1
Truth table0%0/2
A
A= $user_selection - 1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | $user_selection = $path."/".$list->[($user_selection - 1 || 0)]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$user_selection - 1 || 0
MC/DC0%0/1
$user_selection - 1 || 0
$user_selection - 1
Truth table0%0/2
A
A= $user_selection - 1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | $user_selection =~ s!/$!! unless $user_selection =~ m!^/$!; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | $user_selection =~ s!/\./!/!g; $user_selection =~ s!/+!/!g; | |||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | last FSEL; | |||||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | $user_selection = undef(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | $path =~ s!(/*)!/!; $path =~ s!/\./!/!g; | |||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | $self->_beep($args->{'beepafter'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | my $rv = $self->rv(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | $self->ra('NULL'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | if ($rv && $rv >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rv and $rv >= 1
MC/DC0%0/2
$rv and $rv >= 1
$rv
$rv >= 1
Truth table0%0/3
A and B
A= $rvB= $rv >= 1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | $self->rs('NULL'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | $self->rs($user_selection); | |||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | return($user_selection); | |||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | #: directory selection | ||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | sub dselect { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dselect: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | my $caller = (caller(1))[3] || 'main'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
(caller 1)[3] || 'main'
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
(caller 2)[3] or "main"
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | if ($_[0] && $_[0] eq 'caller') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[0] and $_[0] eq "caller"
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0]
$_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | shift(); $caller = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | my $args = $self->_pre($caller,@_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my $dirname; | |||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | $self->rv('NULL'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | $self->rs('NULL'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | $self->ra('NULL'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | while (not $dirname && $self->state() !~ /^(CANCEL|ESC|ERROR)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dirname and not $self->state =~ /^(CANCEL|ESC|ERROR)$/
MC/DC0%0/2
$dirname and not $self->state =~ /^(CANCEL|ESC|ERROR)$/
$dirname
not $self->state =~ /^(CANCEL|ESC|ERROR)$/
Truth table0%0/3
A and not(B)
A= $dirnameB= not $self->state =~ /^(CANCEL|ESC|ERROR)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $dirname = $self->fselect(@_,'dselect',1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | if ($self->state() =~ /^(CANCEL|ESC|ERROR)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | unless (not $dirname) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | # if it's a directory or not exist (assume new dir) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | unless (-d $dirname || not -e $dirname) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d $dirname or not -e $dirname
MC/DC0%0/2
-d $dirname or not -e $dirname
-d $dirname
not -e $dirname
Truth table0%0/3
A or not(B)
A= -d $dirnameB= not -e $dirname
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | $self->msgbox( text => $dirname . " is not a directory.\nPlease select a directory." ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | $dirname = undef(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | return($dirname||''); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dirname || ''
MC/DC0%0/1
$dirname || ''
$dirname
Truth table0%0/2
A
A= $dirname
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | #: Backend Methods | ||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | #: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | sub _pre { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pre: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $caller = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my $args = $self->_merge_attrs(@_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | $args->{'caller'} = $caller; | |||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | my $class = ref($self); | |||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | my $CODEREFS = $args->{'callbacks'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | if (ref($CODEREFS) eq "HASH") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my $PRECODE = $CODEREFS->{'PRE'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | if (ref($PRECODE) eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | &$PRECODE($args,$self->state()); | |||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $self->_beep($args->{'beepbefore'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $self->_clear($args->{'clearbefore'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | return($args); | |||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | sub _post { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_post: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | my $args = shift() || {}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | my $class = ref($self); | |||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | $self->_beep($args->{'beepafter'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | $self->_clear($args->{'clearafter'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | my $CODEREFS = $args->{'callbacks'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | if (ref($CODEREFS) eq "HASH") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | my $state = $self->state(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | if ($state eq "OK") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | my $OKCODE = $CODEREFS->{'OK'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | if (ref($OKCODE) eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | &$OKCODE($args); | |||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | elsif ($state eq "ESC") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | my $ESCCODE = $CODEREFS->{'ESC'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | if (ref($ESCCODE) eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | &$ESCCODE($args); | |||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | elsif ($state eq "CANCEL") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | my $CANCELCODE = $CODEREFS->{'CANCEL'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | if (ref($CANCELCODE) eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | &$CANCELCODE($args); | |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | my $POSTCODE = $CODEREFS->{'POST'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | if (ref($POSTCODE) eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | &$POSTCODE($args,$state); | |||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | #: indent and organize the text argument | ||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | sub _organize_text { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_organize_text: not called CC=20 SCAR=60.4
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | my $text = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | my $width = $_[2] || 65; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[2] || 65
MC/DC0%0/1
$_[2] || 65
$_[2]
Truth table0%0/2
A
A= $_[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | my $trust = (exists $_[3] && defined $_[3]) ? $_[3] : '0'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $_[3] and defined $_[3]
MC/DC0%0/2
exists $_[3] and defined $_[3]
exists $_[3]
defined $_[3]
Truth table0%0/3
A and B
A= exists $_[3]B= defined $_[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | $width -= 4; # take account of borders? | |||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | my @array; | |||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | if (ref($text) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | push(@array,@{$text}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | elsif ($text =~ /\\n/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | @array = split(/\\n/,$text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | @array = split(/\n/,$text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | $text = undef; | |||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | @array = $self->word_wrap($width,"","",@array); | |||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | if ($self->{'scale'}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | foreach my $line (@array) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | my $s_line = $line;#$self->__TRANSLATE_CLEAN($line); | |||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | $s_line =~ s!\[A\=\w+\]!!gi; | |||||||||||||||||||||||||||||||||||||||||||||||
| 767 | $self->{'width'} = length($s_line) + 5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | if ($self->{'width'} - 5) < length($s_line) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | && (length($s_line) <= $self->{'max-scale'}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"width"} - 5 < length $s_line and length $s_line <= $self->{"max-scale"}
MC/DC0%0/2
$self->{"width"} - 5 < length $s_line and length $s_line <= $self->{"max-scale"}
$self->{"width"} - 5 < length $s_line
length $s_line <= $self->{"max-scale"}
Truth table0%0/3
A and B
A= $self->{"width"} - 5 < length $s_lineB= length $s_line <= $self->{"max-scale"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | foreach my $line (@array) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | my $pad; | |||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | $self->clean_format( $trust, \$line ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | my $s_line = $self->_strip_text($line); | |||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | if ($line =~ /\[A\=(\w+)\]/i) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | my $align = $1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | $line =~ s!\[A\=\w+\]!!gi; | |||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | if (uc($align) eq "CENTER" || uc($align) eq "C") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
uc $align eq "CENTER" or uc $align eq "C"
MC/DC0%0/2
uc $align eq "CENTER" or uc $align eq "C"
uc $align eq "CENTER"
uc $align eq "C"
Truth table0%0/3
A or B
A= uc $align eq "CENTER"B= uc $align eq "C"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | $pad = ((($self->{'_opts'}->{'width'} - 5) - length($s_line)) / 2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | ▶ | elsif (uc($align) eq "LEFT" || uc($align) eq "L") { | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
uc $align eq "LEFT" or uc $align eq "L"
MC/DC0%0/2
uc $align eq "LEFT" or uc $align eq "L"
uc $align eq "LEFT"
uc $align eq "L"
Truth table0%0/3
A or B
A= uc $align eq "LEFT"B= uc $align eq "L"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | $pad = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | ▶ | elsif (uc($align) eq "RIGHT" || uc($align) eq "R") { | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
uc $align eq "RIGHT" or uc $align eq "R"
MC/DC0%0/2
uc $align eq "RIGHT" or uc $align eq "R"
uc $align eq "RIGHT"
uc $align eq "R"
Truth table0%0/3
A or B
A= uc $align eq "RIGHT"B= uc $align eq "R"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | $pad = (($self->{'_opts'}->{'width'} - 5) - length($s_line)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | ▶ | if ($pad) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | $text .= (" " x $pad).$line."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | $text .= $line."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | $text = $self->_strip_text($text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | chomp($text) if $text; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | return($text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | #: merge the arguments with the default attributes, and arguments override defaults. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | sub _merge_attrs { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_merge_attrs: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | my $args = (@_ % 2) ? { @_, '_odd' } : { @_ }; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | my $defs = $self->{'_opts'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | foreach my $def (keys(%$defs)) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 809 | # default unless exists | ||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | $args->{$def} = $defs->{$def} unless exists $args->{$def}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | # alias 'filename' and 'file' to path | ||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | $args->{'path'} = (($args->{'filename'}) ? $args->{'filename'} : | ||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | ($args->{'file'}) ? $args->{'file'} : | ||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | ($args->{'path'}) ? $args->{'path'} : ""); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | $args->{'clear'} = $args->{'clearbefore'} || $args->{'clearafter'} || $args->{'autoclear'} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$args->{'clearbefore'} || $args->{'clearafter'} || $args->{'autoclear'} || 0
$args->{"clearbefore"} or $args->{"clearafter"} or $args->{"autoclear"}
$args->{"clearbefore"} or $args->{"clearafter"}
MC/DC0%0/3
$args->{'clearbefore'} || $args->{'clearafter'} || $args->{'autoclear'} || 0
$args->{"clearbefore"}
$args->{"clearafter"}
$args->{"autoclear"}
Truth table0%0/4
A or B or C
A= $args->{"clearbefore"}B= $args->{"clearafter"}C= $args->{"autoclear"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | ▶ | $args->{'beep'} = $args->{'beepbefore'} || $args->{'beepafter'} || $args->{'autobeep'} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$args->{'beepbefore'} || $args->{'beepafter'} || $args->{'autobeep'} || 0
$args->{"beepbefore"} or $args->{"beepafter"} or $args->{"autobeep"}
$args->{"beepbefore"} or $args->{"beepafter"}
MC/DC0%0/3
$args->{'beepbefore'} || $args->{'beepafter'} || $args->{'autobeep'} || 0
$args->{"beepbefore"}
$args->{"beepafter"}
$args->{"autobeep"}
Truth table0%0/4
A or B or C
A= $args->{"beepbefore"}B= $args->{"beepafter"}C= $args->{"autobeep"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | return($args); | |||||||||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | #: search through the given paths for a specific variant | ||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | sub _find_bin { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 33 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_bin: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 33 | my $variant = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 827 | $self->{'PATHS'} = ((ref($self->{'PATHS'}) eq "ARRAY") ? $self->{'PATHS'} : | ||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 33 | ▶ | ($self->{'PATHS'}) ? [ $self->{'PATHS'} ] : | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | [ '/bin', '/usr/bin', '/usr/local/bin', '/opt/bin' ]); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 33 | foreach my $PATH (@{$self->{'PATHS'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 263 | ▶ | return($PATH . '/' . $variant) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | unless not -x $PATH . '/' . $variant; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 21 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | #: clean the text arguments of all colour codes, alignments and attributes. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | sub _strip_text { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip_text: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | my $text = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | $text ||= ''; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$text ||= ""
MC/DC0%0/1
$text ||= ""
$text
Truth table0%0/2
A
A= $text
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | $text =~ s!\\Z[0-7bBuUrRn]!!gmi; | |||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | $text =~ s!\[[AC]=\w+\]!!gmi; | |||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | $text =~ s!\[/?[BURN]\]!!gmi; | |||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | return($text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | #: is this a BSD system? | ||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | sub _is_bsd { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_bsd: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | return(1) if $^O =~ /bsd/i; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | #: gather a list of the contents of a directory and return it in | ||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | #: two forms, one is the "simple" list of all the filenames and the | ||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | #: other is a 'menu' list corresponding to the simple list. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | sub _list_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list_dir: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | ▶ | my $path = shift() || return(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return ())
MC/DC0%0/1
shift() || (return ())
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | my $pref = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | my $paths_only = (@_ == 1 && $_[0] == 1) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 and $_[0] == 1
MC/DC0%0/2
@_ == 1 and $_[0] == 1
@_ == 1
$_[0] == 1
Truth table0%0/3
A and B
A= @_ == 1B= $_[0] == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | my (@listing,@list); | |||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | if (opendir(GETDIR,$path)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | my @dir_data = readdir(GETDIR); | |||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | closedir(GETDIR); | |||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | if ($pref) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | push(@listing,@{$pref}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | foreach my $dir (sort(grep { -d $path."/".$_ } @dir_data)) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | push(@listing,$dir."/"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | ▶ | unless ($paths_only) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | foreach my $item (sort(grep { !-d $path."/".$_ } @dir_data)) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | push(@listing,$item); | |||||||||||||||||||||||||||||||||||||||||||||||
| 876 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | my $c = 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | foreach my $item (@listing) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | push(@list,"$c",$item); $c++; | |||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | return(\@list,\@listing); | |||||||||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | return("failed to read directory: ".$path); | |||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | sub _debug { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_debug: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | my $mesg = $_[1] || 'null debug message given!'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[1] || 'null debug message given!'
MC/DC0%0/1
$_[1] || 'null debug message given!'
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | ▶ | my $rate = $_[2] || 1; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[2] || 1
MC/DC0%0/1
$_[2] || 1
$_[2]
Truth table0%0/2
A
A= $_[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | return() unless $self->{'_opts'}->{'debug'} and $self->{'_opts'}->{'debug'} >= $rate; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_opts"}{"debug"} and $self->{"_opts"}{"debug"} >= $rate
MC/DC0%0/2
$self->{"_opts"}{"debug"} and $self->{"_opts"}{"debug"} >= $rate
$self->{"_opts"}{"debug"}
$self->{"_opts"}{"debug"} >= $rate
Truth table0%0/3
A and B
A= $self->{"_opts"}{"debug"}B= $self->{"_opts"}{"debug"} >= $rate
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | chomp($mesg); | |||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | print STDERR "Debug: ".$mesg."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | sub _error { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_error: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | ▶ | my $mesg = $_[1] || 'null error message given!'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[1] || 'null error message given!'
MC/DC0%0/1
$_[1] || 'null error message given!'
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | chomp($mesg); | |||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | print STDERR "Error: ".$mesg."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | #: really make some noise | ||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | sub _beep { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_beep: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | my $beep = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | unless (not $beep) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | ▶ | if (-x $self->{'_opts'}->{'beepbin'}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | return(eval { system($self->{'_opts'}->{'beepbin'}); 1; }); | |||||||||||||||||||||||||||||||||||||||||||||||
| 911 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | ▶ | return (1) unless $ENV{'TERM'} && $ENV{'TERM'} ne "dumb"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"TERM"} and $ENV{"TERM"} ne "dumb"
MC/DC0%0/2
$ENV{"TERM"} and $ENV{"TERM"} ne "dumb"
$ENV{"TERM"}
$ENV{"TERM"} ne "dumb"
Truth table0%0/3
A and B
A= $ENV{"TERM"}B= $ENV{"TERM"} ne "dumb"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | print STDERR "\a"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | #: The actual clear action. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | sub _clear { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clear: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | ▶ | my $clear = $_[1] || 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[1] || 0
MC/DC0%0/1
$_[1] || 0
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | # Useless with GUI based variants so we return here. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | # Is the use of the "dumb" TERM appropriate? need feedback. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | return (1) unless $ENV{'TERM'} && $ENV{'TERM'} ne "dumb"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"TERM"} and $ENV{"TERM"} ne "dumb"
MC/DC0%0/2
$ENV{"TERM"} and $ENV{"TERM"} ne "dumb"
$ENV{"TERM"}
$ENV{"TERM"} ne "dumb"
Truth table0%0/3
A and B
A= $ENV{"TERM"}B= $ENV{"TERM"} ne "dumb"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | ▶ | unless (not $clear and not $self->{'_opts'}->{'autoclear'}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$clear or $self->{"_opts"}{"autoclear"}
MC/DC0%0/2
$clear or $self->{"_opts"}{"autoclear"}
$clear
$self->{"_opts"}{"autoclear"}
Truth table0%0/3
A or B
A= $clearB= $self->{"_opts"}{"autoclear"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | ▶ | $self->{'_clear'} ||= `clear`; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_clear"} ||= `clear`
MC/DC0%0/2
$self->{"_clear"} ||= `clear`
$self->{"_clear"}
`clear`
Truth table0%0/3
A ||= B
A= $self->{"_clear"}B= `clear`
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | print STDOUT $self->{'_clear'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||