| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # DBIx::FileSystem; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Manage database tables with a simulated filesystem shell environment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Mar 2003,2018 Alexander Haderer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # License: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # along with this program; if not, write to the Free Software | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | package DBIx::FileSystem; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # for access class: return results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | ▶ | use constant OK => 0; # everything ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | use constant NOFILE => 1; # file not found in db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | use constant NFOUND => 2; # more than one entry found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | ▶ | use constant ERROR => 3; # nothing found, errorstring set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | $DBIx::FileSystem::VERSION = '2.5'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | @ISA = qw( Exporter ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | @EXPORT = qw( ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | &recreatedb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | &mainloop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | OK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | NOFILE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | NFOUND | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ERROR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | %EXPORT_TAGS = ( symbols => [ qw( OK NOFILE NFOUND ERROR ) ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | ▶ | use vars qw( $OUT $vwd $dbh ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | ▶ | use DBI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | ▶ | use Term::ReadLine; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | ▶ | use File::Temp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | ▶ | use POSIX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | ▶ | use Fcntl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ## classical interface: the shell | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # c o m m a n d s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 4 | my %commands = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ('cd'=> { func => \&com_cd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | doc => "change to directory: 'cd DIR'" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'help' => { func => \&com_help, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | doc => "display help text: 'help [command]'" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 'quit' => { func => \&com_quit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | doc => "quit it" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'ls' => { func => \&com_ls, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | doc => "list dirs and files" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 'ld'=> { func => \&com_ld, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | doc => "list long dirs and files with comments" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 'll' => { func => \&com_ll, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | doc => "list long files with comments" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 'rm' => { func => \&com_rm, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | doc => "remove file: 'rm FILE'" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 'cp' => { func => \&com_cp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | doc => "copy file: 'cp OLD NEW'" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 'cat' => { func => \&com_cat, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | doc => "show contents of a file: 'cat FILE'" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 'sum' => { func => \&com_sum, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | doc => "show summary of a file: 'sum FILE'" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 'vi' => { func => \&com_vi, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | doc => "edit/create a file: 'vi FILE'" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 'ver' => { func => \&com_ver, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | doc => "show version" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 'vgrep' => { func => \&com_vgrep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | doc => "grep var/value pairs in all files: vgrep PATTERN" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 'wrefs' => { func => \&com_wref, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | doc => "show who references a file: 'wrefs FILE'" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # C o n s t a n t s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # for ls output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | my $NUM_LS_COL = 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 4 | my $LS_COL_WIDTH = 16; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | my $EDITOR = $ENV{EDITOR}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | ▶ | $EDITOR = "/usr/bin/vi" unless $EDITOR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # m a i n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # input: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # vdirs: reference to vdir hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # PRG: program name for the shell-program | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # VERSION four digit version string for program/database version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # DBCONN DBI connect string for the database | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # DBUSER database user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # returns nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 4 | my $vdirs; # reference to vdir hash | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # $vwd ; # current virtual working directory (exported) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # my $dbh; # database handle (exported) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | my $term; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # $OUT; # the stdout (exported) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 4 | my $DBCONN; # DBI database connect string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 4 | my $DBUSER; # DBI database user | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 4 | my $DBPWD; # DBI password | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 4 | my $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | my $PRG; # program name of the shell | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub mainloop(\%$$$$$\%) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mainloop: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $customcmds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ($vdirs,$PRG,$VERSION,$DBCONN,$DBUSER,$DBPWD,$customcmds) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # merge custom commands, if any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if( defined $customcmds ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | foreach my $cucmd (keys (%{$customcmds} ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if( defined $commands{$cucmd} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | die "$PRG: redefinition of command '$cucmd' by customcommands"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | unless( defined $customcmds->{$cucmd}{func} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | die "$PRG: customcommand '$cucmd': elem func not set"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | unless( defined $customcmds->{$cucmd}{doc} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | die "$PRG: customcommand '$cucmd': elem doc not set"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $commands{$cucmd} = $customcmds->{$cucmd}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # connect to db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | ($dbh = DBI->connect( $DBCONN, $DBUSER, $DBPWD, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | {ChopBlanks => 1, AutoCommit => 1, PrintError => 0})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | || die "$PRG: connect to '$DBCONN' failed:\n", $DBI::errstr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # check vdirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if( check_vdirs_struct() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | $dbh->disconnect || die "$PRG: Disconnect failed. Reason: ", $DBI::errstr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | die "$PRG: check 'vdirs' structure in $PRG\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # check database | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if( check_db_tables() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $dbh->disconnect || die "$PRG: Disconnect failed. Reason: ", $DBI::errstr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | die "$PRG: database wrong: run '$PRG recreatedb' to recreate tables\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # readline settings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $term = new Term::ReadLine 'dbshell console'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | $OUT = $term->OUT || \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$term->OUT || \*STDOUT
MC/DC0%0/1
$term->OUT || \*STDOUT
$term->OUT
Truth table0%0/2
A
A= $term->OUT
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $term->ornaments( 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $term->Attribs->{attempted_completion_function} = \&dbshell_completion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $line; # command line | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | my $cmd; # the command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my @arg; # the command's parameters | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $prompttemplate = "$PRG (/%s): "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $prompt = sprintf( $prompttemplate, $vwd ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # the loop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | while ( defined ($line = $term->readline($prompt)) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # remove whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $line =~ s/^\s*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $line =~ s/\s*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ($cmd, @arg ) = split( ' ', $line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | next unless defined $cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $command = $commands{$cmd}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if( defined $command ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | last if &{$command->{func}}( @arg ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | print $OUT "unknown command '$cmd', try 'help'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $prompt = sprintf( $prompttemplate, $vwd ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $dbh->disconnect || die "$PRG: Disconnect failed. Reason: ", $DBI::errstr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub recreatedb(\%$$$$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recreatedb: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ($vdirs,$PRG,$VERSION,$DBCONN,$DBUSER,$DBPWD) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # connect to db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | ($dbh = DBI->connect( $DBCONN, $DBUSER, $DBPWD, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | {ChopBlanks => 1, AutoCommit => 1, PrintError => 0})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | || die "$PRG: connect to '$DBCONN' failed:\n", $DBI::errstr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # check vdirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if( check_vdirs_struct() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | die "$PRG: check 'vdirs' structure in $PRG\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | recreate_db_tables(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | $dbh->disconnect || die "$PRG: Disconnect failed. Reason: ", $DBI::errstr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # c o m m a n d f u n c t i o n s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # com_help() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub com_help() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_help: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | if( defined $arg ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if( defined $commands{$arg} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | print $OUT "$arg\t$commands{$arg}->{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | print $OUT "no help for '$arg'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | foreach my $i (sort keys(%commands) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | print $OUT "$i\t$commands{$i}->{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # com_ls() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub com_ls() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_ls: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | my $i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if( defined $x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | print $OUT "ls: usage: $commands{ls}->{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # get dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | foreach $i (sort keys(%{$vdirs}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | push @files, "($i)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # get files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if( length($vwd) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $col = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $st = $dbh->prepare("select $col from $vwd order by $col"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | print $OUT "$PRG: can't prepare ls query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | unless( $st->execute() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | print $OUT "$PRG: can't exec ls query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | while( $i = $st->fetchrow_array() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | push @files, "$i"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # show it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $numrow = int( $#files / $NUM_LS_COL ) + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $r = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $c = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $placeh = $LS_COL_WIDTH - 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | for( $r=0; $r<$numrow; $r++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | for( $c=0; $c<$NUM_LS_COL; $c++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $i = $c*$numrow+$r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | printf $OUT "%-${placeh}s ", $files[$i] if $i <= $#files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | print $OUT "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | # com_ld() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub com_ld() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_ld: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | my @com; # comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if( defined $x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | print $OUT "ls: usage: $commands{ld}->{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # get dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | foreach $i (sort keys(%{$vdirs}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | push @files, "($i)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | push @com, $vdirs->{$i}{desc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # show it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my $maxlen = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | foreach $i (@files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | if( length($i) > $maxlen ) {$maxlen = length($i); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | for( $i=0; $i<=$#files; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | printf $OUT "%-${maxlen}s| %s\n", $files[$i], $com[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | print $OUT "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | com_ll(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # com_ll() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | sub com_ll() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_ll: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | my @com; # comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if( defined $x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | print $OUT "ls: usage: $commands{ll}->{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # get files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | if( defined $vdirs->{$vwd}{comcol} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my $comcol = $vdirs->{$vwd}{comcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $col = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $st = $dbh->prepare("select $col, $comcol from $vwd order by $col"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | print $OUT "$PRG: can't prepare ll query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | unless( $st->execute() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | print $OUT "$PRG: can't exec ll query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | while( ($i,$c) = $st->fetchrow_array() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | $c = "" unless defined $c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | push @files, "$i"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | push @com, "$c"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $col = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $st = $dbh->prepare("select $col from $vwd order by $col"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | print $OUT "$PRG: can't prepare ls query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | unless( $st->execute() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | print $OUT "$PRG: can't exec ls query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | while( $i = $st->fetchrow_array() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | push @files, "$i"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | push @com, ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # show it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my $maxlen = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | foreach $i (@files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | if( length($i) > $maxlen ) {$maxlen = length($i); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | for( $i=0; $i<=$#files; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | printf $OUT "%-${maxlen}s| %s\n", $files[$i], $com[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | # com_cd() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | sub com_cd() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_cd: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my ($arg,$x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if( defined $arg and !defined $x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg and not defined $x
MC/DC0%0/2
defined $arg and not defined $x
defined $arg
not defined $x
Truth table0%0/3
A and not(B)
A= defined $argB= not defined $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | if( exists $vdirs->{$arg} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $vwd = "$arg"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | print $OUT "no such directory '$arg'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | print $OUT "cd: usage: $commands{cd}->{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # com_quit() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | sub com_quit() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_quit: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # com_ver() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | sub com_ver() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_ver: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | print $OUT " DBIx-FileSystem Version: $DBIx::FileSystem::VERSION\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | print $OUT " $PRG \%vdirs version: $VERSION\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # com_rm() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | sub com_rm() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_rm: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my ($arg,$x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | if( defined $arg and !defined $x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg and not defined $x
MC/DC0%0/2
defined $arg and not defined $x
defined $arg
not defined $x
Truth table0%0/3
A and not(B)
A= defined $argB= not defined $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | if( $vdirs->{$vwd}{edit} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if( $vdirs->{$vwd}{defaultfile} and $vdirs->{$vwd}{defaultfile} eq $arg ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} and $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} eq $arg
MC/DC0%0/2
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} and $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} eq $arg
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"}
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} eq $arg
Truth table0%0/3
A and B
A= $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"}B= $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} eq $arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | print $OUT "rm: error: cannot remove default file '$arg'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my @reffiles = get_who_refs_me( $vwd, $arg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if( $#reffiles == -1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my $rmerr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | if( exists $vdirs->{$vwd}{rmcheck} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $rmerr = &{$vdirs->{$vwd}->{rmcheck}}( $vwd, $arg, $dbh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | if( defined $rmerr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | print $OUT "rm: cannot remove: $rmerr\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $fnc = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $r = $dbh->do( "delete from $vwd where $fnc='$arg'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | if( !defined $r ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | print $OUT "rm: database error:\n" . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | }elsif( $r==0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | print $OUT "rm: no such file '$arg'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | print $OUT "rm: cannot remove: file '$arg' referenced by:\n "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | print $OUT join( "\n ", @reffiles ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | print $OUT "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | print $OUT "rm: error: read only directory '/$vwd'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | print $OUT "rm: usage: $commands{rm}{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # com_cp() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | sub com_cp() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_cp: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my ($old,$new,$x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | if( defined $old and defined $new and !defined $x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $old and defined $new and not defined $x
defined $old and defined $new
MC/DC0%0/3
defined $old and defined $new and not defined $x
defined $old
defined $new
not defined $x
Truth table0%0/4
A and B and not(C)
A= defined $oldB= defined $newC= not defined $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | if( $vdirs->{$vwd}{edit} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | my $fnc = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | if( (length($new)<=$vdirs->{$vwd}{cols}{$fnc}{len}) and !($new=~/\W+/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $new <= $vdirs->{$DBIx::FileSystem::vwd}{"cols"}{$fnc}{"len"} and not $new =~ /\W+/
MC/DC0%0/2
length $new <= $vdirs->{$DBIx::FileSystem::vwd}{"cols"}{$fnc}{"len"} and not $new =~ /\W+/
length $new <= $vdirs->{$DBIx::FileSystem::vwd}{"cols"}{$fnc}{"len"}
not $new =~ /\W+/
Truth table0%0/3
A and not(B)
A= length $new <= $vdirs->{$DBIx::FileSystem::vwd}{"cols"}{$fnc}{"len"}B= not $new =~ /\W+/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my $fnc = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my $insert = "insert into $vwd ("; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | my $select = "select "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | my $cols = $vdirs->{$vwd}{cols}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | foreach my $col (sort keys(%{$cols}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $insert .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | if( $col eq $fnc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $select .= "'$new',"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | }elsif( exists $vdirs->{$vwd}{cols}{$col}{uniq} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | $select .= "NULL,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | }elsif( exists $vdirs->{$vwd}{cols}{$col}{cpdelete} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $select .= "NULL,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $select .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | chop $insert; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | chop $select; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $insert .= ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $select .= " from $vwd where $fnc='$old'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $r = $dbh->do( "$insert $select"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | if( !defined $r or $r!=1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $r or $r != 1
MC/DC0%0/2
not defined $r or $r != 1
not defined $r
$r != 1
Truth table0%0/3
not(A) or B
A= not defined $rB= $r != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | print "cp: error: no file '$old' or file '$new' exists\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | print $OUT "cp: error: illegal or to long filename '$new'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | print $OUT "cp: error: read only directory '/$vwd'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | print $OUT "cp: usage: $commands{cp}{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # com_sum() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | sub com_sum() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_sum: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | my ($arg,$x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | if( defined $arg and !defined $x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg and not defined $x
MC/DC0%0/2
defined $arg and not defined $x
defined $arg
not defined $x
Truth table0%0/3
A and not(B)
A= defined $argB= not defined $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | if( print_file( $OUT, $arg, 0 ) == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | print $OUT "sum: no such file '$arg'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | print $OUT "sum: usage: $commands{sum}{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # com_cat() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | sub com_cat() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_cat: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my ($arg,$x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | if( defined $arg and !defined $x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg and not defined $x
MC/DC0%0/2
defined $arg and not defined $x
defined $arg
not defined $x
Truth table0%0/3
A and not(B)
A= defined $argB= not defined $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | if( print_file( $OUT, $arg, 1 ) == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | print $OUT "cat: no such file '$arg'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | print $OUT "cat: usage: $commands{cat}{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # com_vi() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | sub com_vi() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_vi: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my ($arg,$x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $tmpf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | my $tmpf_mtime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my $r; # 0: file printed exists / create update SQL string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | ; # 1: file printed did not exist / create insert SQL string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | my $sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my $ln = 1; # line number where editor starts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | if( defined $arg and !defined $x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg and not defined $x
MC/DC0%0/2
defined $arg and not defined $x
defined $arg
not defined $x
Truth table0%0/3
A and not(B)
A= defined $argB= not defined $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | if( $vdirs->{$vwd}{edit} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my $fnc = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | if( (length($arg)<=$vdirs->{$vwd}{cols}{$fnc}{len}) and !($arg=~/\W+/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $arg <= $vdirs->{$DBIx::FileSystem::vwd}{"cols"}{$fnc}{"len"} and not $arg =~ /\W+/
MC/DC0%0/2
length $arg <= $vdirs->{$DBIx::FileSystem::vwd}{"cols"}{$fnc}{"len"} and not $arg =~ /\W+/
length $arg <= $vdirs->{$DBIx::FileSystem::vwd}{"cols"}{$fnc}{"len"}
not $arg =~ /\W+/
Truth table0%0/3
A and not(B)
A= length $arg <= $vdirs->{$DBIx::FileSystem::vwd}{"cols"}{$fnc}{"len"}B= not $arg =~ /\W+/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my $fh = File::Temp->new( UNLINK => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | TEMPLATE => "${arg}.XXXXXXXX", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | TMPDIR => 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $tmpf = $fh->filename(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $r = print_file( $fh, $arg, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | close( $fh ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | $tmpf_mtime = (stat $tmpf)[9]; # remember mtime of tempfile | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | if( $r==0 or $r==1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$r == 0 or $r == 1
MC/DC0%0/2
$r == 0 or $r == 1
$r == 0
$r == 1
Truth table0%0/3
A or B
A= $r == 0B= $r == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | while( 1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | system( "$EDITOR +$ln $tmpf" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ($ln,$err,$sql) = create_sql_from_file( $tmpf, $vwd, $arg, $r ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | if( defined $err ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my $inp = want_to_edit_again( $err ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | next if $inp eq 'y'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | last if $inp eq 'n'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | ### print $OUT ">>>$sql<<<\n"; ######### hierhierhier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if( length($sql) and $tmpf_mtime != (stat $tmpf)[9] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $sql and $tmpf_mtime != (stat $tmpf)[9]
MC/DC0%0/2
length $sql and $tmpf_mtime != (stat $tmpf)[9]
length $sql
$tmpf_mtime != (stat $tmpf)[9]
Truth table0%0/3
A and B
A= length $sqlB= $tmpf_mtime != (stat $tmpf)[9]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my $res = $dbh->do( $sql ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | if( !defined $res ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $inp=want_to_edit_again( "save to database:\n".$dbh->errstr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | if($inp eq 'y') { $ln = 1; next; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | }elsif( $res == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | print $OUT "\n\n\n\n\nvi: nothing saved\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | print $OUT "\n\n\n\n\nvi: nothing saved\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | print $OUT "vi: no such file '$arg'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | unlink( $tmpf ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | print $OUT "vi: error: illegal or too long filename '$arg'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | print $OUT "vi: error: read only directory '/$vwd'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | print $OUT "vi: usage: $commands{vi}{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | # com_wref() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | sub com_wref() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_wref: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my ($arg,$x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | if( defined $arg and !defined $x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg and not defined $x
MC/DC0%0/2
defined $arg and not defined $x
defined $arg
not defined $x
Truth table0%0/3
A and not(B)
A= defined $argB= not defined $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | my @reffiles = get_who_refs_me( $vwd, $arg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | if( $#reffiles > -1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | print $OUT join( "\n", @reffiles ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | print $OUT "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | print $OUT "wrefs: no one references '$arg'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | print $OUT "wrefs: usage: $commands{wrefs}{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # com_vgrep() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | sub com_vgrep() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
com_vgrep: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | my ($arg,$x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | if( defined $arg and !defined $x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg and not defined $x
MC/DC0%0/2
defined $arg and not defined $x
defined $arg
not defined $x
Truth table0%0/3
A and not(B)
A= defined $argB= not defined $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | do_vgrep( $arg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | print $OUT "vgrep: usage: $commands{vgrep}{doc}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | # c o m p l e t i o n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | # from p5-ReadLine example 'FileManager' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | # Attempt to complete on the contents of TEXT. START and END bound | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | # the region of rl_line_buffer that contains the word to complete. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | # TEXT is the word to complete. We can use the entire contents of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # rl_line_buffer in case we want to do some simple parsing. Return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | # the array of matches, or NULL if there aren't any. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | sub dbshell_completion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbshell_completion: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my ($text, $line, $start, $end) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my @matches = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | # If this word is at the start of the line, then it is a command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # to complete. Otherwise it is the name of a file in the current | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | # directory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | if ($start == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | @matches = $term->completion_matches($text, \&command_generator); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | }elsif($line =~ /^cd\s.*/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | @matches = $term->completion_matches($text, \&vdir_generator); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | @matches = $term->completion_matches($text, \&vfile_generator); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | return @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | # from p5-ReadLine example 'FileManager' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | # Generator function for command completion. STATE lets us know | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | # whether to start from scratch; without any state (i.e. STATE == 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # then we start at the top of the list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | ## Term::ReadLine::Gnu has list_completion_function similar with this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | ## function. I defined new one to be compared with original C version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 4 | my $list_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 4 | my @name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | sub command_generator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command_generator: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | my ($text, $state) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | $text =~ s/\./\\\./g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | $text =~ s/\*/\\\*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $text =~ s/\[/\\\[/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | $text =~ s/\]/\\\]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | $text =~ s/\$/\\\$/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | $text =~ s/\^/\\\^/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | # If this is a new word to complete, initialize now. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # includes saving the length of TEXT for efficiency, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # initializing the index variable to 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | unless ($state) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | $list_index = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | @name = keys(%commands); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | # Return the next name which partially matches from the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # command list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | while ($list_index <= $#name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | $list_index++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | return $name[$list_index - 1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | if ($name[$list_index - 1] =~ /^$text/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | # If no names matched, then return NULL. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 4 | my $list_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 4 | my @name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | ▶ | sub vdir_generator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vdir_generator: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | my ($text, $state) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $text =~ tr/a-zA-Z0-9_\///cd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $text =~ s/\./\\\./g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | $text =~ s/\*/\\\*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | $text =~ s/\[/\\\[/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | $text =~ s/\]/\\\]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | $text =~ s/\$/\\\$/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | $text =~ s/\^/\\\^/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | # If this is a new word to complete, initialize now. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | # includes saving the length of TEXT for efficiency, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | # initializing the index variable to 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | unless ($state) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | $list_index = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | @name = keys(%{$vdirs}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | # Return the next name which partially matches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | while ($list_index <= $#name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | $list_index++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | return $name[$list_index - 1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | if ($name[$list_index - 1] =~ /^$text/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | # If no names matched, then return NULL. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 4 | my $list_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 4 | my @name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | sub vfile_generator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vfile_generator: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | my ($text, $state) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | $text =~ tr/a-zA-Z0-9_\///cd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | $text =~ s/\./\\\./g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | $text =~ s/\*/\\\*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | $text =~ s/\[/\\\[/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | $text =~ s/\]/\\\]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | $text =~ s/\$/\\\$/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | $text =~ s/\^/\\\^/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | unless ($state) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | undef @name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | $list_index = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | my $col = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | $st = $dbh->prepare("select $col from $vwd order by $col"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | print $OUT "$PRG: prep completion query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | unless( $st->execute() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | print $OUT "$PRG: exec completion query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | ▶ | while( $i = $st->fetchrow_array() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | push @name, $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | # Return the next name which partially matches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | while ($list_index <= $#name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $list_index++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | ▶ | return $name[$list_index - 1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | if ($name[$list_index - 1] =~ /^$text/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | # If no names matched, then return NULL. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | # c h e c k i n g & c r e a t i o n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | # check_vdirs_struct() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 4 | ▶ | sub check_vdirs_struct() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_vdirs_struct: not called CC=54 SCAR=79.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | my $pre = "internal error: vdirs structure:\n "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | foreach my $dir (keys(%{$vdirs}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | # init refby: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | # a hash holding the dir (key) and list of columns (value) this dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | # is referenced by. Will be set up 57 lines later (# setup refby) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | $vdirs->{$dir}->{refby} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | foreach my $dir (sort keys(%{$vdirs}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | ▶ | $vwd = $dir unless defined $vwd; # set $vwd to alphabetic first dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | ▶ | unless( defined $vdirs->{$dir}->{desc}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | print "$pre dir '$dir': 'desc' missing\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | unless( defined $vdirs->{$dir}->{edit}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | print "$pre dir '$dir': 'edit' missing\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | unless( defined $vdirs->{$dir}->{cols}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | print "$pre dir '$dir': 'cols' missing\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | ▶ | unless( defined $vdirs->{$dir}->{refby}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | print "$pre dir '$dir': 'refby' missing \n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | my $fnamcol = $vdirs->{$dir}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | unless( defined $fnamcol) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | print "$pre dir '$dir': 'fnamcol' missing\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | ▶ | unless( defined $vdirs->{$dir}{cols}{$fnamcol} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | print "$pre dir '$dir', fnamcol set to '$fnamcol', but column missing\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | if( $vdirs->{$dir}{cols}{$fnamcol}{type} ne 'char' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | print "$pre dir '$dir', fnamcol-column '$fnamcol' type must be 'char'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | if( $vdirs->{$dir}{edit} == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | ▶ | unless( defined $vdirs->{$dir}{cols}{$fnamcol}{len} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | print "$pre dir '$dir', fnamcol-column '$fnamcol': missing 'len'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | ▶ | if( $vdirs->{$dir}{cols}{$fnamcol}{len} + 2 > $LS_COL_WIDTH ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | my $maxlen = $LS_COL_WIDTH - 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | print "$pre dir '$dir', fnamcol-column '$fnamcol' len > $maxlen\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | my $comcol = $vdirs->{$dir}{comcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | if( defined $comcol) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | unless( defined $vdirs->{$dir}{cols}{$comcol} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | print "$pre dir '$dir', comcol set to '$comcol', but column missing\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | ▶ | if( $vdirs->{$dir}{cols}{$comcol}{type} ne 'char' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | print "$pre dir '$dir', comcol-column '$comcol' type must be 'char'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | ▶ | unless( defined $vdirs->{$dir}{cols}{$comcol}{len} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | print "$pre dir '$dir', comcol-column '$comcol': missing 'len'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | my %varnames = (); # duplicate check: key=varname value=column name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | my $cols = $vdirs->{$dir}{cols}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | foreach my $col (keys(%{$cols} )) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | # check for deprecated 'delcp' option | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | ▶ | if( exists $cols->{$col}{delcp} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | $cols->{$col}{uniq} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | print "\nWARNING: $PRG: internal vdirs struct:\n dir '$dir', column '$col', option 'delcp' deprecated, use 'uniq'\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | # check for 'type' / 'ref' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | ▶ | unless( defined $cols->{$col}{type} || defined $cols->{$col}{ref} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $cols->{$col}{"type"} or defined $cols->{$col}{"ref"}
MC/DC0%0/2
defined $cols->{$col}{"type"} or defined $cols->{$col}{"ref"}
defined $cols->{$col}{"type"}
defined $cols->{$col}{"ref"}
Truth table0%0/3
A or B
A= defined $cols->{$col}{"type"}B= defined $cols->{$col}{"ref"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | print "$pre dir '$dir', column '$col', either 'type' or 'ref' must be set\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | if( defined $cols->{$col}{ref} and !defined $vdirs->{$cols->{$col}{ref}}){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $cols->{$col}{"ref"} and not defined $$vdirs{$cols->{$col}{"ref"}}
MC/DC0%0/2
defined $cols->{$col}{"ref"} and not defined $$vdirs{$cols->{$col}{"ref"}}
defined $cols->{$col}{"ref"}
not defined $$vdirs{$cols->{$col}{"ref"}}
Truth table0%0/3
A and not(B)
A= defined $cols->{$col}{"ref"}B= not defined $$vdirs{$cols->{$col}{"ref"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | print "$pre dir '$dir', column '$col', elem 'ref': no dir '$cols->{$col}{ref}'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | # check for flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | ▶ | if( exists $cols->{$col}{flags} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | ▶ | if( $cols->{$col}{type} ne 'int' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | print "$pre dir '$dir', column '$col', when using 'flags' type must be 'int'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | ▶ | unless( ref( $cols->{$col}{flags} ) eq "HASH" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | print "$pre dir '$dir', column '$col', 'flags' must be a hash\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | foreach my $i (sort keys(%{$cols->{$col}{flags} }) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | ▶ | if( $i =~ /\D/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | print "$pre dir '$dir', column '$col', flags: bitno must be an int\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | ▶ | unless( ref( $cols->{$col}{flags}{$i} ) eq "ARRAY" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | print "$pre dir '$dir', column '$col', bitno '$i': missing array with flagname + flagdescritpion\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | unless( defined $cols->{$col}{flags}{$i}->[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | print "$pre dir '$dir', column '$col', bitno '$i': missing flagname\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | if( $cols->{$col}{flags}{$i}->[0] =~ / / ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | print "$pre dir '$dir', column '$col', bitno '$i': flagname must be a single word\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | unless( defined $cols->{$col}{flags}{$i}->[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | print "$pre dir '$dir', column '$col', bitno '$i': missing flagdescription\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | # check for enums | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | if( exists $cols->{$col}{enums} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | ▶ | if( $cols->{$col}{type} ne 'int' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | print "$pre dir '$dir', column '$col', when using 'enums' type must be 'int'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | unless( ref( $cols->{$col}{enums} ) eq "HASH" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | print "$pre dir '$dir', column '$col', 'enums' must be a hash\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | foreach my $i (sort keys(%{$cols->{$col}{enums} }) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | if( $i =~ /\D/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | print "$pre dir '$dir', column '$col', enums: enumvalue must be an int\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | ▶ | unless( ref( $cols->{$col}{enums}{$i} ) eq "ARRAY" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | print "$pre dir '$dir', column '$col', enumvalue '$i': missing array with enumname + enumdescritpion\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | ▶ | unless( defined $cols->{$col}{enums}{$i}->[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | print "$pre dir '$dir', column '$col', enumvalue '$i': missing enumname\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | ▶ | if( $cols->{$col}{enums}{$i}->[0] =~ / / ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | print "$pre dir '$dir', column '$col', enumvalue '$i': enumname must be a single word\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | ▶ | unless( defined $cols->{$col}{enums}{$i}->[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | print "$pre dir '$dir', column '$col', enumvalue '$i': missing enumdescription\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | # setup refby | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | ▶ | if( defined $cols->{$col}{ref} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | push @{$vdirs->{$cols->{$col}{ref}}{refby}{$dir} }, $col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | ▶ | if( defined $cols->{$col}{type} and $vdirs->{$dir}{edit}==1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $cols->{$col}{"type"} and $vdirs->{$dir}{"edit"} == 1
MC/DC0%0/2
defined $cols->{$col}{"type"} and $vdirs->{$dir}{"edit"} == 1
defined $cols->{$col}{"type"}
$vdirs->{$dir}{"edit"} == 1
Truth table0%0/3
A and B
A= defined $cols->{$col}{"type"}B= $vdirs->{$dir}{"edit"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | ▶ | if( $cols->{$col}{type} ne 'char' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/12
$cols->{$col}{"type"} ne "char" and $cols->{$col}{"type"} ne "int" and $cols->{$col}{"type"} ne "smallint" and $cols->{$col}{"type"} ne "inet" and $cols->{$col}{"type"} ne "cidr"
$cols->{$col}{"type"} ne "char" and $cols->{$col}{"type"} ne "int" and $cols->{$col}{"type"} ne "smallint" and $cols->{$col}{"type"} ne "inet"
$cols->{$col}{"type"} ne "char" and $cols->{$col}{"type"} ne "int" and $cols->{$col}{"type"} ne "smallint"
$cols->{$col}{"type"} ne "char" and $cols->{$col}{"type"} ne "int"
MC/DC0%0/5
$cols->{$col}{"type"} ne "char" and $cols->{$col}{"type"} ne "int" and $cols->{$col}{"type"} ne "smallint" and $cols->{$col}{"type"} ne "inet" and $cols->{$col}{"type"} ne "cidr"
$cols->{$col}{"type"} ne "char"
$cols->{$col}{"type"} ne "int"
$cols->{$col}{"type"} ne "smallint"
$cols->{$col}{"type"} ne "inet"
$cols->{$col}{"type"} ne "cidr"
Truth table0%0/6
A and B and C and D and E
A= $cols->{$col}{"type"} ne "char"B= $cols->{$col}{"type"} ne "int"C= $cols->{$col}{"type"} ne "smallint"D= $cols->{$col}{"type"} ne "inet"E= $cols->{$col}{"type"} ne "cidr"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | $cols->{$col}{type} ne 'int' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | $cols->{$col}{type} ne 'smallint' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | $cols->{$col}{type} ne 'inet' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | $cols->{$col}{type} ne 'cidr' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | print "$pre dir '$dir', column '$col', type must be one of char/int/smallint/inet/cidr when edit=1\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | unless( defined $cols->{$col}{var} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | print "$pre dir '$dir', column '$col', missing elem 'var'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | ▶ | unless( defined $cols->{$col}{desc} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | print "$pre dir '$dir', column '$col', missing elem 'desc'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | ▶ | unless( defined $cols->{$col}{pos} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | print "$pre dir '$dir', column '$col', missing elem 'pos'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | # check for duplicate var | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | my $varname = $cols->{$col}{var}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | ▶ | if( defined $varnames{ $varname } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | print "$pre dir '$dir', var '$varname' used for columns '$col' and '$varnames{$varname}'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | $varnames{ $varname } = $col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | # check_db_tables() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | ▶ | sub check_db_tables() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_db_tables: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | # check version no of db tables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | $st = $dbh->prepare("select value from tablestatus where tag='version' "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | print "$PRG: can't prepare query 'version':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | ▶ | unless( $st->execute() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | print "$PRG: can't execute query 'version':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | my ($dbversion) = $st->fetchrow_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | ▶ | unless( $dbversion ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | print "$PRG: can't query db: table version\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | ▶ | if( $VERSION ne $dbversion ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | "$PRG: version mismatch: $PRG='$VERSION' dbtables='$dbversion'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | # check (existence) of other tables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | foreach my $i (sort keys(%{$vdirs}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | $st = $dbh->prepare("select * from $i limit 1"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | print "$PRG: can't prepare query '$i':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | ▶ | unless( $st->execute() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | print "$PRG: can't execute query '$i':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | my @dummy = $st->fetchrow_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | return 0; # all Ok | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | # recreate_db_tables(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | ▶ | sub recreate_db_tables() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recreate_db_tables: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | my $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | $dbh->do( "drop table tablestatus" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | $r = $dbh->do( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | qq{ create table tablestatus ("tag" char(16), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | "value" char(16) PRIMARY KEY) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | ▶ | unless( $r ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | print "$PRG: create table tablestatus:\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | $r = $dbh->do( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | qq{ insert into tablestatus (tag, value) values ('version','$VERSION' )}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | ▶ | unless( $r ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | print "$PRG: insert version into tablestatus:\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | # recreate other tables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | foreach my $tab (sort keys(%{$vdirs}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | $dbh->do( "drop table $tab" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | my $create = "create table $tab ("; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | my $cols = $vdirs->{$tab}{cols}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | foreach my $col (keys(%{$cols}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | ▶ | if( defined $cols->{$col}{ref} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 0 | my $rdir = $cols->{$col}{ref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | my $rfnc = $vdirs->{$rdir}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | ▶ | if( defined $vdirs->{$rdir}{cols}{$rfnc}{len} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | $create .= "$col $vdirs->{$rdir}{cols}{$rfnc}{type}($vdirs->{$rdir}{cols}{$rfnc}{len})"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | $create .= "$col $vdirs->{$rdir}{cols}{$rfnc}{type}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | if( defined $cols->{$col}{len} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | $create .= "$col $cols->{$col}{type}($cols->{$col}{len})"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | $create .= "$col $cols->{$col}{type}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | ▶ | $create .= " $cols->{$col}{colopt}" if defined $cols->{$col}{colopt}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | $create .= ","; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | chop $create; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | $create .= ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | $r = $dbh->do( $create ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | ▶ | unless( $r ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | print "$PRG: create table $tab:\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | ▶ | my $df = $vdirs->{$tab}{defaultfile} if exists $vdirs->{$tab}{defaultfile}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | ▶ | if( $df ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | my $fnc = $vdirs->{$tab}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | ▶ | if( (length($df)<=$vdirs->{$tab}{cols}{$fnc}{len}) and !($df=~/\W+/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $df <= $vdirs->{$tab}{"cols"}{$fnc}{"len"} and not $df =~ /\W+/
MC/DC0%0/2
length $df <= $vdirs->{$tab}{"cols"}{$fnc}{"len"} and not $df =~ /\W+/
length $df <= $vdirs->{$tab}{"cols"}{$fnc}{"len"}
not $df =~ /\W+/
Truth table0%0/3
A and not(B)
A= length $df <= $vdirs->{$tab}{"cols"}{$fnc}{"len"}B= not $df =~ /\W+/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | $r = $dbh->do( "insert into $tab ($fnc) values ('$df')"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | ▶ | if( !defined $r or $r==0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $r or $r == 0
MC/DC0%0/2
not defined $r or $r == 0
not defined $r
$r == 0
Truth table0%0/3
not(A) or B
A= not defined $rB= $r == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | print "ERROR: couldn't create default entry '$df' in '/$tab':" . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | $dbh->errstr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | print "ERROR: illegal or to long default filename '$df' in '/$tab'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | } # recreate_db_tables() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | # print_file( FH, fnam, verbose ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | # create new pseudo file for cat/vi from database | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | # FH: file handle for output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | # fnam: the filename (key from db) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | # verbose: 0: exclude comments, print only if fnam exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | # 1: include comments, print only if fnam exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | # 2: include comments, always print: print values if fnam exists, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | # else print NULL values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | # return: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | # 0: Ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | # 1: file does not exist, (but NULL valued file was printed if verbose=2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | # 2: other error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | ▶ | sub print_file() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_file: not called CC=33 SCAR=70.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | my $FH = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | my $fnam = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | my $verbose = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | my @vars; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | my @dbvars; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | my $var; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | my $maxvarlen = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | my @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | my @defaults; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | my @descs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | my @isref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | my @flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | my @enums; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | my $select = "select "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | my $retval = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | # prepare db query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | my $fnc = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | my $cols = $vdirs->{$vwd}{cols}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | foreach my $col (sort {$cols->{$a}{pos} <=> $cols->{$b}{pos}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | keys(%{$cols}) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | ▶ | next if $col eq $fnc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | $var = $cols->{$col}{var}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | ▶ | if( length($var) > $maxvarlen ) {$maxvarlen = length($var); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | push @vars, $var; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | push @dbvars,$col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | push @descs, $cols->{$col}{desc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | ▶ | push @isref, exists $cols->{$col}{ref} ? $cols->{$col}{ref} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | ▶ | push @flags, exists $cols->{$col}{flags} ? $cols->{$col}{flags} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | ▶ | push @enums, exists $cols->{$col}{enums} ? $cols->{$col}{enums} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | $select .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | chop $select; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | $select .= " from $vwd where $fnc=?"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | # query db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | $st = $dbh->prepare( $select ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | print $FH "$PRG: can't prep print query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | ▶ | unless( $st->execute( $fnam ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | print $FH "$PRG: can't exec print query 1 '$vwd' :\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | @values = $st->fetchrow_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | ▶ | if( $vdirs->{$vwd}{defaultfile} and $vdirs->{$vwd}{defaultfile} ne $fnam ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} and $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
MC/DC0%0/2
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} and $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"}
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
Truth table0%0/3
A and B
A= $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"}B= $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | ▶ | unless( $st->execute( $vdirs->{$vwd}{defaultfile} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | print $FH "$PRG: can't exec print query 2 '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | @defaults = $st->fetchrow_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | # print it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | my $em = "*unset*"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | ▶ | if( $verbose == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 0 | ▶ | if( @values ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | # print short version (command 'sum') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | $retval = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | ▶ | for( my $i=0; $i<= $#values; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | ▶ | print $FH &var_value_s( $maxvarlen, $vars[$i], $values[$i], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | $defaults[$i], $flags[$i], $enums[$i], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | @defaults ? 1 : 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | $retval = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | # verbose == 1: (print long) 2: (print long, even if file does not exist) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | my $newfilemsg = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | my $print_it = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | ▶ | if( @values ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | # file exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | $retval = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | $print_it = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | # file does not exist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | $retval = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | ▶ | if( $verbose == 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | $newfilemsg = "#\n# NEW FILE NEW FILE NEW FILE NEW FILE\n#\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | $print_it = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | ▶ | for( my $i=0; $i<= $#vars; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | $values[$i] = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | ▶ | if( $print_it == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | # command 'cat/vi': long version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | print $FH "$newfilemsg" ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | print $FH "#\n# Settings for $vdirs->{$vwd}{cols}{$fnc}{desc} '$fnam'" ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | ▶ | if( $vdirs->{$vwd}{defaultfile} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} and $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
MC/DC0%0/2
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} and $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"}
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
Truth table0%0/3
A and B
A= $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"}B= $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | $vdirs->{$vwd}{defaultfile} ne $fnam ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | print $FH " (defaults: '$vdirs->{$vwd}{defaultfile}')"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | print $FH "\n#\n". | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | "# - this is a comment, comments always start in the first column.\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | "# - all lines begin in the first column or are blank lines\n". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | "# - a unset variable will write NULL into the database column\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 0 | ▶ | if( $vdirs->{$vwd}{defaultfile} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} and $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
MC/DC0%0/2
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} and $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"}
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
Truth table0%0/3
A and B
A= $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"}B= $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | $vdirs->{$vwd}{defaultfile} ne $fnam ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | print $FH "# - unset variables use the default values\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | print $FH "#\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | ▶ | for( my $i=0; $i<= $#values; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | # variable with comment header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | printf $FH "\n# %-50s(%s)\n", $vars[$i], $dbvars[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | foreach my $descline (split '\n', $descs[$i] ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | print $FH "# $descline\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | print $FH "#\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | ▶ | if( @defaults ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | my $def; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | ▶ | if( defined $defaults[$i] and defined $flags[$i] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
defined $defaults[$i] and defined $flags[$i]
MC/DC0%0/2
defined $defaults[$i] and defined $flags[$i]
defined $defaults[$i]
defined $flags[$i]
Truth table0%0/3
A and B
A= defined $defaults[$i]B= defined $flags[$i]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | $def = build_flags( $defaults[$i], $flags[$i] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | ▶ | }elsif( defined $defaults[$i] and defined $enums[$i] ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $defaults[$i] and defined $enums[$i]
MC/DC0%0/2
defined $defaults[$i] and defined $enums[$i]
defined $defaults[$i]
defined $enums[$i]
Truth table0%0/3
A and B
A= defined $defaults[$i]B= defined $enums[$i]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | $def = build_enums( $defaults[$i], $enums[$i] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | }elsif( defined $defaults[$i] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | $def = $defaults[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | print $FH "# default: "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | ▶ | print $FH defined $def ? "$def\n#\n" : "$em\n#\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | print $FH &var_value_v( $vars[$i],$values[$i],$isref[$i], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | $flags[$i],$enums[$i] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 0 | print $FH "\n# end of file '$fnam'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | return $retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | } # print_file() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | # var_value_v( var, value, ref, flags, enums ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | # return a var = value string for verbose print_file() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | # var: variable name (long version for cat/vi) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | # value: the value of var or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | # ref: the dir/table referenced by this var or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | # flags: anon hashref with flags setup from vdir or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | # enums: anon hashref with enums setup from vdir or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | # return: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | # the string to be printed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 0 | ▶ | sub var_value_v() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
var_value_v: not called CC=31 SCAR=69.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 0 | my ($var, $value, $ref, $flags, $enums ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 0 | my $s = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | ▶ | if( defined $ref ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | # query db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | my $rval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | my $st; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | my $select = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | "select $vdirs->{$ref}{fnamcol} from $ref order by $vdirs->{$ref}{fnamcol}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | 0 | $s .= "# This is a reference to a file in dir '$ref'.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 0 | $st = $dbh->prepare( $select ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | $s .= "$PRG: can't prep var query '$ref':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 0 | ▶ | unless( $st->execute( ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | $s .= "$PRG: can't exec var query '$ref' :\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 0 | my $selected = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 0 | my $available = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | ▶ | $selected = " $value" if defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | ▶ | while( ($rval) = $st->fetchrow_array() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 0 | ▶ | next if defined $value and $value eq $rval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $value eq $rval
MC/DC0%0/2
defined $value and $value eq $rval
defined $value
$value eq $rval
Truth table0%0/3
A and B
A= defined $valueB= $value eq $rval
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | $available .= " $rval\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | $s .= "$var = {\n Selected:\n$selected\n Available:\n$available}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | }elsif( defined $flags ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 0 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | my $maxlen = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | ▶ | for( $i=0; $i<32; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | ▶ | if( exists $flags->{$i} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | ▶ | if( length( $flags->{$i}[0] ) > $maxlen ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | $maxlen = length( $flags->{$i}[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 0 | $s .= "# Flags:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | ▶ | my $hash = defined $value ? '' : '#'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 0 | my $on = "$hash On:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | my $off = "$hash Off:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | ▶ | for( $i=0; $i<32; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | ▶ | if( exists $flags->{$i} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | my $first = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 0 | foreach my $dscline (split '\n', $flags->{$i}[1] ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | ▶ | if( $first ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | $s .= sprintf( "# %${maxlen}s: %s\n",$flags->{$i}[0], $dscline ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | $s .= sprintf( "# %${maxlen}s %s\n", ' ', $dscline ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | ▶ | if( defined $value and ($value & (1<<$i) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $value & 1 << $i
MC/DC0%0/2
defined $value and $value & 1 << $i
defined $value
$value & 1 << $i
Truth table0%0/3
A and B
A= defined $valueB= $value & 1 << $i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 0 | $on .= "$hash $flags->{$i}[0]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | $off .= "$hash $flags->{$i}[0]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | ▶ | if( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | $s .= "#\n$var = {\n$on$off}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 0 | $s .= "#\n$var = { # undefined!\n$on$off}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | }elsif( defined $enums ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | my $maxlen = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | foreach $i (keys(%{$enums}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | ▶ | if( length( $enums->{$i}[0] ) > $maxlen ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | $maxlen = length( $enums->{$i}[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 0 | $s .= "# Enums:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | my $selected = " Selected:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | 0 | my $avail = " Available:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | ▶ | if( defined $value and !exists $enums->{$value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and not exists $enums->{$value}
MC/DC0%0/2
defined $value and not exists $enums->{$value}
defined $value
not exists $enums->{$value}
Truth table0%0/3
A and not(B)
A= defined $valueB= not exists $enums->{$value}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | $selected .= " *unknown-enum-value*\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | foreach $i (sort { $a <=> $b } keys(%{$enums}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | my $first = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | foreach my $dscline (split '\n', $enums->{$i}[1] ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | ▶ | if( $first ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | $s .= sprintf( "# %${maxlen}s: %s\n",$enums->{$i}[0], $dscline ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | $s .= sprintf( "# %${maxlen}s %s\n", ' ', $dscline ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | ▶ | if( defined $value and $value == $i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $value == $i
MC/DC0%0/2
defined $value and $value == $i
defined $value
$value == $i
Truth table0%0/3
A and B
A= defined $valueB= $value == $i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | $selected .= " $enums->{$i}[0]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 0 | $avail .= " $enums->{$i}[0]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | $s .= "#\n$var = {\n$selected\n$avail}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | $s .= "$var = "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | ▶ | $s .= "$value" if defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | $s .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | } # var_value_v() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | # var_value_s( aligned, var, value, flags, enums, hasdefault ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | # return a var = value string for short output (sum & vgrep) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | # maxvarlen: if not 0: align all '=' using $maxvarlen, else: no alignment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | # var: variable name (long version for cat/vi) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | # value: the value of var or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | # default: the default value of var or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | # flags: anon hashref with flags setup from vdir or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | # enums: anon hashref with enums setup from vdir or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | # hasdefault: 1: we have a defaults file 0: we don't have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | # return: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | # the string to be printed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 0 | ▶ | sub var_value_s() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
var_value_s: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 0 | my ($maxvarlen,$var,$value,$default,$flags,$enums,$hasdefault) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | my $s = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | ▶ | if( defined $flags ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | $value = build_flags( $value, $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | $default = build_flags( $default, $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | }elsif( defined $enums ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | $value = build_enums( $value, $enums ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 0 | $default = build_enums( $default, $enums ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 0 | ▶ | if( $maxvarlen ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | $s = sprintf( "%-${maxvarlen}s ", $var ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | $s = "$var "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | ▶ | if( $hasdefault ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | ▶ | if( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | $s .= "= $value\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 0 | ▶ | $s .= defined $default ? "-> $default\n" : "-> *unset*\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 0 | ▶ | $s .= defined $value ? "= $value\n" : "= *unset*\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | } # var_value_s() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | # build_flags( value, flags ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | # return a string containing all flags set in value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | # value: the value of var or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | # flags: anon hashref with flags setup from vdir or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | # return: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | # the string of set flags if any flags are set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | # '' if no flags set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | # undef if value or flags is undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 0 | ▶ | sub build_flags() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_flags: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 0 | my ( $value, $flags ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 0 | my $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | my $i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 0 | ▶ | if( defined $flags and defined $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $flags and defined $value
MC/DC0%0/2
defined $flags and defined $value
defined $flags
defined $value
Truth table0%0/3
A and B
A= defined $flagsB= defined $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 0 | $s = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 0 | ▶ | for( $i=0; $i<32; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 0 | ▶ | if( exists $flags->{$i} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | ▶ | if( $value & (1<<$i) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | $s .= "$flags->{$i}[0],"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 0 | chop $s; # chop , | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | } # build_flags() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | # build_enums( value, enums ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | # return a string containing the enum set in value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | # value: the value of var or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | # enums: anon hashref with enums setup from vdir or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | # return: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | # the string of set enum if enum is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | # undef if - value is undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | # - enum is undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | # - value is not contained in enums | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 0 | ▶ | sub build_enums() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_enums: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 0 | my ( $value, $enums ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 0 | my $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | my $i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 0 | ▶ | if( defined $enums and defined $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $enums and defined $value
MC/DC0%0/2
defined $enums and defined $value
defined $enums
defined $value
Truth table0%0/3
A and B
A= defined $enumsB= defined $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | 0 | ▶ | if( exists $enums->{$value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 0 | $s = "$enums->{$value}[0]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 0 | $s = "*unknown-enum-value*"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | } # build_enums() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | # get_who_refs_me( dir, file ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | # return all files referenced by FILE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | # dir: an existing directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | # file: the (probably existing) file within DIR which references | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | # to be checked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | # return: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | # - a list of strings in format "dir/file" if references are found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | # - empty list if no references are found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | # - a list whith one entry holding the errormessage in case of an error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | 0 | ▶ | sub get_who_refs_me() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_who_refs_me: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 0 | my ($dir,$file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 0 | my @res = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 0 | foreach my $refdir (sort keys(%{$vdirs->{$dir}{refby}}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 0 | my $select = "select $vdirs->{$refdir}{fnamcol} from $refdir where "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | my @rcols = @{$vdirs->{$dir}{refby}{$refdir}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | 0 | map { $_ .= "='$file'" } @rcols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 0 | $select .= join( " or ", @rcols ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 0 | $select .= " order by $vdirs->{$refdir}{fnamcol}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 0 | $st = $dbh->prepare( $select ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | push @res,"$PRG: can't prep wrefs query '$file':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 0 | return @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 0 | ▶ | unless( $st->execute( ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 0 | push @res,"$PRG: can't exec wrefs query '$file':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | return @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 0 | my $reffile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 0 | ▶ | while( ($reffile) = $st->fetchrow_array() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | push @res, "$refdir/$reffile"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 0 | return @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | # create_sql_from_file( tempfile, dir, vfile, insert_flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | # tmpfile: Absolute path to temporary file on local disk holding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | # the edited parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | # vdir: exisiting virtual dir (table) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | # vfile: A file (db-row) for which to generate the $sql SQL code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | # insert_flag: 0: $sql --> 'update' string 1: $sql --> 'insert' string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | # a list: ($lineno,$err, $sql): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | # - $lineno: when an error was detected: the errornous line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | # - $err: when an error was detected: a one line error text, else: undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | # when $err is set then $sql is invalid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | # - $sql: when no error was detected: a SQL insert/update string or '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | # if nothing to do, when $err is set: trash or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | ▶ | sub create_sql_from_file( ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_sql_from_file: not called CC=102 SCAR=92.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 0 | my ($tmpfile,$vdir,$vfile,$insert_flag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 0 | my $lineno = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 0 | my $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | my $var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | 0 | my $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 0 | my $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 0 | my $sql1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | 0 | my $sql2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 0 | my %varcol; # translataion varname -> columnname | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 0 | my %isset; # flags: variable already set? 1: yes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 0 | my %filevars; # variables from file for phase 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 0 | my %filevarslineno; # lineno of variables from file for phase 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | ▶ | if( $insert_flag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 0 | $sql1 = "insert into $vdir ($vdirs->{$vdir}{fnamcol},"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 0 | $sql2 = " values('$vfile',"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | 0 | $sql1 = "update $vdir set "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | 0 | $sql2 = " where $vdirs->{$vdir}{fnamcol}='$vfile'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | # setup varname translation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | my $cols = $vdirs->{$vdir}{cols}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 0 | foreach my $col ( keys( %{$cols} ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 0 | $varcol{ $cols->{$col}{var} } = $col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | # phase 1: do the basic checks, remember var values and their lineno for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | # phase 2 check (user supplied check functions) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 0 | ▶ | open( TF, $tmpfile ) or return ( 1,"can't open tempfile '$tmpfile'", undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | 0 | ▶ | MAIN: while( <TF> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 0 | $line = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 0 | $lineno++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | 0 | chop( $line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 0 | $line =~ s/^\s*//; # remove leading space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 0 | ▶ | next MAIN if $line =~ /^$/; # skip empty lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 0 | ▶ | next MAIN if $line =~ /^\#.*/;# skip comment lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 0 | ▶ | unless( $line =~ /=/ ) { # missing = ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | $err = "line $lineno: missing '='"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 0 | ($var,$val) = split( /=/, $line, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | $var =~ s/\s*$//; # remove trailing space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | $val =~ s/^\s*//; # remove leading space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 0 | $val =~ s/\s*$//; # remove trailing space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | 0 | ▶ | if( length($var)==0 or $var =~ /\W+/ ) { # var name ok? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $var == 0 or $var =~ /\W+/
MC/DC0%0/2
length $var == 0 or $var =~ /\W+/
length $var == 0
$var =~ /\W+/
Truth table0%0/3
A or B
A= length $var == 0B= $var =~ /\W+/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | $err = "line $lineno: syntax error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | # check if variable name exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 0 | ▶ | if( defined $varcol{$var} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | 0 | ▶ | if( defined $isset{$var} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 0 | $err = "line $lineno: variable '$var' set twice"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 0 | my $col = $varcol{$var}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 0 | my $vlen = length( $val ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 0 | ▶ | if( $vlen > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | # check types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 0 | ▶ | if( defined $cols->{$col}{ref} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | # type ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | # 1st parse ref section like an enum to get the 'real' $val | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 0 | ▶ | if( $val eq '{' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | 0 | undef $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | my $mode = '{'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | my $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 0 | ▶ | VALREF: while( defined ( $l = <TF> ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 0 | chop( $l ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 0 | $lineno++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 0 | $l =~ s/\s*$//; # remove trailing space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 0 | $l =~ s/^\s*//; # remove leading space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 0 | ▶ | next VALREF if $l =~ /^$/; # skip empty lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | ▶ | next VALREF if $l =~ /^\#.*/; # skip comment lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | ▶ | if( $l eq 'Selected:' ) { $mode = 'sel'; next VALREF; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | ▶ | if( $l eq 'Available:' ) { $mode = 'ava'; next VALREF; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | 0 | ▶ | if( $l eq '}' ) { $mode = '}'; last VALREF; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | ▶ | if( $mode eq 'sel' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | ▶ | if( ! defined $val ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | $val = $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | 0 | $err = "line $lineno: only one elem may be selected for '$var'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | } # loop VALREF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | 0 | ▶ | if( $mode ne '}' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | 0 | $err = "line $lineno: missing '}' from refs section"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | $err = "line $lineno: refs must start with '{'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | # now we have a $val (probably undef!), process it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | 0 | my $rdir = $cols->{$col}{ref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | my $rfnc = $vdirs->{$rdir}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | ▶ | if( defined $vdirs->{$rdir}{cols}{$rfnc}{len} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | my $rlen = $vdirs->{$rdir}{cols}{$rfnc}{len}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | ▶ | if( $vlen > $rlen ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 0 | $err = "line $lineno: value longer than $rlen"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | 0 | ▶ | if( $vlen > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 0 | $err = "line $lineno: value longer than 1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | # check if val exists in referenced table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | ▶ | if( defined $val ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | my $dbval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | 0 | $st = $dbh->prepare("select $rfnc from $rdir where $rfnc=?"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | 0 | $err = "$PRG: internal error: prepare 'exist' query '$rdir':\n "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 0 | $err .= $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 0 | ▶ | unless( $st->execute( $val ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 0 | $err = "$PRG: internal error: exec 'exist' query '$rdir':\n "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | 0 | $err .= $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | $dbval = $st->fetchrow_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 0 | ▶ | unless( defined $dbval ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 0 | $err = "line $lineno: reference '$val' does no exist in '$rdir'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | 0 | ▶ | my $sqlval = defined $val ? $dbh->quote( $val ) : "NULL"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | ▶ | if( $insert_flag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | 0 | $sql1 .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 0 | $sql2 .= "$sqlval,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 0 | $sql1 .= "$col=$sqlval,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 0 | $filevars{$col} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 0 | $filevarslineno{$col} = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | }elsif( $cols->{$col}{type} eq 'char' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | # type char | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 0 | ▶ | if( defined $cols->{$col}{len} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | 0 | ▶ | if( $vlen > $cols->{$col}{len} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 0 | $err = "line $lineno: value longer than $cols->{$col}{len}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | 0 | ▶ | if( $vlen > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | 0 | $err = "line $lineno: value longer than 1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | 0 | ▶ | if( $insert_flag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 0 | $sql1 .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | $sql2 .= $dbh->quote( $val ) . ","; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | $sql1 .= "$col=" . $dbh->quote( $val ) . ","; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | 0 | $filevars{$col} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 0 | $filevarslineno{$col} = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | }elsif( $cols->{$col}{type} eq 'int' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | # type int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | 0 | ▶ | if( exists $cols->{$col}{flags} ) { # flags: process the flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | 0 | ▶ | if( $val =~ /{.*/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | 0 | $val = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | 0 | my $mode = '{'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | 0 | my $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | my $flagfound; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | 0 | ▶ | FLAGS: while( defined ( $l = <TF> ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | 0 | chop( $l ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | 0 | $lineno++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | 0 | $l =~ s/\s*$//; # remove trailing space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | 0 | $l =~ s/^\s*//; # remove leading space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | 0 | ▶ | next FLAGS if $l =~ /^$/; # skip empty lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | ▶ | next FLAGS if $l =~ /^\#.*/; # skip comment lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 0 | ▶ | if( $l eq 'On:' ) { $mode = 'on'; next FLAGS; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | 0 | ▶ | if( $l eq 'Off:' ) { $mode = 'off'; next FLAGS; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | 0 | ▶ | if( $l eq '}' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | 0 | ▶ | $val = 'NULL' if $mode eq '{'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | 0 | $mode = '}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 0 | last FLAGS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | 0 | $flagfound = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | 0 | foreach my $bit ( keys( %{$cols->{$col}{flags}} ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | 0 | ▶ | if( $cols->{$col}{flags}{$bit}[0] eq $l ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 0 | $flagfound = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | 0 | ▶ | $val |= (1<<$bit) if $mode eq 'on'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | 0 | ▶ | unless( $flagfound ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | 0 | $err = "line $lineno: unknown flag '$l' for '$var'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | } # loop FLAGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 0 | ▶ | if( $mode ne '}' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 0 | $err = "line $lineno: missing '}' from flags section"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | 0 | $err = "line $lineno: flags must start with '{'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | }elsif( exists $cols->{$col}{enums} ) { # enums: process the enums | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 0 | ▶ | if( $val eq '{' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 0 | $val = 'NULL'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | 0 | my $mode = '{'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | 0 | my $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | my $enumfound; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | 0 | ▶ | ENUMS: while( defined ( $l = <TF> ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | 0 | chop( $l ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | 0 | $lineno++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | 0 | $l =~ s/\s*$//; # remove trailing space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | 0 | $l =~ s/^\s*//; # remove leading space | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 0 | ▶ | next ENUMS if $l =~ /^$/; # skip empty lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | 0 | ▶ | next ENUMS if $l =~ /^\#.*/; # skip comment lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 0 | ▶ | if( $l eq 'Selected:' ) { $mode = 'sel'; next ENUMS; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | ▶ | if( $l eq 'Available:' ) { $mode = 'ava'; next ENUMS; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | 0 | ▶ | if( $l eq '}' ) { $mode = '}'; last ENUMS; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | 0 | $enumfound = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 0 | foreach my $enumval ( keys( %{$cols->{$col}{enums}} ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | 0 | ▶ | if( $cols->{$col}{enums}{$enumval}[0] eq $l ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | 0 | $enumfound = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | 0 | ▶ | if( $mode eq 'sel' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | 0 | ▶ | if( $val eq 'NULL' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | 0 | $val = $enumval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | 0 | $err = "line $lineno: only one elem may be selected for '$var'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | ▶ | unless( $enumfound ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | $err = "line $lineno: unknown enum tag '$l' for '$var'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | } # loop ENUMS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 0 | ▶ | if( $mode ne '}' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | $err = "line $lineno: missing '}' from enums section"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | 0 | $err = "line $lineno: enums must start with '{'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | }else{ # no flags,no enums, normal int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | 0 | ▶ | unless( $val =~ /^-?\d+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | 0 | $err = "line $lineno: value not an integer"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | 0 | ▶ | if( $val <= -2147483648 or $val >= 2147483647 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$val <= '-2147483648' or $val >= 2147483647
MC/DC0%0/2
$val <= '-2147483648' or $val >= 2147483647
$val <= '-2147483648'
$val >= 2147483647
Truth table0%0/3
A or B
A= $val <= '-2147483648'B= $val >= 2147483647
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | 0 | $err = "line $lineno: value out of int range"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | 0 | ▶ | if( $insert_flag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | 0 | $sql1 .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | 0 | $sql2 .= "$val,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | 0 | $sql1 .= "$col=$val,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | # workaroud: if enum and no elem was selected $val is 'NULL' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | # normally $val here is defined and has usefull value, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | # empty/NULL case will be handled above ($vlen > 0) but enum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | # is special. $val must stay NULL to make the sql's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | # work, but the user supplied valok functions expect 'undef' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | 0 | ▶ | if( $val eq 'NULL' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | 0 | $filevars{$col} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | 0 | $filevars{$col} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | 0 | $filevarslineno{$col} = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | }elsif( $cols->{$col}{type} eq 'smallint' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | # type smallint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | 0 | ▶ | unless( $val =~ /^-?\d+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | 0 | $err = "line $lineno: value not an integer"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | 0 | ▶ | if( $val <= -32768 or $val >= 32767 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$val <= -32768 or $val >= 32767
MC/DC0%0/2
$val <= -32768 or $val >= 32767
$val <= -32768
$val >= 32767
Truth table0%0/3
A or B
A= $val <= -32768B= $val >= 32767
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | 0 | $err = "line $lineno: value out of smallint range"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | 0 | ▶ | if( $insert_flag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | $sql1 .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | 0 | $sql2 .= "$val,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 0 | $sql1 .= "$col=$val,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | 0 | $filevars{$col} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | 0 | $filevarslineno{$col} = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | }elsif( $cols->{$col}{type} eq 'cidr' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | # type cidr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | my $dbval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | 0 | $st = $dbh->prepare( "select cidr '$val'" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | 0 | $err = "$PRG: internal error: select cidr\n "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | 0 | $err .= $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | 0 | ▶ | unless( $st->execute( ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | 0 | $err = $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | 0 | ($dbval) = $st->fetchrow_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | 0 | ▶ | if( $insert_flag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | 0 | $sql1 .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | 0 | $sql2 .= "'$val',"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | 0 | $sql1 .= "$col='$val',"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | 0 | $filevars{$col} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | 0 | $filevarslineno{$col} = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | }elsif( $cols->{$col}{type} eq 'inet' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | # type inet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | my $dbval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | 0 | $st = $dbh->prepare( "select inet '$val'" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | 0 | $err = "$PRG: internal error: select inet\n "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | 0 | $err .= $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | 0 | ▶ | unless( $st->execute( ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | 0 | $err = $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | 0 | ($dbval) = $st->fetchrow_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | 0 | ▶ | if( $insert_flag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | 0 | $sql1 .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | 0 | $sql2 .= "'$val',"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | 0 | $sql1 .= "$col='$val',"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 0 | $filevars{$col} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | 0 | $filevarslineno{$col} = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | # type unknown! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | 0 | $err = "line $lineno: unsupported datatype from vdirs for $var"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | }else{ # $vlen == 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | 0 | ▶ | if( $insert_flag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | 0 | $sql1 .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | 0 | $sql2 .= "NULL,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | 0 | $sql1 .= "$col=NULL,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | 0 | $filevars{$col} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 0 | $filevarslineno{$col} = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | 0 | $isset{$var} = 1; # remember that this var is set | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | 0 | $err = "line $lineno: unknown variable '$var'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | 0 | last MAIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | 0 | close( TF ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | 0 | ▶ | if( $insert_flag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | 0 | chop( $sql1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | 0 | chop( $sql2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | 0 | $sql1 .= ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | 0 | $sql2 .= ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | 0 | ▶ | if( chop( $sql1 ) ne ',' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | # no columns to update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | 0 | $sql1 = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | 0 | $sql2 = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | # phase 2: if basic check didn't show an error, do the user supplied checks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | 0 | my $hasuniqcols = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | 0 | $filevars{ $vdirs->{$vdir}{fnamcol} } = $vfile; # add our filename to hash | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | 0 | ▶ | if( !defined $err ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | 0 | foreach my $col (keys(%filevars) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | 0 | my $valerr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | 0 | ▶ | if( exists $cols->{$col}{uniq} ) { $hasuniqcols = 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | 0 | ▶ | if( exists $cols->{$col}{valok} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | 0 | $valerr = &{$cols->{$col}{valok}}( $filevars{$col}, \%filevars, $dbh ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | 0 | ▶ | if( defined $valerr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | 0 | $err = "line $filevarslineno{$col}: $valerr"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | 0 | $lineno = $filevarslineno{$col}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | # phase 3: check if there are columns/vars that have to be uniq | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | 0 | my $fnc = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | 0 | ▶ | if( !defined $err and $hasuniqcols == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $err and $hasuniqcols == 1
MC/DC0%0/2
not defined $err and $hasuniqcols == 1
not defined $err
$hasuniqcols == 1
Truth table0%0/3
not(A) and B
A= not defined $errB= $hasuniqcols == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | 0 | foreach my $col (keys(%filevars) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | 0 | my $valerr = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | 0 | ▶ | if( exists $cols->{$col}{uniq} and defined $filevars{$col} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $cols->{$col}{"uniq"} and defined $filevars{$col}
MC/DC0%0/2
exists $cols->{$col}{"uniq"} and defined $filevars{$col}
exists $cols->{$col}{"uniq"}
defined $filevars{$col}
Truth table0%0/3
A and B
A= exists $cols->{$col}{"uniq"}B= defined $filevars{$col}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | my $dbval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | 0 | $st = $dbh->prepare( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | "select $fnc from $vwd where $col=? and $fnc != '$vfile'"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | 0 | $err = "$PRG: internal error: prepare 'uniq' query '$vwd':\n "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | 0 | $err .= $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | 0 | ▶ | unless( $st->execute( "$filevars{$col}" ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | 0 | $err = "$PRG: internal error: exec 'uniq' query '$vwd':\n "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | 0 | $err .= $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | 0 | ▶ | while( ($dbval) = $st->fetchrow_array() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | 0 | $valerr .= " $dbval"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | 0 | ▶ | if( $valerr ne "" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | 0 | $err = "line $filevarslineno{$col}: uniq value '$filevars{$col}' " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | "already in file(s): $valerr"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | 0 | $lineno = $filevarslineno{$col}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | 0 | return ( $lineno, $err, "$sql1$sql2" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | } # create_sql_from_file() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | # want_to_edit_again( errortext ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | # ask the user if he wants to edit again | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | # errortext: one line error text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | # return: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | # 'y' or 'n' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | 0 | ▶ | sub want_to_edit_again() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
want_to_edit_again: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | 0 | my $errortext = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | 0 | my $inp = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | 0 | my $IN = $term->IN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | 0 | print $OUT "\n\n\n\n\n\n\n$errortext\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | 0 | ▶ | while( $inp ne 'y' and $inp ne 'n' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$inp ne "y" and $inp ne "n"
MC/DC0%0/2
$inp ne "y" and $inp ne "n"
$inp ne "y"
$inp ne "n"
Truth table0%0/3
A and B
A= $inp ne "y"B= $inp ne "n"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | 0 | print $OUT "Do you want to edit again ('n' will abort) [y/n] ? "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | 0 | $inp = <$IN>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | 0 | ▶ | $inp = '\n' unless defined $inp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | 0 | chop $inp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | 0 | return $inp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | # do_vgrep( pattern ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | # grep all val/value pairs in vwd for pattern and print matching lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | # pattern: the pattern to grep for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | # return: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | # nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | 0 | ▶ | sub do_vgrep() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_vgrep: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | 0 | my $pattern = quotemeta shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | 0 | my @vars; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | my @dbvars; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | 0 | my $var; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | 0 | my @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | 0 | my @defaults; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | 0 | my @flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | 0 | my @enums; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | 0 | my $fnam; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | 0 | my $em = "*unset*"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | 0 | my $hasdefault; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | # prepare db query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | 0 | my $fnc = $vdirs->{$vwd}{fnamcol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | 0 | my $select = "select $fnc,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | 0 | my $seldef = "select "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | 0 | my $cols = $vdirs->{$vwd}{cols}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | 0 | my $fnlen = $cols->{$fnc}{len}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | 0 | foreach my $col (sort {$cols->{$a}{pos} <=> $cols->{$b}{pos}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | 0 | keys(%{$cols}) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | 0 | ▶ | next if $col eq $fnc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | 0 | $var = $cols->{$col}{var}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | 0 | push @vars, $var; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | 0 | push @dbvars,$col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | 0 | ▶ | push @flags, exists $cols->{$col}{flags} ? $cols->{$col}{flags} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | 0 | ▶ | push @enums, exists $cols->{$col}{enums} ? $cols->{$col}{enums} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | 0 | $select .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | 0 | $seldef .= "$col,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | 0 | chop $select; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | 0 | chop $seldef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | 0 | $select .= " from $vwd order by $fnc"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | 0 | $seldef .= " from $vwd where $fnc=?"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | # query default if available | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | 0 | ▶ | if( $vdirs->{$vwd}{defaultfile} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | 0 | $st = $dbh->prepare( $seldef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | 0 | print $OUT "$PRG: prep vgrep default query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | 0 | ▶ | unless( $st->execute( $vdirs->{$vwd}{defaultfile} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | 0 | print $OUT "$PRG: exec vgrep default query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | 0 | @defaults = $st->fetchrow_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | # query all files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | 0 | $st = $dbh->prepare( $select ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | 0 | print $OUT "$PRG: prep vgrep query '$vwd':\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | 0 | ▶ | unless( $st->execute() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | 0 | print $OUT "$PRG: exec vgrep query 1 '$vwd' :\n " . $dbh->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | # print result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | 0 | ▶ | while (($fnam, @values ) = $st->fetchrow_array() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | 0 | ▶ | if( @values ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | 0 | ▶ | for( my $i=0; $i<= $#values; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | 0 | ▶ | if( $vdirs->{$vwd}{defaultfile} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} and $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
MC/DC0%0/2
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} and $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"}
$vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
Truth table0%0/3
A and B
A= $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"}B= $vdirs->{$DBIx::FileSystem::vwd}{"defaultfile"} ne $fnam
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | $vdirs->{$vwd}{defaultfile} ne $fnam ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | 0 | $hasdefault = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | 0 | $hasdefault = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | 0 | my $line = &var_value_s( 0, $vars[$i], $values[$i], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | $defaults[$i], $flags[$i], $enums[$i], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | $hasdefault | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | 0 | ▶ | printf $OUT "%${fnlen}s: %s", $fnam, $line if $line =~ /$pattern/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | ## obejct orientated interface: the access class for config database | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | # new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | # contructor for DBIx::FileSystem access class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | # parameter: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | # dbconn: database connect string used for DBI database connect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | # dbuser: database user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | # dbpasswd: database user's password | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | # progdbver: program's databaase layout version string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | # or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | # rdbh: reference to DBI database handle setup elsewhere | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | # progdbver: program's databaase layout version string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | # return: the object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=35.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | 2 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | 2 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | 2 | bless( $self, $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | 2 | $self->{dbh} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | 2 | $self->{rdbh} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | 2 | $self->{err} = "Ok"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | # initialize object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | 2 | ▶ | if( exists $params{rdbh} and defined( $params{rdbh} ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $params{"rdbh"} and defined $params{"rdbh"}
MC/DC0%0/2
exists $params{"rdbh"} and defined $params{"rdbh"}
exists $params{"rdbh"}
defined $params{"rdbh"}
Truth table33%1/3
A and B
A= exists $params{"rdbh"}B= defined $params{"rdbh"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | 0 | ▶ | if( exists $params{progdbver} and defined( $params{progdbver} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $params{"progdbver"} and defined $params{"progdbver"}
MC/DC0%0/2
exists $params{"progdbver"} and defined $params{"progdbver"}
exists $params{"progdbver"}
defined $params{"progdbver"}
Truth table0%0/3
A and B
A= exists $params{"progdbver"}B= defined $params{"progdbver"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | 0 | $self->{progdbver} = $params{progdbver}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | 0 | $self->{rdbh} = $params{rdbh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | 0 | $self->{progdbver} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | 0 | $self->{err} = "parameter 'progdbver' undefined"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | 2 | FINI: while( 1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | 2 | ▶ | if( exists $params{dbconn} and defined( $params{dbconn} ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $params{"dbconn"} and defined $params{"dbconn"}
MC/DC0%0/2
exists $params{"dbconn"} and defined $params{"dbconn"}
exists $params{"dbconn"}
defined $params{"dbconn"}
Truth table33%1/3
A and B
A= exists $params{"dbconn"}B= defined $params{"dbconn"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | 2 | $self->{dbconn} = $params{dbconn}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | 0 | $self->{dbconn} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | 0 | $self->{err} = "parameter 'dbconn' undefined"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | 0 | last FINI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | 2 | ▶ | if( exists $params{progdbver} and defined( $params{progdbver} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $params{"progdbver"} and defined $params{"progdbver"}
MC/DC0%0/2
exists $params{"progdbver"} and defined $params{"progdbver"}
exists $params{"progdbver"}
defined $params{"progdbver"}
Truth table33%1/3
A and B
A= exists $params{"progdbver"}B= defined $params{"progdbver"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | 2 | $self->{progdbver} = $params{progdbver}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | 0 | $self->{progdbver} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | 0 | $self->{err} = "parameter 'progdbver' undefined"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | 0 | last FINI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | $self->{dbh} = DBI->connect( $self->{dbconn}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | $params{dbuser}, $params{dbpasswd}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | 2 | { PrintError => 0, AutoCommit => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | ChopBlanks =>1 } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | 0 | ▶ | unless( $self->{dbh} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | 0 | $self->{err} = "connect: " . $DBI::errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | 0 | last FINI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | 0 | $self->{rdbh} = \$self->{dbh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | 0 | last FINI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | } # new() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | # DESTROY(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | # parameter: none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | # return: nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | 2 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | 2 | ▶ | $self->{dbh}->disconnect() if defined $self->{dbh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | 2 | $self->{dbh} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | 2 | $self->{rdbh} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | 2 | $self->{dbconn} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | 2 | $self->{progdbver} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | 2 | $self->{err} = "object destroyed"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | } # DESTROY() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | # database_bad(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | # check if the database connection is ok. If not, set an errormessage into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | # the errorbuffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | # parameter: none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | # return: 0: database ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | # 1: database wrong | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | 0 | ▶ | sub database_bad { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
database_bad: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | 0 | my $ret = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | 0 | ▶ | if( defined ${$self->{rdbh}} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | # check version number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | 0 | my $st = ${$self->{rdbh}}->prepare( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | "SELECT value FROM tablestatus WHERE tag='version'" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | 0 | ▶ | if( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | 0 | ▶ | if( $st->execute() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | 0 | my ($dbdbver) = $st->fetchrow_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | 0 | ▶ | if( $dbdbver eq $self->{progdbver} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | 0 | $ret = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | $self->{err} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | 0 | "version mismatch: program <--> db ('$self->{progdbver}' <--> '$dbdbver')"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | 0 | $self->{err} = "exec query dbversion: " . ${$self->{rdbh}}->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | 0 | $self->{err} = "prepare qry dbversion: " . ${$self->{rdbh}}->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | 0 | ▶ | if( $ret ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | 0 | ▶ | $self->{dbh}->disconnect() if defined $self->{dbh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | 0 | $self->{dbh} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | } # database_bad() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | # get_err(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | # read the last error message from the error buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | # parameter: none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | # return: last errorstring | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | 0 | ▶ | sub get_err { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_err: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | 0 | return $self->{err}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | } # get_err() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2297 | # get_conf_by_var(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2298 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2299 | # parameter: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2300 | # in: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2301 | # $dir: the directory (table) to search in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2302 | # $defaultfname: the filename of the defaultfile if availalble, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2303 | # else undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2304 | # $fnamcol: the column which contains the symbolic filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2305 | # in/out: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2306 | # \%vars: a hashref pointing to a hash containing the column | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2307 | # names to fetch as a key, values will be set by function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2308 | # in: \%searchvars a hashref pointing to a hash containing the values to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2309 | # to use as a filter (SQL WHERE part). Key: column name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2310 | # value: The value or an anon array-ref with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2311 | # [ 'compare-operator', 'value-to-search-for' ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2312 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2313 | # return: OK Ok, one file found, \%vars filled with values from db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2314 | # NOFILE no file found, \%vars's values will be undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2315 | # NFOUND more than one file found, \%vars's values will be undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2316 | # ERROR error, call method get_err to pick the error message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2317 | # \%vars's values will be undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2318 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2319 | 0 | ▶ | sub get_conf_by_var { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_conf_by_var: not called CC=34 SCAR=70.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2320 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2321 | 0 | my $dir = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2322 | 0 | my $defaultfname =shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2323 | 0 | my $fnamcol = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2324 | 0 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2325 | 0 | my $searchvars = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2327 | 0 | my $r = ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2328 | 0 | my $st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2330 | 0 | ▶ | unless( defined ${$self->{rdbh}} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2331 | 0 | $self->{err} = "DBIx::FileSystem database not initialized"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2332 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2335 | # check parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2336 | 0 | ▶ | if( !defined $dir or $dir eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $dir or $dir eq ""
MC/DC0%0/2
not defined $dir or $dir eq ""
not defined $dir
$dir eq ""
Truth table0%0/3
not(A) or B
A= not defined $dirB= $dir eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2337 | 0 | $self->{err} = "get_conf_by_var(): parameter 'dir' is empty"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2338 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2340 | 0 | ▶ | if( !defined $fnamcol or $fnamcol eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $fnamcol or $fnamcol eq ""
MC/DC0%0/2
not defined $fnamcol or $fnamcol eq ""
not defined $fnamcol
$fnamcol eq ""
Truth table0%0/3
not(A) or B
A= not defined $fnamcolB= $fnamcol eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2341 | 0 | $self->{err} = "get_conf_by_var(): parameter 'fnamcol' is empty"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2342 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2344 | 0 | ▶ | if( ref( $vars ) ne 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2345 | 0 | $self->{err} = "get_conf_by_var(): parameter 'vars' is no hashref"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2346 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2348 | 0 | ▶ | if( keys( %{$vars} ) == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2349 | 0 | $self->{err} = "get_conf_by_var(): hash 'vars' is empty"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2350 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2352 | 0 | ▶ | if( ref( $searchvars ) ne 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2353 | 0 | $self->{err} = "get_conf_by_var(): parameter 'searchvars' is no hashref"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2354 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2356 | 0 | ▶ | if( keys( %{$searchvars} ) == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2357 | 0 | $self->{err} = "get_conf_by_var(): hash 'searchvars' is empty"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2358 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2361 | 0 | foreach my $v ( keys %{$vars} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2362 | 0 | $vars->{$v} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2365 | 0 | DB: while( 1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2366 | 0 | my %extra; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2367 | 0 | my $qry = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2368 | 0 | my $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2370 | # check query parameters against defaultfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2371 | 0 | ▶ | if( defined $defaultfname ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2372 | 0 | foreach my $searchvar (keys %{$searchvars} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2373 | $qry = "SELECT count($fnamcol) FROM $dir WHERE $searchvar" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2374 | 0 | $self->sqlize( $searchvars->{$searchvar} ) . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2375 | " AND $fnamcol = '$defaultfname'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2376 | 0 | $st = ${$self->{rdbh}}->prepare( "$qry" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2377 | 0 | ▶ | unless( $st ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2378 | 0 | $self->{err} = "prepare extra qry: " . ${$self->{rdbh}}->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2379 | 0 | last DB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2381 | 0 | ▶ | if( $st->execute() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2382 | 0 | ($res) = $st-> fetchrow_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2383 | 0 | ▶ | if( defined $res and $res == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $res and $res == 1
MC/DC0%0/2
defined $res and $res == 1
defined $res
$res == 1
Truth table0%0/3
A and B
A= defined $resB= $res == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2384 | 0 | $extra{$searchvar} = " OR $searchvar IS NULL"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2385 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2386 | 0 | $extra{$searchvar} = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2388 | 0 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2389 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2390 | 0 | $self->{err} = "exec extra qry: " . ${$self->{rdbh}}->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2391 | 0 | last DB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2394 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2395 | 0 | foreach my $searchvar (keys %{$searchvars} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2396 | 0 | $extra{$searchvar} = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2400 | # base query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2402 | 0 | $qry = "SELECT "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2403 | 0 | foreach my $var (keys %{$vars} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2404 | 0 | $qry .= "$var,"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2406 | 0 | chop $qry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2407 | 0 | $qry .= " FROM $dir WHERE "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2408 | 0 | my $rest = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2409 | 0 | foreach my $searchvar (keys %{$searchvars} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2410 | 0 | ▶ | $qry .= " AND " if $rest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2411 | 0 | $qry .= "( $searchvar" . $self->sqlize( $searchvars->{$searchvar} ) . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2412 | "$extra{$searchvar} )"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2413 | 0 | ▶ | $rest = 1 unless $rest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2415 | ### print "qry: '$qry'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2417 | 0 | $res = ${$self->{rdbh}}->selectall_arrayref( $qry, { Slice => {} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2418 | 0 | ▶ | if( !defined $res or defined ${$self->{rdbh}}->{err} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $res or defined ${$$self{"rdbh"};}->{"err"}
MC/DC0%0/2
not defined $res or defined ${$$self{"rdbh"};}->{"err"}
not defined $res
defined ${$$self{"rdbh"};}->{"err"}
Truth table0%0/3
not(A) or B
A= not defined $resB= defined ${$$self{"rdbh"};}->{"err"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2419 | 0 | $self->{err} = "get_conf_by_var(): query: " . ${$self->{rdbh}}->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2420 | 0 | last DB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2423 | 0 | ▶ | if( @$res == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2424 | 0 | $self->{err} = "no file found"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2425 | 0 | $r = NOFILE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2426 | 0 | last DB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2427 | }elsif( @$res == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2428 | 0 | foreach my $col (keys %{$res->[0]} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2429 | 0 | $vars->{$col} = $res->[0]->{$col}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2431 | 0 | $r = OK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2432 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2433 | 0 | $self->{err} = "more than one file found"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2434 | 0 | $r = NFOUND;; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2435 | 0 | last DB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2438 | # read defaults from defaultfile if necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2440 | 0 | ▶ | if( defined $defaultfname ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2441 | 0 | my %sv = ( $fnamcol => $defaultfname ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2442 | 0 | my %v = %{$vars}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2443 | 0 | $r = $self->get_conf_by_var( $dir, undef, $fnamcol, \%v, \%sv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2445 | 0 | ▶ | if( $r == OK ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2446 | 0 | foreach my $var ( keys %v ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2447 | 0 | ▶ | $vars->{$var} = $v{$var} unless defined $vars->{$var}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2449 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2450 | 0 | ▶ | if( $r == NOFILE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2451 | 0 | $self->{err} = "defaultfile '$dir/$defaultfname' not found"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2452 | }elsif( $r == NFOUND ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2453 | 0 | $self->{err} = "more than one file '$dir/$defaultfname' found"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2455 | 0 | foreach my $v ( keys %{$vars} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2456 | 0 | $vars->{$v} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2458 | 0 | $r = ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2462 | 0 | last DB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2464 | } # while( DB ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2466 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2468 | } # get_conf_by_var() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2470 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2471 | # sqlize(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2472 | # build the right-hand-side of the WHERE part, incl. compare operator. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2473 | # respect quoting of strings, integer values and 'undef' / NULL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2474 | # parameter: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2475 | # $val: the value to SQLize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2476 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2477 | # return: the sqlized string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2478 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2479 | 0 | ▶ | sub sqlize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sqlize: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2480 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2481 | 0 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2482 | 0 | my $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2483 | 0 | ▶ | if( ! defined $val ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2484 | 0 | $r = " IS NULL"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2485 | }elsif( ref( $val ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2486 | 0 | ▶ | if( defined $val->[0] and defined $val->[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $val->[0] and defined $val->[1]
MC/DC0%0/2
defined $val->[0] and defined $val->[1]
defined $val->[0]
defined $val->[1]
Truth table0%0/3
A and B
A= defined $val->[0]B= defined $val->[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2487 | 0 | ▶ | if( $self->isanumber( $val->[1] ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2488 | 0 | $r = " $val->[0] $val->[1]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2489 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2490 | 0 | $r = " $val->[0] " . ${$self->{rdbh}}->quote( $val->[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2492 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2493 | 0 | $r = " IS NULL"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2495 | }elsif( ref( $val ) eq '' ) { # scalar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2496 | 0 | ▶ | if( $self->isanumber( $val ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2497 | 0 | $r = "=$val"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2498 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2499 | 0 | $r = "=" . ${$self->{rdbh}}->quote( $val ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2501 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2502 | 0 | $r = "='-->INVALID-SEARCH-VALUE-SPECIFIED<--'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2505 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2507 | } # sqlize() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2510 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2511 | # isanumber(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2512 | # check if $str is a number or not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2513 | # parameter: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2514 | # $str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2515 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2516 | # return: 0 $val is string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2517 | # 1 $val is number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2518 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2519 | 41 | ▶ | sub isanumber() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isanumber: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2520 | 41 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2521 | 41 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2522 | 41 | my $r = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2524 | 41 | ▶ | if( !defined $str ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2525 | 1 | $r = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2526 | }elsif( $str eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2527 | 1 | $r = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2528 | }elsif( $str =~ / / ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2529 | 7 | $r = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2530 | }elsif( $str =~ /infinity/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2531 | 2 | $r = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2532 | }elsif( $str =~ /nan/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2533 | 2 | $r = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2534 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2535 | 28 | $! = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2536 | 28 | my ($num, $unparsed ) = POSIX::strtod( $str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2537 | 28 | ▶ | if( ($unparsed != 0) || $!) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$unparsed != 0 or $!
MC/DC50%1/2
$unparsed != 0 or $!
$unparsed != 0
$!
Truth table66%2/3
A or B
A= $unparsed != 0B= $!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2538 | 9 | $r = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2541 | 41 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2543 | } # isanumber() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2546 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2547 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2548 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2549 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2551 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2552 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||