DirectConnect/pslib/psmisc.pm

filter: Statementstmt 10.3% 99 / 960 Branchbran 1.0% 6 / 596 Conditioncond 2.2% 15 / 666 MC/DCmcdc 0.0% 0 / 365 Subroutinesub 11.9% 18 / 151 Podpod 0.0% 0 / 97 totaltotal 4.8% 138 / 2835 CC 585 SCAR 59.4
CC
585
Cov
5%
__ANON__
2652.0
printlog
1260.0
http_get
812.0
CRAP 381.7
« DirectConnect.pm ↑ Summary DirectConnect/clihub.pm »
1 #!/usr/bin/perl
2 #$Id: psmisc.pm 4847 2014-06-30 23:41:45Z pro $ $URL: svn://svn.setun.net/search/trunk/lib/psmisc.pm $
3  
4 =copyright
5 PRO-search shared library
6 Copyright (C) 2003-2011 Oleg Alexeenkov http://pro.setun.net/search/ proler@gmail.com
7  
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12  
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17  
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 =cut
21  
22 #print "Content-type: text/html\n\n" if defined($ENV{'SERVER_PORT'}); # for web dev debug
23 #print "misc execute " , $mi++;
24 #=pac
25 #local *config = *main::config;
26 #%config
27 #our ( %config );
28 package #not ready for cpan
29 psmisc;
30 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶no warnings qw(uninitialized);
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 ▶no if $] >= 5.017011, warnings => 'experimental::smartmatch';
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 #use open qw(:utf8 :std);
35 #use encoding "utf8", STDOUT => "utf8", STDIN => "utf8", STDERR => "utf8";
36 #use open ':utf8';
37 1 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶use Time::HiRes qw(time);
Subroutine BEGIN: called CC=1 SCAR=0.0
39 #use locale;
40 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 1 ▶use POSIX qw(strftime);
Subroutine BEGIN: called CC=1 SCAR=0.0
42 1 ▶use lib::abs;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 our $VERSION = ( split( ' ', '$Revision: 4847 $' ) )[1];
44 1 our (%config);
45 #my ( %config );
46 #local *config = *main::config;
47 #local
48 #*psmisc::config = *main::config;
49 1 *config = *main::config;
50 1 *stat = *main::stat;
51 1 *work = *main::work;
52 1 *param = *main::param;
53 1 *static = *main::static;
54 #*psmisc::program = *main::program;
55 1 ▶use Data::Dumper; #dev only
Subroutine BEGIN: called CC=1 SCAR=0.0
56 1 $Data::Dumper::Sortkeys = $Data::Dumper::Useqq = $Data::Dumper::Indent = 1;
57 #use vars qw( %config %work %stat %static $param %processor %program %out ); #%human,
58 #our ( @ISA, @EXPORT, @EXPORT_OK ,%EXPORT_TAGS);
59 1 our ( @EXPORT, @EXPORT_OK, %EXPORT_TAGS );
60 #use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
61 #require Exporter;
62 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
63 #our
64 #@
65 #@ISA = qw(Exporter);
66 # @EXPORT = qw(A1 A2 A3 A4 A5);
67 # @EXPORT_OK = qw(B1 B2 B3 B4 B5);
68 # %EXPORT_TAGS = (T1 => [qw(A1 A2 B1 B2)], T2 => [qw(A1 A2 B3 B4)]);
69 #our %config;
70 1 @EXPORT = qw(
71 );
72 1 @EXPORT_OK = qw(
73 get_params_one
74 get_params
75 array
76 encode_url
77 encode_url_link
78 decode_url
79 printlog
80 dmp
81 printprog
82 openproc
83 state
84 hconfig
85 html_chars
86 name_to_ip
87 normalize_ip
88 ip_to_name
89 counter
90 timer
91 join_url
92 split_url
93 full_host
94 cp_trans
95 utf_trans
96 to_utf_trans
97 cp_trans_hash
98 cp_detect_trans
99 lang
100 min
101 max
102 alarmed
103 mkdir_rec
104 sleeper
105 mysleep
106 check_int
107 shuffle
108 config_reload
109 conf
110 http_get
111 http_get_code
112 loadlist
113 shelldata
114 printall
115 %work %static $param
116 %program
117 );
118 # %config
119 1 %EXPORT_TAGS = ( log => [qw(printlog dmp)], config => [qw(%config)], all => \@EXPORT_OK, ); #%human %out %processor %stat
120  
121 =no
122 open_out_file
123 close_out_file
124 =cut
125  
126 #flush
127 #our ( %config, %work, %stat, %static, $param, %program, $root_path, ); #%human, %out, %processor,
128 1 our ( %work, %static, $param, %program, $root_path, ); #%human, %out, %processor, %stat,
129 #my %human;
130 #sub conf_once {
131 1 ▶sub config_init {
Subroutine config_init: called CC=2 SCAR=17.7
Pod undocumented
132 1 ▶ return if $static{'lib_init_psmisc'}{ $ENV{'SCRIPT_FILENAME'} }++;
Branch: 1 branch
BranchTrueFalseTotal
if $psmisc::static{"lib_init_psmisc"}{$ENV{"SCRIPT_FILENAME"}}++ 0 1 1
133 1 my ($param) = @_;
134 #print " config_init;";
135 #caller_trace(10);
136 conf(
137 0 ▶ sub {
Subroutine __ANON__: not called CC=51 SCAR=78.8
138 #print " config_init:sub;";
139 0 ▶ $config{'stderr_redirect'} ||= '2>&1'; #'2>/dev/null';
Condition0%0/2
$config{"stderr_redirect"} ||= "2>&1"
l!l
00
MC/DC0%0/1
$config{"stderr_redirect"} ||= "2>&1"
$config{"stderr_redirect"}
Truth table0%0/2
A
A= $config{"stderr_redirect"}
Aresult
11
00
140 #A | YA E a | ya e |-ukr------------------|
141 0 ▶ $config{'trans'}{'cp1251'} ||=
Condition0%0/2
$config{"trans"}{"cp1251"} ||= "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\250\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\270\262\263\257\277\252\272"
l!l
00
MC/DC0%0/1
$config{"trans"}{"cp1251"} ||= "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\250\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\270\262\263\257\277\252\272"
$config{"trans"}{"cp1251"}
Truth table0%0/2
A
A= $config{"trans"}{"cp1251"}
Aresult
11
00
142 "\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xA8\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF\xB8\xB2\xB3\xAF\xBF\xAA\xBA";
143 0 ▶ $config{'trans'}{'koi8-r'} ||=
Condition0%0/2
$config{"trans"}{"koi8-r"} ||= "\341\342\367\347\344\345\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\377\371\370\374\340\361\263\301\302\327\307\304\305\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\337\331\330\334\300\321\243\266\246\267\247\264\244"
l!l
00
MC/DC0%0/1
$config{"trans"}{"koi8-r"} ||= "\341\342\367\347\344\345\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\377\371\370\374\340\361\263\301\302\327\307\304\305\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\337\331\330\334\300\321\243\266\246\267\247\264\244"
$config{"trans"}{"koi8-r"}
Truth table0%0/2
A
A= $config{"trans"}{"koi8-r"}
Aresult
11
00
144 "\xE1\xE2\xF7\xE7\xE4\xE5\xF6\xFA\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF2\xF3\xF4\xF5\xE6\xE8\xE3\xFE\xFB\xFD\xFF\xF9\xF8\xFC\xE0\xF1\xB3\xC1\xC2\xD7\xC7\xC4\xC5\xD6\xDA\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD2\xD3\xD4\xD5\xC6\xC8\xC3\xDE\xDB\xDD\xDF\xD9\xD8\xDC\xC0\xD1\xA3\xB6\xA6\xB7\xA7\xB4\xA4";
145 0 ▶ $config{'trans'}{'iso8859-5'} ||=
Condition0%0/2
$config{"trans"}{"iso8859-5"} ||= "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\241\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\361\246\366\247\367\244\364"
l!l
00
MC/DC0%0/1
$config{"trans"}{"iso8859-5"} ||= "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\241\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\361\246\366\247\367\244\364"
$config{"trans"}{"iso8859-5"}
Truth table0%0/2
A
A= $config{"trans"}{"iso8859-5"}
Aresult
11
00
146 "\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xA1\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF1\xA6\xF6\xA7\xF7\xA4\xF4";
147 0 ▶ $config{'trans'}{'cp866'} ||=
Condition0%0/2
$config{"trans"}{"cp866"} ||= "\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\360\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\361\366\367\370\371\364\365"
l!l
00
MC/DC0%0/1
$config{"trans"}{"cp866"} ||= "\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\360\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\361\366\367\370\371\364\365"
$config{"trans"}{"cp866"}
Truth table0%0/2
A
A= $config{"trans"}{"cp866"}
Aresult
11
00
148 "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xF0\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF1\xF6\xF7\xF8\xF9\xF4\xF5";
149 0 ▶ $config{'trans'}{'utf-8'} ||= "\xD0\xD1"; #JUST TRICK for autodetect
Condition0%0/2
$config{"trans"}{"utf-8"} ||= "\320\321"
l!l
00
MC/DC0%0/1
$config{"trans"}{"utf-8"} ||= "\320\321"
$config{"trans"}{"utf-8"}
Truth table0%0/2
A
A= $config{"trans"}{"utf-8"}
Aresult
11
00
150 #$config{'trans_up'}{$_} = (split//, $config{'trans'}{$_})[0..32] for keys %{$config{'trans'}};
151 $config{'trans_up'}{$_} = substr( $config{'trans'}{$_}, 0, 33 ),
152 $config{'trans_lo'}{$_} = substr( $config{'trans'}{$_}, 33, 33 ),
153 #print("$config{'trans_up'}{$_}\n$config{'trans_lo'}{$_}\n"),
154 0 for grep { length $config{'trans'}{$_} >= 66 } keys %{ $config{'trans'} };
155 #exit;
156  
157 =with 50% UPPER case
158 #cp detect with cp_learn_symbols=10; from 28691 bytes text
159 $config{'trans_detect'}{'cp1251'} ||= '\xCE\xEE\xC0\xE0\xE5\xC5\xD2\xF2\xE8\xC8'; # [­Ќоћ…Ґађ•е] = [­Ќоћ…Ґађ•е]; stat:­[CE]=658; Ќ[EE]=658; о[C0]=578; ћ[E0]=578; …[E5]=503; Ґ[C5]=503; а[D2]=434; ђ[F2]=434; •[E8]=422; е[C8]=422;
160 $config{'trans_detect'}{'cp866'} ||= '\xAE\x8E\x80\xA0\xA5\x85\x92\xE2\xA8\x88'; # [R__Н_:'Ѓ»_] = [Ќ­оћ…Ґађ•е]; stat:Ќ[AE]=658; ­[8E]=658; о[80]=578; ћ[A0]=578; …[A5]=503; Ґ[85]=503; а[92]=434; ђ[E2]=434; •[A8]=422; е[88]=422;
161 $config{'trans_detect'}{'koi8-r'} ||= '\xCF\xEF\xC1\xE1\xC5\xE5\xD4\xF4\xC9\xE9'; # [®Ћ ЂҐ…в’Ё€] = [Ќ­ћо…Ґђа•е]; stat:Ќ[CF]=658; ­[EF]=658; ћ[C1]=578; о[E1]=578; …[C5]=503; Ґ[E5]=503; ђ[D4]=434; а[F4]=434; •[C9]=422; е[E9]=422;
162 $config{'trans_detect'}{'utf-8'} ||= '\xD0\xD1\x9E\xBE\xB0\x90\x95\xB5\xA2\x82'; # [Їп__З_‚Х'] = [Їпз_ЗЇг‚ЃЎ]; stat:Ї[D0]=10542; п[D1]=1934; з[9E]=658; _[BE]=658; З[B0]=578; Ї[90]=578; г[95]=503; ‚[B5]=503; Ѓ[A2]=434; Ў[82]=434;
163 #$config{'trans_detect'}{'iso8859-5'} ||= '\xDE\xBE\xD0\xB0\xB5\xD5\xC2\xE2\xB8\xD8'; # [з_ЇЗ‚гЎЃЛм] = [Ќ­ћоҐ…ађе•]; stat:Ќ[DE]=658; ­[BE]=658; ћ[D0]=578; о[B0]=578; Ґ[B5]=503; …[D5]=503; а[C2]=434; ђ[E2]=434; е[B8]=422; •[D8]=422;
164 =cut
165  
166 =was
167 #cp detect with cp_learn_symbols=20; from 14344 bytes text
168 $config{'trans_detect'}{'cp1251'} ||= '\xEE\xE0\xE5\xF2\xE8\xED\xF1\xF0\xE2\xEA\xEB\xEF\xE4\xFC\xEC\xE7\xF3\xE1\xFB\xF7'
169 ; # [Ќћ…ђ•ЊџЏЃ‰ЉЋ„ќ‹ѓ‘Ђ˜‚] = [Ќћ…ђ•ЊџЏЃ‰ЉЋ„ќ‹ѓ‘Ђ˜‚]; stat:Ќ[EE]=649; ћ[E0]=573; …[E5]=489; ђ[F2]=425; •[E8]=416; Њ[ED]=410; џ[F1]=379; Џ[F0]=296; Ѓ[E2]=269; ‰[EA]=256; Љ[EB]=221; Ћ[EF]=194; „[E4]=174; ќ[FC]=156; ‹[EC]=153; ѓ[E7]=152; ‘[F3]=141; Ђ[E1]=109; ˜[FB]=108; ‚[F7]=100;
170 $config{'trans_detect'}{'cp866'} ||= '\xAE\xA0\xA5\xE2\xA8\xAD\xE1\xE0\xA2\xAA\xAB\xAF\xA4\xEC\xAC\xA7\xE3\xA1\xEB\xE7'
171 ; # [RН_Ѓ»-ЂћХУ<ЖЦ‹ѕ·–єЉѓ] = [Ќћ…ђ•ЊџЏЃ‰ЉЋ„ќ‹ѓ‘Ђ˜‚]; stat:Ќ[AE]=649; ћ[A0]=573; …[A5]=489; ђ[E2]=425; •[A8]=416; Њ[AD]=410; џ[E1]=379; Џ[E0]=296; Ѓ[A2]=269; ‰[AA]=256; Љ[AB]=221; Ћ[AF]=194; „[A4]=174; ќ[EC]=156; ‹[AC]=153; ѓ[A7]=152; ‘[E3]=141; Ђ[A1]=109; ˜[EB]=108; ‚[E7]=100;
172 $config{'trans_detect'}{'koi8-r'} ||= '\xCF\xC1\xC5\xD4\xC9\xCE\xD3\xD2\xD7\xCB\xCC\xD0\xC4\xD8\xCD\xDA\xD5\xC2\xD9\xDE'
173 ; # [® ҐвЁ­баўЄ«Ї¤м¬§гЎлз] = [Ќћ…ђ•ЊџЏЃ‰ЉЋ„ќ‹ѓ‘Ђ˜‚]; stat:Ќ[CF]=649; ћ[C1]=573; …[C5]=489; ђ[D4]=425; •[C9]=416; Њ[CE]=410; џ[D3]=379; Џ[D2]=296; Ѓ[D7]=269; ‰[CB]=256; Љ[CC]=221; Ћ[D0]=194; „[C4]=174; ќ[D8]=156; ‹[CD]=153; ѓ[DA]=152; ‘[D5]=141; Ђ[C2]=109; ˜[D9]=108; ‚[DE]=100;
174 $config{'trans_detect'}{'utf-8'} ||= '\xD0\xD1\xBE\xB0\xB5\x82\xB8\xBD\x81\x80\xB2\xBA\xBB\xBF\xB4\x8C\xBC\xB7\x83\xB1'
175 ; # [Їп_З‚'Л____Р>ь___Т_+] = [Їп_З‚ЎЛ_ о_Р>ь_«_Тж+]; stat:Ї[D0]=4352; п[D1]=1894; _[BE]=649; З[B0]=573; ‚[B5]=489; Ў[82]=425; Л[B8]=416; _[BD]=410;  [81]=379; о[80]=296; _[B2]=269; Р[BA]=256; >[BB]=221; ь[BF]=194; _[B4]=174; «[8C]=156; _[BC]=153; Т[B7]=152; ж[83]=141; +[B1]=109;
176 =cut
177  
178 #cp detect with cp_learn_symbols=20; from 145699 bytes text
179 0 $config{'trans_detect'}{'cp1251'} = '\xEE\xE0\xE5\xE8\xED\xF2\xF1\xF0\xEB\xE2\xEA\xF3\xEF\xEC\xE4\xFF\xFB\xFC\xE7\xE3'
180 ; # [оаеинтсрлвкупмдяыьзг] = [оаеинтсрлвкупмдяыьзг]; stat:о[EE]=12122; а[E0]=10566; е[E5]=9827; и[E8]=8929; н[ED]=7504; т[F2]=6931; с[F1]=6839; р[F0]=6744; л[EB]=6225; в[E2]=5384; к[EA]=4505; у[F3]=3912; п[EF]=3864; м[EC]=3811; д[E4]=3497; я[FF]=3047; ы[FB]=2693; ь[FC]=2628; з[E7]=2192; г[E3]=1934;
181 0 $config{'trans_detect'}{'utf-8'} = '\xD0\xD1\xBE\xB0\xB5\xB8\xBD\x82\x81\x80\xBB\xB2\xBA\x83\xBF\xBC\xB4\x8F\x8B\x8C'
182 ; # [РС?°чё?'??>Iє?ї???<?] = [РС?°чё?ВБА>IєГї??ПЛМ]; stat:Р[D0]=88304; С[D1]=39900; ?[BE]=12122; °[B0]=10566; ч[B5]=9827; ё[B8]=8929; ?[BD]=7504; В[82]=6931; Б[81]=6845; А[80]=6744; >[BB]=6225; I[B2]=5384; є[BA]=4505; Г[83]=3912; ї[BF]=3864; ?[BC]=3811; ?[B4]=3497; П[8F]=3047; Л[8B]=2693; М[8C]=2628;
183 0 $config{'trans_detect'}{'cp866'} = '\xAE\xA0\xA5\xA8\xAD\xE2\xE1\xE0\xAB\xA2\xAA\xE3\xAF\xAC\xA4\xEF\xEB\xEC\xA7\xA3'
184 ; # [R ?Ё-вба<ўЄгЇ¬¤плм§?] = [оаеинтсрлвкупмдяыьзг]; stat:о[AE]=12122; а[A0]=10566; е[A5]=9827; и[A8]=8929; н[AD]=7504; т[E2]=6931; с[E1]=6839; р[E0]=6744; л[AB]=6225; в[A2]=5384; к[AA]=4505; у[E3]=3912; п[AF]=3864; м[AC]=3811; д[A4]=3497; я[EF]=3047; ы[EB]=2693; ь[EC]=2628; з[A7]=2192; г[A3]=1934;
185 0 $config{'trans_detect'}{'koi8-r'} = '\xCF\xC1\xC5\xC9\xCE\xD4\xD3\xD2\xCC\xD7\xCB\xD5\xD0\xCD\xC4\xD1\xD9\xD8\xDA\xC7'
186 ; # [ПБЕЙОФУТМЧЛХРНДСЩШЪЗ] = [оаеинтсрлвкупмдяыьзг]; stat:о[CF]=12122; а[C1]=10566; е[C5]=9827; и[C9]=8929; н[CE]=7504; т[D4]=6931; с[D3]=6839; р[D2]=6744; л[CC]=6225; в[D7]=5384; к[CB]=4505; у[D5]=3912; п[D0]=3864; м[CD]=3811; д[C4]=3497; я[D1]=3047; ы[D9]=2693; ь[D8]=2628; з[DA]=2192; г[C7]=1934;
187 #$config{'trans_detect'}{'iso8859-5'} = '\xDE\xD0\xD5\xD8\xDD\xE2\xE1\xE0\xDB\xD2\xDA\xE3\xDF\xDC\xD4\xEF\xEB\xEC\xD7\xD3'; # [ЮРХШЭвбаЫТЪгЯЬФплмЧУ] = [оаеинтсрлвкупмдяыьзг]; stat:о[DE]=12122; а[D0]=10566; е[D5]=9827; и[D8]=8929; н[DD]=7504; т[E2]=6931; с[E1]=6839; р[E0]=6744; л[DB]=6225; в[D2]=5384; к[DA]=4505; у[E3]=3912; п[DF]=3864; м[DC]=3811; д[D4]=3497; я[EF]=3047; ы[EB]=2693; ь[EC]=2628; з[D7]=2192; г[D3]=1934;
188 #$config{'trans_detect'}{'iso8859-5'} ||= '\xDE\xD0\xD5\xE2\xD8\xDD\xE1\xE0\xD2\xDA\xDB\xDF\xD4\xEC\xDC\xD7\xE3\xD1\xEB\xE7'; # [зЇгЃмйЂћа§икв‹нў–пЉѓ] = [Ќћ…ђ•ЊџЏЃ‰ЉЋ„ќ‹ѓ‘Ђ˜‚]; stat:Ќ[DE]=649; ћ[D0]=573; …[D5]=489; ђ[E2]=425; •[D8]=416; Њ[DD]=410; џ[E1]=379; Џ[E0]=296; Ѓ[D2]=269; ‰[DA]=256; Љ[DB]=221; Ћ[DF]=194; „[D4]=174; ќ[EC]=156; ‹[DC]=153; ѓ[D7]=152; ‘[E3]=141; Ђ[D1]=109; ˜[EB]=108; ‚[E7]=100;
189 #$config{'trans_detect'}{'cp1251'} ||= "\xE0\xC0\xEE\xCE"; #ћо Ќ­
190 #$config{'trans_detect'}{'cp866'} ||= "\xA0\x80\xAE\x8E";
191 #$config{'trans_detect'}{'koi8-r'} ||= "\xC1\xE1\xCF\xEF";
192 ## $config{'trans_detect'}{'iso8859-5'} ||= "\xD0\xB0\xDE\xBE";
193 #$config{'trans_detect'}{'utf-8'} ||= "\xD0\xD1";
194 #$config{'trans_detect'}{'bin'} ||= join '', map{'\\x'.sprintf '%02X', $_}0..0x08,0x0B,0x0C,0x0E,0x0F;
195 #$config{'trans_detect'}{'latin'} ||= 'a-zA-Z';
196 #print $config{'trans_detect'}{'bin'};exit;
197 #$config{'trans_name'}{'cp1251'} ||= 'cp1251';
198 0 ▶ $config{'trans_name'}{'win1251'} ||= 'cp1251';
Condition0%0/2
$config{"trans_name"}{"win1251"} ||= "cp1251"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"win1251"} ||= "cp1251"
$config{"trans_name"}{"win1251"}
Truth table0%0/2
A
A= $config{"trans_name"}{"win1251"}
Aresult
11
00
199 0 ▶ $config{'trans_name'}{'windows1251'} ||= 'cp1251';
Condition0%0/2
$config{"trans_name"}{"windows1251"} ||= "cp1251"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"windows1251"} ||= "cp1251"
$config{"trans_name"}{"windows1251"}
Truth table0%0/2
A
A= $config{"trans_name"}{"windows1251"}
Aresult
11
00
200 0 ▶ $config{'trans_name'}{'windows-1251'} ||= 'cp1251';
Condition0%0/2
$config{"trans_name"}{"windows-1251"} ||= "cp1251"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"windows-1251"} ||= "cp1251"
$config{"trans_name"}{"windows-1251"}
Truth table0%0/2
A
A= $config{"trans_name"}{"windows-1251"}
Aresult
11
00
201 0 ▶ $config{'trans_name'}{'win'} ||= 'cp1251';
Condition0%0/2
$config{"trans_name"}{"win"} ||= "cp1251"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"win"} ||= "cp1251"
$config{"trans_name"}{"win"}
Truth table0%0/2
A
A= $config{"trans_name"}{"win"}
Aresult
11
00
202 0 ▶ $config{'trans_name'}{'1251'} ||= 'cp1251';
Condition0%0/2
$config{"trans_name"}{1251} ||= "cp1251"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{1251} ||= "cp1251"
$config{"trans_name"}{1251}
Truth table0%0/2
A
A= $config{"trans_name"}{1251}
Aresult
11
00
203 #$config{'trans_name'}{'koi8-r'} ||= 'koi8-r';
204 0 ▶ $config{'trans_name'}{'koi8r'} ||= 'koi8-r';
Condition0%0/2
$config{"trans_name"}{"koi8r"} ||= "koi8-r"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"koi8r"} ||= "koi8-r"
$config{"trans_name"}{"koi8r"}
Truth table0%0/2
A
A= $config{"trans_name"}{"koi8r"}
Aresult
11
00
205 0 ▶ $config{'trans_name'}{'koi8'} ||= 'koi8-r';
Condition0%0/2
$config{"trans_name"}{"koi8"} ||= "koi8-r"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"koi8"} ||= "koi8-r"
$config{"trans_name"}{"koi8"}
Truth table0%0/2
A
A= $config{"trans_name"}{"koi8"}
Aresult
11
00
206 0 ▶ $config{'trans_name'}{'koi'} ||= 'koi8-r';
Condition0%0/2
$config{"trans_name"}{"koi"} ||= "koi8-r"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"koi"} ||= "koi8-r"
$config{"trans_name"}{"koi"}
Truth table0%0/2
A
A= $config{"trans_name"}{"koi"}
Aresult
11
00
207 #$config{'trans_name'}{'iso8859-5'} ||='iso8859-5';
208 0 ▶ $config{'trans_name'}{'iso88595'} ||= 'iso8859-5';
Condition0%0/2
$config{"trans_name"}{"iso88595"} ||= "iso8859-5"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"iso88595"} ||= "iso8859-5"
$config{"trans_name"}{"iso88595"}
Truth table0%0/2
A
A= $config{"trans_name"}{"iso88595"}
Aresult
11
00
209 0 ▶ $config{'trans_name'}{'iso8859'} ||= 'iso8859-5';
Condition0%0/2
$config{"trans_name"}{"iso8859"} ||= "iso8859-5"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"iso8859"} ||= "iso8859-5"
$config{"trans_name"}{"iso8859"}
Truth table0%0/2
A
A= $config{"trans_name"}{"iso8859"}
Aresult
11
00
210 0 ▶ $config{'trans_name'}{'iso'} ||= 'iso8859-5';
Condition0%0/2
$config{"trans_name"}{"iso"} ||= "iso8859-5"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"iso"} ||= "iso8859-5"
$config{"trans_name"}{"iso"}
Truth table0%0/2
A
A= $config{"trans_name"}{"iso"}
Aresult
11
00
211 #$config{'trans_name'}{'cp866'} ||='cp866';
212 0 ▶ $config{'trans_name'}{'866'} ||= 'cp866';
Condition0%0/2
$config{"trans_name"}{866} ||= "cp866"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{866} ||= "cp866"
$config{"trans_name"}{866}
Truth table0%0/2
A
A= $config{"trans_name"}{866}
Aresult
11
00
213 0 ▶ $config{'trans_name'}{'dos'} ||= 'cp866';
Condition0%0/2
$config{"trans_name"}{"dos"} ||= "cp866"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"dos"} ||= "cp866"
$config{"trans_name"}{"dos"}
Truth table0%0/2
A
A= $config{"trans_name"}{"dos"}
Aresult
11
00
214 #$config{'trans_name'}{'utf-8'} ||= 'utf-8';
215 0 ▶ $config{'trans_name'}{'utf8'} ||= 'utf-8';
Condition0%0/2
$config{"trans_name"}{"utf8"} ||= "utf-8"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"utf8"} ||= "utf-8"
$config{"trans_name"}{"utf8"}
Truth table0%0/2
A
A= $config{"trans_name"}{"utf8"}
Aresult
11
00
216 0 ▶ $config{'trans_name'}{'utf'} ||= 'utf-8';
Condition0%0/2
$config{"trans_name"}{"utf"} ||= "utf-8"
l!l
00
MC/DC0%0/1
$config{"trans_name"}{"utf"} ||= "utf-8"
$config{"trans_name"}{"utf"}
Truth table0%0/2
A
A= $config{"trans_name"}{"utf"}
Aresult
11
00
217 0 ▶ $config{'cp_detect_strings'} ||= 0;
Condition0%0/2
$config{"cp_detect_strings"} ||= 0
l!l
00
MC/DC0%0/1
$config{"cp_detect_strings"} ||= 0
$config{"cp_detect_strings"}
Truth table0%0/2
A
A= $config{"cp_detect_strings"}
Aresult
11
00
218 0 ▶ $config{'cp_detect_letters'} ||= 2;
Condition0%0/2
$config{"cp_detect_letters"} ||= 2
l!l
00
MC/DC0%0/1
$config{"cp_detect_letters"} ||= 2
$config{"cp_detect_letters"}
Truth table0%0/2
A
A= $config{"cp_detect_letters"}
Aresult
11
00
219 0 ▶ $config{'cp_detect_length'} ||= 10000;
Condition0%0/2
$config{"cp_detect_length"} ||= 10000
l!l
00
MC/DC0%0/1
$config{"cp_detect_length"} ||= 10000
$config{"cp_detect_length"}
Truth table0%0/2
A
A= $config{"cp_detect_length"}
Aresult
11
00
220 0 ▶ $config{'kilo'} ||= 8; # 5000k 6000k 7000k >8<m 9m 10m
Condition0%0/2
$config{"kilo"} ||= 8
l!l
00
MC/DC0%0/1
$config{"kilo"} ||= 8
$config{"kilo"}
Truth table0%0/2
A
A= $config{"kilo"}
Aresult
11
00
221 0 ▶ $config{'lng'}{'en'}{'months'} ||= [qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)];
Condition0%0/2
$config{"lng"}{"en"}{"months"} ||= ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
l!l
00
MC/DC0%0/1
$config{"lng"}{"en"}{"months"} ||= ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
$config{"lng"}{"en"}{"months"}
Truth table0%0/2
A
A= $config{"lng"}{"en"}{"months"}
Aresult
11
00
222 0 ▶ $config{'lng'}{'ru'}{'months'} ||=
Condition0%0/2
$config{"lng"}{"ru"}{"months"} ||= ["\x{42f}\x{43d}\x{432}", "\x{424}\x{435}\x{432}", "\x{41c}\x{430}\x{440}", "\x{410}\x{43f}\x{440}", "\x{41c}\x{430}\x{439}", "\x{418}\x{44e}\x{43d}", "\x{418}\x{44e}\x{43b}", "\x{410}\x{432}\x{433}", "\x{421}\x{435}\x{43d}", "\x{41e}\x{43a}\x{442}", "\x{41d}\x{43e}\x{44f}", "\x{414}\x{435}\x{43a}"]
l!l
00
MC/DC0%0/1
$config{"lng"}{"ru"}{"months"} ||= ["\x{42f}\x{43d}\x{432}", "\x{424}\x{435}\x{432}", "\x{41c}\x{430}\x{440}", "\x{410}\x{43f}\x{440}", "\x{41c}\x{430}\x{439}", "\x{418}\x{44e}\x{43d}", "\x{418}\x{44e}\x{43b}", "\x{410}\x{432}\x{433}", "\x{421}\x{435}\x{43d}", "\x{41e}\x{43a}\x{442}", "\x{41d}\x{43e}\x{44f}", "\x{414}\x{435}\x{43a}"]
$config{"lng"}{"ru"}{"months"}
Truth table0%0/2
A
A= $config{"lng"}{"ru"}{"months"}
Aresult
11
00
223 [qw(Янв Фев Мар Апр Май Июн Июл Авг Сен Окт Ноя Дек)];
224 0 ▶ @{ $config{'lng'}{$_}{'month_table'} }{ @{ $config{'lng'}{$_}{'months'} || [] } } = ( 0 .. 11 )
Condition0%0/2
$config{'lng'}{$_}{'months'} || []
l!l
00
MC/DC0%0/1
$config{'lng'}{$_}{'months'} || []
$config{'lng'}{$_}{'months'}
Truth table0%0/2
A
A= $config{'lng'}{$_}{'months'}
Aresult
11
00
225 0 for keys %{ $config{'lng'} };
226 #@{ $config{'lng'}{''}{'month_table'} }{ @{ $config{'lng'}{''}{'months'} } } = ( 0 .. 11 ) ;
227 0 ▶ $config{'lng'}{'en'}{'wdays'} ||= [qw(Sun Mon Tue Wed Thu Fri Sat)];
Condition0%0/2
$config{"lng"}{"en"}{"wdays"} ||= ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
l!l
00
MC/DC0%0/1
$config{"lng"}{"en"}{"wdays"} ||= ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
$config{"lng"}{"en"}{"wdays"}
Truth table0%0/2
A
A= $config{"lng"}{"en"}{"wdays"}
Aresult
11
00
228 0 ▶ $config{'log_screen'} ||= 1;
Condition0%0/2
$config{"log_screen"} ||= 1
l!l
00
MC/DC0%0/1
$config{"log_screen"} ||= 1
$config{"log_screen"}
Truth table0%0/2
A
A= $config{"log_screen"}
Aresult
11
00
229 0 ▶ $config{'log_dir'} ||= $config{'root_path'};
Condition0%0/3
$config{"log_dir"} ||= $config{"root_path"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"log_dir"} ||= $config{"root_path"}
$config{"log_dir"} $config{"root_path"}
Truth table0%0/3
A ||= B
A= $config{"log_dir"}B= $config{"root_path"}
ABresult
1X1
011
000
230 0 ▶ unless ( $ENV{'SERVER_PORT'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"SERVER_PORT"}) 0 0 0
231 0 $0 =~ m{([^\\/\s]+)\.\w+$};
232 #warn "LD[$0:$1]";
233 0 ▶ $config{'log_default'} ||= ( $1 // $0 // 'log' ) . '.log';
Condition0%0/7
$config{"log_default"} ||= (($1 // $0) // "log") . '.log'
l!l
00
($1 // $0) // "log"
l!l
00
$1 // $0
l!l&&r!l&&!r
000
MC/DC0%0/1
$config{"log_default"} ||= (($1 // $0) // "log") . '.log'
$config{"log_default"}
Truth table0%0/2
A
A= $config{"log_default"}
Aresult
11
00
234 }
235 #$config{'log_all'} ||= '#book.log';
236 #$config{'log_all'} ||= '1';
237 0 ▶ $config{'encode_url_file_mask'} ||= '[^a-zA-Z0-9\-.()_]'; #url = '[^a-zA-Z0-9\-.()_!,]';
Condition0%0/2
$config{"encode_url_file_mask"} ||= "[^a-zA-Z0-9\\-.()_]"
l!l
00
MC/DC0%0/1
$config{"encode_url_file_mask"} ||= "[^a-zA-Z0-9\\-.()_]"
$config{"encode_url_file_mask"}
Truth table0%0/2
A
A= $config{"encode_url_file_mask"}
Aresult
11
00
238 0 ▶ $config{'human'}{'date'} ||= sub { #v1
Subroutine __ANON__: not called CC=3 SCAR=24.8
239 #my ( $day_of_month, $month, $year ) = ( localtime( ( $_[0] or time() ) ) )[ 3 .. 5 ];
240 #return sprintf( '%04d' . ( ( ( $_[1] or '/' ) . '%02d' ) x 2 ), $year + 1900, $month + 1, $day_of_month );
241 0 ▶ my $d = $_[1] || '/';
Condition0%0/2
$_[1] || '/'
l!l
00
MC/DC0%0/1
$_[1] || '/'
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
242 0 ▶ return strftime "%Y${d}%m${d}%d", localtime( $_[0] || time() );
Condition0%0/3
$_[0] || &psmisc::time()
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0] || &psmisc::time()
$_[0] &psmisc::time()
Truth table0%0/3
A || B
A= $_[0]B= &psmisc::time()
ABresult
1X1
011
000
243 #strftime "%Y%m%d%H%M%S", localtime
244 0 ▶ };
Condition0%0/3
$config{"human"}{"date"} ||= sub { my $d = $_[1] || "/"; return strftime("%Y$d%m$d%d", localtime($_[0] || &psmisc::time())); }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"date"} ||= sub { my $d = $_[1] || "/"; return strftime("%Y$d%m$d%d", localtime($_[0] || &psmisc::time())); }
$config{"human"}{"date"} sub { my $d = $_[1] || "/"; return strftime("%Y$d%m$d%d", localtime($_[0] || &psmisc::time())); }
Truth table0%0/3
A ||= B
A= $config{"human"}{"date"}B= sub { my $d = $_[1] || "/"; return strftime("%Y$d%m$d%d", localtime($_[0] || &psmisc::time())); }
ABresult
1X1
011
000
245 0 ▶ $config{'human'}{'time'} ||= sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
246 #return sprintf( join( ( $_[1] or ':' ), ( ("%02d") x 3 ) ), ( reverse( ( localtime( ( $_[0] or time() ) ) )[ 0 .. 2 ] ) ) );
247 0 ▶ my $d = $_[1] || ':';
Condition0%0/2
$_[1] || ':'
l!l
00
MC/DC0%0/1
$_[1] || ':'
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
248 0 ▶ return strftime "%H${d}%M${d}%S", localtime( $_[0] || time() );
Condition0%0/3
$_[0] || &psmisc::time()
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0] || &psmisc::time()
$_[0] &psmisc::time()
Truth table0%0/3
A || B
A= $_[0]B= &psmisc::time()
ABresult
1X1
011
000
249 0 ▶ };
Condition0%0/3
$config{"human"}{"time"} ||= sub { my $d = $_[1] || ":"; return strftime("%H$d%M$d%S", localtime($_[0] || &psmisc::time())); }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"time"} ||= sub { my $d = $_[1] || ":"; return strftime("%H$d%M$d%S", localtime($_[0] || &psmisc::time())); }
$config{"human"}{"time"} sub { my $d = $_[1] || ":"; return strftime("%H$d%M$d%S", localtime($_[0] || &psmisc::time())); }
Truth table0%0/3
A ||= B
A= $config{"human"}{"time"}B= sub { my $d = $_[1] || ":"; return strftime("%H$d%M$d%S", localtime($_[0] || &psmisc::time())); }
ABresult
1X1
011
000
250 # strftime "%Y-%m-%dT%H:%M:%S", localtime( $_[0] || time() )
251 $config{'human'}{'date_time'} ||=
252 0 ▶ sub { return human( 'date', $_[0] || time(), $_[2] ) . ( $_[1] || '-' ) . human( 'time', $_[0] || time(), $_[3] ); };
Subroutine __ANON__: not called CC=4 SCAR=30.0
Condition0%0/11
$config{"human"}{"date_time"} ||= sub { return &human("date", $_[0] || &psmisc::time(), $_[2]) . ($_[1] || "-") . &human("time", $_[0] || &psmisc::time(), $_[3]); }
l!l&&r!l&&!r
000
$_[0] || &psmisc::time()
l!l&&r!l&&!r
000
$_[1] || '-'
l!l
00
$_[0] || &psmisc::time()
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"date_time"} ||= sub { return &human("date", $_[0] || &psmisc::time(), $_[2]) . ($_[1] || "-") . &human("time", $_[0] || &psmisc::time(), $_[3]); }
$config{"human"}{"date_time"} sub { return &human("date", $_[0] || &psmisc::time(), $_[2]) . ($_[1] || "-") . &human("time", $_[0] || &psmisc::time(), $_[3]); }
MC/DC0%0/2
$_[0] || &psmisc::time()
$_[0] &psmisc::time()
MC/DC0%0/1
$_[1] || '-'
$_[1]
MC/DC0%0/2
$_[0] || &psmisc::time()
$_[0] &psmisc::time()
Truth table0%0/3
A ||= B
A= $config{"human"}{"date_time"}B= sub { return &human("date", $_[0] || &psmisc::time(), $_[2]) . ($_[1] || "-") . &human("time", $_[0] || &psmisc::time(), $_[3]); }
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $_[0]B= &psmisc::time()
ABresult
1X1
011
000
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
Truth table0%0/3
A || B
A= $_[0]B= &psmisc::time()
ABresult
1X1
011
000
253 0 ▶ $config{'human'}{'float'} ||= sub { #v1
Subroutine __ANON__: not called CC=5 SCAR=34.0
254 0 ▶ return ( $_[0] < 8 and $_[0] - int( $_[0] ) )
Branch: 3 branches
BranchTrueFalseTotal
$_[0] < 8 && $_[0] - int($_[0]) ? : 0 0 0
$_[0] < 1 ? : 0 0 0
$_[0] < 3 ? : 0 0 0
Condition0%0/3
$_[0] < 8 and $_[0] - int($_[0])
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] < 8 and $_[0] - int($_[0])
$_[0] < 8 $_[0] - int($_[0])
Truth table0%0/3
A and B
A= $_[0] < 8B= $_[0] - int($_[0])
ABresult
0X0
100
111
255 ? sprintf( '%.' . ( $_[0] < 1 ? 3 : ( $_[0] < 3 ? 2 : 1 ) ) . 'f', $_[0] )
256 : int( $_[0] );
257 0 ▶ };
Condition0%0/3
$config{"human"}{"float"} ||= sub { return $_[0] < 8 && $_[0] - int($_[0]) ? sprintf('%.' . ($_[0] < 1 ? 3 : ($_[0] < 3 ? 2 : 1)) . 'f', $_[0]) : int $_[0]; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"float"} ||= sub { return $_[0] < 8 && $_[0] - int($_[0]) ? sprintf('%.' . ($_[0] < 1 ? 3 : ($_[0] < 3 ? 2 : 1)) . 'f', $_[0]) : int $_[0]; }
$config{"human"}{"float"} sub { return $_[0] < 8 && $_[0] - int($_[0]) ? sprintf('%.' . ($_[0] < 1 ? 3 : ($_[0] < 3 ? 2 : 1)) . 'f', $_[0]) : int $_[0]; }
Truth table0%0/3
A ||= B
A= $config{"human"}{"float"}B= sub { return $_[0] < 8 && $_[0] - int($_[0]) ? sprintf('%.' . ($_[0] < 1 ? 3 : ($_[0] < 3 ? 2 : 1)) . 'f', $_[0]) : int $_[0]; }
ABresult
1X1
011
000
258 0 ▶ $config{'human'}{'micro_time'} ||= sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
259 0 my $now = time();
260 0 ( $now = human( 'float', abs( int($now) - $now ) ) ) =~ s/^0//;
261 0 ▶ return ( $now or '' );
Condition0%0/2
$now || ''
l!l
00
MC/DC0%0/1
$now || ''
$now
Truth table0%0/2
A
A= $now
Aresult
11
00
262 0 ▶ };
Condition0%0/3
$config{"human"}{"micro_time"} ||= sub { my $now = &psmisc::time(); ($now = &human("float", abs int($now) - $now)) =~ s/^0//; return $now || ""; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"micro_time"} ||= sub { my $now = &psmisc::time(); ($now = &human("float", abs int($now) - $now)) =~ s/^0//; return $now || ""; }
$config{"human"}{"micro_time"} sub { my $now = &psmisc::time(); ($now = &human("float", abs int($now) - $now)) =~ s/^0//; return $now || ""; }
Truth table0%0/3
A ||= B
A= $config{"human"}{"micro_time"}B= sub { my $now = &psmisc::time(); ($now = &human("float", abs int($now) - $now)) =~ s/^0//; return $now || ""; }
ABresult
1X1
011
000
263 0 ▶ $config{'human'}{'rfc822_date_time'} ||= sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
264 0 ▶ my ( $day_of_month, $month, $year, $wday ) = ( localtime( ( $_[0] or time() ) ) )[ 3 .. 6 ];
Condition0%0/3
$_[0] || &psmisc::time()
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0] || &psmisc::time()
$_[0] &psmisc::time()
Truth table0%0/3
A || B
A= $_[0]B= &psmisc::time()
ABresult
1X1
011
000
265 return sprintf( $config{'lng'}{'en'}{'wdays'}[$wday] . ', %02d ' . $config{'lng'}{'en'}{'months'}[$month] . ' %02d',
266 $day_of_month, $year + 1900 )
267 . ' '
268 0 ▶ . $config{'human'}{'time'}->( ( $_[0] or time() ) )
Condition0%0/3
$_[0] || &psmisc::time()
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0] || &psmisc::time()
$_[0] &psmisc::time()
Truth table0%0/3
A || B
A= $_[0]B= &psmisc::time()
ABresult
1X1
011
000
269 . ' +0300';
270 0 ▶ };
Condition0%0/3
$config{"human"}{"rfc822_date_time"} ||= sub { my($day_of_month, $month, $year, $wday) = (localtime($_[0] || &psmisc::time()))[3..6]; return sprintf($config{"lng"}{"en"}{"wdays"}[$wday] . ', %02d ' . $config{"lng"}{"en"}{"months"}[$month] . ' %02d', $day_of_month, $year + 1900) . ' ' . $config{"human"}{"time"}->($_[0] || &psmisc::time()) . ' +0300'; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"rfc822_date_time"} ||= sub { my($day_of_month, $month, $year, $wday) = (localtime($_[0] || &psmisc::time()))[3..6]; return sprintf($config{"lng"}{"en"}{"wdays"}[$wday] . ', %02d ' . $config{"lng"}{"en"}{"months"}[$month] . ' %02d', $day_of_month, $year + 1900) . ' ' . $config{"human"}{"time"}->($_[0] || &psmisc::time()) . ' +0300'; }
$config{"human"}{"rfc822_date_time"} sub { my($day_of_month, $month, $year, $wday) = (localtime($_[0] || &psmisc::time()))[3..6]; return sprintf($config{"lng"}{"en"}{"wdays"}[$wday] . ', %02d ' . $config{"lng"}{"en"}{"months"}[$month] . ' %02d', $day_of_month, $year + 1900) . ' ' . $config{"human"}{"time"}->($_[0] || &psmisc::time()) . ' +0300'; }
Truth table0%0/3
A ||= B
A= $config{"human"}{"rfc822_date_time"}B= sub { my($day_of_month, $month, $year, $wday) = (localtime($_[0] || &psmisc::time()))[3..6]; return sprintf($config{"lng"}{"en"}{"wdays"}[$wday] . ', %02d ' . $config{"lng"}{"en"}{"months"}[$month] . ' %02d', $day_of_month, $year + 1900) . ' ' . $config{"human"}{"time"}->($_[0] || &psmisc::time()) . ' +0300'; }
ABresult
1X1
011
000
271 0 ▶ $config{'human'}{'size'} ||= sub {
Subroutine __ANON__: not called CC=11 SCAR=48.8
272 0 my ( $size, $sp, $unit, $kilo ) = @_;
273 0 ▶ $sp //= ( $ENV{'SERVER_PORT'} ? ' ' : ' ' );
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'SERVER_PORT'} ? : 0 0 0
Condition0%0/2
$sp //= $ENV{"SERVER_PORT"} ? "\x{a0}" : " "
l!l
00
MC/DC0%0/1
$sp //= $ENV{"SERVER_PORT"} ? "\x{a0}" : " "
$sp
Truth table0%0/2
A
A= $sp
Aresult
11
00
274 0 ▶ $unit //= 'B';
Condition0%0/2
$unit //= "B"
l!l
00
MC/DC0%0/1
$unit //= "B"
$unit
Truth table0%0/2
A
A= $unit
Aresult
11
00
275 0 ▶ $kilo //= $config{'kilo'} || 8;
Condition0%0/4
$kilo //= $config{"kilo"} || 8
l!l
00
$config{'kilo'} || 8
l!l
00
MC/DC0%0/1
$kilo //= $config{"kilo"} || 8
$kilo
Truth table0%0/2
A
A= $kilo
Aresult
11
00
276 0 ▶ return int( $size / 1099511627776 ) . $sp . 'T' . $unit if ( $size >= $kilo * 1099511627776 );
Branch: 1 branch
BranchTrueFalseTotal
if $size >= $kilo * '1099511627776' 0 0 0
277 0 ▶ return int( $size / 1073741824 ) . $sp . 'G' . $unit if ( $size >= $kilo * 1073741824 );
Branch: 1 branch
BranchTrueFalseTotal
if $size >= $kilo * 1073741824 0 0 0
278 0 ▶ return int( $size / 1048576 ) . $sp . 'M' . $unit if ( $size >= $kilo * 1048576 );
Branch: 1 branch
BranchTrueFalseTotal
if $size >= $kilo * 1048576 0 0 0
279 0 ▶ return int( $size / 1024 ) . $sp . 'K' . $unit if ( $size >= $kilo * 1024 );
Branch: 1 branch
BranchTrueFalseTotal
if $size >= $kilo * 1024 0 0 0
280 0 ▶ return human( 'float', $size ) . $sp . $unit if ( $size > 0 );
Branch: 1 branch
BranchTrueFalseTotal
if $size > 0 0 0 0
281 0 return $size;
282 0 ▶ };
Condition0%0/3
$config{"human"}{"size"} ||= sub { my($size, $sp, $unit, $kilo) = @_; $sp //= $ENV{"SERVER_PORT"} ? "\x{a0}" : " "; $unit //= "B"; $kilo //= $config{"kilo"} || 8; return int($size / '1099511627776') . $sp . 'T' . $unit if $size >= $kilo * '1099511627776'; return int($size / 1073741824) . $sp . 'G' . $unit if $size >= $kilo * 1073741824; return int($size / 1048576) . $sp . 'M' . $unit if $size >= $kilo * 1048576; return int($size / 1024) . $sp . 'K' . $unit if $size >= $kilo * 1024; return &human("float", $size) . $sp . $unit if $size > 0; return $size; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"size"} ||= sub { my($size, $sp, $unit, $kilo) = @_; $sp //= $ENV{"SERVER_PORT"} ? "\x{a0}" : " "; $unit //= "B"; $kilo //= $config{"kilo"} || 8; return int($size / '1099511627776') . $sp . 'T' . $unit if $size >= $kilo * '1099511627776'; return int($size / 1073741824) . $sp . 'G' . $unit if $size >= $kilo * 1073741824; return int($size / 1048576) . $sp . 'M' . $unit if $size >= $kilo * 1048576; return int($size / 1024) . $sp . 'K' . $unit if $size >= $kilo * 1024; return &human("float", $size) . $sp . $unit if $size > 0; return $size; }
$config{"human"}{"size"} sub { my($size, $sp, $unit, $kilo) = @_; $sp //= $ENV{"SERVER_PORT"} ? "\x{a0}" : " "; $unit //= "B"; $kilo //= $config{"kilo"} || 8; return int($size / '1099511627776') . $sp . 'T' . $unit if $size >= $kilo * '1099511627776'; return int($size / 1073741824) . $sp . 'G' . $unit if $size >= $kilo * 1073741824; return int($size / 1048576) . $sp . 'M' . $unit if $size >= $kilo * 1048576; return int($size / 1024) . $sp . 'K' . $unit if $size >= $kilo * 1024; return &human("float", $size) . $sp . $unit if $size > 0; return $size; }
Truth table0%0/3
A ||= B
A= $config{"human"}{"size"}B= sub { my($size, $sp, $unit, $kilo) = @_; $sp //= $ENV{"SERVER_PORT"} ? "\x{a0}" : " "; $unit //= "B"; $kilo //= $config{"kilo"} || 8; return int($size / '1099511627776') . $sp . 'T' . $unit if $size >= $kilo * '1099511627776'; return int($size / 1073741824) . $sp . 'G' . $unit if $size >= $kilo * 1073741824; return int($size / 1048576) . $sp . 'M' . $unit if $size >= $kilo * 1048576; return int($size / 1024) . $sp . 'K' . $unit if $size >= $kilo * 1024; return &human("float", $size) . $sp . $unit if $size > 0; return $size; }
ABresult
1X1
011
000
283 0 ▶ $config{'human'}{'number_k'} ||= sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
284 0 local $_ = $_[0];
285 0 ▶ $_ *= 1024 if ( $_ =~ s/kb?$//gi );
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ s/kb?$//gi 0 0 0
286 0 ▶ $_ *= 1048576 if ( $_ =~ s/mb?$//gi );
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ s/mb?$//gi 0 0 0
287 0 ▶ $_ *= 1073741824 if ( $_ =~ s/gb?$//gi );
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ s/gb?$//gi 0 0 0
288 0 ▶ $_ *= 1099511627776 if ( $_ =~ s/tb?$//gi );
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ s/tb?$//gi 0 0 0
289 0 return $_;
290 0 ▶ };
Condition0%0/3
$config{"human"}{"number_k"} ||= sub { local $_ = $_[0]; $_ *= 1024 if $_ =~ s/kb?$//gi; $_ *= 1048576 if $_ =~ s/mb?$//gi; $_ *= 1073741824 if $_ =~ s/gb?$//gi; $_ *= '1099511627776' if $_ =~ s/tb?$//gi; return $_; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"number_k"} ||= sub { local $_ = $_[0]; $_ *= 1024 if $_ =~ s/kb?$//gi; $_ *= 1048576 if $_ =~ s/mb?$//gi; $_ *= 1073741824 if $_ =~ s/gb?$//gi; $_ *= '1099511627776' if $_ =~ s/tb?$//gi; return $_; }
$config{"human"}{"number_k"} sub { local $_ = $_[0]; $_ *= 1024 if $_ =~ s/kb?$//gi; $_ *= 1048576 if $_ =~ s/mb?$//gi; $_ *= 1073741824 if $_ =~ s/gb?$//gi; $_ *= '1099511627776' if $_ =~ s/tb?$//gi; return $_; }
Truth table0%0/3
A ||= B
A= $config{"human"}{"number_k"}B= sub { local $_ = $_[0]; $_ *= 1024 if $_ =~ s/kb?$//gi; $_ *= 1048576 if $_ =~ s/mb?$//gi; $_ *= 1073741824 if $_ =~ s/gb?$//gi; $_ *= '1099511627776' if $_ =~ s/tb?$//gi; return $_; }
ABresult
1X1
011
000
291 0 ▶ $config{'human'}{'procent'} ||= sub { #v1
Subroutine __ANON__: not called CC=2 SCAR=17.9
292 0 ▶ return sprintf( '%' . ( $_[0] < 10 ? '.3f' : 'd' ), $_[0] ) . '%';
Branch: 1 branch
BranchTrueFalseTotal
$_[0] < 10 ? : 0 0 0
293 0 ▶ };
Condition0%0/3
$config{"human"}{"procent"} ||= sub { return sprintf('%' . ($_[0] < 10 ? ".3f" : "d"), $_[0]) . '%'; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"procent"} ||= sub { return sprintf('%' . ($_[0] < 10 ? ".3f" : "d"), $_[0]) . '%'; }
$config{"human"}{"procent"} sub { return sprintf('%' . ($_[0] < 10 ? ".3f" : "d"), $_[0]) . '%'; }
Truth table0%0/3
A ||= B
A= $config{"human"}{"procent"}B= sub { return sprintf('%' . ($_[0] < 10 ? ".3f" : "d"), $_[0]) . '%'; }
ABresult
1X1
011
000
294 0 ▶ $config{'human'}{'time_period'} ||= sub { #v0
Subroutine __ANON__: not called CC=9 SCAR=45.0
295 0 my ( $tim, $delim, $sign ) = @_;
296 0 ▶ $sign = '-', $tim = -$tim if $tim < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $tim < 0 0 0 0
297 #print("tpern[", $tim, ']'),
298 0 ▶ return '' if $tim == 0 or $tim > 1000000000;
Branch: 1 branch
BranchTrueFalseTotal
if $tim == 0 or $tim > 1000000000 0 0 0
Condition0%0/3
$tim == 0 or $tim > 1000000000
l!l&&r!l&&!r
000
MC/DC0%0/2
$tim == 0 or $tim > 1000000000
$tim == 0 $tim > 1000000000
Truth table0%0/3
A or B
A= $tim == 0B= $tim > 1000000000
ABresult
1X1
011
000
299 #print("tperf[", $tim, ']'),
300 0 ▶ return ( $sign . human( 'float', $tim ) . $delim . "s" ) if $tim < 60;
Branch: 1 branch
BranchTrueFalseTotal
if $tim < 60 0 0 0
301 0 $tim = $tim / 60;
302 0 ▶ return ( $sign . int($tim) . $delim . "m" ) if $tim < 60;
Branch: 1 branch
BranchTrueFalseTotal
if $tim < 60 0 0 0
303 0 $tim = $tim / 60;
304 0 ▶ return ( $sign . int($tim) . $delim . "h" ) if $tim < 24;
Branch: 1 branch
BranchTrueFalseTotal
if $tim < 24 0 0 0
305 0 $tim = $tim / 24;
306 0 ▶ return ( $sign . int($tim) . $delim . "d" ) if $tim <= 31;
Branch: 1 branch
BranchTrueFalseTotal
if $tim <= 31 0 0 0
307 0 $tim = $tim / 30.5;
308 0 ▶ return ( $sign . int($tim) . $delim . "M" ) if $tim < 12;
Branch: 1 branch
BranchTrueFalseTotal
if $tim < 12 0 0 0
309 0 $tim = $tim / 12;
310 0 return ( $sign . int($tim) . $delim . "Y" );
311 0 ▶ };
Condition0%0/3
$config{"human"}{"time_period"} ||= sub { my($tim, $delim, $sign) = @_; $sign = "-", $tim = -$tim if $tim < 0; return "" if $tim == 0 or $tim > 1000000000; return $sign . &human("float", $tim) . $delim . 's' if $tim < 60; $tim = $tim / 60; return $sign . int($tim) . $delim . 'm' if $tim < 60; $tim = $tim / 60; return $sign . int($tim) . $delim . 'h' if $tim < 24; $tim = $tim / 24; return $sign . int($tim) . $delim . 'd' if $tim <= 31; $tim = $tim / "30.5"; return $sign . int($tim) . $delim . 'M' if $tim < 12; $tim = $tim / 12; return $sign . int($tim) . $delim . 'Y'; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"time_period"} ||= sub { my($tim, $delim, $sign) = @_; $sign = "-", $tim = -$tim if $tim < 0; return "" if $tim == 0 or $tim > 1000000000; return $sign . &human("float", $tim) . $delim . 's' if $tim < 60; $tim = $tim / 60; return $sign . int($tim) . $delim . 'm' if $tim < 60; $tim = $tim / 60; return $sign . int($tim) . $delim . 'h' if $tim < 24; $tim = $tim / 24; return $sign . int($tim) . $delim . 'd' if $tim <= 31; $tim = $tim / "30.5"; return $sign . int($tim) . $delim . 'M' if $tim < 12; $tim = $tim / 12; return $sign . int($tim) . $delim . 'Y'; }
$config{"human"}{"time_period"} sub { my($tim, $delim, $sign) = @_; $sign = "-", $tim = -$tim if $tim < 0; return "" if $tim == 0 or $tim > 1000000000; return $sign . &human("float", $tim) . $delim . 's' if $tim < 60; $tim = $tim / 60; return $sign . int($tim) . $delim . 'm' if $tim < 60; $tim = $tim / 60; return $sign . int($tim) . $delim . 'h' if $tim < 24; $tim = $tim / 24; return $sign . int($tim) . $delim . 'd' if $tim <= 31; $tim = $tim / "30.5"; return $sign . int($tim) . $delim . 'M' if $tim < 12; $tim = $tim / 12; return $sign . int($tim) . $delim . 'Y'; }
Truth table0%0/3
A ||= B
A= $config{"human"}{"time_period"}B= sub { my($tim, $delim, $sign) = @_; $sign = "-", $tim = -$tim if $tim < 0; return "" if $tim == 0 or $tim > 1000000000; return $sign . &human("float", $tim) . $delim . 's' if $tim < 60; $tim = $tim / 60; return $sign . int($tim) . $delim . 'm' if $tim < 60; $tim = $tim / 60; return $sign . int($tim) . $delim . 'h' if $tim < 24; $tim = $tim / 24; return $sign . int($tim) . $delim . 'd' if $tim <= 31; $tim = $tim / "30.5"; return $sign . int($tim) . $delim . 'M' if $tim < 12; $tim = $tim / 12; return $sign . int($tim) . $delim . 'Y'; }
ABresult
1X1
011
000
312 0 ▶ $config{'human'}{'number'} ||= sub { #v0 #FIXIT
Subroutine __ANON__: not called CC=1 SCAR=6.9
313 #return $_ = reverse( join( ' ', split( /(\d{3})/, reverse $_[0] ) ) );
314 #local $_ = reverse( join( ' ', split( /(\d{3})/, reverse $_[0] ) ) );
315 #return $_;
316 #return reverse( join( ' ', grep {length $_} split( /(\d{3})/, reverse $_[0] ) ) )
317 0 return local $_ = reverse join ' ', grep { length $_ } split /(\d{3})/, reverse $_[0];
318 0 ▶ };
Condition0%0/3
$config{"human"}{"number"} ||= sub { return local $_ = reverse(join(" ", grep({length $_;} split(/(\d{3})/, reverse($_[0]), 0)))); }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"number"} ||= sub { return local $_ = reverse(join(" ", grep({length $_;} split(/(\d{3})/, reverse($_[0]), 0)))); }
$config{"human"}{"number"} sub { return local $_ = reverse(join(" ", grep({length $_;} split(/(\d{3})/, reverse($_[0]), 0)))); }
Truth table0%0/3
A ||= B
A= $config{"human"}{"number"}B= sub { return local $_ = reverse(join(" ", grep({length $_;} split(/(\d{3})/, reverse($_[0]), 0)))); }
ABresult
1X1
011
000
319 #print 'dh1:',Dumper $config{'human'};
320 0 ▶ $config{'human'}{'string_long'} ||= sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
321 0 ▶ my $maxlen = ( $_[1] or 20 );
Condition0%0/2
$_[1] || 20
l!l
00
MC/DC0%0/1
$_[1] || 20
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
322 0 html_chars( \$_[0] );
323 0 ▶ return $_[0] if length $_[0] <= $maxlen;
Branch: 1 branch
BranchTrueFalseTotal
if length $_[0] <= $maxlen 0 0 0
324 0 my $print = substr( $_[0], 0, $maxlen );
325 0 $print =~ s/[\xD0\xD1]$//;
326 0 $_[0] =~ s/\"/&quot;/g;
327 0 return "<span title=\"" . $_[0] . "\">$print...</span>";
328 0 ▶ };
Condition0%0/3
$config{"human"}{"string_long"} ||= sub { my $maxlen = $_[1] || 20; &html_chars(\$_[0]); return $_[0] if length $_[0] <= $maxlen; my $print = substr($_[0], 0, $maxlen); $print =~ s/[\xD0\xD1]$//; $_[0] =~ s/\"/&quot;/g; return '<span title="' . $_[0] . qq[">$print...</span>]; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{"human"}{"string_long"} ||= sub { my $maxlen = $_[1] || 20; &html_chars(\$_[0]); return $_[0] if length $_[0] <= $maxlen; my $print = substr($_[0], 0, $maxlen); $print =~ s/[\xD0\xD1]$//; $_[0] =~ s/\"/&quot;/g; return '<span title="' . $_[0] . qq[">$print...</span>]; }
$config{"human"}{"string_long"} sub { my $maxlen = $_[1] || 20; &html_chars(\$_[0]); return $_[0] if length $_[0] <= $maxlen; my $print = substr($_[0], 0, $maxlen); $print =~ s/[\xD0\xD1]$//; $_[0] =~ s/\"/&quot;/g; return '<span title="' . $_[0] . qq[">$print...</span>]; }
Truth table0%0/3
A ||= B
A= $config{"human"}{"string_long"}B= sub { my $maxlen = $_[1] || 20; &html_chars(\$_[0]); return $_[0] if length $_[0] <= $maxlen; my $print = substr($_[0], 0, $maxlen); $print =~ s/[\xD0\xD1]$//; $_[0] =~ s/\"/&quot;/g; return '<span title="' . $_[0] . qq[">$print...</span>]; }
ABresult
1X1
011
000
329 #print 'dh2:',Dumper $config{'human'};
330 },
331 1 1010,
332 );
333 }
334  
335 0 ▶sub get_params_one(@) { # p=x,p=y,p=z => p=x,p1=y,p2=z ; p>=z => p=z, p_mode='>'; p => p; -p => -p=1;
Subroutine get_params_one: not called CC=9 SCAR=45.0
Pod undocumented
336 0 ▶ local %_ = %{ ref $_[0] eq 'HASH' ? shift : {} };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
337 0 for (@_) { # PERL RULEZ # SORRY # 8-) #
338 #tr/+/ /, s/%([a-f\d]{2})/pack 'C', hex $1/gei for my ( $k, $v ) = /^([^=]+=?)=(.+)$/ ? ( $1, $2 ) : ( /^([^=]*)=?$/, /^-/ );
339 0 ▶ tr/+/ /, s/%([a-f\d]{2})/pack 'H*', $1/gei for my ( $k, $v ) = /^([^=]+=?)=(.+)$/ ? ( $1, $2 ) : ( /^([^=]*)=?$/, /^-/ );
Branch: 1 branch
BranchTrueFalseTotal
/^([^=]+=?)=(.+)$/ ? : 0 0 0
340 0 ▶ $_{"${1}_mode$2"} .= $3 if $k =~ s/^(.+?)(\d*)([=!><~@]+)$/$1$2/;
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ s/^(.+?)(\d*)([=!><~\@]+)$/$1$2/ 0 0 0
341 0 ▶ $k =~ s/(\d*)$/($1 < 100 ? $1 + 1 : last)/e while defined $_{$k};
Branch: 2 branches
BranchTrueFalseTotal
defined $_{$k} and do { $k =~ s/(\d*)$/$1 < 100 ? $1 + 1 : (last);/e } 0 0 0
$1 < 100 ? : 0 0 0
342 0 $_{$k} = $v; #lc can be here
343 }
344 0 ▶ wantarray ? %_ : \%_;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
345 }
346  
347 0 ▶sub get_params(;$$) { #v7
Subroutine get_params: not called CC=6 SCAR=37.4
Pod undocumented
348 0 my ( $string, $delim ) = @_;
349 0 ▶ $delim ||= '&';
Condition0%0/2
$delim ||= "&"
l!l
00
MC/DC0%0/1
$delim ||= "&"
$delim
Truth table0%0/2
A
A= $delim
Aresult
11
00
350 0 ▶ read( STDIN, local $_ = '', $ENV{'CONTENT_LENGTH'} ) if !$string and $ENV{'CONTENT_LENGTH'};
Branch: 1 branch
BranchTrueFalseTotal
if not $string and $ENV{"CONTENT_LENGTH"} 0 0 0
Condition0%0/3
not $string and $ENV{"CONTENT_LENGTH"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $string and $ENV{"CONTENT_LENGTH"}
not $string $ENV{"CONTENT_LENGTH"}
Truth table0%0/3
not(A) and B
A= not $stringB= $ENV{"CONTENT_LENGTH"}
ABresult
0X0
100
111
351 local %_ = $string
352 ? get_params_one split $delim, $string
353 : (
354 0 get_params_one(@ARGV), map { get_params_one split $delim, $_ } split( /;\s*/, $ENV{'HTTP_COOKIE'} ),
355 0 ▶ $ENV{'QUERY_STRING'}, $_
Branch: 1 branch
BranchTrueFalseTotal
$string ? : 0 0 0
356 );
357 #dmp (\%_);
358 0 ▶ wantarray ? %_ : \%_;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
359 }
360  
361 0 ▶sub get_params_utf8(;$$) {
Subroutine get_params_utf8: not called CC=3 SCAR=24.8
Pod undocumented
362 0 local $_ = &get_params;
363 0 utf8::decode $_ for %$_;
364 #dmp (\%_);
365 0 ▶ wantarray ? %$_ : $_;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
366 }
367  
368 0 ▶sub use_try ($;@) {
Subroutine use_try: not called CC=3 SCAR=24.8
Pod undocumented
369 0 ( my $path = ( my $module = shift ) . '.pm' ) =~ s{::}{/}g;
370 0 ▶ $INC{$path} or eval 'use ' . $module . ' qw(' . ( join ' ', @_ ) . ');1;' and $INC{$path};
Branch: 1 branch
BranchTrueFalseTotal
$INC{$path} or eval 'use ' . $module . ' qw(' . join(" ", @_) . ');1;' and $INC{$path} 0 0 0
Condition0%0/6
$INC{$path} || eval 'use ' . $module . ' qw(' . join(' ', @_) . ');1;' && $INC{$path}
l!l&&r!l&&!r
000
eval 'use ' . $module . ' qw(' . join(" ", @_) . ');1;' and $INC{$path}
!ll&&!rl&&r
000
MC/DC0%0/3
$INC{$path} || eval 'use ' . $module . ' qw(' . join(' ', @_) . ');1;' && $INC{$path}
$INC{$path} eval 'use ' . $module . ' qw(' . join(" ", @_) . ');1;' $INC{$path}
Truth table0%0/4
A || B and C
A= $INC{$path}B= eval 'use ' . $module . ' qw(' . join(" ", @_) . ');1;'C= $INC{$path}
ABCresult
1XX1
0111
00X0
0100
371 }
372 0 ▶sub is_array ($) { UNIVERSAL::isa( $_[0], 'ARRAY' ) }
Subroutine is_array: not called CC=1 SCAR=6.9
Pod undocumented
373 0 ▶sub is_array_size ($) { UNIVERSAL::isa( $_[0], 'ARRAY' ) and @{ $_[0] } }
Subroutine is_array_size: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], "ARRAY") and @{$_[0];} 0 0 0
374 0 ▶sub is_hash ($) { UNIVERSAL::isa( $_[0], 'HASH' ) }
Subroutine is_hash: not called CC=1 SCAR=6.9
Pod undocumented
375 0 ▶sub is_hash_size ($) { UNIVERSAL::isa( $_[0], 'HASH' ) and %{ $_[0] } }
Subroutine is_hash_size: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], "HASH") and %{$_[0];} 0 0 0
376 0 ▶sub is_code ($) { UNIVERSAL::isa( $_[0], 'CODE' ) }
Subroutine is_code: not called CC=1 SCAR=6.9
Pod undocumented
377 0 ▶sub code_run ($;@) { my $f = shift; return $f->(@_) if UNIVERSAL::isa( $f, 'CODE' ) }
Subroutine code_run: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($f, "CODE") 0 0 0
378  
379 0 ▶sub array (@) {
Subroutine array: not called CC=5 SCAR=34.0
Pod undocumented
380 0 ▶ local @_ = map { is_array $_ ? @$_ : $_ } ( @_ == 1 and !defined $_[0] ) ? () : @_;
Branch: 2 branches
BranchTrueFalseTotal
&is_array($_) ? : 0 0 0
@_ == 1 && !defined($_[0]) ? : 0 0 0
Condition0%0/3
@_ == 1 and not defined $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and not defined $_[0]
@_ == 1 not defined $_[0]
Truth table0%0/3
A and not(B)
A= @_ == 1B= not defined $_[0]
ABresult
0X0
100
111
381 #local@_ = map { ref $_ eq 'ARRAY' ? @$_ : $_ } (@_ == 1 and !defined$_[0]) ? () : @_;
382 0 ▶ wantarray ? @_ : \@_;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
383 }
384  
385 0 ▶sub array_any (@) {
Subroutine array_any: not called CC=5 SCAR=34.0
Pod undocumented
386 0 ▶ local @_ = map { is_array $_ ? @$_ : is_hash $_ ? sort keys %$_ : is_code $_ ? $_->() : $_ } @_;
Branch: 3 branches
BranchTrueFalseTotal
&is_array($_) ? : 0 0 0
&is_hash($_) ? : 0 0 0
&is_code($_) ? : 0 0 0
387 0 ▶ wantarray ? @_ : \@_;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
388 }
389  
390 0 ▶sub in ($@) {
Subroutine in: not called CC=1 SCAR=6.9
Pod undocumented
391 0 my $v = shift;
392 0 grep { $v eq $_ } &array_any;
393 }
394 0 ▶sub hash_merge ($$) { $_[0]{$_} = $_[1]{$_} for keys %{ $_[1] }; }
Subroutine hash_merge: not called CC=2 SCAR=17.9
Pod undocumented
395  
396 =todo
397 ------------jCZJhSDkEEg0Avf4h2hejC
398 Content-Disposition: form-data; name="n1"
399  
400 ertyeryery
401 ------------jCZJhSDkEEg0Avf4h2hejC
402 Content-Disposition: form-data; name="n2"
403  
404 ryertytry
405 ------------jCZJhSDkEEg0Avf4h2hejC
406 Content-Disposition: form-data; name="q"
407  
408 ertyeryery
409 ------------jCZJhSDkEEg0Avf4h2hejC--
410 =cut
411  
412 0 ▶sub encode_url($;$) { #v5
Subroutine encode_url: not called CC=4 SCAR=30.0
Pod undocumented
413 0 my ( $str, $mask ) = @_;
414 0 ▶ return $str if defined $mask and !$mask;
Branch: 1 branch
BranchTrueFalseTotal
if defined $mask and not $mask 0 0 0
Condition0%0/3
defined $mask and not $mask
!ll&&!rl&&r
000
MC/DC0%0/2
defined $mask and not $mask
defined $mask not $mask
Truth table0%0/3
A and not(B)
A= defined $maskB= not $mask
ABresult
0X0
100
111
415 0 ▶ $mask ||= '[^a-zA-Z0-9\-.()_!,]';
Condition0%0/2
$mask ||= "[^a-zA-Z0-9\\-.()_!,]"
l!l
00
MC/DC0%0/1
$mask ||= "[^a-zA-Z0-9\\-.()_!,]"
$mask
Truth table0%0/2
A
A= $mask
Aresult
11
00
416 0 utf8::encode $str;
417 #return join( '+', map { s/$mask/'%'.sprintf('%02X', ord($&))/ge; $_ } split( /\x20/, $str ) );
418 0 return join '+', map { s/($mask)/sprintf'%%%02X',ord $1/ge; $_ } split /\x20/, $str;
419 }
420  
421 0 ▶sub encode_url_link($;$) {
Subroutine encode_url_link: not called CC=7 SCAR=40.3
Pod undocumented
422 #v5
423 0 my ( $str, $mask ) = @_;
424 0 ▶ return $str if defined $mask and !$mask;
Branch: 1 branch
BranchTrueFalseTotal
if defined $mask and not $mask 0 0 0
Condition0%0/3
defined $mask and not $mask
!ll&&!rl&&r
000
MC/DC0%0/2
defined $mask and not $mask
defined $mask not $mask
Truth table0%0/3
A and not(B)
A= defined $maskB= not $mask
ABresult
0X0
100
111
425 0 ▶ return $str if $str =~ /^(magnet|file):/i;
Branch: 1 branch
BranchTrueFalseTotal
if $str =~ /^(magnet|file):/i 0 0 0
426 #fixed?
427 #return $str if $config{'client_ie'};
428 #printlog('Eb',Dumper $str);
429 # eval {utf8::downgrade($str, 'FAIL_OK')# if utf8::is_utf8($str);
430 #};
431 #utf8::encode($str);
432 #utf8::downgrade($str, 'FAIL_OK') if utf8::is_utf8($str);
433 0 ▶ utf8::is_utf8($str) ? utf8::encode($str) : utf8::downgrade( $str, 'FAIL_OK' );
Branch: 1 branch
BranchTrueFalseTotal
utf8::is_utf8($str) ? : 0 0 0
434 0 local %_ = split_url($str);
435 0 ▶ $mask ||= '[^a-zA-Z0-9\-.()_\:@\/!,=]';
Condition0%0/2
$mask ||= "[^a-zA-Z0-9\\-.()_\\:\@\\/!,=]"
l!l
00
MC/DC0%0/1
$mask ||= "[^a-zA-Z0-9\\-.()_\\:\@\\/!,=]"
$mask
Truth table0%0/2
A
A= $mask
Aresult
11
00
436 #utf8::encode($_{$_}),
437 #utf8::downgrade($_{$_}, 'FAIL_OK'),
438 0 $_{$_} =~ s/$mask/sprintf'%%%2X',ord$&/ge for keys %_;
439 #printlog('Ea',Dumper \%_);
440 0 return join_url( \%_ );
441 }
442  
443 0 ▶sub decode_url($;$) { #v1
Subroutine decode_url: not called CC=2 SCAR=17.9
Pod undocumented
444 0 my ( $str, $noutf ) = @_;
445 0 $str =~ s/%([a-fA-F0-9]{2})/pack'C',hex$1/eg;
446 0 ▶ utf8::decode $str unless $noutf;
Branch: 1 branch
BranchTrueFalseTotal
unless $noutf 0 0 0
447 0 return $str;
448 }
449 {
450 1 my %fh;
451 1 my $savetime = 0;
452  
453 0 ▶ sub file_append(;$@) {
Subroutine file_append: not called CC=11 SCAR=48.8
Pod undocumented
454 0 local $_ = shift;
455 0 ▶ for ( defined $_ ? $_ : keys %fh ) { close( $fh{$_} ), delete( $fh{$_} ) if $fh{$_} and !@_; }
Branch: 2 branches
BranchTrueFalseTotal
defined $_ ? : 0 0 0
if $fh{$_} and not @_ 0 0 0
Condition0%0/3
$fh{$_} and not @_
!ll&&!rl&&r
000
MC/DC0%0/2
$fh{$_} and not @_
$fh{$_} not @_
Truth table0%0/3
A and not(B)
A= $fh{$_}B= not @_
ABresult
0X0
100
111
456 0 ▶ return if !@_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
457 0 ▶ unless ( $fh{$_} ) { return unless open $fh{$_}, '>>', $_; return unless $fh{$_}; }
Branch: 3 branches
BranchTrueFalseTotal
unless ($fh{$_}) 0 0 0
unless open $fh{$_}, ">>", $_ 0 0 0
unless $fh{$_} 0 0 0
458 0 print { $fh{$_} } @_;
459 0 ▶ if ( time() > $savetime + 5 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&psmisc::time() > $savetime + 5) 0 0 0
460 0 close( $fh{$_} ), delete( $fh{$_} ) for keys %fh;
461 0 $savetime = time();
462 }
463 0 return @_;
464 }
465 1 ▶ END { close( $fh{$_} ) for keys %fh; }
Subroutine END: called CC=2 SCAR=6.9
466 }
467  
468 1 ▶sub file_rewrite(;$@) {
Subroutine file_rewrite: not called CC=2 SCAR=14.6
Pod undocumented
469 0 local $_ = shift;
470 0 ▶ return unless open my $fh, '>', $_;
Branch: 1 branch
BranchTrueFalseTotal
unless open my $fh, ">", $_ 0 0 0
471 0 print $fh @_;
472 }
473  
474 #all def fac =
475 #u u u 0
476 #u 1 u 1
477 #u 0 u 0
478 #u 1 0 0
479 #u * 1 1
480 #0 * * 0
481 #1 * * 1
482 0 ▶sub printlog (@) { #v5
Subroutine printlog: not called CC=35 SCAR=71.4
Pod undocumented
483 #print "[devlog][fac:$_[0]=".$config{ 'log_' . $_[0]}."][][log_screen=$config{'log_screen'} ]\n",Dumper (\%config );
484 0 ▶ return if defined $config{ 'log_' . $_[0] } and !$config{ 'log_' . $_[0] } and !$config{'log_all'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $config{'log_' . $_[0]} and not $config{'log_' . $_[0]} and not $config{"log_all"} 0 0 0
Condition0%0/6
defined $config{'log_' . $_[0]} and not $config{'log_' . $_[0]} and not $config{"log_all"}
!ll&&!rl&&r
000
defined $config{'log_' . $_[0]} and not $config{'log_' . $_[0]}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $config{'log_' . $_[0]} and not $config{'log_' . $_[0]} and not $config{"log_all"}
defined $config{'log_' . $_[0]} not $config{'log_' . $_[0]} not $config{"log_all"}
Truth table0%0/4
A and not(B) and not(C)
A= defined $config{'log_' . $_[0]}B= not $config{'log_' . $_[0]}C= not $config{"log_all"}
ABCresult
0XX0
10X0
1100
1111
485 #my $file = ( $config{'log_all'} or ( defined $config{ 'log_' . $_[0] } ? $config{ 'log_' . $_[0] } : '' ) );
486 my $file = ( (
487 defined $config{'log_all'}
488 ? $config{'log_all'}
489 0 ▶ : ( defined $config{ 'log_' . $_[0] } ? $config{ 'log_' . $_[0] } : $config{'log_default'} )
Branch: 2 branches
BranchTrueFalseTotal
defined $config{'log_all'} ? : 0 0 0
defined $config{'log_' . $_[0]} ? : 0 0 0
490 )
491 );
492 0 my $noscreen;
493 0 for ( 0 .. 1 ) {
494 0 ▶ $noscreen = 1 if $file =~ s/^[\-_]// or !$file;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ s/^[\-_]// or not $file 0 0 0
Condition0%0/3
$file =~ s/^[\-_]// or not $file
l!l&&r!l&&!r
000
MC/DC0%0/2
$file =~ s/^[\-_]// or not $file
$file =~ s/^[\-_]// not $file
Truth table0%0/3
A or not(B)
A= $file =~ s/^[\-_]//B= not $file
ABresult
1X1
011
000
495 0 ▶ $noscreen = 0 if $file =~ s/^[+\#]//;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ s/^[+\#]// 0 0 0
496 0 ▶ $file = $config{'log_default'}, next if $file eq '1';
Branch: 1 branch
BranchTrueFalseTotal
if $file eq 1 0 0 0
497 0 last;
498 }
499 0 ▶ my $html = !$file and ( $ENV{'SERVER_PORT'} or $config{'view'} eq 'html' or $config{'view'} =~ /http/i );
Branch: 1 branch
BranchTrueFalseTotal
my $html = !$file and $ENV{"SERVER_PORT"} || $config{"view"} eq "html" || $config{"view"} =~ /http/i 0 0 0
Condition0%0/9
(my $html = !$file) && ($ENV{'SERVER_PORT'} || $config{'view'} eq 'html' || $config{'view'} =~ /http/i)
!ll&&!rl&&r
000
$ENV{"SERVER_PORT"} or $config{"view"} eq "html" or $config{"view"} =~ /http/i
l!l&&r!l&&!r
000
$ENV{"SERVER_PORT"} or $config{"view"} eq "html"
l!l&&r!l&&!r
000
MC/DC0%0/4
(my $html = !$file) && ($ENV{'SERVER_PORT'} || $config{'view'} eq 'html' || $config{'view'} =~ /http/i)
(my $html = !$file) $ENV{"SERVER_PORT"} $config{"view"} eq "html" $config{"view"} =~ /http/i
Truth table0%0/5
not(A) && B or C or D
A= (my $html = !$file)B= $ENV{"SERVER_PORT"}C= $config{"view"} eq "html"D= $config{"view"} =~ /http/i
ABCDresult
0XXX0
10000
11XX1
101X1
10011
500 0 ▶ $file = undef if $file eq '1';
Branch: 1 branch
BranchTrueFalseTotal
if $file eq 1 0 0 0
501 0 my $xml = $config{'view'} eq 'xml';
502 0 ▶ my $delim = $config{'log_delim'} || ' ';
Condition0%0/2
$config{'log_delim'} || ' '
l!l
00
MC/DC0%0/1
$config{'log_delim'} || ' '
$config{'log_delim'}
Truth table0%0/2
A
A= $config{'log_delim'}
Aresult
11
00
503 my $string = join '', ( $xml ? '<debug><![CDATA[' : () ), ( $html ? '<div class="debug">' : () ), (
504 ( ( $html || $xml ) and !$file ) ? ()
505 : (
506 $config{'log_datetime'} eq '0' ? () : human( 'date_time', ),
507 ( $config{'log_micro'} ? human('micro_time') : () ),
508 ( $config{'log_pid'} ? (" [$$]") : () ),
509 )
510 ), (
511 $config{'log_caller'}
512 ? (
513 0 ▶ ' [', join( ',', grep { $_ and !/^ps/ } ( map { ( caller($_) )[ 2 .. 3 ] } ( 0 .. $config{'log_caller'} - 1 ) ) ), ']'
Branch: 9 branches
BranchTrueFalseTotal
$xml ? : 0 0 0
$html ? : 0 0 0
($html || $xml) && !$file ? : 0 0 0
$config{'log_datetime'} eq '0' ? : 0 0 0
$config{'log_micro'} ? : 0 0 0
$config{'log_pid'} ? : 0 0 0
$config{'log_caller'} ? : 0 0 0
$html ? : 0 0 0
$xml ? : 0 0 0
Condition0%0/9
$html || $xml and not $file
!ll&&!rl&&r
000
$html or $xml
l!l&&r!l&&!r
000
$_ && !/^ps/
!ll&&!rl&&r
000
MC/DC0%0/3
$html || $xml and not $file
$html $xml not $file
MC/DC0%0/2
$_ && !/^ps/
$_ !/^ps/
Truth table0%0/5
A or B and not(C)
A= $htmlB= $xmlC= not $file
ABCresult
00X0
1X00
0100
1X11
0111
Truth table0%0/3
A && not(B)
A= $_B= !/^ps/
ABresult
0X0
100
111
514 )
515 : ()
516 ),
517 $delim, join( $delim, @_ ),
518 #(),
519 ( $html ? '</div>' : () ), ( $xml ? ']]></debug>' : () ), ("\n");
520 #print "[devlog][fac:$_[0]=".$config{ 'log_' . $_[0]}."][file=$file][log_screen=$config{'log_screen'} log_default=$config{'log_default'} noscreen=$noscreen html=$html xml=$xml]\n" ;
521 0 file_append( $config{'log_dir'} . $file, $string );
522 0 ▶ file_append() if !$config{'log_cache'}; #flush buffer
Branch: 1 branch
BranchTrueFalseTotal
unless $config{"log_cache"} 0 0 0
523 #if ( @_ and $file and open( LOG, '>>', $config{'log_dir'}.$file ) ) {
524 #print LOG@string;
525 #close(LOG);
526 #}
527 #local $_ = join '', @string;
528 #print @string if @_ and $config{'log_screen'} and !$noscreen and ;
529 0 ▶ print $string if @_ and $config{'log_screen'} and !$noscreen and ( !utf8::is_utf8($string) or utf8::valid($string) );
Branch: 1 branch
BranchTrueFalseTotal
if @_ and $config{"log_screen"} and not $noscreen and !utf8::is_utf8($string) || utf8::valid($string) 0 0 0
Condition0%0/12
@_ and $config{"log_screen"} and not $noscreen and !utf8::is_utf8($string) || utf8::valid($string)
!ll&&!rl&&r
000
@_ and $config{"log_screen"} and not $noscreen
!ll&&!rl&&r
000
@_ and $config{"log_screen"}
!ll&&!rl&&r
000
not utf8::is_utf8($string) or utf8::valid($string)
l!l&&r!l&&!r
000
MC/DC0%0/5
@_ and $config{"log_screen"} and not $noscreen and !utf8::is_utf8($string) || utf8::valid($string)
@_ $config{"log_screen"} not $noscreen not utf8::is_utf8($string) utf8::valid($string)
Truth table0%0/6
A and B and not(C) and not(D) or E
A= @_B= $config{"log_screen"}C= not $noscreenD= not utf8::is_utf8($string)E= utf8::valid($string)
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
530 #print "not valid string\n"if utf8::is_utf8($string) and !utf8::valid($string);
531 #state(@_);
532 0 ▶ flush() if $config{'log_flush'};
Branch: 1 branch
BranchTrueFalseTotal
if $config{"log_flush"} 0 0 0
533 0 return @_;
534 }
535  
536 0 ▶sub file_read_ref ($) {
Subroutine file_read_ref: not called CC=2 SCAR=17.9
Pod undocumented
537 0 ▶ open my $f, '<', $_[0] or return;
Branch: 1 branch
BranchTrueFalseTotal
open my $f, "<", $_[0] or return 0 0 0
538 0 local $/ = undef;
539 0 my $ret = <$f>;
540 0 close $f;
541 0 return \$ret;
542 }
543  
544 0 ▶sub file_read ($) { #dont use, del
Subroutine file_read: not called CC=2 SCAR=17.9
Pod undocumented
545 0 ▶ open my $f, '<', $_[0] or return;
Branch: 1 branch
BranchTrueFalseTotal
open my $f, "<", $_[0] or return 0 0 0
546 0 local $/ = undef;
547 0 my $ret = <$f>;
548 0 close $f;
549 0 return $ret;
550 }
551  
552 0 ▶sub openproc($;$) { #my ($proc) = @_;
Subroutine openproc: not called CC=3 SCAR=24.8
Pod undocumented
553 0 printlog( 'dbg', 'run ext:', @_ );
554 0 my $handle;
555 #printlog('openok', $handle),
556 0 ▶ return $handle if $_[1] ? open( $handle, $_[0], $_[1] ) : open( $handle, $_[0] );
Branch: 2 branches
BranchTrueFalseTotal
if $_[1] ? open($handle, $_[0], $_[1]) : open($handle, $_[0]) 0 0 0
$_[1] ? : 0 0 0
557 #return $handle if open( $handle, ((), @_));
558 #printlog('openfail');
559 0 return;
560 }
561  
562 0 ▶sub printprog($;$$) { #v1
Subroutine printprog: not called CC=10 SCAR=47.0
Pod undocumented
563 0 my ( $proc, $nologbody, $handler, $layer ) = @_;
564 0 ▶ return unless $proc;
Branch: 1 branch
BranchTrueFalseTotal
unless $proc 0 0 0
565 0 my $ret;
566 0 my $tim = timer();
567 0 printlog( 'dbg', "Starting [$proc]:" );
568 0 ▶ system($proc), return if $nologbody and !$handler;
Branch: 1 branch
BranchTrueFalseTotal
if $nologbody and not $handler 0 0 0
Condition0%0/3
$nologbody and not $handler
!ll&&!rl&&r
000
MC/DC0%0/2
$nologbody and not $handler
$nologbody not $handler
Truth table0%0/3
A and not(B)
A= $nologbodyB= not $handler
ABresult
0X0
100
111
569 0 ▶ my $h = openproc( '-|' . $layer, "$proc $config{'stderr_redirect'}" ) or return 1;
Branch: 1 branch
BranchTrueFalseTotal
my $h = &openproc('-|' . $layer, qq[$proc $config{"stderr_redirect"}]) or return 1 0 0 0
570 0 ▶ while ( defined( local $_ = <$h> ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(local $_ = readline $h)) 0 0 0
571 0 s/\s*[\x0A\x0D]*$//;
572 0 ▶ next unless length $_;
Branch: 1 branch
BranchTrueFalseTotal
unless length $_ 0 0 0
573 0 ▶ printlog( 'dbg', $_ ) unless $nologbody;
Branch: 1 branch
BranchTrueFalseTotal
unless $nologbody 0 0 0
574 0 ▶ last if ref $handler eq 'CODE' and $ret = $handler->($_);
Branch: 1 branch
BranchTrueFalseTotal
if ref $handler eq "CODE" and $ret = &$handler($_) 0 0 0
Condition0%0/3
ref $handler eq "CODE" and $ret = &$handler($_)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $handler eq "CODE" and $ret = &$handler($_)
ref $handler eq "CODE" $ret = &$handler($_)
Truth table0%0/3
A and B
A= ref $handler eq "CODE"B= $ret = &$handler($_)
ABresult
0X0
100
111
575 }
576 0 close($h);
577 0 printlog( 'dbg', 'prog done per', human( 'time_period', $tim->() ) );
578 0 return $ret;
579 }
580  
581 0 ▶sub start(;$@) {
Subroutine start: not called CC=7 SCAR=40.3
Pod undocumented
582 0 my ($cmd) = shift;
583 0 ▶ if ($cmd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd) 0 0 0
584 #$processor{'out'}{'array'}->();
585 0 ▶ if ( $^O =~ /^(?:(ms)?(dos|win(32|nt)?))/i and $^O !~ /^cygwin/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /^(?:(ms)?(dos|win(32|nt)?))/i and not $^O =~ /^cygwin/i) { } 0 0 0
Condition0%0/3
$^O =~ /^(?:(ms)?(dos|win(32|nt)?))/i and not $^O =~ /^cygwin/i
!ll&&!rl&&r
000
MC/DC0%0/2
$^O =~ /^(?:(ms)?(dos|win(32|nt)?))/i and not $^O =~ /^cygwin/i
$^O =~ /^(?:(ms)?(dos|win(32|nt)?))/i not $^O =~ /^cygwin/i
Truth table0%0/3
A and not(B)
A= $^O =~ /^(?:(ms)?(dos|win(32|nt)?))/iB= not $^O =~ /^cygwin/i
ABresult
0X0
100
111
586 0 ▶ $config{'starter'} ||= 'cmd /c';
Condition0%0/2
$config{"starter"} ||= "cmd /c"
l!l
00
MC/DC0%0/1
$config{"starter"} ||= "cmd /c"
$config{"starter"}
Truth table0%0/2
A
A= $config{"starter"}
Aresult
11
00
587 0 ▶ $config{'spawn_prefix'} ||= 'start /min /low';
Condition0%0/2
$config{"spawn_prefix"} ||= "start /min /low"
l!l
00
MC/DC0%0/1
$config{"spawn_prefix"} ||= "start /min /low"
$config{"spawn_prefix"}
Truth table0%0/2
A
A= $config{"spawn_prefix"}
Aresult
11
00
588 } else {
589 0 ▶ $config{'spawn_postfix'} ||= '&';
Condition0%0/2
$config{"spawn_postfix"} ||= "&"
l!l
00
MC/DC0%0/1
$config{"spawn_postfix"} ||= "&"
$config{"spawn_postfix"}
Truth table0%0/2
A
A= $config{"spawn_postfix"}
Aresult
11
00
590 }
591 #"$config{'starter'} $config{'spawn_prefix'} $config{'perl'} $config{'root_path'}crawler.pl $force $start $config{'spawn_postfix'}";
592 0 my $com = join ' ', $config{'starter'}, $config{'spawn_prefix'}, $cmd, @_, $config{'spawn_postfix'};
593 0 printlog( 'dbg', "starting with $cmd:", $com );
594 #printlog( 'dbg', $com );
595 0 return system($com);
596 }
597 }
598  
599 0 ▶sub startme(;$@) {
Subroutine startme: not called CC=3 SCAR=24.8
Pod undocumented
600 0 my ($start) = shift;
601 0 ▶ if ($start) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start) 0 0 0
602  
603 =old
604 my ($start) = shift;
605 if ($start) {
606 #$processor{'out'}{'array'}->();
607 if ( $^O =~ /^(?:(ms)?(dos|win(32|nt)?))/i and $^O !~ /^cygwin/i ) {
608 $config{'starter'} ||= 'cmd /c';
609 $config{'spawn_prefix'} ||= 'start /min /low';
610 } else {
611 $config{'spawn_postfix'} ||= '&';
612 }
613 my $com =
614 #"$config{'starter'} $config{'spawn_prefix'} $config{'perl'} $config{'root_path'}crawler.pl $force $start $config{'spawn_postfix'}";
615 join ' ', $config{'starter'}, $config{'spawn_prefix'}, $^X, $work{'$0'} || $0, $start, @_, $config{'spawn_postfix'};
616 printlog( 'dbg', "starting with $start:", $com );
617 #printlog( 'dbg', $com );
618 system($com);
619 }
620 =cut
621  
622 0 ▶ return start( $^X, $work{'$0'} || $0, $start, @_ );
Condition0%0/3
$work{'$0'} || $0
l!l&&r!l&&!r
000
MC/DC0%0/2
$work{'$0'} || $0
$work{'$0'} $0
Truth table0%0/3
A || B
A= $work{'$0'}B= $0
ABresult
1X1
011
000
623 }
624 }
625 1 our $indent = 1;
626 1 our $join = ', ';
627 1 our $prefix = 'dmp'; # 'dmp '
628 1 our $caller_shift = 0;
629  
630 0 ▶sub dmp (@) {
Subroutine dmp: not called CC=6 SCAR=37.4
Pod undocumented
631 0 my $fname = (caller(1 + $caller_shift))[3];
632 0 ▶ $fname = (caller(0 + $caller_shift))[0] if $fname eq '(eval)';
Branch: 1 branch
BranchTrueFalseTotal
if $fname eq "(eval)" 0 0 0
633 printlog $prefix, $fname, ':', ( caller(0 + $caller_shift) )[2], ' ',
634 join $join,
635 0 ▶ map { ref $_ ? Data::Dumper->new( [$_] )->Indent($indent)->Pair( $indent ? ' => ' : '=>' )->Terse(1)->Sortkeys(1)->Dump() : "'$_'" } @_ ? @_ : $_;
Branch: 3 branches
BranchTrueFalseTotal
ref $_ ? : 0 0 0
$psmisc::indent ? : 0 0 0
@_ ? : 0 0 0
636 0 ▶ wantarray ? @_ : $_[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
637 }
638  
639 # trace; # trace 5 calls
640 # trace 10; # trace 10 calls
641 # trace 'bzzzz', [42]; # trace 5 and dumpit
642 0 ▶sub trace (;@) {
Subroutine trace: not called CC=6 SCAR=37.4
Pod undocumented
643 0 local $caller_shift = 1;
644 0 ▶ for (1..($_[0] =~ /^\d+$/ ? shift : 10)) {
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /^\d+$/ ? : 0 0 0
645 0 ▶ dmp $_, ((caller $_ + 1 )[3]||(caller $_ )[0]) . ':' . ((caller $_ )[2] || last), ($_ > 1 ? () : @_),;
Branch: 1 branch
BranchTrueFalseTotal
$_ > 1 ? : 0 0 0
Condition0%0/5
(caller $_ + 1)[3] || (caller $_)[0]
l!l&&r!l&&!r
000
(caller $_)[2] || (last)
l!l
00
MC/DC0%0/2
(caller $_ + 1)[3] || (caller $_)[0]
(caller $_ + 1)[3] (caller $_)[0]
MC/DC0%0/1
(caller $_)[2] || (last)
(caller $_)[2]
Truth table0%0/3
A || B
A= (caller $_ + 1)[3]B= (caller $_)[0]
ABresult
1X1
011
000
Truth table0%0/2
A
A= (caller $_)[2]
Aresult
11
00
646 }
647 }
648  
649 0 ▶sub state {
Subroutine state: not called CC=2 SCAR=17.9
Pod undocumented
650 0 ▶ $work{'$0'} ||= $0;
Condition0%0/3
$work{"\$0"} ||= $0
l!l&&r!l&&!r
000
MC/DC0%0/2
$work{"\$0"} ||= $0
$work{"\$0"} $0
Truth table0%0/3
A ||= B
A= $work{"\$0"}B= $0
ABresult
1X1
011
000
651 0 $0 = $config{'state_prefix'} . join ' ', @_;
652 }
653  
654 0 ▶sub hconfig($;@) {
Subroutine hconfig: not called CC=2 SCAR=17.9
Pod undocumented
655 0 my $par = shift;
656 #printlog('hc0', $par,@_);
657 #printlog('hc1', $_, $par),
658 0 return $config{'fine'}{$_}{$par} for grep { defined( $config{'fine'}{$_}{$par} ) } @_;
659 #printlog('hc2', $par),
660 0 return $config{$par};
661 }
662  
663 0 ▶sub html_chars($) {
Subroutine html_chars: not called CC=3 SCAR=24.8
Pod undocumented
664 #local $_ = $_[0];
665 0 local $_; # = $_[0];
666 0 ▶ $_ = \$_[0] unless ref $_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] 0 0 0
667 0 ▶ $_ ||= $_[0];
Condition0%0/3
$_ ||= $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ ||= $_[0]
$_ $_[0]
Truth table0%0/3
A ||= B
A= $_B= $_[0]
ABresult
1X1
011
000
668 #print "REf:",ref $_, $$_;
669 0 $$_ =~ s/\&/\&amp\;/g;
670 0 $$_ =~ s/\</\&lt\;/g;
671 0 $$_ =~ s/\>/\&gt\;/g;
672 0 $$_ =~ s/"/\&quot\;/g; #"
673 0 return $$_;
674 }
675  
676 0 ▶sub human($;@) {
Subroutine human: not called CC=2 SCAR=17.9
Pod undocumented
677 #print "HUM", @_;
678 0 my $via = shift;
679 #print "CO[$config{'human'}{$via}]", Dumper $config{'human'};
680 #my $code = $config{'human'}{$via} if ref $config{'human'}{$via} eq 'CODE';
681 #$code ||= $config{'human'}{$via} if ref $config{'human'}{$via} eq 'CODE';
682 #return $code->(@_) if $code;
683 0 ▶ return $config{'human'}{$via}->(@_) if ref $config{'human'}{$via} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $config{"human"}{$via} eq "CODE" 0 0 0
684 0 return @_;
685 }
686  
687 0 ▶sub func_cache($;@) {
Subroutine func_cache: not called CC=3 SCAR=24.8
Pod undocumented
688 0 my ($func) = shift;
689 0 my $save = $func . join( ':', @_ );
690 0 ▶ unless ( $static{'func_cache'}{$save} ) { @{ $static{'func_cache'}{$save} } = $func->(@_); }
Branch: 1 branch
BranchTrueFalseTotal
if ($psmisc::static{'func_cache'}{$save}) { } 0 0 0
691 else { }
692 0 ▶ return wantarray ? @{ $static{'func_cache'}{$save} } : $static{'func_cache'}{$save}[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
693 }
694  
695 0 ▶sub name_to_ip_noc($) {
Subroutine name_to_ip_noc: not called CC=3 SCAR=24.8
Pod undocumented
696 0 my ($name) = @_;
697 0 ▶ unless ( $name =~ /^\d+\.\d+\.\d+\.\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name =~ /^\d+\.\d+\.\d+\.\d+$/) 0 0 0
698 0 local $_ = ( gethostbyname($name) )[4];
699 0 ▶ return ( $name, 1 ) unless length($_) == 4;
Branch: 1 branch
BranchTrueFalseTotal
unless length $_ == 4 0 0 0
700 0 $name = inet_ntoa($_);
701 }
702 0 return $name;
703 }
704  
705 0 ▶sub ip_to_name_noc($) { #v1
Subroutine ip_to_name_noc: not called CC=2 SCAR=17.9
Pod undocumented
706 0 local $_;
707 0 ▶ return $_[0] unless $_ = ( gethostbyname( $_[0] ) )[4];
Branch: 1 branch
BranchTrueFalseTotal
unless $_ = (gethostbyname $_[0])[4] 0 0 0
708 0 return inet_ntoa($_);
709 }
710 0 ▶sub normalize_ip($) { return func_cache( \&normalize_ip_noc, @_ ); }
Subroutine normalize_ip: not called CC=1 SCAR=6.9
Pod undocumented
711 0 ▶sub ip_to_name($) { return func_cache( \&ip_to_name_noc, @_ ); }
Subroutine ip_to_name: not called CC=1 SCAR=6.9
Pod undocumented
712 0 ▶sub name_to_ip($) { return func_cache( \&name_to_ip_noc, @_ ); }
Subroutine name_to_ip: not called CC=1 SCAR=6.9
Pod undocumented
713  
714 0 ▶sub normalize_ip_noc($) { #v2
Subroutine normalize_ip_noc: not called CC=18 SCAR=58.3
Pod undocumented
715 0 my ($host) = @_;
716 #my ($err);
717 0 my ( $ip, $err ) = name_to_ip($host);
718 #printlog "ip[$ip]";
719 0 ▶ return undef if $ip =~ /^(?:0|127)\./ and !$host =~ /^(?:0|127)\./;
Branch: 1 branch
BranchTrueFalseTotal
if $ip =~ /^(?:0|127)\./ and !$host =~ /^(?:0|127)\./ 0 0 0
Condition0%0/3
$ip =~ /^(?:0|127)\./ and !$host =~ /^(?:0|127)\./
!ll&&!rl&&r
000
MC/DC0%0/2
$ip =~ /^(?:0|127)\./ and !$host =~ /^(?:0|127)\./
$ip =~ /^(?:0|127)\./ !$host =~ /^(?:0|127)\./
Truth table0%0/3
A and not(B)
A= $ip =~ /^(?:0|127)\./B= !$host =~ /^(?:0|127)\./
ABresult
0X0
100
111
720 return lc $host
721 if $config{'norm_skip_host'}
722 and ( (
723 0 ▶ ref $config{'norm_skip_host'} eq 'Regexp' ? $host =~ $config{'norm_skip_host'} : $host =~ /$config{'norm_skip_host'}/i
Branch: 2 branches
BranchTrueFalseTotal
if $config{"norm_skip_host"} and ref $config{"norm_skip_host"} eq "Regexp" ? $host =~ /$config{"norm_skip_host"}/ : $host =~ /$config{"norm_skip_host"}/i 0 0 0
ref $config{'norm_skip_host'} eq 'Regexp' ? : 0 0 0
Condition0%0/3
$config{"norm_skip_host"} and ref $config{"norm_skip_host"} eq "Regexp" ? $host =~ /$config{"norm_skip_host"}/ : $host =~ /$config{"norm_skip_host"}/i
!ll&&!rl&&r
000
MC/DC0%0/2
$config{"norm_skip_host"} and ref $config{"norm_skip_host"} eq "Regexp" ? $host =~ /$config{"norm_skip_host"}/ : $host =~ /$config{"norm_skip_host"}/i
$config{"norm_skip_host"} ref $config{"norm_skip_host"} eq "Regexp" ? $host =~ /$config{"norm_skip_host"}/ : $host =~ /$config{"norm_skip_host"}/i
Truth table0%0/3
A and B
A= $config{"norm_skip_host"}B= ref $config{"norm_skip_host"} eq "Regexp" ? $host =~ /$config{"norm_skip_host"}/ : $host =~ /$config{"norm_skip_host"}/i
ABresult
0X0
100
111
724 )
725 );
726 0 ▶ return $ip if $err;
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 0 0
727 0 my ($tmp);
728 0 ▶ return $ip unless $tmp = inet_aton($ip);
Branch: 1 branch
BranchTrueFalseTotal
unless $tmp = inet_aton($ip) 0 0 0
729 0 ▶ return $ip unless $host = ( gethostbyaddr( $tmp, AF_INET ) )[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $host = (gethostbyaddr $tmp, 2)[0] 0 0 0
730 0 ▶ for my $repl ( @{ $config{'ip_normalize_pre'} || [] } ) {
Condition0%0/2
$config{'ip_normalize_pre'} || []
l!l
00
MC/DC0%0/1
$config{'ip_normalize_pre'} || []
$config{'ip_normalize_pre'}
Truth table0%0/2
A
A= $config{'ip_normalize_pre'}
Aresult
11
00
731 0 ▶ last if $host =~ /^$repl\./;
Branch: 1 branch
BranchTrueFalseTotal
if $host =~ /^$repl\./ 0 0 0
732 0 my $thost = $host;
733 0 $thost =~ s/^[^.]+/$repl/;
734 0 my $pip = inet_aton($ip);
735 0 ▶ for $thost ( ( $host =~ /\..+\./ ? ($thost) : () ), $repl . '.' . $host ) {
Branch: 1 branch
BranchTrueFalseTotal
$host =~ /\..+\./ ? : 0 0 0
736 0 ▶ next unless @_ = grep $_, ( ( gethostbyname($thost) )[ 4 .. 14 ] );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ = grep($_, (gethostbyname $thost)[4..14]) 0 0 0
737 0 return $thost for ( grep $_ eq $pip, @_ );
738 }
739 }
740 0 ▶ return $ip unless @_ = ( gethostbyname($host) )[4];
Branch: 1 branch
BranchTrueFalseTotal
unless @_ = (gethostbyname $host)[4] 0 0 0
741 0 return $host for grep $_ eq $ip, map $_ = inet_ntoa($_), @_;
742 0 return $ip;
743 }
744  
745 0 ▶sub counter($;$) {
Subroutine counter: not called CC=1 SCAR=6.9
Pod undocumented
746 0 my $start = $_[0];
747 0 ▶ return sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
748 0 ▶ $start = $_[1] if $_[1];
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 0 0 0
749 0 ▶ return ( $_[0] - $start ) >= 0 ? ( $_[0] - $start ) : $start;
Branch: 1 branch
BranchTrueFalseTotal
$_[0] - $start >= 0 ? : 0 0 0
750 0 };
751 }
752  
753 0 ▶sub timer(;$) {
Subroutine timer: not called CC=2 SCAR=17.9
Pod undocumented
754 0 ▶ my ( $start, $ret ) = ( $_[0] || time() );
Condition0%0/3
$_[0] || &psmisc::time()
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0] || &psmisc::time()
$_[0] &psmisc::time()
Truth table0%0/3
A || B
A= $_[0]B= &psmisc::time()
ABresult
1X1
011
000
755 0 ▶ return sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
756 0 $ret = time() - $start;
757 0 ▶ $start = ( $_[0] or time() ) if defined( $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] 0 0 0
Condition0%0/3
$_[0] || &psmisc::time()
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0] || &psmisc::time()
$_[0] &psmisc::time()
Truth table0%0/3
A || B
A= $_[0]B= &psmisc::time()
ABresult
1X1
011
000
758 0 return $ret;
759 0 };
760 }
761  
762 0 ▶sub join_url($) { #v2
Subroutine join_url: not called CC=18 SCAR=58.3
Pod undocumented
763 return
764 ( $_[0]->{'prot'} ? $_[0]->{'prot'} . '://' : '' )
765 . ( $_[0]->{'user'} ? $_[0]->{'user'} . ( $_[0]->{'pass'} ? ':' . $_[0]->{'pass'} : '' ) . '@' : '' )
766 . $_[0]->{'host'}
767 . ( (
768 $_[0]->{'port'}
769 and ( !$static{'port2prot'}{ $_[0]->{'port'} } or ( $static{'port2prot'}{ $_[0]->{'port'} } ne $_[0]->{'prot'} ) )
770 )
771 ? ':'
772 . $_[0]->{'port'}
773 : ''
774 )
775 . ( $_[0]->{'dcuser'} ? '/' . $_[0]->{'dcuser'} : '' )
776 . ( ( !$_[0]->{'path'} or $_[0]->{'path'} =~ /^\// ) ? '' : '/' )
777 . $_[0]->{'path'}
778 . ( ( ( !$_[0]->{'path'} and ( !$_[0]->{'host'} or !( $_[0]->{'name'} or $_[0]->{'ext'} ) ) ) or $_[0]->{'path'} =~ /\/$/ )
779 ? ''
780 : '/' )
781 . $_[0]->{'name'}
782 . ( $_[0]->{'ext'} ? '.' . $_[0]->{'ext'} : '' )
783 . ( $_[0]->{'param'} ? '?' . $_[0]->{'param'} : '' )
784 0 ▶ . ( $_[0]->{'pos'} ? '#' . $_[0]->{'pos'} : '' );
Branch: 10 branches
BranchTrueFalseTotal
$_[0]{'prot'} ? : 0 0 0
$_[0]{'user'} ? : 0 0 0
$_[0]{'pass'} ? : 0 0 0
$_[0]{'port'} && (!$psmisc::static{'port2prot'}{$_[0]{'port'}} || $psmisc::static{'port2prot'}{$_[0]{'port'}} ne $_[0]{'prot'}) ? : 0 0 0
$_[0]{'dcuser'} ? : 0 0 0
!$_[0]{'path'} || $_[0]{'path'} =~ m[^/] ? : 0 0 0
!($_[0]{'path'} || $_[0]{'host'} && ($_[0]{'name'} || $_[0]{'ext'})) || $_[0]{'path'} =~ m[/$] ? : 0 0 0
$_[0]{'ext'} ? : 0 0 0
$_[0]{'param'} ? : 0 0 0
$_[0]{'pos'} ? : 0 0 0
Condition0%0/21
$_[0]{"port"} and !$psmisc::static{"port2prot"}{$_[0]{"port"}} || $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"}
!ll&&!rl&&r
000
not $psmisc::static{"port2prot"}{$_[0]{"port"}} or $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"}
l!l&&r!l&&!r
000
not $_[0]{"path"} or $_[0]{"path"} =~ m[^/]
l!l&&r!l&&!r
000
not $_[0]{"path"} || $_[0]{"host"} && ($_[0]{"name"} || $_[0]{"ext"}) or $_[0]{"path"} =~ m[/$]
l!l&&r!l&&!r
000
$_[0]{'path'} || $_[0]{'host'} && ($_[0]{'name'} || $_[0]{'ext'})
l!l&&r!l&&!r
000
$_[0]{"host"} and $_[0]{"name"} || $_[0]{"ext"}
!ll&&!rl&&r
000
$_[0]{"name"} or $_[0]{"ext"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$_[0]{"port"} and !$psmisc::static{"port2prot"}{$_[0]{"port"}} || $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"}
$_[0]{"port"} not $psmisc::static{"port2prot"}{$_[0]{"port"}} $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"}
MC/DC0%0/2
not $_[0]{"path"} or $_[0]{"path"} =~ m[^/]
not $_[0]{"path"} $_[0]{"path"} =~ m[^/]
MC/DC0%0/5
not $_[0]{"path"} || $_[0]{"host"} && ($_[0]{"name"} || $_[0]{"ext"}) or $_[0]{"path"} =~ m[/$]
$_[0]{'path'} $_[0]{"host"} $_[0]{"name"} $_[0]{"ext"} $_[0]{"path"} =~ m[/$]
Truth table0%0/4
A and not(B) or C
A= $_[0]{"port"}B= not $psmisc::static{"port2prot"}{$_[0]{"port"}}C= $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"}
ABCresult
0XX0
1000
11X1
1011
Truth table0%0/3
not(A) or B
A= not $_[0]{"path"}B= $_[0]{"path"} =~ m[^/]
ABresult
1X1
011
000
Truth table0%0/8
not(A || B and C or D) or E
A= $_[0]{'path'}B= $_[0]{"host"}C= $_[0]{"name"}D= $_[0]{"ext"}E= $_[0]{"path"} =~ m[/$]
ABCDEresult
00XXX1
0100X1
1XXX11
011X11
010111
1XXX00
011X00
010100
785 }
786 #[[prot://][user[:pass]@]host[:port][/dcuser][/[path]][/[name[.ext]]][?param][#pos]
787 0 ▶sub split_url($;$) { #v3
Subroutine split_url: not called CC=24 SCAR=64.0
Pod undocumented
788 0 ▶ my $table = ( $_[1] or $config{'sql_tresource'} );
Condition0%0/3
$_[1] || $config{'sql_tresource'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[1] || $config{'sql_tresource'}
$_[1] $config{'sql_tresource'}
Truth table0%0/3
A || B
A= $_[1]B= $config{'sql_tresource'}
ABresult
1X1
011
000
789 0 local %_ = ();
790 0 ( $_{'prot'}, $_{'host'} ) = $_[0] =~ m|^\s*(?:(\w+)\://)?(.*)$|;
791 0 ( $_{'host'}, $_{'path'} ) = $_{'host'} =~ m|^([^/]*)(/.*)?$|;
792 0 ( $_{'user'}, $_{'host'} ) = $_{'host'} =~ m|^(?:(.+)@)?(.*)|;
793 0 ( $_{'user'}, $_{'pass'} ) = $_{'user'} =~ m|^([^/:@]+):?(.*)|;
794 0 ( $_{'host'}, $_{'port'} ) = $_{'host'} =~ m|([^/:@]+)\:?(\d*)$|;
795 0 $_{'path'} =~ s|([^/]*)$||;
796 0 ( $_{'name'} ) = $1;
797 0 ▶ $_{'path'} =~ s|/*$|| if $_{'path'} ne '/';
Branch: 1 branch
BranchTrueFalseTotal
if $_{"path"} ne "/" 0 0 0
798 0 ▶ $_{'path'} ||= '/' if $_{'name'} or $_{'ext'};
Branch: 1 branch
BranchTrueFalseTotal
if $_{"name"} or $_{"ext"} 0 0 0
Condition0%0/5
$_{"name"} or $_{"ext"}
l!l&&r!l&&!r
000
$_{"path"} ||= "/"
l!l
00
MC/DC0%0/2
$_{"name"} or $_{"ext"}
$_{"name"} $_{"ext"}
MC/DC0%0/1
$_{"path"} ||= "/"
$_{"path"}
Truth table0%0/3
A or B
A= $_{"name"}B= $_{"ext"}
ABresult
1X1
011
000
Truth table0%0/2
A
A= $_{"path"}
Aresult
11
00
799 #( $_{'pos'} ) = ( $_{'name'} =~ s/#(.+)$// ? ($1) : (undef) );
800 0 ▶ ( $_{'pos'} ) = $1 if $_{'name'} =~ s/#(.+)$//;
Branch: 1 branch
BranchTrueFalseTotal
if $_{"name"} =~ s/#(.+)$// 0 0 0
801 0 ▶ ( $_{'param'} ) = $1 if $_{'name'} =~ s/\?(.+)$//;
Branch: 1 branch
BranchTrueFalseTotal
if $_{"name"} =~ s/\?(.+)$// 0 0 0
802 0 ▶ ( $_{'ext'} ) = ( $_{'name'} =~ s/\.([^\.]+)$// ? ($1) : ('') );
Branch: 1 branch
BranchTrueFalseTotal
$_{'name'} =~ s/\.([^\.]+)$// ? : 0 0 0
803 delete $_{'port'}
804 0 ▶ unless ( $_{'port'} and ( !$static{'port2prot'}{ $_{'port'} } or ( $static{'port2prot'}{ $_{'port'} } ne $_{'prot'} ) ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $_{"port"} and !$psmisc::static{"port2prot"}{$_{"port"}} || $psmisc::static{"port2prot"}{$_{"port"}} ne $_{"prot"} 0 0 0
Condition0%0/6
$_{"port"} and !$psmisc::static{"port2prot"}{$_{"port"}} || $psmisc::static{"port2prot"}{$_{"port"}} ne $_{"prot"}
!ll&&!rl&&r
000
not $psmisc::static{"port2prot"}{$_{"port"}} or $psmisc::static{"port2prot"}{$_{"port"}} ne $_{"prot"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$_{"port"} and !$psmisc::static{"port2prot"}{$_{"port"}} || $psmisc::static{"port2prot"}{$_{"port"}} ne $_{"prot"}
$_{"port"} not $psmisc::static{"port2prot"}{$_{"port"}} $psmisc::static{"port2prot"}{$_{"port"}} ne $_{"prot"}
Truth table0%0/4
A and not(B) or C
A= $_{"port"}B= not $psmisc::static{"port2prot"}{$_{"port"}}C= $psmisc::static{"port2prot"}{$_{"port"}} ne $_{"prot"}
ABCresult
0XX0
1000
11X1
1011
805 0 ▶ if ( $_{'prot'} eq 'dchub' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_{"prot"} eq "dchub") 0 0 0
806 #printlog ('split_url', 1, Dumper \%_);
807 0 my $dcuser;
808 ( $_{'path'} =~ s|^/([^/]+)|| and $dcuser = $1 )
809 or ($_{'path'} =~ s|^/?$||
810 and $_{'name'} =~ s|(.+)||
811 and $dcuser = $1
812 0 ▶ and $_{'ext'} =~ s|(.*)||
Branch: 2 branches
BranchTrueFalseTotal
$_{"path"} =~ s[^/([^/]+)][] and $dcuser = $1 or $_{"path"} =~ s[^/?$][] and $_{"name"} =~ s/(.+)// and $dcuser = $1 and $_{"ext"} =~ s/(.*)// and $dcuser .= ($1 ? ".$1" : "") 0 0 0
$1 ? : 0 0 0
Condition0%0/18
$_{'path'} =~ s[^/([^/]+)][] && ($dcuser = $1) || $_{'path'} =~ s[^/?$][] && $_{'name'} =~ s/(.+)// && ($dcuser = $1) && $_{'ext'} =~ s/(.*)// && ($dcuser .= ($1 ? ".$1" : ''))
l!l&&r!l&&!r
000
$_{"path"} =~ s[^/([^/]+)][] and $dcuser = $1
!ll&&!rl&&r
000
$_{"path"} =~ s[^/?$][] and $_{"name"} =~ s/(.+)// and $dcuser = $1 and $_{"ext"} =~ s/(.*)// and $dcuser .= ($1 ? ".$1" : "")
!ll&&!rl&&r
000
$_{"path"} =~ s[^/?$][] and $_{"name"} =~ s/(.+)// and $dcuser = $1 and $_{"ext"} =~ s/(.*)//
!ll&&!rl&&r
000
$_{"path"} =~ s[^/?$][] and $_{"name"} =~ s/(.+)// and $dcuser = $1
!ll&&!rl&&r
000
$_{"path"} =~ s[^/?$][] and $_{"name"} =~ s/(.+)//
!ll&&!rl&&r
000
MC/DC0%0/7
$_{'path'} =~ s[^/([^/]+)][] && ($dcuser = $1) || $_{'path'} =~ s[^/?$][] && $_{'name'} =~ s/(.+)// && ($dcuser = $1) && $_{'ext'} =~ s/(.*)// && ($dcuser .= ($1 ? ".$1" : ''))
$_{"path"} =~ s[^/([^/]+)][] $dcuser = $1 $_{"path"} =~ s[^/?$][] $_{"name"} =~ s/(.+)// $dcuser = $1 $_{"ext"} =~ s/(.*)// $dcuser .= ($1 ? ".$1" : "")
Truth table0%0/13
A and B || C and D and E and F and G
A= $_{"path"} =~ s[^/([^/]+)][]B= $dcuser = $1C= $_{"path"} =~ s[^/?$][]D= $_{"name"} =~ s/(.+)//E= $dcuser = $1F= $_{"ext"} =~ s/(.*)//G= $dcuser .= ($1 ? ".$1" : "")
ABCDEFGresult
11XXXXX1
0X111111
10111111
0X0XXXX0
0X10XXX0
0X110XX0
0X1110X0
0X111100
100XXXX0
1010XXX0
10110XX0
101110X0
10111100
813 and $dcuser .= ( $1 ? ".$1" : '' ) );
814 #printlog('dcu', $dcuser);
815 #printlog ('split_url', 2, join ':', %_);
816 0 ▶ if ( %{ $config{'sql'}{'table'}{$table}{'dcuser'} or {} } ) { $_{'dcuser'} = $dcuser; }
Branch: 1 branch
BranchTrueFalseTotal
if (%{$config{'sql'}{'table'}{$table}{'dcuser'} or {};}) { } 0 0 0
Condition0%0/2
$config{'sql'}{'table'}{$table}{'dcuser'} || {}
l!l
00
MC/DC0%0/1
$config{'sql'}{'table'}{$table}{'dcuser'} || {}
$config{'sql'}{'table'}{$table}{'dcuser'}
Truth table0%0/2
A
A= $config{'sql'}{'table'}{$table}{'dcuser'}
Aresult
11
00
817 else {
818 0 ( $_{'host'} = join_url( { 'host' => $_{'host'}, 'port' => $_{'port'}, 'path' => $dcuser, } ) ) =~ s|/$||;
819 0 delete $_{'port'};
820 #printlog ('split_url', 3, join ':', %_);
821 }
822 }
823 0 delete $_{$_} for grep !length $_{$_}, keys %_;
824 #printlog ('split_url', 'R', join ':', %_);
825 0 ▶ return wantarray ? %_ : \%_;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
826 }
827  
828 0 ▶sub full_host($;$) {
Subroutine full_host: not called CC=14 SCAR=53.5
Pod undocumented
829 0 ▶ my $table = ( $_[1] or $config{'sql_tresource'} );
Condition0%0/3
$_[1] || $config{'sql_tresource'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[1] || $config{'sql_tresource'}
$_[1] $config{'sql_tresource'}
Truth table0%0/3
A || B
A= $_[1]B= $config{'sql_tresource'}
ABresult
1X1
011
000
830 return join_url( {
831 0 ▶ ( %{ $config{'sql'}{'table'}{$table}{'user'} or {} } ? () : ( 'user' => $_[0]->{'user'} ) ),
Branch: 1 branch
BranchTrueFalseTotal
%{$config{'sql'}{'table'}{$table}{'pass'} or {};} ? : 0 0 0
Condition0%0/2
$config{'sql'}{'table'}{$table}{'user'} || {}
l!l
00
MC/DC0%0/1
$config{'sql'}{'table'}{$table}{'user'} || {}
$config{'sql'}{'table'}{$table}{'user'}
Truth table0%0/2
A
A= $config{'sql'}{'table'}{$table}{'user'}
Aresult
11
00
832 0 ▶ ( %{ $config{'sql'}{'table'}{$table}{'pass'} or {} } ? () : ( 'pass' => $_[0]->{'pass'} ) ),
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'port'} && (!$psmisc::static{'port2prot'}{$_[0]{'port'}} || $psmisc::static{'port2prot'}{$_[0]{'port'}} ne $_[0]{'prot'}) && (!%{$config{'sql'}{'table'}{$table}{'port'} or {};} || $_[0]{'prot'} eq 'dchub') ? : 0 0 0
Condition0%0/14
$config{'sql'}{'table'}{$table}{'pass'} || {}
l!l
00
$_[0]{"port"} and !$psmisc::static{"port2prot"}{$_[0]{"port"}} || $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"} and !%{$config{"sql"}{"table"}{$table}{"port"} or {};} || $_[0]{"prot"} eq "dchub"
!ll&&!rl&&r
000
$_[0]{"port"} and !$psmisc::static{"port2prot"}{$_[0]{"port"}} || $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"}
!ll&&!rl&&r
000
not $psmisc::static{"port2prot"}{$_[0]{"port"}} or $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"}
l!l&&r!l&&!r
000
not %{$config{"sql"}{"table"}{$table}{"port"} or {};} or $_[0]{"prot"} eq "dchub"
l!l&&r!l&&!r
000
MC/DC0%0/1
$config{'sql'}{'table'}{$table}{'pass'} || {}
$config{'sql'}{'table'}{$table}{'pass'}
MC/DC0%0/5
$_[0]{"port"} and !$psmisc::static{"port2prot"}{$_[0]{"port"}} || $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"} and !%{$config{"sql"}{"table"}{$table}{"port"} or {};} || $_[0]{"prot"} eq "dchub"
$_[0]{"port"} not $psmisc::static{"port2prot"}{$_[0]{"port"}} $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"} not %{$config{"sql"}{"table"}{$table}{"port"} or {};} $_[0]{"prot"} eq "dchub"
Truth table0%0/2
A
A= $config{'sql'}{'table'}{$table}{'pass'}
Aresult
11
00
Truth table0%0/8
A and not(B) or C and not(D) or E
A= $_[0]{"port"}B= not $psmisc::static{"port2prot"}{$_[0]{"port"}}C= $psmisc::static{"port2prot"}{$_[0]{"port"}} ne $_[0]{"prot"}D= not %{$config{"sql"}{"table"}{$table}{"port"} or {};}E= $_[0]{"prot"} eq "dchub"
ABCDEresult
0XXXX0
100XX0
11X000
101000
11X1X1
11X011
1011X1
101011
833 'host' => $_[0]->{'host'}, ( ( (
834 $_[0]->{'port'}
835 and ( !$static{'port2prot'}{ $_[0]->{'port'} } or ( $static{'port2prot'}{ $_[0]->{'port'} } ne $_[0]->{'prot'} ) )
836 )
837 0 ▶ and ( !%{ $config{'sql'}{'table'}{$table}{'port'} or {} } or ( $_[0]->{'prot'} eq 'dchub' ) )
Branch: 1 branch
BranchTrueFalseTotal
%{$config{'sql'}{'table'}{$table}{'dcuser'} or {};} ? : 0 0 0
Condition0%0/2
$config{'sql'}{'table'}{$table}{'port'} || {}
l!l
00
MC/DC0%0/1
$config{'sql'}{'table'}{$table}{'port'} || {}
$config{'sql'}{'table'}{$table}{'port'}
Truth table0%0/2
A
A= $config{'sql'}{'table'}{$table}{'port'}
Aresult
11
00
838 ) ? ( 'port' => $_[0]->{'port'} ) : ()
839 ),
840 0 ▶ ( %{ $config{'sql'}{'table'}{$table}{'dcuser'} or {} } ? () : ( 'dcuser' => $_[0]->{'dcuser'} ) ),
Branch: 1 branch
BranchTrueFalseTotal
%{$config{'sql'}{'table'}{$table}{'user'} or {};} ? : 0 0 0
Condition0%0/2
$config{'sql'}{'table'}{$table}{'dcuser'} || {}
l!l
00
MC/DC0%0/1
$config{'sql'}{'table'}{$table}{'dcuser'} || {}
$config{'sql'}{'table'}{$table}{'dcuser'}
Truth table0%0/2
A
A= $config{'sql'}{'table'}{$table}{'dcuser'}
Aresult
11
00
841 }
842 );
843 }
844 0 ▶sub cp_normalize($) { return $config{'trans_name'}{ lc $_[0] } || lc $_[0]; }
Subroutine cp_normalize: not called CC=2 SCAR=17.9
Pod undocumented
Condition0%0/3
$config{'trans_name'}{lc $_[0]} || lc $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{'trans_name'}{lc $_[0]} || lc $_[0]
$config{'trans_name'}{lc $_[0]} lc $_[0]
Truth table0%0/3
A || B
A= $config{'trans_name'}{lc $_[0]}B= lc $_[0]
ABresult
1X1
011
000
845  
846 0 ▶sub encode_safe ($$) {
Subroutine encode_safe: not called CC=3 SCAR=24.8
Pod undocumented
847 0 my ( $cto, $string ) = @_;
848 #printlog('es', $string);
849 0 $cto = cp_normalize($cto);
850 0 ▶ return $string if !$cto or $cto eq 'utf-8';
Branch: 1 branch
BranchTrueFalseTotal
if not $cto or $cto eq "utf-8" 0 0 0
Condition0%0/3
not $cto or $cto eq "utf-8"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $cto or $cto eq "utf-8"
not $cto $cto eq "utf-8"
Truth table0%0/3
not(A) or B
A= not $ctoB= $cto eq "utf-8"
ABresult
1X1
011
000
851 #return
852 #utf8::downgrade($string),
853 #Encode::_utf8_off($string);
854 #printlog('ensafeB',$cto, Dumper $string, utf8::is_utf8 $string);
855 #local $_ = Encode::encode $cto, Encode::decode 'utf-8', $string;
856 0 local $_ = Encode::encode $cto, $string, Encode::FB_WARN;
857 # Encode::_utf8_off($_);
858 #utf8::downgrade($_),
859 #utf8::decode($_),
860 #printlog('ensafeA',$cto, Dumper $_, utf8::is_utf8 $_);
861 #printlog('esR', $_);
862 0 return $_;
863 }
864  
865 0 ▶sub cp_trans($$$) { #v1
Subroutine cp_trans: not called CC=6 SCAR=37.4
Pod undocumented
866 0 my ( $cfrom, $cto, $string ) = @_;
867 0 $cfrom = cp_normalize($cfrom);
868 0 $cto = cp_normalize($cto);
869 #printlog('dev', 'cp_trans:', $cfrom, $cto, $string);
870 0 ▶ return $string if $cto eq $cfrom or !length($string) or !$cfrom or !$cto;
Branch: 1 branch
BranchTrueFalseTotal
if $cto eq $cfrom or not length $string or not $cfrom or not $cto 0 0 0
Condition0%0/9
$cto eq $cfrom or not length $string or not $cfrom or not $cto
l!l&&r!l&&!r
000
$cto eq $cfrom or not length $string or not $cfrom
l!l&&r!l&&!r
000
$cto eq $cfrom or not length $string
l!l&&r!l&&!r
000
MC/DC0%0/4
$cto eq $cfrom or not length $string or not $cfrom or not $cto
$cto eq $cfrom not length $string not $cfrom not $cto
Truth table0%0/5
A or not(B) or not(C) or not(D)
A= $cto eq $cfromB= not length $stringC= not $cfromD= not $cto
ABCDresult
1XXX1
01XX1
001X1
00011
00000
871 0 ▶ print( 'dev', 'cp_trans:', join ':', $cfrom, $cto, $string ) if $config{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $config{"debug"} 0 0 0
872 #local $_ = "$cfrom -> $cto";
873 #caller_trace();
874 #return scalar cp_trans_count(@_); # unless $config{'fast_cp_trans'};
875 #use Encode;
876 #$string = encode($cto, decode($cfrom, $string));
877 #return eval {Encode::encode $cto, Encode::decode $cfrom, $string} or $string;
878 0 Encode::from_to $string, $cfrom, $cto, Encode::FB_WARN;
879 0 return $string;
880 }
881  
882 0 ▶sub cp_trans_count($$$) { #v1
Subroutine cp_trans_count: not called CC=12 SCAR=50.5
Pod undocumented
883 0 my ( $cfrom, $cto, $string ) = @_;
884 0 $cfrom = cp_normalize($cfrom);
885 0 $cto = cp_normalize($cto);
886 #printlog('dev', 'cp_trans:', $cfrom, $cto, $string);
887 0 ▶ return $string if $cto eq $cfrom or !length($string) or !$cfrom or !$cto;
Branch: 1 branch
BranchTrueFalseTotal
if $cto eq $cfrom or not length $string or not $cfrom or not $cto 0 0 0
Condition0%0/9
$cto eq $cfrom or not length $string or not $cfrom or not $cto
l!l&&r!l&&!r
000
$cto eq $cfrom or not length $string or not $cfrom
l!l&&r!l&&!r
000
$cto eq $cfrom or not length $string
l!l&&r!l&&!r
000
MC/DC0%0/4
$cto eq $cfrom or not length $string or not $cfrom or not $cto
$cto eq $cfrom not length $string not $cfrom not $cto
Truth table0%0/5
A or not(B) or not(C) or not(D)
A= $cto eq $cfromB= not length $stringC= not $cfromD= not $cto
ABCDresult
1XXX1
01XX1
001X1
00011
00000
888 #print('dev', 'cp_trans:', join ':',$cfrom, $cto, $string);
889 #local $_ = "$cfrom -> $cto";
890 #caller_trace();
891 #use Encode;
892 #$string = encode($cto, decode($cfrom, $string));
893 #return encode($cto, decode($cfrom, $string));
894 0 ▶ return utf_trans( $cto, $string ) if $cfrom eq 'utf-8' and $config{'trans'}{$cto};
Branch: 1 branch
BranchTrueFalseTotal
if $cfrom eq "utf-8" and $config{"trans"}{$cto} 0 0 0
Condition0%0/3
$cfrom eq "utf-8" and $config{"trans"}{$cto}
!ll&&!rl&&r
000
MC/DC0%0/2
$cfrom eq "utf-8" and $config{"trans"}{$cto}
$cfrom eq "utf-8" $config{"trans"}{$cto}
Truth table0%0/3
A and B
A= $cfrom eq "utf-8"B= $config{"trans"}{$cto}
ABresult
0X0
100
111
895 0 ▶ return to_utf_trans( $cfrom, $string ) if $cto eq 'utf-8' and $config{'trans'}{$cfrom};
Branch: 1 branch
BranchTrueFalseTotal
if $cto eq "utf-8" and $config{"trans"}{$cfrom} 0 0 0
Condition0%0/3
$cto eq "utf-8" and $config{"trans"}{$cfrom}
!ll&&!rl&&r
000
MC/DC0%0/2
$cto eq "utf-8" and $config{"trans"}{$cfrom}
$cto eq "utf-8" $config{"trans"}{$cfrom}
Truth table0%0/3
A and B
A= $cto eq "utf-8"B= $config{"trans"}{$cfrom}
ABresult
0X0
100
111
896 0 my $cnt;
897 0 ▶ if ( $config{'trans'}{$cfrom} and $config{'trans'}{$cto} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config{"trans"}{$cfrom} and $config{"trans"}{$cto}) 0 0 0
Condition0%0/3
$config{"trans"}{$cfrom} and $config{"trans"}{$cto}
!ll&&!rl&&r
000
MC/DC0%0/2
$config{"trans"}{$cfrom} and $config{"trans"}{$cto}
$config{"trans"}{$cfrom} $config{"trans"}{$cto}
Truth table0%0/3
A and B
A= $config{"trans"}{$cfrom}B= $config{"trans"}{$cto}
ABresult
0X0
100
111
898 0 ( $cfrom, $cto ) = \( $config{'trans'}{$cfrom}, $config{'trans'}{$cto} );
899 0 eval "\$cnt = \$string =~ tr/$$cfrom/$$cto/";
900 }
901 #printlog('dev', "cp_trans($_):", $string), caller_trace() if $cnt;
902 0 ▶ return wantarray ? ( $string, $cnt ) : $string;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
903 }
904  
905 0 ▶sub utf_trans($$) {
Subroutine utf_trans: not called CC=4 SCAR=30.0
Pod undocumented
906 0 my ( $cto, $string ) = @_;
907 0 ▶ $cto ||= $config{'cp_db'};
Condition0%0/3
$cto ||= $config{"cp_db"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cto ||= $config{"cp_db"}
$cto $config{"cp_db"}
Truth table0%0/3
A ||= B
A= $ctoB= $config{"cp_db"}
ABresult
1X1
011
000
908 0 $cto = cp_normalize($cto);
909 0 ▶ return if $cto eq 'utf-8';
Branch: 1 branch
BranchTrueFalseTotal
if $cto eq "utf-8" 0 0 0
910 0 my ( $cnt, $cnt2 );
911 0 $cnt += $string =~ s/\xD0\x81/\xF0/g; # e
912 0 $cnt += $string =~ s/\xD1\x91/\xF1/g; # E
913 0 $cnt += $string =~ s/\xD0\x84/\xF4/g; # ukr beg
914 0 $cnt += $string =~ s/\xD1\x94/\xF5/g;
915 0 $cnt += $string =~ s/\xD0\x86/\xF6/g;
916 0 $cnt += $string =~ s/\xD1\x96/\xF7/g;
917 0 $cnt += $string =~ s/\xD0\x87/\xF8/g;
918 0 $cnt += $string =~ s/\xD1\x97/\xF9/g; # ukr end
919 0 $cnt += $string =~ s/\xE2\x80\x94/-/g; # -
920 0 $cnt += $string =~ s/\xC2\xAB/"/g; # «
921 0 $cnt += $string =~ s/\xC2\xBB/"/g; # »
922 0 $cnt += $string =~ s/\xD1\x98/j/g; #
923 0 $cnt += $string =~ s/\xD0\xB9/\xA9/g; # й
924 #$cnt += $string =~ s/\xD0\xA9/\xC9/g; # Щ
925 0 $cnt += $string =~ s/\xD0([\x90-\xBF])/chr(ord($1)-16)/eg;
926 0 $cnt += $string =~ s/\xD1([\x80-\x8F])/chr(ord($1)+96)/eg;
927 0 ( $string, $cnt2 ) = cp_trans_count( 'cp866', $cto, $string );
928 0 $cnt += $cnt2;
929 0 $cnt += $string =~ s/\x21\x16/\xB9/g; # й
930 0 ▶ return wantarray ? ( $string, $cnt ) : $string;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
931 }
932  
933 0 ▶sub to_utf_trans($$) {
Subroutine to_utf_trans: not called CC=4 SCAR=30.0
Pod undocumented
934 0 my ( $cfrom, $string ) = @_;
935 0 ▶ $cfrom ||= $config{'cp_db'};
Condition0%0/3
$cfrom ||= $config{"cp_db"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cfrom ||= $config{"cp_db"}
$cfrom $config{"cp_db"}
Truth table0%0/3
A ||= B
A= $cfromB= $config{"cp_db"}
ABresult
1X1
011
000
936 0 $cfrom = cp_normalize($cfrom);
937 0 ▶ return if $cfrom eq 'utf-8';
Branch: 1 branch
BranchTrueFalseTotal
if $cfrom eq "utf-8" 0 0 0
938 0 my $cnt;
939 #$cnt += $string =~ s/\xE9/\xD0\xB9/g; # й
940 0 $cnt += $string =~ s/\xAB/"/g; # <
941 0 $cnt += $string =~ s/\xBB/"/g; # <
942 #print "\ndos0[$string]\n";
943 0 ( $string, $cnt ) = cp_trans_count( $cfrom, 'cp866', $string );
944 #print "\ndos1[$string]\n";
945 0 $cnt += $string =~ s/([\x80-\x88\x8A-\xA8\xAA-\xAF])/"\xD0".chr(ord($1)+16)/eg;
946 0 $cnt += $string =~ s/([\xE0-\xE8\xEA-\xEF])/"\xD1".chr(ord($1)-96)/eg;
947 #print "\ndos2[$string]\n";
948 0 $cnt += $string =~ s/\xF0/\xD0\x81/g; # e
949 0 $cnt += $string =~ s/\xF1/\xD1\x91/g; # E
950 0 $cnt += $string =~ s/\xF4/\xD0\x84/g; # ukr beg
951 0 $cnt += $string =~ s/\xF5/\xD1\x94/g;
952 0 $cnt += $string =~ s/\xF6/\xD0\x86/g;
953 0 $cnt += $string =~ s/\xF7/\xD1\x96/g;
954 0 $cnt += $string =~ s/\xF8/\xD0\x87/g;
955 0 $cnt += $string =~ s/\xF9/\xD1\x97/g; # ukr end
956 #=c
957 0 $cnt += $string =~ s/(?<!\xD0)\xB9/\x21\x16/g; # №
958 0 $cnt += $string =~ s/(?<!\xD0)\xA9/\xD0\xB9/g; # й
959 0 $cnt += $string =~ s/(?<!\xD0)\x89/\xD0\x99/g; # Й
960 0 $cnt += $string =~ s/(?<!\xD0)\xE9/\xD1\x89/g; # щ
961 0 $cnt += $string =~ s/(?<!\xD0)\x99/\xD0\xA9/g; # Щ
962 #=cut
963 #$cnt += $string =~ s/\xAB/"/g; # <
964 #$cnt += $string =~ s/\xBB/"/g; # >
965 0 ▶ return wantarray ? ( $string, $cnt ) : $string;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
966 }
967  
968 0 ▶sub cp_trans_hash($$$) {
Subroutine cp_trans_hash: not called CC=4 SCAR=30.0
Pod undocumented
969 0 my ( $from, $to, $hash ) = @_;
970 #printlog('dev', 'cp_trans_hash:', $from, $to, Dumper $hash);
971 0 ▶ return $hash if $from eq $to;
Branch: 1 branch
BranchTrueFalseTotal
if $from eq $to 0 0 0
972 0 $hash->{$_} = cp_trans( $from, $to, $hash->{$_} ) for grep { !ref $hash->{$_} }keys %$hash;
973 0 ▶ return wantarray ? %$hash : $hash;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
974 }
975  
976 0 ▶sub max_hash_el($$;$) {
Subroutine max_hash_el: not called CC=3 SCAR=24.8
Pod undocumented
977 0 my ( $hash, $max, $ret ) = @_;
978 0 ▶ $hash->{$_} >= $max ? ( $max = $hash->{$_}, $ret = $_ ) : () for grep $_, keys %$hash;
Branch: 1 branch
BranchTrueFalseTotal
$hash->{$_} >= $max ? : 0 0 0
979 0 return $ret;
980 }
981  
982 0 ▶sub cp_dump($) {
Subroutine cp_dump: not called CC=2 SCAR=17.9
Pod undocumented
983 0 my ($data) = @_;
984 0 printlog( 'devcp', "$_ = $data->{'stat'}{$_}" ) for keys %{ $data->{'stat'} };
985 }
986  
987 0 ▶sub detectcp($) {
Subroutine detectcp: not called CC=4 SCAR=30.0
Pod undocumented
988 0 my ($string) = @_;
989 0 my ( $detectedcp, $t );
990 0 my %cpstat;
991 0 for my $cp ( keys %{ $config{'trans_detect'} } ) {
992 0 ▶ ( length($$string) > $config{'cp_detect_length'} ? substr( $$string, 0, $config{'cp_detect_length'} ) : $$string ) =~
Branch: 1 branch
BranchTrueFalseTotal
length $$string > $config{'cp_detect_length'} ? : 0 0 0
993 0 s/([$config{'trans_detect'}{$cp}])/++$cpstat{$cp},$1/eg;
994 #printlog('testcp:', $cp, $cpstat{$cp});
995 #$$string
996 }
997 0 $detectedcp = max_hash_el( \%cpstat, $config{'cp_detect_letters'} );
998 0 ▶ return wantarray ? ( $detectedcp, \%cpstat ) : $detectedcp;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
999 }
1000  
1001 0 ▶sub cp_detect_trans(\$;$$$$$) {
Subroutine cp_detect_trans: not called CC=14 SCAR=53.5
Pod undocumented
1002 0 my ( $string, $data, $cp_to, $cp_default, $prot, $host ) = @_;
1003 0 ▶ $data ||= {};
Condition0%0/2
$data ||= {}
l!l
00
MC/DC0%0/1
$data ||= {}
$data
Truth table0%0/2
A
A= $data
Aresult
11
00
1004 0 ▶ $cp_to = cp_normalize( $cp_to || hconfig( 'cp_db', $host ) ) || 'utf-8';
Condition0%0/5
&cp_normalize(scalar($cp_to || &hconfig('cp_db', $host))) || 'utf-8'
l!l
00
$cp_to || &hconfig('cp_db', $host)
l!l&&r!l&&!r
000
MC/DC0%0/1
&cp_normalize(scalar($cp_to || &hconfig('cp_db', $host))) || 'utf-8'
&cp_normalize(scalar($cp_to || &hconfig('cp_db', $host)))
MC/DC0%0/2
$cp_to || &hconfig('cp_db', $host)
$cp_to &hconfig('cp_db', $host)
Truth table0%0/2
A
A= &cp_normalize(scalar($cp_to || &hconfig('cp_db', $host)))
Aresult
11
00
Truth table0%0/3
A || B
A= $cp_toB= &hconfig('cp_db', $host)
ABresult
1X1
011
000
1005  
1006 =bat
1007 if (use_try('Encode::Detect')) {
1008 eval {$$string = decode("Detect", $$string);
1009 return;
1010 };
1011 } elsif (use_try('Encode::Guess')) {
1012 my $decoder; eval {$decoder = Encode::Guess::guess_encoding($$string, Encode->encodings(":all"));};
1013 printlog(Dumper $decoder);
1014 if ($decoder) {
1015 $$string = $decoder->decode($$string);
1016 return;
1017 }
1018 }
1019 =cut
1020  
1021 0 ▶ return 'utf-8' if $cp_to eq 'utf-8' and utf8::decode($$string);
Branch: 1 branch
BranchTrueFalseTotal
if $cp_to eq "utf-8" and utf8::decode($$string) 0 0 0
Condition0%0/3
$cp_to eq "utf-8" and utf8::decode($$string)
!ll&&!rl&&r
000
MC/DC0%0/2
$cp_to eq "utf-8" and utf8::decode($$string)
$cp_to eq "utf-8" utf8::decode($$string)
Truth table0%0/3
A and B
A= $cp_to eq "utf-8"B= utf8::decode($$string)
ABresult
0X0
100
111
1022 0 ▶ $cp_default = cp_normalize( $cp_default || hconfig( 'cp_res', $host, $prot ) );
Condition0%0/3
$cp_default || &hconfig('cp_res', $host, $prot)
l!l&&r!l&&!r
000
MC/DC0%0/2
$cp_default || &hconfig('cp_res', $host, $prot)
$cp_default &hconfig('cp_res', $host, $prot)
Truth table0%0/3
A || B
A= $cp_defaultB= &hconfig('cp_res', $host, $prot)
ABresult
1X1
011
000
1023 0 my $cnt;
1024 0 ▶ if ( !hconfig( 'no_cp_detect', $host ) and ( ++$data->{'tries'} < 20 or !$data->{'cp'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not &hconfig("no_cp_detect", $host) and ++$data->{"tries"} < 20 || !$data->{"cp"}) 0 0 0
Condition0%0/6
not &hconfig("no_cp_detect", $host) and ++$data->{"tries"} < 20 || !$data->{"cp"}
!ll&&!rl&&r
000
++$data->{"tries"} < 20 or not $data->{"cp"}
l!l&&r!l&&!r
000
MC/DC0%0/3
not &hconfig("no_cp_detect", $host) and ++$data->{"tries"} < 20 || !$data->{"cp"}
not &hconfig("no_cp_detect", $host) ++$data->{"tries"} < 20 not $data->{"cp"}
Truth table0%0/4
not(A) and B or not(C)
A= not &hconfig("no_cp_detect", $host)B= ++$data->{"tries"} < 20C= not $data->{"cp"}
ABCresult
0XX0
1000
11X1
1011
1025 0 ++$data->{'stat'}{ detectcp($string) };
1026 0 $data->{'cp'} = max_hash_el( $data->{'stat'}, hconfig( 'cp_detect_strings', $host ) );
1027 #printlog( 'dbg', 'charset detected:', $data->{'cp'}, ' dbg: ', %{ $data->{'stat'} }, Dumper($data), Dumper(detectcp($string)),' [', $$string, ']', "def:$cp_default",);# if $data->{'cp'} and $data->{'cp'} ne $cp_default;
1028 }
1029 #printlog( 'dbg', "encto: from=$data->{'cp'} to=$cp_to, def=$cp_default");
1030 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{"cp"}) 0 0 0
1031 $data->{'cp'} #and ($data->{'cp'} ne $cp_to
1032 #or $data->{'cp'} eq 'utf-8')
1033 )
1034 {
1035 #( $$string, $cnt ) = cp_trans_count( $data->{'cp'}, $cp_to, $$string );
1036 0 ▶ return $data->{'cp'} if $data->{'cp'} eq $cp_to;
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"cp"} eq $cp_to 0 0 0
1037 0 $$string = Encode::decode $data->{'cp'}, $$string, Encode::FB_WARN;
1038 #return $cnt ? $data->{'cp'} : undef;
1039 #printlog( 'dbg', "charset decoded [$data->{'cp'}]:", $$string);
1040 0 return $data->{'cp'};
1041 }
1042 0 ▶ if ( $cp_default and $cp_default ne $cp_to ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cp_default and $cp_default ne $cp_to) 0 0 0
Condition0%0/3
$cp_default and $cp_default ne $cp_to
!ll&&!rl&&r
000
MC/DC0%0/2
$cp_default and $cp_default ne $cp_to
$cp_default $cp_default ne $cp_to
Truth table0%0/3
A and B
A= $cp_defaultB= $cp_default ne $cp_to
ABresult
0X0
100
111
1043 #( $$string, $cnt ) = cp_trans_count( $cp_default, $cp_to, $$string );
1044 #return $cnt ? $cp_default : undef;
1045 0 $$string = Encode::decode $cp_default, $$string, Encode::FB_WARN;
1046 #printlog( 'dbg', "charset decoded def [$cp_default]:", $$string);
1047 0 return $cp_default;
1048 }
1049 0 return undef;
1050 }
1051  
1052 0 ▶sub cp_up($;$) { #v1
Subroutine cp_up: not called CC=4 SCAR=30.0
Pod undocumented
1053 0 ▶ my ( $string, $cp ) = ( shift, cp_normalize( shift || 'cp1251' ) );
Condition0%0/2
shift() || 'cp1251'
l!l
00
MC/DC0%0/1
shift() || 'cp1251'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
1054 eval "\$string =~ tr/$config{'trans_lo'}{$cp}/$config{'trans_up'}{$cp}/"
1055 0 ▶ if ( $config{'trans_up'}{$cp} and $config{'trans_lo'}{$cp} );
Branch: 1 branch
BranchTrueFalseTotal
if $config{"trans_up"}{$cp} and $config{"trans_lo"}{$cp} 0 0 0
Condition0%0/3
$config{"trans_up"}{$cp} and $config{"trans_lo"}{$cp}
!ll&&!rl&&r
000
MC/DC0%0/2
$config{"trans_up"}{$cp} and $config{"trans_lo"}{$cp}
$config{"trans_up"}{$cp} $config{"trans_lo"}{$cp}
Truth table0%0/3
A and B
A= $config{"trans_up"}{$cp}B= $config{"trans_lo"}{$cp}
ABresult
0X0
100
111
1056 0 return $string;
1057 }
1058  
1059 0 ▶sub cp_lo($;$) { #v1
Subroutine cp_lo: not called CC=4 SCAR=30.0
Pod undocumented
1060 0 ▶ my ( $string, $cp ) = ( shift, cp_normalize( shift || 'cp1251' ) );
Condition0%0/2
shift() || 'cp1251'
l!l
00
MC/DC0%0/1
shift() || 'cp1251'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
1061 eval "\$string =~ tr/$config{'trans_up'}{$cp}/$config{'trans_lo'}{$cp}/"
1062 0 ▶ if ( $config{'trans_up'}{$cp} and $config{'trans_lo'}{$cp} );
Branch: 1 branch
BranchTrueFalseTotal
if $config{"trans_up"}{$cp} and $config{"trans_lo"}{$cp} 0 0 0
Condition0%0/3
$config{"trans_up"}{$cp} and $config{"trans_lo"}{$cp}
!ll&&!rl&&r
000
MC/DC0%0/2
$config{"trans_up"}{$cp} and $config{"trans_lo"}{$cp}
$config{"trans_up"}{$cp} $config{"trans_lo"}{$cp}
Truth table0%0/3
A and B
A= $config{"trans_up"}{$cp}B= $config{"trans_lo"}{$cp}
ABresult
0X0
100
111
1063 0 return $string;
1064 }
1065  
1066 0 ▶sub unref ($;@) {
Subroutine unref: not called CC=6 SCAR=37.4
Pod undocumented
1067 0 local $_ = shift;
1068 0 ▶ return unless length $_;
Branch: 1 branch
BranchTrueFalseTotal
unless length $_ 0 0 0
1069 0 ▶ $_ = $$_ while ref $_ eq 'REF';
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq "REF" and do { $_ = $$_ } 0 0 0
1070 0 ▶ return $_->(@_) if ref $_ eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "CODE" 0 0 0
1071 0 ▶ @_ = () if ref $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] 0 0 0
1072 0 ▶ return join $,, ( $$_, @_ ) if ref $_ eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "SCALAR" 0 0 0
1073 0 return join $,, $_, @_;
1074 }
1075  
1076 0 ▶sub lang($;$$$) {
Subroutine lang: not called CC=5 SCAR=34.0
Pod undocumented
1077 0 my ( $key, $lang ) = shift, shift;
1078 #print "CP[$config{'cp_config'},$work{'codepage'}]" if $key eq 'search';
1079 local $_ = (
1080 defined $config{'lng'}{ $lang ||= ( $work{'lang'} || $config{'lang'} ) }{$key} ? $config{'lng'}{$lang}{$key}
1081 0 ▶ : defined $config{'lng'}{''}{$key} ? $config{'lng'}{''}{$key}
Branch: 2 branches
BranchTrueFalseTotal
defined $config{'lng'}{$lang ||= $work{'lang'} || $config{'lang'}}{$key} ? : 0 0 0
defined $config{'lng'}{''}{$key} ? : 0 0 0
Condition0%0/6
$lang ||= $work{"lang"} || $config{"lang"}
l!l&&r!l&&!r
000
$work{'lang'} || $config{'lang'}
l!l&&r!l&&!r
000
MC/DC0%0/3
$lang ||= $work{"lang"} || $config{"lang"}
$lang $work{'lang'} $config{'lang'}
Truth table0%0/4
A ||= B || C
A= $langB= $work{'lang'}C= $config{'lang'}
ABCresult
1XX1
01X1
0011
0000
1082 : $key );
1083 #return unref $_ if ref $_;
1084 return
1085 #"[".(%config)."]".
1086 0 shift() . # "CP[$config{'cp_config'},$work{'codepage'}]".
1087 unref($_) .
1088 #cp_trans(
1089 #( $config{'cp_config'} || $config{'cp_perl'} ),
1090 #$work{'codepage'},
1091 #) .
1092 shift();
1093 }
1094  
1095 0 ▶sub printu (@) {
Subroutine printu: not called CC=3 SCAR=24.8
Pod undocumented
1096 0 for (@_) {
1097 0 ▶ print($_), next unless utf8::is_utf8($_);
Branch: 1 branch
BranchTrueFalseTotal
unless utf8::is_utf8($_) 0 0 0
1098 0 my $s = $_;
1099 0 utf8::encode($s);
1100 0 print($s);
1101 }
1102 }
1103  
1104 0 ▶sub json_encode($) {
Subroutine json_encode: not called CC=3 SCAR=24.8
Pod undocumented
1105 0 ▶ if ( use_try 'JSON::XS' ) { return \( JSON::XS->new->encode(@_) ) }
Branch: 1 branch
BranchTrueFalseTotal
if (&use_try("JSON::XS")) 0 0 0
1106 0 ▶ if ( use_try('JSON') ) { return \( JSON->new->encode(@_) ); }
Branch: 1 branch
BranchTrueFalseTotal
if (&use_try("JSON")) 0 0 0
1107 {
1108 0 ▶ local *Data::Dumper::qquote = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1109 0 $_[0] =~ s/\\/\\\\/g, s/"/\\"/g for $_[0];
1110 0 return ( '"' . $_[0] . '"' );
1111 0 };
1112 0 return \( Data::Dumper->new( \@_ )->Pair(':')->Terse(1)->Indent(0)->Useqq(1)->Useperl(1)->Dump() );
1113 }
1114 }
1115  
1116 0 ▶sub min (@) {
Subroutine min: not called CC=2 SCAR=17.9
Pod undocumented
1117 0 ▶ ( sort { $a <=> $b || $a cmp $b } @_ )[0];
Condition0%0/3
$a <=> $b || $a cmp $b
l!l&&r!l&&!r
000
MC/DC0%0/2
$a <=> $b || $a cmp $b
$a <=> $b $a cmp $b
Truth table0%0/3
A || B
A= $a <=> $bB= $a cmp $b
ABresult
1X1
011
000
1118 }
1119  
1120 0 ▶sub max (@) {
Subroutine max: not called CC=2 SCAR=17.9
Pod undocumented
1121 0 ▶ ( sort { $b <=> $a || $b cmp $a } @_ )[0];
Condition0%0/3
$b <=> $a || $b cmp $a
l!l&&r!l&&!r
000
MC/DC0%0/2
$b <=> $a || $b cmp $a
$b <=> $a $b cmp $a
Truth table0%0/3
A || B
A= $b <=> $aB= $b cmp $a
ABresult
1X1
011
000
1122 }
1123  
1124 0 ▶sub alarmed {
Subroutine alarmed: not called CC=8 SCAR=42.8
Pod undocumented
1125 0 my ( $timeout, $proc, @proc_param ) = @_;
1126 0 my $ret;
1127 0 eval {
1128 0 ▶ local $SIG{ALRM} = sub { die "alarm\n" }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1129 0 ▶ if $timeout; # NB: \n required
Branch: 1 branch
BranchTrueFalseTotal
if $timeout 0 0 0
1130 0 ▶ alarm $timeout if $timeout;
Branch: 1 branch
BranchTrueFalseTotal
if $timeout 0 0 0
1131 0 ▶ $ret = $proc->(@proc_param) if ref $proc eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $proc eq "CODE" 0 0 0
1132 0 ▶ alarm 0 if $timeout;
Branch: 1 branch
BranchTrueFalseTotal
if $timeout 0 0 0
1133 };
1134 0 ▶ if ( $timeout and $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($timeout and $@) { } 0 0 0
Condition0%0/3
$timeout and $@
!ll&&!rl&&r
000
MC/DC0%0/2
$timeout and $@
$timeout $@
Truth table0%0/3
A and B
A= $timeoutB= $@
ABresult
0X0
100
111
1135 0 ▶ printlog( 'err', 'Sorry, unknown error (',
Branch: 1 branch
BranchTrueFalseTotal
unless $@ eq "alarm\n" 0 0 0
1136 $@, ') runs:', ' [', join( ',', grep $_, map ( ( caller($_) )[2], ( 0 .. 15 ) ) ), ']' ),
1137 sleeper( 3600, 'alarmed' ), return
1138 unless $@ eq "alarm\n"; # propagate unexpected errors
1139 0 printlog( 'err', 'Sorry, timeout (', $timeout, ')' );
1140 } else {
1141 0 sleeper( undef, 'alarmed' );
1142 } # else { print "no timeout<br/>"; }
1143 0 return $ret;
1144 }
1145  
1146 0 ▶sub mkdir_rec(;$$) {
Subroutine mkdir_rec: not called CC=6 SCAR=37.4
Pod undocumented
1147 0 ▶ local $_ = shift // $_;
Condition0%0/3
shift() // $_
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() // $_
shift() $_
Truth table0%0/3
A // B
A= shift()B= $_
ABresult
1X1
011
000
1148 0 ▶ $_ .= '/' unless m{/$};
Branch: 1 branch
BranchTrueFalseTotal
unless m[/$] 0 0 0
1149 0 my @ret;
1150 0 ▶ while (m{/}g) { ( push @ret, $` ), ( @_ ? mkdir $`, $_[0] : mkdir $` ) if length $` }
Branch: 3 branches
BranchTrueFalseTotal
if (m[/]g) 0 0 0
if length $` 0 0 0
@_ ? : 0 0 0
1151 0 @ret;
1152 }
1153  
1154 0 ▶sub check_int($;$$$) {
Subroutine check_int: not called CC=9 SCAR=45.0
Pod undocumented
1155 0 my ( $int, $min, $max, $def ) = @_;
1156 #printlog('dev', 'int', ( "int=$int,min=$min,max=$max,def=$def" ));
1157 0 ▶ $def = 0 unless defined $def;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $def 0 0 0
1158 0 ▶ return $def unless ( defined($int) and length($int) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $int and length $int 0 0 0
Condition0%0/3
defined $int and length $int
!ll&&!rl&&r
000
MC/DC0%0/2
defined $int and length $int
defined $int length $int
Truth table0%0/3
A and B
A= defined $intB= length $int
ABresult
0X0
100
111
1159 #printlog('dev', "int0[$int]", defined $int, length($int));
1160 0 $int =~ s/\s+//g;
1161 0 $int = int($int);
1162 #printlog('dev', 'int1',$int);
1163 0 ▶ return $def unless $int =~ /^-?\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $int =~ /^-?\d+$/ 0 0 0
1164 #printlog('dev', 'int2',$int, $min);
1165 0 ▶ return $min if defined $min and $int < $min;
Branch: 1 branch
BranchTrueFalseTotal
if defined $min and $int < $min 0 0 0
Condition0%0/3
defined $min and $int < $min
!ll&&!rl&&r
000
MC/DC0%0/2
defined $min and $int < $min
defined $min $int < $min
Truth table0%0/3
A and B
A= defined $minB= $int < $min
ABresult
0X0
100
111
1166 #printlog('dev', 'int3',$int, $max);
1167 0 ▶ return $max if defined $max and $int > $max;
Branch: 1 branch
BranchTrueFalseTotal
if defined $max and $int > $max 0 0 0
Condition0%0/3
defined $max and $int > $max
!ll&&!rl&&r
000
MC/DC0%0/2
defined $max and $int > $max
defined $max $int > $max
Truth table0%0/3
A and B
A= defined $maxB= $int > $max
ABresult
0X0
100
111
1168 #printlog('dev', 'int4',$int);
1169 0 return $int;
1170 }
1171  
1172 =old trash
1173 {
1174 my $current_name;
1175  
1176 sub open_out_file {
1177 my ($name) = join( '.', grep ( /.+/, @_ ) );
1178 $name =~ s/\W+/_/g;
1179 close_out_file();
1180 $current_name = "$config{'datadir'}$config{'slash_sys'}$name.$config{'output'}";
1181 $work{'current_name_work'} = "$current_name$config{'work_ext'}";
1182 rename( $current_name, $work{'current_name_work'} ) if -e $current_name and $work{'current_name_work'} and $current_name;
1183 open( I, '>>', $work{'current_name_work'} )
1184 or printlog( 'err', "!!! UNABLE TO OPEN $work{'current_name_work'}" )
1185 and return;
1186 }
1187  
1188 sub close_out_file {
1189 if ( $work{'current_name_work'} ) {
1190 $processor{'out'}{'array'}->();
1191 print I";\n";
1192 close(I);
1193 rename( $work{'current_name_work'}, $current_name ) if $work{'current_name_work'} and $current_name;
1194 }
1195 $work{'current_name_work'} = $current_name = '';
1196 }
1197 }
1198 =cut
1199  
1200 0 ▶sub caller_trace(;$) {
Subroutine caller_trace: not called CC=4 SCAR=30.0
Pod undocumented
1201 0 ▶ for ( 0 .. $_[0] || 5 ) { local @_ = caller $_; last unless @_; printlog( 'caller', $_, @_ ); }
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
Condition0%0/2
$_[0] || 5
l!l
00
MC/DC0%0/1
$_[0] || 5
$_[0]
Truth table0%0/2
A
A= $_[0]
Aresult
11
00
1202 }
1203  
1204 0 ▶sub lib_init() {
Subroutine lib_init: not called CC=5 SCAR=34.0
Pod undocumented
1205 0 ▶ $SIG{__WARN__} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1206 0 printlog( 'warn', $@, $!, @_ );
1207 #printlog( 'die', 'caller', $_, caller($_) ) for ( 0 .. 15 );
1208 #caller_trace(15);
1209 0 ▶ }, $SIG{__DIE__} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1210 0 printlog( 'die', 'psm',$@, $!, @_ );
1211 #printlog( 'die', 'caller', $_, caller($_) || last ) for ( 0 .. 15 );
1212 0 trace(15);
1213 }
1214 0 ▶ if !$static{'no_sig_log'} and !$ENV{'SERVER_PORT'}; #die $!;
Branch: 1 branch
BranchTrueFalseTotal
unless $psmisc::static{"no_sig_log"} or $ENV{"SERVER_PORT"} 0 0 0
Condition0%0/3
$psmisc::static{"no_sig_log"} or $ENV{"SERVER_PORT"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$psmisc::static{"no_sig_log"} or $ENV{"SERVER_PORT"}
$psmisc::static{"no_sig_log"} $ENV{"SERVER_PORT"}
Truth table0%0/3
A or B
A= $psmisc::static{"no_sig_log"}B= $ENV{"SERVER_PORT"}
ABresult
1X1
011
000
1215 0 ▶ unless ( $static{'port2prot'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($psmisc::static{"port2prot"}) 0 0 0
1216 0 @{ $static{'port2prot'} }{ ( $config{'scanner'}{$_}{'port'}, $_ ) } = ( $_, $_ ) for keys %{ $config{'scanner'} };
1217 }
1218 }
1219  
1220 0 ▶sub mysleep($) {
Subroutine mysleep: not called CC=4 SCAR=30.0
Pod undocumented
1221 0 ▶ if ( $_[0] > 1 and $config{'system'} eq 'win' ) { #activeperl only?
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] > 1 and $config{'system'} eq 'win') { } 0 0 0
Condition0%0/3
$_[0] > 1 and $config{"system"} eq "win"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] > 1 and $config{"system"} eq "win"
$_[0] > 1 $config{"system"} eq "win"
Truth table0%0/3
A and B
A= $_[0] > 1B= $config{"system"} eq "win"
ABresult
0X0
100
111
1222 0 sleep(1) for ( 0 .. $_[0] );
1223 } else {
1224 0 sleep( $_[0] );
1225 }
1226 }
1227  
1228 0 ▶sub sleeper($;$$) {
Subroutine sleeper: not called CC=8 SCAR=42.8
Pod undocumented
1229 0 my ( $max, $where, $min, ) = @_;
1230 0 ▶ $where ||= join '', caller;
Condition0%0/3
$where ||= join("", caller)
l!l&&r!l&&!r
000
MC/DC0%0/2
$where ||= join("", caller)
$where join("", caller)
Truth table0%0/3
A ||= B
A= $whereB= join("", caller)
ABresult
1X1
011
000
1231 ( $work{'sleeper'}{$where} ? printlog( 'dev', "sleeper: clean $where was $work{'sleeper'}{$where}" ) : () ),
1232 $work{'sleeper'}{$where} = 0, return 0
1233 if !$max
1234 0 ▶ or $ENV{'SERVER_PORT'};
Branch: 2 branches
BranchTrueFalseTotal
if not $max or $ENV{"SERVER_PORT"} 0 0 0
$work{'sleeper'}{$where} ? : 0 0 0
Condition0%0/3
not $max or $ENV{"SERVER_PORT"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $max or $ENV{"SERVER_PORT"}
not $max $ENV{"SERVER_PORT"}
Truth table0%0/3
not(A) or B
A= not $maxB= $ENV{"SERVER_PORT"}
ABresult
1X1
011
000
1235 0 ▶ $min ||= 0.5;
Condition0%0/2
$min ||= "0.5"
l!l
00
MC/DC0%0/1
$min ||= "0.5"
$min
Truth table0%0/2
A
A= $min
Aresult
11
00
1236 #printlog( 'dbg', "sleepe0: sleep $where $work{'sleeper'}{$where} mi=$min" );
1237 0 ▶ ( $work{'sleeper'}{$where} ||= $min ) *= ( $work{'sleeper'}{$where} > $max ? 1 : 2 );
Branch: 1 branch
BranchTrueFalseTotal
$work{'sleeper'}{$where} > $max ? : 0 0 0
Condition0%0/3
$work{"sleeper"}{$where} ||= $min
l!l&&r!l&&!r
000
MC/DC0%0/2
$work{"sleeper"}{$where} ||= $min
$work{"sleeper"}{$where} $min
Truth table0%0/3
A ||= B
A= $work{"sleeper"}{$where}B= $min
ABresult
1X1
011
000
1238 0 printlog( 'dbg', "sleeper: sleep $where $work{'sleeper'}{$where}" );
1239 0 mysleep( $work{'sleeper'}{$where} );
1240 0 return $work{'sleeper'}{$where};
1241 }
1242  
1243 0 ▶sub shuffle(@) { #@$deck = map{ splice @$deck, rand(@$deck), 1 } 0..$#$deck;
Subroutine shuffle: not called CC=4 SCAR=30.0
Pod undocumented
1244 0 my $deck = shift;
1245 0 ▶ $deck = [ $deck, @_ ] unless ref $deck eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $deck eq "ARRAY" 0 0 0
1246 0 my $i = @$deck;
1247 0 ▶ while ( $i-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i--) 0 0 0
1248 0 my $j = int rand( $i + 1 );
1249 0 @$deck[ $i, $j ] = @$deck[ $j, $i ];
1250 }
1251 0 ▶ return wantarray ? @$deck : $deck;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1252 }
1253  
1254 0 ▶sub flush(;$) {
Subroutine flush: not called CC=3 SCAR=24.8
Pod undocumented
1255 #printlog('dev', 'FLUSH') ;
1256 0 ▶ return if $config{'no_flush'};
Branch: 1 branch
BranchTrueFalseTotal
if $config{"no_flush"} 0 0 0
1257 0 ▶ select( ( select( $_[0] || *STDOUT ), $| = 1 )[0] );
Condition0%0/3
$_[0] || *STDOUT
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0] || *STDOUT
$_[0] *STDOUT
Truth table0%0/3
A || B
A= $_[0]B= *STDOUT
ABresult
1X1
011
000
1258 }
1259  
1260 =todo
1261 sub paintdots_onreload {
1262 my ($ref) = shift;
1263 sub {
1264 if ( $_[0] =~ /[Ss]ubroutine (\w+) redefined/ ) {
1265 my ($subr) = $1;
1266 ++$$ref;
1267 local ($|) = 1;
1268 #$CPAN::Frontend->myprint(".($subr)");
1269 #$CPAN::Frontend->myprint(".");
1270 print(".");
1271 return;
1272 }
1273 warn @_;
1274 };
1275 }
1276 =cut
1277  
1278 0 ▶sub count(@) { local %_; ++$_{$_} for @_; \%_ }
Subroutine count: not called CC=2 SCAR=17.9
Pod undocumented
1279 0 ▶sub uniq(@) { keys %{ count @_ } }
Subroutine uniq: not called CC=1 SCAR=6.9
Pod undocumented
1280  
1281 0 ▶sub config_read {
Subroutine config_read: not called CC=20 SCAR=60.4
Pod undocumented
1282 #warn Dumper \@_;
1283 0 my @files;
1284 0 ▶ @files = @{ shift(@_) } if ref $_[0] eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "ARRAY" 0 0 0
1285 #warn Dumper \@files;
1286 #warn Dumper \@_;
1287 #print "config_read($ENV{'SCRIPT_FILENAME'}, $_[0]);\n";
1288 #print ("config_read NOREAD!;\n");
1289 #my $file = ;
1290 #return if $static{'config_read'}{ $ENV{'SCRIPT_FILENAME'} . $file }++ and !$_[0];
1291 #print " [$file] config_read($_[0])";
1292 #do $ENV{'PROSEARCH_PATH'} . './config.pl' or do '../config.pl';
1293 #print "config_readb(); root_path = $root_path\n";
1294 #$root_path ||= lib::abs::path('../').'/';
1295 0 ▶ ( $ENV{'SCRIPT_FILENAME'} || $work{'$0'} || $0 ) =~ m|^(.+)[/\\].+?$|;
Condition0%0/6
$ENV{'SCRIPT_FILENAME'} || $work{'$0'} || $0
l!l&&r!l&&!r
000
$ENV{"SCRIPT_FILENAME"} or $work{"\$0"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$ENV{'SCRIPT_FILENAME'} || $work{'$0'} || $0
$ENV{"SCRIPT_FILENAME"} $work{"\$0"} $0
Truth table0%0/4
A or B || C
A= $ENV{"SCRIPT_FILENAME"}B= $work{"\$0"}C= $0
ABCresult
1XX1
01X1
0011
0000
1296 0 ▶ $root_path = #||= $ENV{'PROSEARCH_PATH'} ||
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 0 0 0
1297 ( $1 ? $1 . '/' : undef );
1298 #$root_path||= $1 . '/' if $1;
1299 0 $root_path =~ s|\\|/|g;
1300 0 ▶ $root_path //= './';
Condition0%0/2
$psmisc::root_path //= "./"
l!l
00
MC/DC0%0/1
$psmisc::root_path //= "./"
$psmisc::root_path
Truth table0%0/2
A
A= $psmisc::root_path
Aresult
11
00
1301 #do $ENV{'PROSEARCH_PATH'} . './config.pl' or
1302 #print "pa=". ( $ENV{'SCRIPT_FILENAME'} ,';', $0),"\n";
1303 0 ▶ unless (@files) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@files) 0 0 0
1304 @files = (
1305 0 ▶ $root_path . ( $config{'config_file'} // 'config.pl' ) #, $root_path . 'confdef.pl'
Condition0%0/2
$config{"config_file"} // "config.pl"
l!l
00
MC/DC0%0/1
$config{"config_file"} // "config.pl"
$config{"config_file"}
Truth table0%0/2
A
A= $config{"config_file"}
Aresult
11
00
1306 );
1307 }
1308 #warn "config_read(); root_path = $root_path ; file = @files\n";
1309 0 my @errs;
1310 0 local $_; #= do ;
1311 #use lib::abs;
1312 0 for my $file ( uniq @files ) {
1313 0 ▶ ++$_, last if $static{'config_read'}{ $ENV{'SCRIPT_FILENAME'} . $file }++ and !$_[0];
Branch: 1 branch
BranchTrueFalseTotal
if $psmisc::static{"config_read"}{$ENV{"SCRIPT_FILENAME"} . $file}++ and not $_[0] 0 0 0
Condition0%0/3
$psmisc::static{"config_read"}{$ENV{"SCRIPT_FILENAME"} . $file}++ and not $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$psmisc::static{"config_read"}{$ENV{"SCRIPT_FILENAME"} . $file}++ and not $_[0]
$psmisc::static{"config_read"}{$ENV{"SCRIPT_FILENAME"} . $file}++ not $_[0]
Truth table0%0/3
A and not(B)
A= $psmisc::static{"config_read"}{$ENV{"SCRIPT_FILENAME"} . $file}++B= not $_[0]
ABresult
0X0
100
111
1314 #warn "reading [$file]", -s $file, ;# lib::abs::path($file);
1315 #print( ' do1:',$_,',', $!, ' eval=', $@, "\n" ) if !$_ or $! or $@;
1316 #MAKE ARRAY
1317 0 ▶ if ( !$ENV{'SERVER_PORT'} and !-e $file and -e $file . '.dist' and use_try('File::Copy') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ENV{"SERVER_PORT"} || -e $file and -e $file . '.dist' and &use_try("File::Copy")) 0 0 0
Condition0%0/9
not $ENV{"SERVER_PORT"} || -e $file and -e $file . '.dist' and &use_try("File::Copy")
!ll&&!rl&&r
000
not $ENV{"SERVER_PORT"} || -e $file and -e $file . '.dist'
!ll&&!rl&&r
000
$ENV{'SERVER_PORT'} || -e $file
l!l&&r!l&&!r
000
MC/DC0%0/4
not $ENV{"SERVER_PORT"} || -e $file and -e $file . '.dist' and &use_try("File::Copy")
$ENV{'SERVER_PORT'} -e $file -e $file . '.dist' &use_try("File::Copy")
Truth table0%0/5
not(A || B) and C and D
A= $ENV{'SERVER_PORT'}B= -e $fileC= -e $file . '.dist'D= &use_try("File::Copy")
ABCDresult
1XXX0
01XX0
000X0
00100
00111
1318 0 printlog( 'warn', 'unfinished install, copying', $file . '.dist', '->', $file );
1319 0 File::Copy::copy( $file . '.dist', $file );
1320 }
1321 0 ▶ $_ += do $file and last; #and warn("read [$file] ok $! $@;")
Branch: 1 branch
BranchTrueFalseTotal
$_ += do $file and last 0 0 0
1322 0 ▶ push @errs, map { "config [$file] not found: " . $_ } grep { $_ } $!, $@, unless $_;
Branch: 1 branch
BranchTrueFalseTotal
unless $_ 0 0 0
1323 #push @errs, grep { $_ } $!, $@ unless $_;
1324 #push @errs, grep { $_ } $!, $@, $_ += do $root_path . '../config.pl', push @errs, grep { $_ } $!, $@ unless $_;
1325 }
1326 0 ▶ if ( !$_ and !$_[1] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ or $_[1]) 0 0 0
Condition0%0/3
$_ or $_[1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ or $_[1]
$_ $_[1]
Truth table0%0/3
A or B
A= $_B= $_[1]
ABresult
1X1
011
000
1327 0 ▶ print "Content-type: text/html\n\n" if defined( $ENV{'SERVER_PORT'} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"SERVER_PORT"} 0 0 0
1328 0 print "config read errors: [@files]: ",, map "$_;\n", @errs;
1329 }
1330 #print"rp set1 to [$root_path]\n";
1331 conf(
1332 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1333 #print"rp set2 to [$root_path]\n";
1334 0 $config{'root_path'} = $root_path;
1335 },
1336 0 0.0001
1337 );
1338 #print( ' do2:',$_,',', $!, ' eval=', $@, "\n" ) if $! or $@;
1339 #print( ' do1:', $!, 'eval=', $@ ,"\n" ) if $! or $@;
1340 #print( 'compile err1:', $!, "\n" ) if $!;
1341 #print ('compile err2:',$@, "\n");
1342 #require $ENV{'PROSEARCH_PATH'} . './config.pl' or do '../config.pl';
1343 #print('config_read',Dumper (\%config ));
1344 #print('config_read',(scalar keys %config ));
1345 }
1346  
1347 0 ▶sub pre_calc_every {
Subroutine pre_calc_every: not called CC=3 SCAR=24.8
Pod undocumented
1348 $config{'post_init_every'}{$_}->(@_)
1349 0 ▶ for grep { ref $config{'post_init_every'}{$_} eq 'CODE' } sort keys %{ $config{'post_init_every'} || {} };
Condition0%0/2
$config{'post_init_every'} || {}
l!l
00
MC/DC0%0/1
$config{'post_init_every'} || {}
$config{'post_init_every'}
Truth table0%0/2
A
A= $config{'post_init_every'}
Aresult
11
00
1350 }
1351  
1352 0 ▶sub pre_calc_once {
Subroutine pre_calc_once: not called CC=3 SCAR=24.8
Pod undocumented
1353 #$config{'post_init_once'}->(@_) if $config{'post_init_once'};
1354 #print "pre_calc_once\n";
1355 $config{'post_init_once'}{$_}->(@_)
1356 0 ▶ for grep { ref $config{'post_init_once'}{$_} eq 'CODE' } sort keys %{ $config{'post_init_once'} || {} };
Condition0%0/2
$config{'post_init_once'} || {}
l!l
00
MC/DC0%0/1
$config{'post_init_once'} || {}
$config{'post_init_once'}
Truth table0%0/2
A
A= $config{'post_init_once'}
Aresult
11
00
1357 }
1358  
1359 0 ▶sub pre_calc {
Subroutine pre_calc: not called CC=1 SCAR=6.9
Pod undocumented
1360 0 pre_calc_once(@_);
1361 0 pre_calc_every(@_);
1362 }
1363  
1364 0 ▶sub config_reload {
Subroutine config_reload: not called CC=8 SCAR=42.8
Pod undocumented
1365 #warn "config_reload(clear=$_[0];; $config{'root_path'})";
1366 #print "config_reload(clear!=$_[0])\n";
1367 0 ▶ my $files = shift if ref $_[0] eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "ARRAY" 0 0 0
1368 0 ▶ %config = () if $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] 0 0 0
1369 0 ▶ config_read( ( $files || () ), $_[1], $_[3] );
Condition0%0/3
$files || ()
l!l&&r!l&&!r
000
MC/DC0%0/2
$files || ()
$files ()
Truth table0%0/3
A || B
A= $filesB= ()
ABresult
1X1
011
000
1370 #print "read end;";
1371 0 ▶ $_[2]->() if ref $_[2] eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[2] eq "CODE" 0 0 0
1372 0 conf();
1373 #print ('compile err2:',$@, "\n");
1374 0 ▶ if ( !%config ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not %config) 0 0 0
1375 0 ▶ print "Content-type: text/html\n\n" if defined( $ENV{'SERVER_PORT'} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"SERVER_PORT"} 0 0 0
1376 0 ▶ print("Please fix error in config.pl: [$@]"), exit if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1377 0 print "Please create config.pl with parametrs (see config.pl.dist) and correct modes [$!]";
1378 0 exit;
1379 }
1380 #print('config_reload',(scalar keys %config ));
1381 #print('config_reload',Dumper (\%config ));
1382 }
1383 0 ▶sub configure { &config_reload; }
Subroutine configure: not called CC=1 SCAR=6.9
Pod undocumented
1384 #sub config { &configure; } #to del
1385 0 ▶sub reload_lib {
Subroutine reload_lib: not called CC=5 SCAR=34.0
Pod undocumented
1386 #%human = ();
1387 0 my $redef = 0;
1388 0 for my $file (@_) {
1389 0 printlog( 'dbg', "reloading $file: $INC{$file}" );
1390 0 ▶ open( my $fh, '<', ( $INC{$file} or $file ) ) or printlog( 'err', "reload err $file=$INC{$file}" ), next;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $INC{$file} || $file or &printlog("err", "reload err $file=$INC{$file}"), next 0 0 0
Condition0%0/3
$INC{$file} || $file
l!l&&r!l&&!r
000
MC/DC0%0/2
$INC{$file} || $file
$INC{$file} $file
Truth table0%0/3
A || B
A= $INC{$file}B= $file
ABresult
1X1
011
000
1391 0 local ($/);
1392 0 local ( $SIG{__WARN__} ) = paintdots_onreload( \$redef );
1393 0 local ( $SIG{__DIE__} ) = paintdots_onreload( \$redef );
1394 0 eval <$fh>;
1395 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1396 }
1397 }
1398 1 our %conf;
1399  
1400 1 ▶sub conf(;$$) {
Subroutine conf: called CC=6 SCAR=24.1
Pod undocumented
1401 #warn 'conf from ', caller, Dumper \@_ ;
1402 1 my ( $sub, $order ) = ( shift, shift );
1403 #if ( !$ENV{'MOD_PERL'} ) { $sub->(@_) if $sub; return; }
1404 my $id = #$ENV{'PROSEARCH_PATH'} ||
1405 1 ▶ $ENV{'SCRIPT_FILENAME'} || $work{'$0'} || $0;
Condition33%2/6
$ENV{'SCRIPT_FILENAME'} || $work{'$0'} || $0
l!l&&r!l&&!r
010
$ENV{"SCRIPT_FILENAME"} or $work{"\$0"}
l!l&&r!l&&!r
001
MC/DC0%0/3
$ENV{'SCRIPT_FILENAME'} || $work{'$0'} || $0
$ENV{"SCRIPT_FILENAME"} $work{"\$0"} $0
Truth table25%1/4
A or B || C
A= $ENV{"SCRIPT_FILENAME"}B= $work{"\$0"}C= $0
ABCresult
1XX1
01X1
0011
0000
1406 #print join ' ',('dev',"conf($sub, $order, [$root_path] id=$id)", caller,"<br\n/>");
1407 1 ▶ unless ($sub) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sub) 0 1 1
1408 #print("running", scalar keys %{ $conf{'conf_init'}{ $ENV{'PROSEARCH_PATH'} } }, "now=",scalar keys %config, "\n");
1409 #warn("RUNCONF[$id]($_/",scalar keys %{ $conf{'conf_init'}{$id } },"] from(",join('|',@{$conf{'conf_init_from'}{$id}{$_}}), ";", "<br\n/>"),
1410 0 $conf{'conf_init'}{$id}{$_}->() for sort { $a <=> $b } keys %{ $conf{'conf_init'}{$id} };
1411 #warn("confrunned", "now=",scalar keys %config, "\n");
1412 0 return;
1413 }
1414 1 local $_;
1415 1 ▶ $conf{'conf_init'}{$id}{ $_ = ( $order or $conf{'conf_count'}{$id} += 10 ) } = $sub;
Condition33%1/3
$order || ($psmisc::conf{'conf_count'}{$id} += 10)
l!l&&r!l&&!r
100
MC/DC0%0/2
$order || ($psmisc::conf{'conf_count'}{$id} += 10)
$order ($psmisc::conf{'conf_count'}{$id} += 10)
Truth table33%1/3
A || B
A= $orderB= ($psmisc::conf{'conf_count'}{$id} += 10)
ABresult
1X1
011
000
1416 1 $conf{'conf_init_from'}{$id}{$_} = [caller];
1417 #print "conf(@_):", Dumper([caller],$conf{'conf_init'}, $conf{'conf_init_from'});
1418 }
1419  
1420 0 ▶sub http_get { # REWRITE easier
Subroutine http_get: not called CC=28 SCAR=67.0
Pod undocumented
1421 0 my ( $what, $asfile, $lwpopt, $method, $content, $headers_out, $headers_in ) = @_;
1422 #return "ZZZZZ";
1423 #printlog( 'dev', 'http_get', $what, $asfile, "cd=$config{'cachedir'};c=$config{'cache_http'}; " );
1424 0 my %url = split_url($what);
1425 0 my $c = encode_url( $what, $config{'encode_url_file_mask'} );
1426 0 ▶ if ( length $c > 200 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $c > 200) 0 0 0
1427 0 my ( $bef, $mid, $aft ) = $c =~ /^(.{50})(.+)(.{50})$/;
1428 #local $_ = 0;
1429 0 my $midv = 0;
1430 0 $midv += ord for split //, $mid;
1431 0 $c = join '__', $bef, $midv, $aft;
1432 #$_ += ord;
1433 #}
1434 }
1435 0 ▶ $c = ( $config{'cachedir'} || '.' ) . '/' . $c if $config{'cachedir'};
Branch: 1 branch
BranchTrueFalseTotal
if $config{"cachedir"} 0 0 0
Condition0%0/2
$config{'cachedir'} || '.'
l!l
00
MC/DC0%0/1
$config{'cachedir'} || '.'
$config{'cachedir'}
Truth table0%0/2
A
A= $config{'cachedir'}
Aresult
11
00
1436 0 ▶ $c = $asfile if $asfile and $asfile != 1;
Branch: 1 branch
BranchTrueFalseTotal
if $asfile and $asfile != 1 0 0 0
Condition0%0/3
$asfile and $asfile != 1
!ll&&!rl&&r
000
MC/DC0%0/2
$asfile and $asfile != 1
$asfile $asfile != 1
Truth table0%0/3
A and B
A= $asfileB= $asfile != 1
ABresult
0X0
100
111
1437 #printlog('dev', $what, $asfile, "cache=$config{'cache_http'}, dir=$config{'cachedir'};");
1438 0 ▶ if ( $config{'cache_http'} and -e $c and -M $c < $config{'cache_http'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config{"cache_http"} and -e $c and -M $c < $config{"cache_http"}) 0 0 0
Condition0%0/6
$config{"cache_http"} and -e $c and -M $c < $config{"cache_http"}
!ll&&!rl&&r
000
$config{"cache_http"} and -e $c
!ll&&!rl&&r
000
MC/DC0%0/3
$config{"cache_http"} and -e $c and -M $c < $config{"cache_http"}
$config{"cache_http"} -e $c -M $c < $config{"cache_http"}
Truth table0%0/4
A and B and C
A= $config{"cache_http"}B= -e $cC= -M $c < $config{"cache_http"}
ABCresult
0XX0
10X0
1100
1111
1439 0 ▶ return $c if $asfile;
Branch: 1 branch
BranchTrueFalseTotal
if $asfile 0 0 0
1440 0 ▶ if ( open( CF, '<', $c ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open CF, "<", $c) 0 0 0
1441 0 local $/;
1442 0 local $_ = <CF>;
1443 0 close(CF);
1444 0 return $_;
1445 }
1446 }
1447 0 ▶ printlog( 'warn', 'http_get disabled' ), return if $config{'no_http_get'};
Branch: 1 branch
BranchTrueFalseTotal
if $config{"no_http_get"} 0 0 0
1448 #printlog('dev', 'http_get',$what, $asfile);
1449 return eval
1450 #do
1451 0 {
1452 #printlog 'dev' ,0 ;
1453 0 ▶ eval('use LWP::UserAgent; use URI::URL;1;') or printlog( 'err', 'http use libs', @!, $! ); #if not installed
Branch: 1 branch
BranchTrueFalseTotal
eval "use LWP::UserAgent; use URI::URL;1;" or &printlog("err", "http use libs", @!, $!) 0 0 0
1454 my $ua = LWP::UserAgent->new(
1455 'agent' => $config{'useragent'} || $config{'crawler_name'},
1456 'timeout' => hconfig( 'timeout', $url{'host'}, $url{'prot'} ) || 10,
1457 0 ▶ %{ $config{'lwp'} || {} }, %{ $lwpopt || {} }
Condition0%0/9
$config{'useragent'} || $config{'crawler_name'}
l!l&&r!l&&!r
000
&hconfig('timeout', $url{'host'}, $url{'prot'}) || 10
l!l
00
$config{'lwp'} || {}
l!l
00
$lwpopt || {}
l!l
00
MC/DC0%0/2
$config{'useragent'} || $config{'crawler_name'}
$config{'useragent'} $config{'crawler_name'}
MC/DC0%0/1
&hconfig('timeout', $url{'host'}, $url{'prot'}) || 10
&hconfig('timeout', $url{'host'}, $url{'prot'})
MC/DC0%0/1
$config{'lwp'} || {}
$config{'lwp'}
MC/DC0%0/1
$lwpopt || {}
$lwpopt
Truth table0%0/3
A || B
A= $config{'useragent'}B= $config{'crawler_name'}
ABresult
1X1
011
000
Truth table0%0/2
A
A= &hconfig('timeout', $url{'host'}, $url{'prot'})
Aresult
11
00
Truth table0%0/2
A
A= $config{'lwp'}
Aresult
11
00
Truth table0%0/2
A
A= $lwpopt
Aresult
11
00
1458 );
1459 #$ua->proxy('http', 'http://proxy.ru:3128');
1460 0 ▶ if ( ref $config{'proxy'} eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $config{'proxy'} eq 'ARRAY') { } 0 0 0
elsif ($config{'proxy'}) { } 0 0 0
1461 0 local @_ = @{ shuffle( $config{'proxy'} )->[0] };
1462 #printlog('proxy', @_, Dumper($config{'proxy'}));
1463 0 $ua->proxy(@_);
1464 } elsif ( $config{'proxy'} ) {
1465 0 $ua->proxy( 'http', $config{'proxy'} );
1466 }
1467 #printlog 'dev' ,1 , $asfile , $c;
1468 0 ▶ $ua->mirror( $what, $c ), return $c if $asfile;
Branch: 1 branch
BranchTrueFalseTotal
if $asfile 0 0 0
1469 0 ▶ $method ||= 'GET';
Condition0%0/2
$method ||= "GET"
l!l
00
MC/DC0%0/1
$method ||= "GET"
$method
Truth table0%0/2
A
A= $method
Aresult
11
00
1470 #print "RwM:$method;";
1471 #my $resp =( $method eq 'HEAD' ? $ua->head($what) :
1472 my $resp = (
1473 $ua->request(
1474 HTTP::Request->new(
1475 $method,
1476 URI::URL->new($what),
1477 HTTP::Headers->new(
1478 #'User-Agent' => ($config{'useragent'} || $config{'crawler_name'}),
1479 0 ▶ %{ $headers_in || {} }
Condition0%0/2
$headers_in || {}
l!l
00
MC/DC0%0/1
$headers_in || {}
$headers_in
Truth table0%0/2
A
A= $headers_in
Aresult
11
00
1480 ),
1481 $content
1482 )
1483 )
1484 );
1485 #my $ret = $headers ? \$resp->content : \$resp->asfile;
1486 0 ▶ my $ret = $headers_out ? 'as_string' : 'content';
Branch: 1 branch
BranchTrueFalseTotal
$headers_out ? : 0 0 0
1487 #printlog 'resp', Dumper $resp;
1488 #print "[H:",$resp->header();
1489 #print "[H:",$resp->code();
1490 0 ▶ if ( $resp->is_success ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resp->is_success) { } 0 0 0
1491 0 ▶ if ( $config{'cachedir'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config{"cachedir"}) 0 0 0
1492 0 ▶ open( CF, '>', $c ) or return;
Branch: 1 branch
BranchTrueFalseTotal
open CF, ">", $c or return 0 0 0
1493 0 binmode(CF);
1494 0 print CF$resp->$ret(); #content;
1495 #print CF $ret->(); #content;
1496 0 close(CF);
1497 }
1498 #return $asfile ? $c : ($resp->content); #{map {$_ => $resp->header($_)}$resp->header_field_names}
1499 #printlog('dev', 'http ret', $ret, $asfile,"NOW");
1500 #return "FUCCCCKKAAA";
1501 #return $resp->$ret();
1502 0 ▶ return ( $asfile ? $c : ( $resp->$ret() ) ); #{map {$_ => $resp->header($_)}$resp->header_field_names}
Branch: 1 branch
BranchTrueFalseTotal
$asfile ? : 0 0 0
1503 #return $asfile ? $c : $ret->(); #{map {$_ => $resp->header($_)}$resp->header_field_names}
1504 } else {
1505 0 printlog( 'dev', 'http getfail', $what, $resp->code(), $resp->message() );
1506 #return $asfile ? undef: $resp->message;
1507 0 return undef;
1508 }
1509 0 1;
1510 } or printlog( 'err', @$, @!, $! );
1511 0 return undef;
1512 }
1513  
1514 0 ▶sub http_get_code ($;$$) {
Subroutine http_get_code: not called CC=8 SCAR=42.8
Pod undocumented
1515 0 my ( $what, $lwpopt, $method ) = @_;
1516 #printlog('dev', 'http_get_code',$what, $method);
1517 0 ▶ my $ret = eval {
Branch: 1 branch
BranchTrueFalseTotal
my $ret = eval { do { eval "use LWP::UserAgent; use URI::URL;1;" or &printlog("err", "http use libs", @!, $!); my $resp = "LWP::UserAgent"->new("timeout", &hconfig("timeout"), %{$config{"lwp"} or {};}, %{$lwpopt or {};})->request("HTTP::Request"->new($method || "GET", "URI::URL"->new($what), "HTTP::Headers"->new("User-Agent", $config{"useragent"} || $config{"crawler_name"}))); return $resp->code } } or &printlog("err", @$, @!, $!) 0 0 0
1518 0 ▶ eval('use LWP::UserAgent; use URI::URL;1;') or printlog( 'err', 'http use libs', @!, $! ); #if not installed
Branch: 1 branch
BranchTrueFalseTotal
eval "use LWP::UserAgent; use URI::URL;1;" or &printlog("err", "http use libs", @!, $!) 0 0 0
1519 #my $ua = ;
1520 #$ua->proxy('http', 'http://proxy.ru:3128');
1521 my $resp = (
1522 0 ▶ ( LWP::UserAgent->new( 'timeout' => hconfig('timeout'), %{ $config{'lwp'} or {} }, %{ $lwpopt or {} } ) )->request(
Condition0%0/9
$config{'lwp'} || {}
l!l
00
$lwpopt || {}
l!l
00
$method || 'GET'
l!l
00
$config{'useragent'} || $config{'crawler_name'}
l!l&&r!l&&!r
000
MC/DC0%0/1
$config{'lwp'} || {}
$config{'lwp'}
MC/DC0%0/1
$lwpopt || {}
$lwpopt
MC/DC0%0/1
$method || 'GET'
$method
MC/DC0%0/2
$config{'useragent'} || $config{'crawler_name'}
$config{'useragent'} $config{'crawler_name'}
Truth table0%0/2
A
A= $config{'lwp'}
Aresult
11
00
Truth table0%0/2
A
A= $lwpopt
Aresult
11
00
Truth table0%0/2
A
A= $method
Aresult
11
00
Truth table0%0/3
A || B
A= $config{'useragent'}B= $config{'crawler_name'}
ABresult
1X1
011
000
1523 HTTP::Request->new(
1524 ( $method or 'GET' ),
1525 0 URI::URL->new($what), HTTP::Headers->new( 'User-Agent' => $config{'useragent'} || $config{'crawler_name'} )
1526 )
1527 )
1528 );
1529 #print "[H:",$resp->header();
1530 #print 'GCR', $resp->code(), "\n";
1531 0 return $resp->code();
1532 } or printlog( 'err', @$, @!, $! );
1533 0 ▶ return $ret || undef;
Condition0%0/2
$ret || undef
l!l
00
MC/DC0%0/1
$ret || undef
$ret
Truth table0%0/2
A
A= $ret
Aresult
11
00
1534 }
1535  
1536 0 ▶sub html_strip($) {
Subroutine html_strip: not called CC=2 SCAR=17.9
Pod undocumented
1537 0 my $s = $_[0];
1538 0 $s =~ s{HTTP/.*?\n\n}{}gs;
1539 0 $s =~ s/<!--.*?-->//gs;
1540 0 $s =~ s{<$_.*?>.*?</$_>}{}gs for qw(script style);
1541 0 $s =~ s{</?.+?/?>}{}gs;
1542 0 return $s;
1543 }
1544  
1545 0 ▶sub loadlist {
Subroutine loadlist: not called CC=8 SCAR=42.8
Pod undocumented
1546 0 my %res = ();
1547 0 for my $sca (@_) {
1548 0 ▶ next unless $sca;
Branch: 1 branch
BranchTrueFalseTotal
unless $sca 0 0 0
1549 0 ▶ open( SSF, '<', $sca ) or next;
Branch: 1 branch
BranchTrueFalseTotal
open SSF, "<", $sca or next 0 0 0
1550 0 ▶ while (<SSF>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline SSF)) 0 0 0
1551 0 ▶ next if /^\s*[#;]/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*[#;]/ 0 0 0
1552 0 local @_ = split /\s+/, $_;
1553 0 ▶ my $host = shift or next;
Branch: 1 branch
BranchTrueFalseTotal
my $host = shift() or next 0 0 0
1554 0 local %_;
1555 0 get_params_one( \%_, @_ );
1556 0 $res{$host} = \%_;
1557 }
1558 0 close(SSF);
1559 }
1560 0 ▶ return wantarray ? %res : \%res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1561 }
1562 0 ▶sub shelldata(@) { s/[\x0d\x0a\"\'\`|><&]//g for @_; } #`
Subroutine shelldata: not called CC=2 SCAR=17.9
Pod undocumented
1563  
1564 =c
1565 sub save_list {
1566 my ($file, $data) = @_;
1567 use Storable;
1568 store($data, $file);
1569 =c
1570 return 1 unless open(SF, '>', $file);
1571 for my $str (sort keys %$data) {
1572 print SF join(' ', map{ encode_url($_) . (length($data->{$str}{$_}) ? ( '='. encode_url($data->{$str}{$_})) : ())} sort keys %{$data->{$str}});
1573 #for my $k (sort keys %{$data->{$str}}) {
1574 #}
1575 print SF "\n";
1576 }
1577
1578 close(SF);
1579 }
1580 =cut
1581  
1582 =schedule
1583  
1584 schedule(everysec, our $___mysub ||= sub{});
1585 schedule([firstafter, everysec], our $___mysub ||= sub{});
1586 schedule({wait=>10, every=>5}, our $___mysub ||= sub{});
1587  
1588 =cut
1589  
1590 0 ▶sub schedule($$;@) { #$Id: psmisc.pm 4847 2014-06-30 23:41:45Z pro $ $URL: svn://svn.setun.net/search/trunk/lib/psmisc.pm $
Subroutine schedule: not called CC=16 SCAR=56.1
Pod undocumented
1591 0 our %schedule;
1592 0 my ( $every, $func ) = ( shift, shift );
1593 0 my $p;
1594 0 ▶ ( $p->{'wait'}, $p->{'every'}, $p->{'runs'}, $p->{'cond'}, $p->{'id'} ) = @$every if ref $every eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $every eq "ARRAY" 0 0 0
1595 0 ▶ $p = $every if ref $every eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $every eq "HASH" 0 0 0
1596 0 ▶ $p->{'every'} ||= $every if !ref $every;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $every 0 0 0
Condition0%0/3
$p->{"every"} ||= $every
l!l&&r!l&&!r
000
MC/DC0%0/2
$p->{"every"} ||= $every
$p->{"every"} $every
Truth table0%0/3
A ||= B
A= $p->{"every"}B= $every
ABresult
1X1
011
000
1597 0 ▶ $p->{'id'} ||= join ';', caller;
Condition0%0/3
$p->{"id"} ||= join(";", caller)
l!l&&r!l&&!r
000
MC/DC0%0/2
$p->{"id"} ||= join(";", caller)
$p->{"id"} join(";", caller)
Truth table0%0/3
A ||= B
A= $p->{"id"}B= join(";", caller)
ABresult
1X1
011
000
1598 #dmp $p, \%schedule;
1599 #dmp $schedule{ $p->{'id'} }{'runs'}, $p->{'runs'}, $p, $schedule{ $p->{'id'} } if $p->{'runs'};
1600 0 ▶ $schedule{ $p->{'id'} }{'func'} = $func if !$schedule{ $p->{'id'} }{'func'} or $p->{'update'};
Branch: 1 branch
BranchTrueFalseTotal
if not $psmisc::schedule{$p->{"id"}}{"func"} or $p->{"update"} 0 0 0
Condition0%0/3
not $psmisc::schedule{$p->{"id"}}{"func"} or $p->{"update"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $psmisc::schedule{$p->{"id"}}{"func"} or $p->{"update"}
not $psmisc::schedule{$p->{"id"}}{"func"} $p->{"update"}
Truth table0%0/3
not(A) or B
A= not $psmisc::schedule{$p->{"id"}}{"func"}B= $p->{"update"}
ABresult
1X1
011
000
1601 0 ▶ $schedule{ $p->{'id'} }{'last'} = time - $p->{'every'} + $p->{'wait'} if $p->{'wait'} and !$schedule{ $p->{'id'} }{'last'};
Branch: 1 branch
BranchTrueFalseTotal
if $p->{"wait"} and not $psmisc::schedule{$p->{"id"}}{"last"} 0 0 0
Condition0%0/3
$p->{"wait"} and not $psmisc::schedule{$p->{"id"}}{"last"}
!ll&&!rl&&r
000
MC/DC0%0/2
$p->{"wait"} and not $psmisc::schedule{$p->{"id"}}{"last"}
$p->{"wait"} not $psmisc::schedule{$p->{"id"}}{"last"}
Truth table0%0/3
A and not(B)
A= $p->{"wait"}B= not $psmisc::schedule{$p->{"id"}}{"last"}
ABresult
0X0
100
111
1602 #dmp("RUN", $p->{'id'}),
1603 ++$schedule{ $p->{'id'} }{'runs'}, $schedule{ $p->{'id'} }{'last'} = time, $schedule{ $p->{'id'} }{'func'}->(@_),
1604 if ( $schedule{ $p->{'id'} }{'last'} + $p->{'every'} < time )
1605 and ( !$p->{'runs'} or $schedule{ $p->{'id'} }{'runs'} < $p->{'runs'} )
1606 and ( !( ref $p->{'cond'} eq 'CODE' ) or $p->{'cond'}->( $p, $schedule{ $p->{'id'} }, @_ ) )
1607 0 ▶ and ref $schedule{ $p->{'id'} }{'func'} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if $psmisc::schedule{$p->{"id"}}{"last"} + $p->{"every"} < &psmisc::time() and !$p->{"runs"} || $psmisc::schedule{$p->{"id"}}{"runs"} < $p->{"runs"} and !(ref $p->{"cond"} eq "CODE") || $p->{"cond"}->($p, $psmisc::schedule{$p->{"id"}}, @_) and ref $psmisc::schedule{$p->{"id"}}{"func"} eq "CODE" 0 0 0
Condition0%0/15
$psmisc::schedule{$p->{"id"}}{"last"} + $p->{"every"} < &psmisc::time() and !$p->{"runs"} || $psmisc::schedule{$p->{"id"}}{"runs"} < $p->{"runs"} and !(ref $p->{"cond"} eq "CODE") || $p->{"cond"}->($p, $psmisc::schedule{$p->{"id"}}, @_) and ref $psmisc::schedule{$p->{"id"}}{"func"} eq "CODE"
!ll&&!rl&&r
000
$psmisc::schedule{$p->{"id"}}{"last"} + $p->{"every"} < &psmisc::time() and !$p->{"runs"} || $psmisc::schedule{$p->{"id"}}{"runs"} < $p->{"runs"} and !(ref $p->{"cond"} eq "CODE") || $p->{"cond"}->($p, $psmisc::schedule{$p->{"id"}}, @_)
!ll&&!rl&&r
000
$psmisc::schedule{$p->{"id"}}{"last"} + $p->{"every"} < &psmisc::time() and !$p->{"runs"} || $psmisc::schedule{$p->{"id"}}{"runs"} < $p->{"runs"}
!ll&&!rl&&r
000
not $p->{"runs"} or $psmisc::schedule{$p->{"id"}}{"runs"} < $p->{"runs"}
l!l&&r!l&&!r
000
not ref $p->{"cond"} eq "CODE" or $p->{"cond"}->($p, $psmisc::schedule{$p->{"id"}}, @_)
l!l&&r!l&&!r
000
MC/DC0%0/6
$psmisc::schedule{$p->{"id"}}{"last"} + $p->{"every"} < &psmisc::time() and !$p->{"runs"} || $psmisc::schedule{$p->{"id"}}{"runs"} < $p->{"runs"} and !(ref $p->{"cond"} eq "CODE") || $p->{"cond"}->($p, $psmisc::schedule{$p->{"id"}}, @_) and ref $psmisc::schedule{$p->{"id"}}{"func"} eq "CODE"
$psmisc::schedule{$p->{"id"}}{"last"} + $p->{"every"} < &psmisc::time() not $p->{"runs"} $psmisc::schedule{$p->{"id"}}{"runs"} < $p->{"runs"} not ref $p->{"cond"} eq "CODE" $p->{"cond"}->($p, $psmisc::schedule{$p->{"id"}}, @_) ref $psmisc::schedule{$p->{"id"}}{"func"} eq "CODE"
Truth table0%0/12
A and not(B) or C and not(D) or E and F
A= $psmisc::schedule{$p->{"id"}}{"last"} + $p->{"every"} < &psmisc::time()B= not $p->{"runs"}C= $psmisc::schedule{$p->{"id"}}{"runs"} < $p->{"runs"}D= not ref $p->{"cond"} eq "CODE"E= $p->{"cond"}->($p, $psmisc::schedule{$p->{"id"}}, @_)F= ref $psmisc::schedule{$p->{"id"}}{"func"} eq "CODE"
ABCDEFresult
0XXXXX0
100XXX0
11X00X0
10100X0
11X1X00
11X0100
1011X00
1010100
11X1X11
11X0111
1011X11
1010111
1608 }
1609 { #$Id: psmisc.pm 4847 2014-06-30 23:41:45Z pro $ $URL: svn://svn.setun.net/search/trunk/lib/psmisc.pm $
1610 1 my (@locks);
1611 0 ▶ sub lockfile($) {
Subroutine lockfile: not called CC=4 SCAR=30.0
Pod undocumented
1612 0 ▶ return ( $config{'lock_dir'} || './' ) . ( length $_[0] ? $_[0] : 'lock' ) . ( $config{'lock_ext'} || '.lock' );
Branch: 1 branch
BranchTrueFalseTotal
length $_[0] ? : 0 0 0
Condition0%0/4
$config{'lock_dir'} || './'
l!l
00
$config{'lock_ext'} || '.lock'
l!l
00
MC/DC0%0/1
$config{'lock_dir'} || './'
$config{'lock_dir'}
MC/DC0%0/1
$config{'lock_ext'} || '.lock'
$config{'lock_ext'}
Truth table0%0/2
A
A= $config{'lock_dir'}
Aresult
11
00
Truth table0%0/2
A
A= $config{'lock_ext'}
Aresult
11
00
1613 }
1614  
1615 0 ▶ sub lock (;$@) {
Subroutine lock: not called CC=17 SCAR=57.2
Pod undocumented
1616 0 my $name = shift;
1617 0 ▶ my %p = ref $_[0] eq 'HASH' ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1618 0 ▶ $p{'sleep'} //= $config{'lock_sleep'} // 1;
Condition0%0/4
$p{"sleep"} //= $config{"lock_sleep"} // 1
l!l
00
$config{"lock_sleep"} // 1
l!l
00
MC/DC0%0/1
$p{"sleep"} //= $config{"lock_sleep"} // 1
$p{"sleep"}
Truth table0%0/2
A
A= $p{"sleep"}
Aresult
11
00
1619 0 ▶ $p{'timeout'} //= $config{'lock_timeout'} // 600 unless length $p{'timeout'};
Branch: 1 branch
BranchTrueFalseTotal
unless length $p{"timeout"} 0 0 0
Condition0%0/4
$p{"timeout"} //= $config{"lock_timeout"} // 600
l!l
00
$config{"lock_timeout"} // 600
l!l
00
MC/DC0%0/1
$p{"timeout"} //= $config{"lock_timeout"} // 600
$p{"timeout"}
Truth table0%0/2
A
A= $p{"timeout"}
Aresult
11
00
1620 0 ▶ $p{'old'} //= $config{'lock_old'} // 3600;
Condition0%0/4
$p{"old"} //= $config{"lock_old"} // 3600
l!l
00
$config{"lock_old"} // 3600
l!l
00
MC/DC0%0/1
$p{"old"} //= $config{"lock_old"} // 3600
$p{"old"}
Truth table0%0/2
A
A= $p{"old"}
Aresult
11
00
1621 #$p{'readonly'} ||= 0; #dont write lock file, only wait
1622 0 my $waitstart = time();
1623 0 my $waits;
1624 LOCKWAIT:
1625 0 ▶ while ( -e lockfile $name) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e &lockfile($name)) 0 0 0
1626 #printlog( 'lockdev', 'locktime', -M lockfile $name, time() - $^T + 86400 * -M lockfile $name, $^T + 86400 * -M lockfile $name, 86400 * -M lockfile $name, );
1627 printlog( 'lock', $name, 'ignore too old', -M lockfile $name, time() - $^T + 86400 * -M lockfile $name), last
1628 0 ▶ if time() - $^T + 86400 * -M lockfile $name > $p{'old'};
Branch: 1 branch
BranchTrueFalseTotal
if &psmisc::time() - $^T + 86400 * (-M &lockfile($name)) > $p{"old"} 0 0 0
1629 0 ▶ printlog( 'lock', $name, 'fail, timeout', int( time() - $waitstart ) ), return 0 if time() - $waitstart > $p{'timeout'};
Branch: 1 branch
BranchTrueFalseTotal
if &psmisc::time() - $waitstart > $p{"timeout"} 0 0 0
1630 0 ▶ printlog( 'lock', 'locked, wait', $name ) unless $waits++;
Branch: 1 branch
BranchTrueFalseTotal
unless $waits++ 0 0 0
1631 0 sleep $p{'sleep'};
1632 }
1633 0 ▶ printlog( 'lock', 'unlocked', $name, 'per', int( time() - $waitstart ) ) if $waits;
Branch: 1 branch
BranchTrueFalseTotal
if $waits 0 0 0
1634 0 ▶ return 1 if $p{'readonly'};
Branch: 1 branch
BranchTrueFalseTotal
if $p{"readonly"} 0 0 0
1635 0 local $_ = "pid=$$ time=" . int( time() );
1636 0 file_rewrite lockfile $name, $_;
1637 0 file_rewrite; #flush
1638 0 ▶ if ( open my $f, '<', lockfile $name) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $f, '<', &lockfile($name)) { } 0 0 0
1639 0 local $/ = undef;
1640 0 my $c = <$f>;
1641 0 close $f;
1642 #printlog 'test', $c;
1643 0 ▶ printlog( 'warn', 'not my lock', $_, $c ), goto LOCKWAIT if $_ ne $c;
Branch: 1 branch
BranchTrueFalseTotal
if $_ ne $c 0 0 0
1644 } else {
1645 0 printlog( 'err', 'lock open err', $name, lockfile $name);
1646 0 return 0;
1647 }
1648 0 push @locks, lockfile $name;
1649 0 return 1;
1650 }
1651  
1652 0 ▶ sub unlock (;$) {
Subroutine unlock: not called CC=4 SCAR=30.0
Pod undocumented
1653 0 my $name = shift;
1654 0 local $_ = pop @locks;
1655 0 ▶ push @locks, $_ if length $name and lockfile($name) ne $_;
Branch: 1 branch
BranchTrueFalseTotal
if length $name and &lockfile($name) ne $_ 0 0 0
Condition0%0/3
length $name and &lockfile($name) ne $_
!ll&&!rl&&r
000
MC/DC0%0/2
length $name and &lockfile($name) ne $_
length $name &lockfile($name) ne $_
Truth table0%0/3
A and B
A= length $nameB= &lockfile($name) ne $_
ABresult
0X0
100
111
1656 #$name ||= $_;
1657 #printlog 'lock', 'unlocking', $name, lockfile $name;
1658 #unlink lockfile( $name ||= $_ );
1659 0 ▶ unlink $name ? lockfile($name) : $_;
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 0 0 0
1660 }
1661  
1662 1 ▶ sub unlock_all () {
Subroutine unlock_all: called CC=2 SCAR=7.6
Pod undocumented
1663 #unlink $_ for reverse @locks;
1664 1 ▶ unlink $_ while $_ = pop @locks;
Branch: 1 branch
BranchTrueFalseTotal
$_ = pop @locks and do { unlink $_ } 0 1 1
1665 }
1666  
1667 1 ▶ END {
Subroutine END: called CC=2 SCAR=7.2
1668 1 ▶ printlog( 'lock', 'END locked unlock', @locks ) if @locks;
Branch: 1 branch
BranchTrueFalseTotal
if @locks 0 1 1
1669 1 unlock_all();
1670 }
1671 0 ▶ $SIG{$_} ||= sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1672 0 ▶ printlog( 'lock', 'SIG locked unlock', @locks ) if @locks;
Branch: 1 branch
BranchTrueFalseTotal
if @locks 0 0 0
1673 0 unlock_all();
1674 0 exit;
1675 }
1676 1 ▶ for qw(INT QUIT KILL TERM); #HUP
Condition33%1/3
$SIG{$_} ||= sub { &printlog("lock", "SIG locked unlock", @locks) if @locks; &unlock_all(); exit; }
l!l&&r!l&&!r
040
MC/DC0%0/2
$SIG{$_} ||= sub { &printlog("lock", "SIG locked unlock", @locks) if @locks; &unlock_all(); exit; }
$SIG{$_} sub { &printlog("lock", "SIG locked unlock", @locks) if @locks; &unlock_all(); exit; }
Truth table33%1/3
A ||= B
A= $SIG{$_}B= sub { &printlog("lock", "SIG locked unlock", @locks) if @locks; &unlock_all(); exit; }
ABresult
1X1
011
000
1677 }
1678 {
1679 1 my ( $current, $order );
1680  
1681 16 ▶ sub program(;$$) {
Subroutine program: called CC=5 SCAR=17.2
Pod undocumented
1682 16 my ( $name, $setorder ) = @_;
1683 16 ▶ return $current unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 11 5 16
1684 5 ▶ $program{ $current = $name }{'order'} ||= ( $setorder or $order += ( $config{'order_step'} || 10 ) );
Condition50%4/8
$psmisc::program{$current = $name}{"order"} ||= $setorder || ($order += $config{"order_step"} || 10)
l!l&&r!l&&!r
050
$setorder || ($order += $config{'order_step'} || 10)
l!l&&r!l&&!r
140
$config{'order_step'} || 10
l!l
04
MC/DC0%0/3
$psmisc::program{$current = $name}{"order"} ||= $setorder || ($order += $config{"order_step"} || 10)
$psmisc::program{$current = $name}{"order"} $setorder ($order += $config{'order_step'} || 10)
MC/DC0%0/1
$config{'order_step'} || 10
$config{'order_step'}
Truth table0%0/4
A ||= B || C
A= $psmisc::program{$current = $name}{"order"}B= $setorderC= ($order += $config{'order_step'} || 10)
ABCresult
1XX1
01X1
0011
0000
Truth table50%1/2
A
A= $config{'order_step'}
Aresult
11
00
1685 #print "newprog($current, $program{$current}{'order'});" ;
1686 5 return $current;
1687 } #v2
1688 }
1689  
1690 1 ▶sub printall {
Subroutine printall: not called CC=6 SCAR=35.9
Pod undocumented
1691 0 local $_ = shift;
1692 0 ▶ return unless length $_;
Branch: 1 branch
BranchTrueFalseTotal
unless length $_ 0 0 0
1693 0 ▶ $_ = $$_ while ref $_ eq 'REF';
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq "REF" and do { $_ = $$_ } 0 0 0
1694 0 ▶ return $_->(@_) if ref $_ eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "CODE" 0 0 0
1695 #local
1696 0 ▶ @_ = () if ref $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] 0 0 0
1697 0 ▶ print( $$_, @_ ), return if ref $_ eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "SCALAR" 0 0 0
1698 0 print $_, @_;
1699 }
1700 1 program('params');
1701 1 $program{ program() }{'force'} = 1;
1702 0 ▶$program{ program() }{'func'} ||= sub { $param = get_params(); };
Subroutine __ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$psmisc::program{&program()}{"func"} ||= sub { $param = &get_params(); }
l!l&&r!l&&!r
010
MC/DC0%0/2
$psmisc::program{&program()}{"func"} ||= sub { $param = &get_params(); }
$psmisc::program{&program()}{"func"} sub { $param = &get_params(); }
Truth table33%1/3
A ||= B
A= $psmisc::program{&program()}{"func"}B= sub { $param = &get_params(); }
ABresult
1X1
011
000
1703 1 program('params_pre_config');
1704 1 ▶$program{ program() }{'mask'} ||= '^(-*c(onf)?-*)|(--).*';
Condition50%1/2
$psmisc::program{&program()}{"mask"} ||= "^(-*c(onf)?-*)|(--).*"
l!l
01
MC/DC0%0/1
$psmisc::program{&program()}{"mask"} ||= "^(-*c(onf)?-*)|(--).*"
$psmisc::program{&program()}{"mask"}
Truth table50%1/2
A
A= $psmisc::program{&program()}{"mask"}
Aresult
11
00
1705 1 ▶$program{ program() }{'param_name'} ||= 1;
Condition50%1/2
$psmisc::program{&program()}{"param_name"} ||= 1
l!l
01
MC/DC0%0/1
$psmisc::program{&program()}{"param_name"} ||= 1
$psmisc::program{&program()}{"param_name"}
Truth table50%1/2
A
A= $psmisc::program{&program()}{"param_name"}
Aresult
11
00
1706 0 ▶$program{ program() }{'func'} ||= sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1707 0 my ( $v, $w ) = @_;
1708 0 $w =~ s/^(-*c(onf?)?-*)|(--)//i;
1709 0 $v =~ s/^NUL$//;
1710 0 ▶ return 0 unless defined($w) and defined($v);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $w and defined $v 0 0 0
Condition0%0/3
defined $w and defined $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $w and defined $v
defined $w defined $v
Truth table0%0/3
A and B
A= defined $wB= defined $v
ABresult
0X0
100
111
1711 #local @_ = split /__/, eval( '$config' . join( '', map { '{$_[' . $_ . ']}' } ( 0 .. $#_ ) ) . '= $param->{$_};' ) for ( grep { $param->{$_} } keys %$param );
1712 0 ▶ local @_ = split( /__/, $w ) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
local @_ = split(/__/, $w, 0) or return 0 0 0 0
1713 #print( 'dev', 'genpre',$w, $v, @_, "\n");
1714 #printlog( 'dev', 'gen', @_,'$config' . join( '', map { '{$_[' . $_ . ']}' } ( 0 .. $#_ ) ) . ' = $v;' );
1715 0 eval( '$config' . join( '', map { '{$_[' . $_ . ']}' } ( 0 .. $#_ ) ) . ' = $v;' );
1716 #for ( grep { $param->{$_} } keys %$param );
1717 #$config{$w} = $v if defined($w) and defined($v);
1718 #printlog('dev', 'res', $config{'zzz'}{'yy'});
1719 0 return 0;
1720 1 ▶};
Condition33%1/3
$psmisc::program{&program()}{"func"} ||= sub { my($v, $w) = @_; $w =~ s/^(-*c(onf?)?-*)|(--)//i; $v =~ s/^NUL$//; return 0 unless defined $w and defined $v; local @_ = split(/__/, $w, 0) or return 0; eval '$config' . join("", map({'{$_[' . $_ . ']}';} 0 .. $#_)) . ' = $v;'; return 0; }
l!l&&r!l&&!r
010
MC/DC0%0/2
$psmisc::program{&program()}{"func"} ||= sub { my($v, $w) = @_; $w =~ s/^(-*c(onf?)?-*)|(--)//i; $v =~ s/^NUL$//; return 0 unless defined $w and defined $v; local @_ = split(/__/, $w, 0) or return 0; eval '$config' . join("", map({'{$_[' . $_ . ']}';} 0 .. $#_)) . ' = $v;'; return 0; }
$psmisc::program{&program()}{"func"} sub { my($v, $w) = @_; $w =~ s/^(-*c(onf?)?-*)|(--)//i; $v =~ s/^NUL$//; return 0 unless defined $w and defined $v; local @_ = split(/__/, $w, 0) or return 0; eval '$config' . join("", map({'{$_[' . $_ . ']}';} 0 .. $#_)) . ' = $v;'; return 0; }
Truth table33%1/3
A ||= B
A= $psmisc::program{&program()}{"func"}B= sub { my($v, $w) = @_; $w =~ s/^(-*c(onf?)?-*)|(--)//i; $v =~ s/^NUL$//; return 0 unless defined $w and defined $v; local @_ = split(/__/, $w, 0) or return 0; eval '$config' . join("", map({'{$_[' . $_ . ']}';} 0 .. $#_)) . ' = $v;'; return 0; }
ABresult
1X1
011
000
1721 1 program('config');
1722 1 $program{ program() }{'force'} = 1;
1723 0 ▶$program{ program() }{'func'} ||= sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1724 #print "COOOO";
1725 0 config_reload(); #$param
1726 0 pre_calc($param);
1727 #config_init($param);
1728 0 return 0;
1729 1 ▶};
Condition33%1/3
$psmisc::program{&program()}{"func"} ||= sub { config_reload(); pre_calc($param); return 0; }
l!l&&r!l&&!r
010
MC/DC0%0/2
$psmisc::program{&program()}{"func"} ||= sub { config_reload(); pre_calc($param); return 0; }
$psmisc::program{&program()}{"func"} sub { config_reload(); pre_calc($param); return 0; }
Truth table33%1/3
A ||= B
A= $psmisc::program{&program()}{"func"}B= sub { config_reload(); pre_calc($param); return 0; }
ABresult
1X1
011
000
1730 1 program('params_config');
1731 1 %{ $program{ program() } } = ( %{ $program{'params_pre_config'} }, 'order' => $program{ program() }{'order'} );
1732 1 program( 'help', 100000 );
1733 1 ▶$program{ program() }{'mask'} ||= '^-*he?l?p?$';
Condition50%1/2
$psmisc::program{&program()}{"mask"} ||= "^-*he?l?p?\$"
l!l
01
MC/DC0%0/1
$psmisc::program{&program()}{"mask"} ||= "^-*he?l?p?\$"
$psmisc::program{&program()}{"mask"}
Truth table50%1/2
A
A= $psmisc::program{&program()}{"mask"}
Aresult
11
00
1734 0 ▶$program{ program() }{'func'} ||= sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1735 0 print "Usage: perl $work{'$0'} [action[=params]] [--config_key[=value]] [...] \n\n Actions:\n";
1736 0 for ( sort keys %program ) {
1737 0 ▶ next if $program{$_}{'force'} or /(_aft)|(_bef)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $psmisc::program{$_}{"force"} or /(_aft)|(_bef)$/ 0 0 0
Condition0%0/3
$psmisc::program{$_}{"force"} or /(_aft)|(_bef)$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$psmisc::program{$_}{"force"} or /(_aft)|(_bef)$/
$psmisc::program{$_}{"force"} /(_aft)|(_bef)$/
Truth table0%0/3
A or B
A= $psmisc::program{$_}{"force"}B= /(_aft)|(_bef)$/
ABresult
1X1
011
000
1738 0 print "$_ $program{$_}{'desc'}\n";
1739 }
1740 0 print "\nConfig defaults:\n";
1741 0 for ( sort keys %config ) { print "--$_\t[$config{$_}]\n"; }
1742 1 ▶};
Condition33%1/3
$psmisc::program{&program()}{"func"} ||= sub { print qq[Usage: perl $work{"\$0"} [action[=params]] [--config_key[=value]] [...] \n\n Actions:\n]; foreach $_ (sort keys %program) { next if $program{$_}{"force"} or /(_aft)|(_bef)$/; print qq[$_ $program{$_}{"desc"}\n]; } ; print "\nConfig defaults:\n"; foreach $_ (sort keys %config) { print "--$_\t[$config{$_}]\n"; } ; }
l!l&&r!l&&!r
010
MC/DC0%0/2
$psmisc::program{&program()}{"func"} ||= sub { print qq[Usage: perl $work{"\$0"} [action[=params]] [--config_key[=value]] [...] \n\n Actions:\n]; foreach $_ (sort keys %program) { next if $program{$_}{"force"} or /(_aft)|(_bef)$/; print qq[$_ $program{$_}{"desc"}\n]; } ; print "\nConfig defaults:\n"; foreach $_ (sort keys %config) { print "--$_\t[$config{$_}]\n"; } ; }
$psmisc::program{&program()}{"func"} sub { print qq[Usage: perl $work{"\$0"} [action[=params]] [--config_key[=value]] [...] \n\n Actions:\n]; foreach $_ (sort keys %program) { next if $program{$_}{"force"} or /(_aft)|(_bef)$/; print qq[$_ $program{$_}{"desc"}\n]; } ; print "\nConfig defaults:\n"; foreach $_ (sort keys %config) { print "--$_\t[$config{$_}]\n"; } ; }
Truth table33%1/3
A ||= B
A= $psmisc::program{&program()}{"func"}B= sub { print qq[Usage: perl $work{"\$0"} [action[=params]] [--config_key[=value]] [...] \n\n Actions:\n]; foreach $_ (sort keys %program) { next if $program{$_}{"force"} or /(_aft)|(_bef)$/; print qq[$_ $program{$_}{"desc"}\n]; } ; print "\nConfig defaults:\n"; foreach $_ (sort keys %config) { print "--$_\t[$config{$_}]\n"; } ; }
ABresult
1X1
011
000
1743  
1744 0 ▶sub program_one($;@) {
Subroutine program_one: not called CC=6 SCAR=37.4
Pod undocumented
1745 0 my $current = shift;
1746 0 ▶ return undef unless exists $program{$current};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $psmisc::program{$current} 0 0 0
1747 0 ▶ if ( $program{$current}{'func'} and !$program{$current}{'disabled'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($psmisc::program{$current}{"func"} and not $psmisc::program{$current}{"disabled"}) 0 0 0
Condition0%0/3
$psmisc::program{$current}{"func"} and not $psmisc::program{$current}{"disabled"}
!ll&&!rl&&r
000
MC/DC0%0/2
$psmisc::program{$current}{"func"} and not $psmisc::program{$current}{"disabled"}
$psmisc::program{$current}{"func"} not $psmisc::program{$current}{"disabled"}
Truth table0%0/3
A and not(B)
A= $psmisc::program{$current}{"func"}B= not $psmisc::program{$current}{"disabled"}
ABresult
0X0
100
111
1748 0 my @ret;
1749 0 printlog( 'trace', 'program run', $current, @_ );
1750 0 eval { @ret = $program{$current}{'func'}->(@_); };
1751 0 ▶ printlog( 'err', 'program', $current, 'run error:', $@ ) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1752 0 ▶ return wantarray ? @ret : $ret[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1753 }
1754 0 return undef;
1755 }
1756  
1757 0 ▶sub program_run(;$) {
Subroutine program_run: not called CC=20 SCAR=60.4
Pod undocumented
1758 0 for my $n ( 0 .. 1 ) {
1759 0 my %masks;
1760 0 ▶ for my $current ( sort keys %program ) { ++$masks{ $program{$current}{'mask'} ||= "^-?$current\\d*\$" }; }
Condition0%0/2
$psmisc::program{$current}{"mask"} ||= "^-?$current\\d*\$"
l!l
00
MC/DC0%0/1
$psmisc::program{$current}{"mask"} ||= "^-?$current\\d*\$"
$psmisc::program{$current}{"mask"}
Truth table0%0/2
A
A= $psmisc::program{$current}{"mask"}
Aresult
11
00
1761 0 $program{'default'}{'notmask'} = '^-?(' . join( '|', keys %masks ) . ")\\d*\$";
1762 0 for my $current ( grep { !$program{$_}{'checked'} } sort { $program{$a}{'order'} <=> $program{$b}{'order'} } keys %program )
1763 {
1764 0 ▶ next if $current eq 'default' and !$n;
Branch: 1 branch
BranchTrueFalseTotal
if $current eq "default" and not $n 0 0 0
Condition0%0/3
$current eq "default" and not $n
!ll&&!rl&&r
000
MC/DC0%0/2
$current eq "default" and not $n
$current eq "default" not $n
Truth table0%0/3
A and not(B)
A= $current eq "default"B= not $n
ABresult
0X0
100
111
1765 0 ++$program{$current}{'checked'};
1766 0 for my $par ( sort( keys %$param ), grep { $program{$_}{'force'} } keys %program ) {
1767 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (!($psmisc::program{$current}{"notmask"} && $par =~ /$psmisc::program{$current}{"notmask"}/i) && $par =~ /$psmisc::program{$current}{"mask"}/i || $psmisc::program{$current}{"force"} and not $psmisc::program{$current}{"runned"}) 0 0 0
Condition0%0/12
!($psmisc::program{$current}{"notmask"} && $par =~ /$psmisc::program{$current}{"notmask"}/i) && $par =~ /$psmisc::program{$current}{"mask"}/i || $psmisc::program{$current}{"force"} and not $psmisc::program{$current}{"runned"}
!ll&&!rl&&r
000
not $psmisc::program{$current}{"notmask"} && $par =~ /$psmisc::program{$current}{"notmask"}/i and $par =~ /$psmisc::program{$current}{"mask"}/i or $psmisc::program{$current}{"force"}
l!l&&r!l&&!r
000
not $psmisc::program{$current}{"notmask"} && $par =~ /$psmisc::program{$current}{"notmask"}/i and $par =~ /$psmisc::program{$current}{"mask"}/i
!ll&&!rl&&r
000
$psmisc::program{$current}{'notmask'} && $par =~ /$psmisc::program{$current}{'notmask'}/i
!ll&&!rl&&r
000
MC/DC0%0/5
!($psmisc::program{$current}{"notmask"} && $par =~ /$psmisc::program{$current}{"notmask"}/i) && $par =~ /$psmisc::program{$current}{"mask"}/i || $psmisc::program{$current}{"force"} and not $psmisc::program{$current}{"runned"}
$psmisc::program{$current}{'notmask'} $par =~ /$psmisc::program{$current}{'notmask'}/i $par =~ /$psmisc::program{$current}{"mask"}/i $psmisc::program{$current}{"force"} not $psmisc::program{$current}{"runned"}
Truth table0%0/13
not(A && B) and C or D and not(E)
A= $psmisc::program{$current}{'notmask'}B= $par =~ /$psmisc::program{$current}{'notmask'}/iC= $par =~ /$psmisc::program{$current}{"mask"}/iD= $psmisc::program{$current}{"force"}E= not $psmisc::program{$current}{"runned"}
ABCDEresult
11X0X0
0X00X0
1000X0
0X1X00
101X00
11X100
0X0100
100100
0X1X11
101X11
11X111
0X0111
100111
1768 #BUG!!! next line always NOT on one char targets (/ z x ....)
1769 ( (
1770 !( $program{$current}{'notmask'} and $par =~ /$program{$current}{'notmask'}/i )
1771 and $par =~ /$program{$current}{'mask'}/i
1772 )
1773 or $program{$current}{'force'}
1774 )
1775 and !$program{$current}{'runned'}
1776 )
1777 {
1778 local @_ = (
1779 ( ( defined( $param->{$par} ) and $param->{$par} ne '' ) ? $param->{$par} : () ),
1780 0 ▶ ( $program{$current}{'param_name'} ? $par : () )
Branch: 2 branches
BranchTrueFalseTotal
defined $psmisc::param->{$par} && $psmisc::param->{$par} ne '' ? : 0 0 0
$psmisc::program{$current}{'param_name'} ? : 0 0 0
Condition0%0/3
defined $psmisc::param->{$par} and $psmisc::param->{$par} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $psmisc::param->{$par} and $psmisc::param->{$par} ne ""
defined $psmisc::param->{$par} $psmisc::param->{$par} ne ""
Truth table0%0/3
A and B
A= defined $psmisc::param->{$par}B= $psmisc::param->{$par} ne ""
ABresult
0X0
100
111
1781 );
1782 0 state( 'program:', $current, @_ );
1783 0 program_one( $current . '_bef', @_ );
1784 0 my @r = program_one( $current, @_ );
1785 0 program_one( $current . '_aft', @_, \@r );
1786 0 ▶ printlog( 'warn', 'program finished', $current, '=', @r ) if $r[0] and !ref $r[0];
Branch: 1 branch
BranchTrueFalseTotal
if $r[0] and not ref $r[0] 0 0 0
Condition0%0/3
$r[0] and not ref $r[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$r[0] and not ref $r[0]
$r[0] not ref $r[0]
Truth table0%0/3
A and not(B)
A= $r[0]B= not ref $r[0]
ABresult
0X0
100
111
1787 0 ▶ $program{$current}{'runned'} = 1 if $program{$current}{'once'} or $program{$current}{'force'};
Branch: 1 branch
BranchTrueFalseTotal
if $psmisc::program{$current}{"once"} or $psmisc::program{$current}{"force"} 0 0 0
Condition0%0/3
$psmisc::program{$current}{"once"} or $psmisc::program{$current}{"force"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$psmisc::program{$current}{"once"} or $psmisc::program{$current}{"force"}
$psmisc::program{$current}{"once"} $psmisc::program{$current}{"force"}
Truth table0%0/3
A or B
A= $psmisc::program{$current}{"once"}B= $psmisc::program{$current}{"force"}
ABresult
1X1
011
000
1788 0 $program{$current}{'force'} = '';
1789 }
1790 }
1791 }
1792 }
1793 }
1794 #BEGIN { config_init(); }
1795 1 config_init();
1796 #
1797 #
1798 #
1799 #
1800 #
1801 package #hide from cpan
1802 psconn;
1803 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1804 1 our $VERSION = ( split( ' ', '$Revision: 4847 $' ) )[1];
1805 #use psmisc;
1806 #sub connection {
1807 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
1808 0 my $class = shift;
1809 0 my $self = {};
1810 0 bless( $self, $class );
1811 0 $self->init(@_);
1812 #printlog( 'conn', 'new', $self, $class, 'deb:', $self->{'error_sleep'} );
1813 0 return $self;
1814 }
1815  
1816 0 ▶sub init {
Subroutine init: not called CC=4 SCAR=30.0
1817 0 my $self = shift;
1818 0 local %_ =
1819 ( 'connected' => 0, 'connect_auto' => 1, 'connect_tries' => 100, 'connect_chain_tries' => 10, 'error_sleep' => 5, @_ );
1820 #@{$self}{ keys %_ } = values %_;
1821 0 ▶ $self->{$_} //= $_{$_} for keys %_;
Condition0%0/3
$self->{$_} //= $_{$_}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{$_} //= $_{$_}
$self->{$_} $_{$_}
Truth table0%0/3
A //= B
A= $self->{$_}B= $_{$_}
ABresult
1X1
011
000
1822 #printlog('dev', 'conn init error_sleep', $self->{'error_sleep'});
1823 0 ▶ $self->connect() if $self->{'auto_connect'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"auto_connect"} 0 0 0
1824 0 return $self;
1825 }
1826 ##methods
1827 #connect
1828 #reconnect
1829 #disconnect
1830 #dropconnect
1831 #keep
1832 ##child can do
1833 #_connect
1834 #_disconnect
1835 #_dropconnect
1836 #check_error
1837 #parse_error
1838 #_keep
1839 ##vars
1840 #tries
1841 #error_sleep
1842 #auto_connect
1843 ##vars status
1844 #connected
1845 0 ▶sub connect {
Subroutine connect: not called CC=12 SCAR=50.5
1846 0 my $self = shift;
1847 #return ($self->{'connect_check'} ? $self->keep() : 0) if $self->{'connected'};
1848 0 ▶ return 1 if $self->{'in_connect'} or $self->{'in_disconnect'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"in_connect"} or $self->{"in_disconnect"} 0 0 0
Condition0%0/3
$self->{"in_connect"} or $self->{"in_disconnect"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"in_connect"} or $self->{"in_disconnect"}
$self->{"in_connect"} $self->{"in_disconnect"}
Truth table0%0/3
A or B
A= $self->{"in_connect"}B= $self->{"in_disconnect"}
ABresult
1X1
011
000
1849 0 ▶ return $self->keep() if $self->{'connected'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"connected"} 0 0 0
1850 #printlog( 'dev', "conn::connect[$self->{'connect_tried'} <= $self->{'connect_tries'}]" );
1851 #if (!$self->_connect()) { #ok
1852 0 my $aftersleep = 1;
1853 0 ▶ while ( !$self->{'die'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"die"}) 0 0 0
1854 0 ▶ if ( ( !$self->{'connect_tries'} or $self->{'connect_tried'}++ <= $self->{'connect_tries'} )
Branch: 1 branch
BranchTrueFalseTotal
if (!$self->{'connect_tries'} || $self->{'connect_tried'}++ <= $self->{'connect_tries'} and !$self->{'connect_chain_tries'} || $self->{'connect_chain_tried'}++ <= $self->{'connect_chain_tries'}) { } 0 0 0
Condition0%0/9
!$self->{"connect_tries"} || $self->{"connect_tried"}++ <= $self->{"connect_tries"} and !$self->{"connect_chain_tries"} || $self->{"connect_chain_tried"}++ <= $self->{"connect_chain_tries"}
!ll&&!rl&&r
000
not $self->{"connect_tries"} or $self->{"connect_tried"}++ <= $self->{"connect_tries"}
l!l&&r!l&&!r
000
not $self->{"connect_chain_tries"} or $self->{"connect_chain_tried"}++ <= $self->{"connect_chain_tries"}
l!l&&r!l&&!r
000
MC/DC0%0/4
!$self->{"connect_tries"} || $self->{"connect_tried"}++ <= $self->{"connect_tries"} and !$self->{"connect_chain_tries"} || $self->{"connect_chain_tried"}++ <= $self->{"connect_chain_tries"}
not $self->{"connect_tries"} $self->{"connect_tried"}++ <= $self->{"connect_tries"} not $self->{"connect_chain_tries"} $self->{"connect_chain_tried"}++ <= $self->{"connect_chain_tries"}
Truth table0%0/7
not(A) or B and not(C) or D
A= not $self->{"connect_tries"}B= $self->{"connect_tried"}++ <= $self->{"connect_tries"}C= not $self->{"connect_chain_tries"}D= $self->{"connect_chain_tried"}++ <= $self->{"connect_chain_tries"}
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
1855 and ( !$self->{'connect_chain_tries'} or $self->{'connect_chain_tried'}++ <= $self->{'connect_chain_tries'} ) )
1856 {
1857 #do { { #ok
1858 0 $self->{'in_connect'} = 1;
1859 0 ▶ if ( !$self->_connect() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_connect) 0 0 0
1860 #printlog('CONNECTED!?');
1861 0 $self->{'in_connect'} = 0;
1862 0 ++$self->{'connected'};
1863 0 ++$self->{'connects'};
1864 0 $self->{'connect_chain_tried'} = 0;
1865 #printlog( 'dev', 'oncon', $_ ),
1866 0 $self->{ 'on_connect' . $_ }->($self) for grep { ref $self->{ 'on_connect' . $_ } eq 'CODE' } ( '', 1 .. 10 );
1867 0 return 0;
1868 }
1869 0 $self->{'in_connect'} = 0;
1870 0 $self->dropconnect();
1871 $self->log(
1872 'dev',
1873 'psconn::connect run sleep',
1874 0 $self->{'error_sleep'},
1875 "c=$self->{'connect_tried'}/$self->{'connect_tries'}",
1876 "ch=$self->{'connect_chain_tried'}/$self->{'connect_chain_tries'}",
1877 );
1878 0 $self->sleep( $self->{'error_sleep'} );
1879 0 $aftersleep = 0;
1880 } else {
1881 0 $self->log( 'dev',
1882 " if (( $self->{'connect_tried'}++ <= $self->{'connect_tries'} or !$self->{'connect_tries'} ) and ( $self->{'connect_chain_tried'}++ <= $self->{'connect_chain_tries'} or !$self->{'connect_chain_tries'} ) )"
1883 );
1884 0 last;
1885 }
1886 }
1887 #} while ( ++$self->{'connect_tried'} <= $self->{'connect_tries'} );
1888 0 ▶ $self->sleep($aftersleep) if $aftersleep;
Branch: 1 branch
BranchTrueFalseTotal
if $aftersleep 0 0 0
1889 0 return 1;
1890 }
1891  
1892 0 ▶sub reconnect {
Subroutine reconnect: not called CC=1 SCAR=6.9
1893 0 my $self = shift;
1894 0 $self->disconnect(@_);
1895 0 return $self->connect(@_);
1896 #++$self->{'reconnects'};
1897 }
1898  
1899 0 ▶sub disconnect {
Subroutine disconnect: not called CC=2 SCAR=17.9
1900 0 my $self = shift;
1901 0 ▶ return 0 unless $self->{'connected'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"connected"} 0 0 0
1902 #printlog('trace', 'psconn::disconnect');
1903 0 $self->_disconnect(@_);
1904 0 $self->dropconnect(@_);
1905 }
1906  
1907 0 ▶sub dropconnect {
Subroutine dropconnect: not called CC=2 SCAR=17.9
1908 0 my $self = shift;
1909 0 ▶ return 0 unless $self->{'connected'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"connected"} 0 0 0
1910 0 $self->_dropconnect(@_);
1911 0 $self->{'connected'} = 0;
1912 }
1913  
1914 0 ▶sub keep {
Subroutine keep: not called CC=4 SCAR=30.0
1915 0 my $self = shift;
1916 #print("psconn::keep\n");
1917 #print("psconn::keep:R1=0\n"),
1918 0 ▶ return 0 if $self->{'connected'} and !$self->{'connect_check'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"connected"} and not $self->{"connect_check"} 0 0 0
Condition0%0/3
$self->{"connected"} and not $self->{"connect_check"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"connected"} and not $self->{"connect_check"}
$self->{"connected"} not $self->{"connect_check"}
Truth table0%0/3
A and not(B)
A= $self->{"connected"}B= not $self->{"connect_check"}
ABresult
0X0
100
111
1919 #local $_ =$self->_check();
1920 #print("keep:preR2[$_]\n");
1921 #print("keep:R2=0[$_]\n"),
1922 #return 0 if !$_;
1923 0 ▶ return 0 if !$self->_check();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_check 0 0 0
1924 #print("keep:postR2[$_]\n");
1925 #print('keep:R3=rc'),
1926 0 return $self->reconnect();
1927 }
1928  
1929 0 ▶sub _connect {
Subroutine _connect: not called CC=1 SCAR=6.9
1930 0 my $self = shift;
1931 #printlog('NEWER');
1932 0 return 0;
1933 }
1934  
1935 0 ▶sub _disconnect {
Subroutine _disconnect: not called CC=1 SCAR=6.9
1936 0 my $self = shift;
1937 0 return 0;
1938 }
1939  
1940 0 ▶sub _dropconnect {
Subroutine _dropconnect: not called CC=1 SCAR=6.9
1941 0 my $self = shift;
1942 0 return 0;
1943 }
1944  
1945 0 ▶sub _check {
Subroutine _check: not called CC=1 SCAR=6.9
1946 0 my $self = shift;
1947 #printlog('DONT');
1948 0 return 0;
1949 }
1950  
1951 0 ▶sub check_error {
Subroutine check_error: not called CC=1 SCAR=6.9
1952 0 my $self = shift;
1953 0 return 0;
1954 }
1955  
1956 0 ▶sub parse_error {
Subroutine parse_error: not called CC=1 SCAR=6.9
1957 0 my $self = shift;
1958 0 return 0;
1959 }
1960  
1961 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=6.9
1962 0 my $self = shift;
1963 #printlog('trace', 'psconn::DESTROY');
1964 0 $self->disconnect();
1965 }
1966  
1967 0 ▶sub sleep {
Subroutine sleep: not called CC=1 SCAR=6.9
1968 0 my $self = shift;
1969 #$self->log( 'dev', 'psconn::sleep', @_ );
1970 #local $_ = $work{'sql_locked'};
1971 #sql_unlock_tables() if $work{'sql_locked'} and $_[0];
1972 0 CORE::sleep(@_);
1973 #return psmisc::sleeper(@_);
1974 #sql_lock_tables($_) if $_ and $_[0];
1975 }
1976 1 1;
« DirectConnect.pm ↑ Summary DirectConnect/clihub.pm »